Example #1
0
void CMap::CheckForExit(int x, int y)
{
	// Let's go through all of the exits and check if there is an exit to use
	for(int i = 0; i < (int)m_vExits.size(); i++)
	{
		// Grab the current exit being checked
		CExit *pExit = &m_vExits[i];

		// If this exit is the same position as the new players position passed in...
		if(x == pExit->GetIndex().x && y == pExit->GetIndex().y)
		{
			char szNewMap[255] = {0};

			// Draw the new map, and due a little pause with the windows Sleep() function.
			// This is so it shows that we actually walked on that spot before we change maps.
			SetDrawFlag(true);
			Draw();
			g_Buffer.SwapBackBuffer(FALSE);
			Sleep(100);

			// Copy the new map's name to load, then set our player's positions accordingly
			strcpy(szNewMap, pExit->GetNewMap());
			g_Player.SetPosition(pExit->GetNewPos());
			g_Player.SetLastPosition(pExit->GetNewPos());

			// Load the new map, then we want to draw the map so we set the draw flag to true.
			// This will get draw from the main game loop when Draw() is called.  Then break.
			Load(szNewMap);
			SetDrawFlag(true);
			break;
		}
	}
}
Example #2
0
void CMap::MoveNpcs()
{
	// Go through all of the npcs
	for(int i = 0; i < (int)m_vNpcs.size(); i++)
	{
		// If the random number is 2500, then move the npc
		if((rand() % 50000000) == 2500)
		{
			COORD position = m_vNpcs[i].GetIndex();
			
			// To make them move even less, we give them a 4/10 chance again :)
			// With the result of this random number they move a random direction.
			switch(rand() % 10)
			{
				case 0:	position.X++;	break;
				case 1:	position.X--;	break;
				case 2:	position.Y++;	break;
				case 3:	position.Y--;	break;
			}

			// Before we assign the new position, we check to see if it's a collision
			if(!IsACollision(position.X, position.Y))
			{
				m_vNpcs[i].SetIndex(position.X, position.Y);
				SetDrawFlag(true);
			}
		}
	}
}
Example #3
0
void SelectClear(int mode)
{
   Uint8 *dst;
   Uint size = 0;
   Uint planes = 0;
   Uint ofset = 0;
   switch(mode) {
     case SCR_200LINE:
       size = 0x4000;
       planes = 3;
       ofset = 0x4000;
       break;
     case SCR_400LINE:
       size = 0x8000;
       planes = 3;
       ofset = 0x8000;
       break;
     case SCR_4096:
       size = 0x2000;
       planes = 12;
       ofset = 0x2000;
       break;
     case SCR_262144:
       size = 0x2000;
       planes = 18;
       ofset = 0x2000;
       break;
   }
   if((size == 0) || (planes == 0)) {
       return;
   }

   if(bCLEnabled) {
#ifdef _USE_OPENCL
     dst = cldraw->GetBufPtr(0);
     if(dst == NULL) {
       cldraw->ReleaseBufPtr();
       return;
     }
     memset(dst, 0x00, size *  planes);
     cldraw->ReleaseBufPtr();
#endif
   } else {
     if(pVram2 == NULL) return;
     switch(nRenderMethod) {
     case RENDERING_RASTER:
       memset(pVram2, 0x00, 640 * 400 * sizeof(Uint32));
       Palet640(); // ?
       Palet320();
       SetDirtyFlag(0, 400, TRUE);
       break;
     case RENDERING_FULL:
     case RENDERING_BLOCK:
       memset(pVram2, 0x00, 640 * 400 * sizeof(Uint32));
       SetDrawFlag(TRUE);
       break;
     }       
   }
   return;
}
//*****************************************************************************
// コンストラクタ
//*****************************************************************************
CAttackBase::CAttackBase(LPDIRECT3DDEVICE9 *pDevice, int nPriority, OBJTYPE objType) : CScene2D(pDevice, nPriority, objType)
{
	// 描画しない
	SetDrawFlag(false);
	
	// 変数初期化
	m_nCount = 0;

	for (int i = 0; i < MAXIMUM_NUMBER_OF_PLAYER; ++i)
	{
		m_bHitPlayer[i] = false;
	}
}
Example #5
0
   /*
    *  320x200、26万色モード セレクト
    */
BOOL Select256k()
{
   /*
    * 全領域無効
    */
//   LockVram();
   int y;
   nDrawTop = 0;
   nDrawBottom = 200;
   nDrawLeft = 0;
   nDrawRight = 320;
   //bPaletFlag = TRUE;
#if defined(USE_SSE2)
    if(pCpuID->use_sse2) {
       pVirtualVramBuilder = &api_vram256k_sse2;
    } else {
       pVirtualVramBuilder = &api_vram256k_generic;
    }
#else
   pVirtualVramBuilder = &api_vram256k_generic;
#endif

   if(!bCLEnabled) {
      Palet640();
      Palet320();
   }
   
   LockVram();
   if((nRenderMethod == RENDERING_RASTER) || (bCLEnabled)){
      bNextFrameRender = TRUE;
      SetDirtyFlag(0, 400, TRUE);
      for(y = 0; y < 400; y++) {
	   bDrawLine[y] = FALSE;
	   bDirtyLine[y] = FALSE;
      }
   } else {
      SetDrawFlag(TRUE);
   }

   /*
    * アナログ(26万色)/200ラインモード
    */
   bMode = SCR_262144;
   SDLDrawFlag.Drawn = TRUE;
   UnlockVram();
   return TRUE;
}
Example #6
0
void CMap::MoveNpcs()
{
	// This function moves the npcs around in random positions.  We just do
	// some simple method of having the npc move only when our random number
	// happens to be 2500 (some trivial number).  That way they sometimes move
	// and sometimes not.  You can make this more smooth with some AI of course.
	// There is another random number that determines which direction they will move.

	// Go through all of the npcs
	for(int i = 0; i < (int)m_vNpcs.size(); i++)
	{
		// Only move the npc if they have a speed
		if(m_vNpcs[i].GetSpeed() <= 0)
			continue;

		// If the random number is 2500, then try to move the npc
		if((rand() % 50000000) == 2500)
		{
			// Get the current npc's position
			POINT position = m_vNpcs[i].GetIndex();
			
			// To make them move even less, we do a random number, mod'ed by 
			// a calculation dealing with the the npc's speed.
			// With the result of this random number they move a random direction.
			switch(rand() % (500 / m_vNpcs[i].GetSpeed()))
			{
				case 0:	position.x += 1;	break;
				case 1:	position.x -= 1;	break;
				case 2:	position.y += 1;	break;
				case 3:	position.y -= 1;	break;
			}

			// Before we assign the new position, we check to see if it's a collision
			if(!IsACollision(position.x, position.y))
			{
				// If no collision, let's position the npc and draw their new position
				m_vNpcs[i].SetIndex(position.x, position.y);
				SetDrawFlag(true);
				g_Map.Draw();
				g_Buffer.SwapBackBuffer(FALSE);
			}
		}
	}
}
Example #7
0
void CMap::MoveNpcs()
{
	// Go through all of the npcs
	for(int i = 0; i < (int)m_vNpcs.size(); i++)
	{
		// Only move the npc if they have a speed
		if(m_vNpcs[i].GetSpeed() <= 0)
			continue;

		// If the random number is 2500, then try to move the npc
		if((rand() % 50000000) == 2500)
		{
			// Get the current npc's position
			POINT position = m_vNpcs[i].GetIndex();
			
			// Move the npcs, according to their spead
			switch(rand() % (500 / m_vNpcs[i].GetSpeed()))
			{
				case 0:	position.x += 1;	break;
				case 1:	position.x -= 1;	break;
				case 2:	position.y += 1;	break;
				case 3:	position.y -= 1;	break;
			}

			// Before we assign the new position, we check to see if it's a collision
			if(!IsACollision(position.x, position.y))
			{
				// If no collision, let's position the npc and draw their new position
				m_vNpcs[i].SetIndex(position.x, position.y);
				SetDrawFlag(true);
				g_Map.Draw();
				g_Buffer.SwapBackBuffer(FALSE);
			}
		}
	}
}
Example #8
0
void CMap::MoveMonsters()
{
	// This function is very much like the MoveNpcs() function, except
	// it has a bit more intelligence.  If a player comes near the monster
	// it will pursue the player and try to attack them.  We do this with
	// a simple distance check between the monster and each player.  If they
	// are in the monster's radius it will pursue the player. Scary huh?!!?!?

	// Go through all of the monsters
	for(int i = 0; i < (int)m_vMonsters.size(); i++)
	{
		// If the monster get lucky and they get the lucky number from random numbers, move'em
		if((rand() % 50000000) == 2500)
		{
			int playerIndex = 0;

			POINT position = m_vMonsters[i].GetIndex();

			// Go through every player and check their distance to the monster
			for(int p = 0; p < g_Player.GetPartySize(); p++)
			{
				// Get the current player in the party and store their position
				CPlayer *pPlayer = g_Player.GetPartyMember(p);	
				POINT playerPos = pPlayer->GetPosition();

				// Here we check if the player is in the range of a monster.  If they
				// are we want the monster to pursue the player and try to attack them.
				if((abs(position.x - playerPos.x) <= kMonsterRange) && 
				   (abs(position.y - playerPos.y) <= kMonsterRange))
				{
					// Store the player that is close to the monster
					playerIndex = p;
					break;
				}
			}

			// Make sure the index returned was valid and not over our party number
			if(playerIndex >= g_Player.GetPartySize())
				playerIndex = 0;

			// Get the player that the monster is close to or the default 0 (Adol)
			CPlayer *pPlayer = g_Player.GetPartyMember(playerIndex);
			POINT playerPos = pPlayer->GetPosition();

			// If the monster is close to them, then move the monster closer to the player
			if((abs(position.x - playerPos.x) <= kMonsterRange) && 
			   (abs(position.y - playerPos.y) <= kMonsterRange))
			{
				// We use the speed to make them go slower if they have a slower speed
				if((rand() % m_vMonsters[i].GetSpeed()/2) != 0)
				{
					// Check which direction on the X axis the monster should move to the player
					if(position.x > playerPos.x)
						position.x -= 1;
					else if(position.x < playerPos.x)
						position.x += 1;

					// Check which direction on the Y axis the monster should move to the player
					if(position.y > playerPos.y)
						position.y -= 1;
					else if(position.y < playerPos.y)
						position.y += 1;
				}
			}
			else	// Otherwise move randomly
			{
				// Do a random number to determine which random direction they should move.
				// We use the speed to make them go slower if they have a slower speed.
				switch(rand() % (500 / m_vMonsters[i].GetSpeed()))
				{
					case 0:	position.x++;	break;
					case 1:	position.x--;	break;
					case 2:	position.y++;	break;
					case 3:	position.y--;	break;
				}
			}

			// If the monster didn't collide with something, set their new position and redraw
			if(!IsACollision(position.x, position.y))
			{
				m_vMonsters[i].SetIndex(position.x, position.y);
				SetDrawFlag(true);
				g_Map.Draw();
				g_Buffer.SwapBackBuffer(FALSE);
			}

			// If the monster ran into a player we should attack the player
			if(position.x == playerPos.x && position.y == playerPos.y)
			{
				m_vMonsters[i].Attack(pPlayer);
			}
		}
	}
}
Example #9
0
void CMap::MoveMonsters()
{
	// This function is very much like the MoveNpcs() function, except
	// it has a bit more intelligence.  If a player comes near the monster
	// it will pursue the player and try to attack them.  We do this with
	// a simple distance check between the monster and each player.  If they
	// are in the monster's radius it will pursue the player. Scary huh?!!?!?

	// Go through all of the monsters
	for(int i = 0; i < (int)m_vMonsters.size(); i++)
	{
		// If the monster get lucky and they get the lucky number from random numbers, move'em
		if((rand() % 50000000) == 2500)
		{
			int playerIndex = 0;

			COORD position = m_vMonsters[i].GetIndex();

			// Go through every player and check their distance to the monster
			for(int p = 0; p < g_Player.GetPartySize(); p++)
			{
				// Get the current player in the party and store their position
				CPlayer *pPlayer = g_Player.GetPartyMember(p);	
				COORD playerPos = pPlayer->GetPosition();

				// Here we check if the player is in the range of a monster.  If they
				// are we want the monster to pursue the player and try to attack them.
				if((abs(position.X - playerPos.X) <= kMonsterRange) && 
				   (abs(position.Y - playerPos.Y) <= kMonsterRange))
				{
					// Store the player that is close to the monster
					playerIndex = p;
					break;
				}
			}

			// Make sure the index returned was valid and not over our party number
			if(playerIndex >= g_Player.GetPartySize())
				playerIndex = 0;

			// Get the player that the monster is close to or the default 0 (Adol)
			CPlayer *pPlayer = g_Player.GetPartyMember(playerIndex);
			COORD playerPos = pPlayer->GetPosition();

			// If the monster is close to them, then move the monster closer to the player
			if((abs(position.X - playerPos.X) <= kMonsterRange) && 
			   (abs(position.Y - playerPos.Y) <= kMonsterRange))
			{
				// Check which direction on the X axis the monster should move to the player
				if(position.X > playerPos.X)
					position.X--;
				else if(position.X < playerPos.X)
					position.X++;

				// Check which direction on the Y axis the monster should move to the player
				if(position.Y > playerPos.Y)
					position.Y--;
				else if(position.Y < playerPos.Y)
					position.Y++;
			}
			else	// Otherwise move randomly
			{
				// Do a random number to determine which random direction they should move
				switch(rand() % 10)
				{
					case 0:	position.X++;	break;
					case 1:	position.X--;	break;
					case 2:	position.Y++;	break;
					case 3:	position.Y--;	break;
				}
			}

			// If the monster didn't collide with something, set their new position
			if(!IsACollision(position.X, position.Y))
			{
				m_vMonsters[i].SetIndex(position.X, position.Y);
				SetDrawFlag(true);
			}

			// If the monster ran into a player we should attack the player
			if(position.X == playerPos.X && position.Y == playerPos.Y)
			{
				m_vMonsters[i].Attack(pPlayer);
			}
		}
	}
}
Example #10
0
void	InitDraw(void)
{
		/*
		 * ワークエリア初期化
		 */
#if XM7_VER >= 3
		bMode = SCR_200LINE;
                bModeOld = bMode;
#else				/*  */
		bAnalog = FALSE;

#endif				/*  */
		bNowBPP = 24;
                pVirtualVramBuilder = NULL;
                _prefetch_data_write_permanent(&rgbTTLGDI, sizeof(rgbTTLGDI));
                memset(rgbTTLGDI, 0, sizeof(rgbTTLGDI));
                _prefetch_data_write_permanent(&rgbAnalogGDI, sizeof(rgbAnalogGDI));
		memset(rgbAnalogGDI, 0, sizeof(rgbAnalogGDI));
                _prefetch_data_write_permanent(&SDLDrawFlag, sizeof(SDLDrawFlag));
		memset((void *)&SDLDrawFlag, 0, sizeof(SDLDrawFlag));
   
		nDrawTop = 0;
		nDrawBottom = 400;
		nDrawLeft = 0;
		nDrawRight = 640;
		nOldDrawHeight = 480;
		nOldDrawWidth = 640;
		nDrawHeight = 480;
		nDrawWidth = 640;
		nDrawFPS = 25;
		nEmuFPS = 20;
		bSyncToVSYNC = TRUE;
		bSmoosing = FALSE;

		bFullScan = TRUE;
		bPaletFlag = FALSE;
		bOldFullScan = bFullScan;
#if XM7_VER >= 3
		nOldVideoMode = SCR_200LINE;
#else
		nOldVideoMode = FALSE;
#endif
	        bFullScanFS = FALSE;
	        bDoubleSize = FALSE;
#if XM7_VER == 1
	        bGreenMonitor = FALSE;
#endif
                bRasterRendering = FALSE;
                bNextFrameRender = FALSE;
                
                _prefetch_data_write_permanent(bDirtyLine, sizeof(bDirtyLine));
                memset(bDirtyLine, 0, sizeof(bDirtyLine));
                _prefetch_data_write_permanent(bDrawLine, sizeof(bDrawLine));
                memset(bDrawLine, 0, sizeof(bDrawLine));
		SetDrawFlag(FALSE);
		nDrawTick1D = 0;
		nDrawTick1E = 0;
		newResize = FALSE;
                old_crtflag = 1;

#if XM7_VER >= 3
		bWindowOpen = FALSE;
		nWindowDx1 = 640;
		nWindowDy1 = 400;
		nWindowDx2 = 0;
		nWindowDy2 = 0;
#endif				/*  */
		bDirectDraw = TRUE;
		DrawINGFlag = FALSE;
		DrawSHUTDOWN = FALSE;
		DrawWaitFlag = FALSE;
//		bUseOpenGL = TRUE;

		/*
		 * 直接書き込み→間接書き込み
		 */

		AG_ThreadCreate(&DrawThread, DrawThreadMain, NULL);
		if(!DrawInitSem) {
			DrawInitSem = SDL_CreateSemaphore(1);
			SDL_SemPost(DrawInitSem);
		}
		/*
		 *  VRAMテクスチャ生成
		 */
#ifdef USE_OPENGL
   uVramTextureID = 0;
#endif /* USE_OPENGL */
   initvramtbl_4096_vec();
   Select640();
}