Beispiel #1
0
/** State - Process game */
void StateUpdateGame()
{
	u8 keyLine;

	// Flip page
	SetPage8(game.page);
	game.page = 1 - game.page;
	game.yOffset = 256 * game.page;

	// Change analglyph effect power
	keyLine = GetKeyMatrixLine(0);
	if((keyLine & KEY_1) == 0)
	{
		if(game.power3d > 0)
			game.power3d--;
		ClearScreen8(BG_COLOR);
	}
	if((keyLine & KEY_2) == 0)
	{
		if(game.power3d < 24)
			game.power3d++;
		ClearScreen8(BG_COLOR);
	}

	// Clear
	ClearLines();
	DrawBackground();

	if(game.playerNum == 1)
	{
		DrawCharacter(128-20, 8 + game.yOffset, '0' + (game.players[0].score >> 4) - ' ', COLOR8_WHITE);
		DrawCharacter(128-12, 8 + game.yOffset, '0' + (game.players[0].score & 0x0F) - ' ', COLOR8_WHITE);
		DrawCharacter(128-4,  8 + game.yOffset, '-' - ' ', COLOR8_WHITE);
		DrawCharacter(128+4,  8 + game.yOffset, '0' + (game.bestScore >> 4) - ' ', COLOR8_WHITE);
		DrawCharacter(128+12, 8 + game.yOffset, '0' + (game.bestScore & 0x0F) - ' ', COLOR8_WHITE);
	}
Beispiel #2
0
/** State - Start game */
void StateStartGame()
{
	game.page = 0;
	SetPage8(game.page);
	game.yOffset = 0;

	SetScreenColor(0, 0, BG_COLOR);
	ClearScreen8(BG_COLOR);

	game.bAnaglyph = TRUE;
	switch(game.anaglyphFx)
	{
		case 0:	game.bAnaglyph = FALSE; break;
		case 1:	game.power3d = 4; break;
		case 2: game.power3d = 8; break;
		case 3: game.power3d = 12; break;
	}
	switch(game.gameSpeed)
	{
		case 0: game.ballSpeed = 10; break;
		case 1: game.ballSpeed = 15; break;
		case 2: game.ballSpeed = 20; break;
	}

	game.page = 0;
	game.yOffset = 0;
	InitBackground();
	game.lineNum[0] = 0;
	game.lineNum[1] = 0;
	game.bestScore = 0;

	// Player 0
	game.players[0].score = 0;
	VEC_SET(game.players[0].position, F10_SET(50), F10_SET(50), F10_SET(0));
	game.players[0].angle = 0;

	// Player 1
	game.players[1].score = 0;
	VEC_SET(game.players[1].position, F10_SET(-50), F10_SET(-50), F10_SET(FIELD_DEPTH));
	game.players[1].angle = 0;

	// Ball
	VEC_SET(game.ballPos, 0, 0, F10_SET(128));
	VEC_SET(game.ballDir, 0, 0, F10_SET(game.ballSpeed));

	game.state = StateUpdateGame;
}
Beispiel #3
0
/** State - initialize system */
void StateInitialize()
{
	u16 x;
	u8 i;

	// Init
	VideoInitialize();
	SetFreq(FREQ_60);
	SetScreen8(LINES_212);
	SetSpriteMode(SPRITE_OFF, 0, 0, 0);
	SetScreenColor(0, 0, COLOR8_BLACK);

	// Clear all VRAM
	ClearScreen8(COLOR8_BLACK);

	// Initialize (ASCII table) sprites
	for(x=0; x<sizeof(g_CharTable) / 8; x++)
	{
		RAMtoVRAM(Modulo2(x * 8, 256), 248 + (x / 32), 8, 1, (u16)&g_CharTable[x * 8]);
	}

	// Create default 8 bytes patern from a 8 bits byte
	for(x=0; x<256; x++)
	{
		for(i=0; i<8; i++)
		{
			if(x & (1 << (7 - (i & 0x07))))
				game.bitToByte[x * 8 + i] = 0xFF;
			else
				game.bitToByte[x * 8 + i] = 0x00;
		}		
	}

	// Create 3D projection table
	for(x=0; x<512; x++)
	{
		game.projZ[x] = (512 - x) >> 3; // (512 - x) << 6 / 512
	}
	game.lineNum[0] = 0;
	game.lineNum[1] = 0;
	game.anaglyphFx = 2;
	game.playerNum = 2;
	game.gameSpeed = 0;

	game.page = 0;
	game.state = StateTitle;
}
Beispiel #4
0
/** State - Initialize title */
void StateTitle()
{
	// Hide working screen (0)
	SetPage8(1);
	SetScreenColor(0, 0, COLOR8_BLACK);
	ClearScreen8(COLOR8_BLACK);

	// Build title
	DrawText(50, 32,       "PONGLYPH", COLOR8_RED);
	DrawText(52, 32 + 256, "PONGLYPH", COLOR8_CYAN);
	DrawText(150, 64,       "PHENIX 2011", COLOR8_GRAY);
	DrawText(150, 64 + 256, "PHENIX 2011", COLOR8_GRAY);

	InitializeMenu(0);
	game.pressed = 0;
	game.page = 0;
	game.state = StateMainMenu;
}
Beispiel #5
0
int main()
{
	initializeGraphics();	

	MouseType mouseObject = IDLE;

	int cursorXLocation = 10;
	int cursorYLocation = 10;

	// These control building & unit logic
	GameEntity* buildingsContainer = NULL;
	GameEntity* unitsContainer = NULL;

	uint16_t population = 0;		// This controls population count
	uint16_t frame = 0;				// This counts frames
	uint16_t unitSpawnDelay = 0;			// This controls the delay between unit spawns

	while (true)
	{
		FlipBuffers();																				// Flip buffers
		
		ClearScreen8(SAND_COLOR);																	// Clear screen

		render(buildingsContainer,unitsContainer);													// Render all buildings and units

		animatePowerPlant(frame);																	// Animate the power plant
		animateBarracks(frame);																		// Animate the barracks

		if(mouseObject!=IDLE)																		// If there has been some mouse action ...
		{
			if(isMovement(mouseObject))																	// ... and it is movement ...
			{
				move(cursorXLocation,cursorYLocation,mouseObject);											// ... movet the mouse.
			}
			 
			else if(isPlacement(mouseObject))															// ... if it is placement ...
			{
				place(cursorXLocation,cursorYLocation,mouseObject,buildingsContainer);						// ... attempt placement.
			}

			else if(isSpawning(mouseObject) && unitSpawnDelay==0 && population!=POP_CAP)				// ... if it is a unit and it's not to soon after the last unit was trained and population cap has not been reached  ...
			{														
				spawn(unitsContainer,buildingsContainer);													// place the unit
				population++;																				// increase population

				unitSpawnDelay = UNIT_SPAWN_COOLDOWN_PERIOD;												// start cooldown timer
			}
		}

		drawCursor(cursorXLocation,cursorYLocation);												// Draw the cursor

		mouseObject = updatedMouseType();															// Update the mouse

		WaitVSync();																				// Sync

		frame = (frame == 100) ? 0 : frame+1;														//	Reset frame count every 100 frames, else increase by one

		if(unitSpawnDelay!=0)																		// If there is a cooldown timer in action ...
			unitSpawnDelay--;																			// ... update it!

	}
	
	// We are environmentaly concious, so we clean after ourselves
	delete buildingsContainer;					
	delete unitsContainer;

	return 0;
}