showPlayerDefeatedByEEUU()
{
	int loop;
	
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = usacpuwinsPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = usacpuwinsData[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(10000);
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabmaonixPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabmaonixdata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6500);
}
void showChinaEnding()
{
	int loop;
	
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabchvsusa1Palette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabchvsusa1data[loop];
   	}
	
    WaitForVblank();
	Flip();
	Sleep(6000);
	EraseScreen();
   	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabchvsusa2Palette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabchvsusa2data[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6000);
	EraseScreen();
   	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabfinalchPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabfinalchdata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6000);
	WaitForStart();
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabmaonixPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabmaonixdata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6500);
}
void showUSAEnding()
{
	int loop;
	
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabusavsch1Palette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabusavsch1data[loop];
   	}
	
    WaitForVblank();
	Flip();
	Sleep(6000);
	EraseScreen();
   	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabusavsch2Palette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabusavsch2data[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6000);
	EraseScreen();
   	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabfinalusaPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabfinalusadata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6000);
	WaitForStart();
	EraseScreen();
	
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabmaonixPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabmaonixdata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(6500);
}
Exemple #4
0
void switchTile(Move_t move)
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;

	// get blank tiles current co-ordinates 
	int x_blank = game_grid[0].x_cord;
	int y_blank = game_grid[0].y_cord;

	// calcualte co-ordinates for the tile that you need to switch with the blank tile
	int x_tile = 0;
	int y_tile = 0;
	int tile_to_move = 0;

	if (move == UP)
	{
		x_tile = x_blank;
		y_tile = y_blank - 1;
		// draw black tiles over the 2 tiles you need to move


	} else if (move == DOWN)
	{
		x_tile = x_blank;
		y_tile = y_blank + 1;
	} else if (move == RIGHT)
	{
		x_tile = x_blank + 1;
		y_tile = y_blank;
	} else //(move == LEFT)
	{
		x_tile = x_blank - 1;
		y_tile = y_blank;
	}

	tile_to_move = game_state[x_tile][y_tile];

	// draw black tiles over the 2 tiles you need to move
	WaitForVblank();
	drawRect3(y_cords[y_tile], x_cords[x_tile], TILE1_WIDTH, TILE1_HEIGHT, BLACK);
	drawRect3(y_cords[y_blank], x_cords[x_blank], TILE1_WIDTH, TILE1_HEIGHT, BLACK);

	// draw the two tiles 
	WaitForVblank();
	drawImage3(y_cords[y_tile], x_cords[x_tile], TILE1_WIDTH, TILE1_HEIGHT, game_grid[0].image_data);
	drawImage3(y_cords[y_blank], x_cords[x_blank], TILE1_WIDTH, TILE1_HEIGHT, game_grid[tile_to_move].image_data);		

	// update game_grid
	game_grid[tile_to_move].x_cord = x_blank;
	game_grid[tile_to_move].y_cord = y_blank;

	game_grid[0].x_cord = x_tile;
	game_grid[0].y_cord = y_tile;

	// update game_state
	game_state[x_blank][y_blank] = tile_to_move;
	game_state[x_tile][y_tile] = 9;

}
////////////////////////////////////////////////////////////
// Draw Tetris Title 
////////////////////////////////////////////////////////////
void DrawTitleDown(int y_cur)
{
	int x, y;
	int y_start_in_image;
	int y_start_in_screen = 0;
	int width, y_temp; 	// For performance
	
	
	y_start_in_image = TETRIS_TITLE_HEIGHT  - y_cur;
	if(y_start_in_image < 0) {
		y_start_in_screen = 0-y_start_in_image;
		y_start_in_image = 0;
	} 
	
	EraseScreenNoFlip();
	width = TETRIS_TITLE_WIDTH / 2;
	
   	for(y = y_start_in_image; y < TETRIS_TITLE_HEIGHT; y++) {
   		y_temp = (y - y_start_in_image) + y_start_in_screen;
		for(x = 0; x < width; x++) {
			PlotPixel(x+10,y_temp, tetrisTitleData[(y*width)+x]);
		}
	}
		
	WaitForVblank();
	Flip();
}
/*
 *
 * @ destination_row: the row on the screen that the animation will begin at
 * @ destination_col: the column on the screen that the animation will begin at
 */
void animator(int theRow, int theCol)
{
	for (int i = 0; i < 4; i++)
	{
		WaitForVblank();
		draw_image_portion(theRow,theCol,0, i*15, 15, 21, ghost, GHOST_WIDTH);
	}
	
}
Exemple #7
0
void startGame() 
{
	// draw grid
	WaitForVblank();
	drawImage3(0,0,160,240, grid);

	// draw tiles
	WaitForVblank();
	for (int i = 0; i < HEIGHT; ++i)
	{
		for (int j = 0; j < WIDTH; ++j)
		{
			// 8, 7, 6,
			// 5, 4, 3, 
			// 2, 1, 0
			drawImage3( y_cords[i], x_cords[j], TILE1_WIDTH, TILE1_HEIGHT, game_grid[((WIDTH * HEIGHT) - 1) - (WIDTH * i) - j].image_data);
		}
	}
}
////////////////////////////////////////////////////////////
// Clear PRESS START image from screen
////////////////////////////////////////////////////////////
void ClearPressStart()
{
	int x, y;
	for(y = 0; y < TETRIS_TITLE_PRESS_START_HEIGHT; y++) {
		for(x = 0; x < TETRIS_TITLE_PRESS_START_WIDTH/2; x++) {			
			PlotPixel(x+38,y+115,0x00);
		}
	}
	
	WaitForVblank();
	Flip();	
}
////////////////////////////////////////////////////////////
// Draw PRESS START image to screen
////////////////////////////////////////////////////////////
void DrawPressStart()
{
	int x, y;
	
	for(y = 0; y < TETRIS_TITLE_PRESS_START_HEIGHT; y++) {
		for(x = 0; x < TETRIS_TITLE_PRESS_START_WIDTH/2; x++) {
			PlotPixel(x+38,y+115,tetrisTitlePressStartData[(y*TETRIS_TITLE_PRESS_START_WIDTH/2)+x]);
		}
	}
	
	WaitForVblank();
	Flip();
}
Exemple #10
0
void intro0()
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;

	WaitForVblank();
	drawImage3(0,0,160,240,welcome);

	while(!KEY_DOWN_NOW(BUTTON_A) && !KEY_DOWN_NOW(BUTTON_SELECT));
		if (KEY_DOWN_NOW(BUTTON_A))
		{
			state = INTRO1;
		} else 
		{
			state = WELCOME;
		}
	while(KEY_DOWN_NOW(BUTTON_A)|| KEY_DOWN_NOW(BUTTON_SELECT));
}
Exemple #11
0
void intro4()
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;

	WaitForVblank();
	drawImage3(0,0,160,240,instruction4);

	while(!KEY_DOWN_NOW(BUTTON_A) && !KEY_DOWN_NOW(BUTTON_SELECT));
		if (KEY_DOWN_NOW(BUTTON_A))
		{
			state = PLAYING;
		} else 
		{
			state = WELCOME;
		}
	while(KEY_DOWN_NOW(BUTTON_A)|| KEY_DOWN_NOW(BUTTON_SELECT));
}
// show the game intro.
void showGameIntro()
{
	int loop;
	
	EraseScreen();
	
	// logo - saludIntro
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = saludIntroPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = saludIntroData[loop];
   	}
	
    WaitForVblank();
	Flip();
	Sleep(2500);
	EraseScreen();
   	
	// logo Hammer Keyboard Studios.
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = HKlogoDataPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = HKlogoDatadata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(2000);
	EraseScreen();
   	
	// logo - Rlogo
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = RlogoPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = Rlogodata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(2000);
	EraseScreen();
	
	// logo - Main Screen
	for(loop=0;loop<256;loop++) {
      	ScreenPal[loop] = tabmainlogoPalette[loop];     
   	}

   	for(loop=0;loop<19200;loop++) {
      	ScreenBuffer[loop] = tabmainlogodata[loop];
   	}
	
   	WaitForVblank();
	Flip();
	Sleep(2000);
}
Exemple #13
0
int main()
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;
	int row = 140;
	int col = 110;
	int oldrow = row;
	int oldcol = col;
	int isPressed = 0;
	int isPressed1 = 0;
	int size = 20;
	int oldsize = size;
	// drawChar(140, 5, 'A', RED);

	int i;
	int dels[] = {1, 2, 3, 4, 5};
	int numdels = sizeof(dels)/sizeof(dels[0]);
	unsigned short colors[] = {RED, GREEN, BLUE, MAGENTA, CYAN, YELLOW, WHITE};
	int numcolors = sizeof(colors)/sizeof(colors[0]);
	COIN objs[4];
	COIN oldobjs[4];
	int numCoins = sizeof(objs)/sizeof(objs[0]);
	COIN *cur;
	for(i=0; i<numCoins; i++)
	{
		objs[i].row = (rand()%100) - 100;// +  rand()% 20;

		//int a = rand() % 3;//tells which column to put block in
		objs[i].col = (i%3)*90 + 20; 
		objs[i].rd = dels[rand()%numdels];
		objs[i].cd = dels[rand()%numdels];
		//objs[i].rd = 2;
		//objs[i].cd = 2;
		objs[i].color = colors[i%numcolors];
		oldobjs[i] = objs[i];
	}



	//unsigned short bgcolor = LTGRAY;
	//DMA[3].src = &bgcolor;
	//DMA[3].dst = videoBuffer;
	//DMA[3].cnt = 38400 | DMA_ON | DMA_SOURCE_FIXED;

	while(1) // Game Loop
	{
		if(KEY_DOWN_NOW(BUTTON_RIGHT))
		{
			if(!isPressed) {
				col = col + (MAXWIDTH - size) / 2;
				if (col >= MAXWIDTH) {
					col = MAXWIDTH;
				}
			}
			isPressed = 1;
		} else {
			isPressed = 0;
		}
		if(KEY_DOWN_NOW(BUTTON_LEFT))
		{
			if(!isPressed1) {
				col = col - (MAXWIDTH - size) / 2;
				if (col <= MINWIDTH) {
					col = MINWIDTH;
				}
			}
			isPressed1 = 1;
		} else {
			isPressed1 = 0;
		}
	//draw coins
		for (i=0; i<numCoins; i++) {
			cur = objs + i;
			cur->row = cur->row + cur->rd;
			//cur->col = cur->col + cur->cd;

			if (boundsCheck(cur->row, 239, 20) == 1) { //passed bounds
				cur->col = (i%3)*90 + 20; //picks new col
        			cur->row = 0; //puts back to top
				cur->rd = dels[rand()%numdels];
			}
		}

		for(i=0; i<numCoins; i++) {
			drawRect(oldobjs[i].row, oldobjs[i].col, 20, 20, BLACK);
		}
		
		for(i=0; i<numCoins; i++) {
			cur = objs + i;
			if (boundsCheck(cur->row, 239, 20) != 2) { //less than 0
				drawRect(cur->row, cur->col, 20, 20, cur->color);
			}
			oldobjs[i] = objs[i];
			
		}
		oldsize = size;
	//


		WaitForVblank();
		drawRect(oldrow, oldcol, oldsize, oldsize, BLACK);// draw background
		drawRect(row, col, size, size, BLUE); //draw player


		oldrow = row;
		oldcol = col;
		oldsize = size;
	}
}
Exemple #14
0
int main() {
	REG_DISPCTL = MODE3 | BG2_ENABLE;


    while(1) {
        died = 0;
        drawImage3(0,0,TITLESCREEN_WIDTH,TITLESCREEN_HEIGHT,titleScreen);
        if (KEY_DOWN_NOW(BUTTON_START)) {    
            CHARACTER character = mario;
            mario.col = 50;
            QUESTIONBLOCK questionBlocks[] = {questionBlock1,questionBlock2};
            int numBlocks = 2;
            ENEMY enemies[] = {goomba1,goomba2,goomba3,goomba4};
            int numEnemies = 4;
            int jumpHeight = 0;
            levelColLeft = 0;
            levelColRight = 240;
            backgroundCol = 0;
            backgroundCount = 0;
            lives = 3;
            coins = 0;
            flag.col = 500;
            drawMenuIcons();
	        while(1) {
                character.atBoundary = 0;
                if (KEY_DOWN_NOW(BUTTON_SELECT)) { break; }
                if (KEY_DOWN_NOW(BUTTON_LEFT)) {
                    moveLeft(&character,questionBlocks,numBlocks,enemies,numEnemies);
                }
                if (KEY_DOWN_NOW(BUTTON_RIGHT)) {
                    moveRight(&character,questionBlocks,numBlocks,enemies,numEnemies);
                }
                if (KEY_DOWN_NOW(BUTTON_A) && !character.jumpingUp && !character.fallingDown) {
                    character.jumpingUp = 1;
                    character.fallingDown = 0;
                    int *rowPtr;
                    rowPtr = (int *) malloc(sizeof(int));
                    *rowPtr = character.row;
                    jumpHeight = *rowPtr - 2 * character.height[character.mode] + 7;
                }
                if (character.jumpingUp) {
                    jump(&character,jumpHeight,questionBlocks,numBlocks);
                } else if (character.fallingDown) {
                    fall(&character,enemies,numEnemies);
                }
		        WaitForVblank();
                if (character.atBoundary && character.direction == 0) {
                    scrollBackgroundRight();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        questionBlocks[b].col -= 1;
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        enemies[e].col -= 1;
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    flag.col -= 1;
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                } else if (character.atBoundary && character.direction == 1) {
                    scrollBackgroundLeft();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        questionBlocks[b].col += 1;
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        enemies[e].col += 1;
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    flag.col += 1;
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                } else {
                    drawBackground();
                    int b;
                    for (b = 0; b < numBlocks; b++) {
                        int screenCol = questionBlocks[b].col - levelColLeft;
                        if (questionBlocks[b].col > levelColLeft && questionBlocks[b].col + questionBlocks[b].width < levelColRight) {
                            drawImage3(questionBlocks[b].row,screenCol,questionBlocks[b].width,
                                questionBlocks[b].height,questionBlocks[b].images[questionBlocks[b].mode]);
                        }
                    }
                    int e;
                    for (e = 0; e < numEnemies; e++) {
                        int screenCol = enemies[e].col - levelColLeft;
                        if (enemies[e].isDead == 0 && enemies[e].col > levelColLeft && enemies[e].col + enemies[e].width < levelColRight) {
                            drawImage3(enemies[e].row,screenCol,enemies[e].width, enemies[e].height,
                                enemies[e].images[enemies[e].mode]);
                        }
                    }
                    int screenCol = flag.col - levelColLeft;
                    if (flag.col > levelColLeft && flag.col + flag.width < levelColRight) {
                        drawImage3(flag.row,screenCol,flag.width,flag.height,flagpole);
                    }
                }
                
                drawImage3(character.row,character.col,character.width[character.mode],
                    character.height[character.mode],character.images[character.mode]);
                if (lives < 0) { 
                    died = 1;                    
                    break; 
                }
                if (character.col > flag.col - levelColLeft) {
                    died = 0;
                    break;
                }
	            updateVars();
	        }
            if (died == 1) {
                while (1) {
                    drawImage3(0,0,GAMEOVER_WIDTH,GAMEOVER_HEIGHT,gameOver);
                    if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_SELECT)) {
                        break;
                    }
                }        
            } else if (died == 0) {
                drawRect(0,0,20,240,BLACK);
                char levelComplete[50] = "Level Complete!\0";
                drawString(5,78,levelComplete,RED);
                while (1) {
                    if (KEY_DOWN_NOW(BUTTON_START) || KEY_DOWN_NOW(BUTTON_SELECT)) {
                        break;
                    }
                }
            }
        }  
    }
}