示例#1
0
文件: gghost.c 项目: kivan117/gghost
/**
 * \brief Logic for custom intro and processes controller input for skipping intro.
 */
void processIntro(void)
{
	//cycles through our sine function to move the ghost smoothly
	wave_tick++;
	if(wave_tick > 127)
		wave_tick = 0;
	player_y = (u8)(100+pgm_read_byte(&(sine32[wave_tick]))); //set ghost height based on sine function
	player_x++; //move ghost left to right 1 pixel
	if(player_x == 104) //at correct moment, trigger sound effect
		TriggerFx(13,0x88,true);
	if(player_x > 224) //when ghost is off screen, end intro and move to main menu
	{
		ResumeSong();
		SetTileTable(title_tiles);
		frame_tick = 8;
		current_frame = 0;
		game_state = MAIN_MENU;
	}

	//read in our player one joypad input
	joy=ReadJoypad(0);

	//if player 1 is currently pressing start
	if((joy&BTN_START) && (joy != lastbuttons))
	{
		ResumeSong();
		SetTileTable(title_tiles);
		frame_tick = 8;
		current_frame = 0;
		lastbuttons=joy;
		game_state = MAIN_MENU;
	}
	lastbuttons=joy;
}
示例#2
0
int main(){

	//Set the font and tiles to use.
	//Always invoke before any ClearVram()
	SetTileTable(font);


	//Clear the screen (fills the vram with tile zero)
	ClearVram();

	//define background color for text rows 10,12 & 14
	backgroundColor[10]=2;
	backgroundColor[12]=6;
	backgroundColor[14]=2;

	//Prints a string on the screen. Note that PSTR() is a macro 
	//that tells the compiler to store the string in flash.
	Print(0,10,PSTR("012345678901234567890123456789012345678901234567890123456789"));
	Print(9,12,PSTR("HIGH RESOLUTION MODE DEMO 60X28 - 6X8 TILES"));
	Print(0,14,PSTR("012345678901234567890123456789012345678901234567890123456789"));
	

	while(1);

} 
示例#3
0
// intro screen
void DoIntro()
{
	
	// random number generator seed
	int rndSeed = 0;
	
	SetTileTable(tiles_mammoth);
	DrawMap2(0, 0, map_mammoth);
	
	// game loop
	char quit = 0;
	while(!quit)
	{
		// wait for v sync
		WaitVsync(1);
		
		// update the seed
		rndSeed += 7;
		
		if(ReadJoypad(0) & BTN_START)
			quit = 1;
	}
	
	// seed the prng
	srand(rndSeed);
}
示例#4
0
	//Callback invoked by UzeboxCore.Initialize()
	void DisplayLogo(){
	
		#if INTRO_LOGO !=0
			#define LOGO_X_POS 18
			
			InitMusicPlayer(logoInitPatches);
			SetTileTable(uzeboxlogo);
					
			//draw logo
			ClearVram();
			WaitVsync(15);		


			#if INTRO_LOGO == 1 
				TriggerFx(0,0xff,true);
			#endif

			DrawMap2(LOGO_X_POS,12,map_uzeboxlogo);
			WaitVsync(6);
			DrawMap2(LOGO_X_POS,12,map_uzeboxlogo2);
			WaitVsync(4);
			DrawMap2(LOGO_X_POS,12,map_uzeboxlogo);

			#if INTRO_LOGO == 2
				SetMasterVolume(0xc0);
				TriggerNote(3,0,16,0xff);
			#endif 
		
			WaitVsync(64);
			ClearVram();
			WaitVsync(20);
		#endif	
	}
示例#5
0
void WinGame(){

	while(GetMasterVolume()){
		if(GetMasterVolume() > 4)
			SetMasterVolume(GetMasterVolume()-4);
		else{
			StopSong();
			break;
		}
		WaitVsync(1);
	}
	FadeOut(9,true);
	SetTileTable(font_tiles);
	ClearVram();
	WaitVsync(45);
	SetMasterVolume(BB_MASTER_VOLUME);
	//TriggerNote(4,24,8,255);//StartSong(main_song);
	FadeIn(2,false);
	TextWriter(1,0,epilogue_string);
	while(1){
		WaitVsync(1);
		if(padState & BTN_START && !(oldPadState & BTN_START))
			break;
	}
	FadeOut(7,true);
}
示例#6
0
void redraw()
{
  int ay,ax; 

  SetTileTable(mazetiles);  // this tells "SetTile" to use teh graphics starting at mazetiles[]
	
	for (ay=0;ay<Y_SIZE-1;ay++)   // go over the maze array depth
		for (ax=0;ax<X_SIZE;ax++) // ...and across the width
			switch (maze[ay][ax])
			{
				case WALL:
					SetTile(ax+3,ay,0); break;  // for each case, check to see what the symbol in the maze is,
				case BLANK:                     // then translate it to a tile from 'mazetiles[]'.  The numbers 
					SetTile(ax+3,ay,5); break;  // are direct tile numbers as seen in Tile Studio
				case EXIT:
					SetTile(ax+3,ay,10); break;
				case PLAYER:
					SetTile(ax+3,ay,7); break;
				default: 
					SetTile(ax+3,ay,2); break;
			};
	for (ax=3;ax<40;ax++) // draw an 'empty' border along the bottom edge of the maze (cosmetics)
		SetTile(ax,24,5);
			//PrintChar(ax+2,ay,maze[ay][ax]);  //this is the 'draw' command from the old text-only version
    Print(3,26,strCred);  // vanity string
}
示例#7
0
文件: gghost.c 项目: kivan117/gghost
/**
 * \brief Setup for custom intro
 */
void initIntro(void)
{
	StopSong(); //don't play song during intro
	MapSprite2(0, player_sprites[0], 0); //setup blue ghost for drawing
	player_x = 0; //set ghost to far left
	player_y = 80; //center ghost vertically
	SetTileTable(logo_tileset); //setup tiles for drawing uzebox logo
}
示例#8
0
int main()
{
	ClearVram();
	SetTileTable(graphicsTiles);
	Screen.overlayTileTable = overlayTiles;
	
	for(int y=0;y<32;y++){
		for(int x=0;x<32;x++){
			SetTile(x,y,0);
		}	
	}

	Screen.scrollHeight = SCREEN_SCROLL_HEIGHT;
	Screen.overlayHeight = SCREEN_OVERLAY_HEIGHT;

	Map_Init();
	int cameraSpeed = 1;
	
	while(1)
	{
		uint16_t joypad = ReadJoypad(0);
		
		if((joypad & BTN_A))
		{
			cameraSpeed = 4;
		}
		else
		{
			cameraSpeed = 1;
		}
		
		if((joypad & BTN_LEFT) && Camera_Position.x > cameraSpeed)
		{
			Camera_Position.x -= cameraSpeed;
		}
		if((joypad & BTN_RIGHT) && Camera_Position.x < (Map_Header.width - MAP_TILE_SCROLL_WRAP_X - 1) * MAP_TILE_PIXEL_SIZE - cameraSpeed)
		{
			Camera_Position.x += cameraSpeed;
		}
		if((joypad & BTN_UP) && Camera_Position.y > cameraSpeed)
		{
			Camera_Position.y -= cameraSpeed;
		}
		if((joypad & BTN_DOWN) && Camera_Position.y < (Map_Header.height - MAP_TILE_SCROLL_WRAP_Y - 1) * MAP_TILE_PIXEL_SIZE - cameraSpeed)
		{
			Camera_Position.y += cameraSpeed;
		}
		
		Map_Update();
//		Screen.scrollX = Camera_Position.x;
	//	Screen.scrollY = Camera_Position.y;

		WaitVsync(1);
	}
	
	return 0;
}
示例#9
0
void GameLoop(){

	InGui = false;
	//if(!Demo)
	//	StartSong(TitleSong);
	FadeIn(3,false);
	ResetLogic();

	SetTileTable(StageTiles);
	DrawMap2(0,0,StageMap);

	Time		= GAMETIME;
//Time = 1;//for fast EEPROM debugging, I'm about 30% sure that 90% of the EEPRom bugs are gone :)
//Frogs[0].Score = 39;
	ColorTime	= 11*60L;//COLORTIMELENGTH;
	ColorIndex	= 0;
	LastAction	= 0;

	while (1){
		WaitVsync(1);



//DrawNumber(ColorTime>>8,3,SCREEN_TILES_V-1,0);
//DrawNumber(ColorTime,8,SCREEN_TILES_V-1,0);
//DrawNumber(ColorIndex,19,SCREEN_TILES_V-1,0);
		if(!ColorTime){
			if(ColorIndex < NUMCOLORSHADES){
				ColorTime = 11*60L;//COLORTIMELENGTH;
				DDRC = pgm_read_byte(&CustomFadeTable[++ColorIndex]);
			}
		}
			ColorTime--;

		UpdateFrogs();
		CheckFlies();
		UpdateFlies();
		Render();

		if(!Time && !(Frogs[0].State & (JUMPING)) && !(Frogs[1].State & (JUMPING))){//let each frog finish jumping if they were in the middle of it
			break;
		}
		else if(Time)
			Time--;
		if(Demo == 255)
			break;

		for(uint8_t i=0;i<MAXPLAYERS;i++){
			if((JoyVal[i] & BTN_START) && !(OldJoyVal[i] & BTN_START)){
				PauseMenu();
				break;
			}	
		}
	}

}
示例#10
0
/**
 * Main code
 */
int main() {
	SetTileTable(tiles);
	SetSpritesTileTable(tiles);
	SetFontTilesIndex(TILE_FIRST_FONT);
	InitMusicPlayer(patches);
	TriggerNote(3,SOUND_INTRO_MUSIC,20,0xff);
	SetUserPostVsyncCallback(vsync_callback);

	// read custom configuration from eeprom
	EepromReadBlock(129, &eeprom_data);
	eeprom_data.id = 129;

	game();
}
示例#11
0
文件: gghost.c 项目: kivan117/gghost
/**
 * \brief Performs some basic initialization functions.
 *
 * Sets up our graphics, initializes a few variables for convenience, loads saved scores and gets the music going.
 */
static void initialSetup()
{
	SetSpritesTileTable(ghost_sprites); //sets the tiles to be used for our various sprites
	SetFontTilesIndex(TITLE_TILES_SIZE); //tiles for the font were included immediately after the include for background tiles
	                               //therefore this says how many tiles in memory to move forward from the first one
	                               //in order to find the beginning of the font tiles
	SetTileTable(title_tiles); //sets the tiles to be used for the normal background tiles in the game
	                     //fonts use this and the index above to set font tiles
	InitMusicPlayer(patches); //initialize the sound engine
	SetMasterVolume(0xff); //set volume to max
	StartSong(midisong); //start playing the main theme
	ClearVram(); //fill entire screen with first tile in the tileset (blank the screen)

	//set up some convenience variables for changing player image and drawing the score
	player_sprites[0]=ghost0;
	player_sprites[1]=ghost1;
	player_sprites[2]=ghost2;
	player_sprites[3]=ghost3;
	player_sprites[4]=ghost4;
	player_sprites[5]=ghost5;
	player_sprites[6]=ghost6;
	player_sprites[7]=ghost7;
	player_sprites[8]=ghost8;
	numbers[0]=num0;
	numbers[1]=num1;
	numbers[2]=num2;
	numbers[3]=num3;
	numbers[4]=num4;
	numbers[5]=num5;
	numbers[6]=num6;
	numbers[7]=num7;
	numbers[8]=num8;
	numbers[9]=num9;

	//checks if our desired eeprom block is setup correctly,
	//if not, it wipes it so we don't have to deal with garbage data in the high score list
	if(checkEeprom()==1)
	{
		wipeEeprom();
	}
	//load our top 10 saved scores from eeprom
	LoadScore(0, 9);
}
示例#12
0
void DisplayHowToPlay(){
	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);

	ClearTextVram();
	DrawMap2(4,1,map_title2);

	Print(1,5,PSTR("The Game of Life is a cellular        "));
	Print(1,6,PSTR("automaton devised by the mathematician"));
	Print(1,7,PSTR("John Conway in 1970. One interacts    "));
	Print(1,8,PSTR("with the game by creating an initial  "));
	Print(1,9,PSTR("configuration and observing how it    "));
	Print(1,10,PSTR("evolves."));

	Print(1,12,PSTR("The game is made of a grid of cells  "));
	Print(1,13,PSTR("each of which has two possible states"));
	Print(1,14,PSTR("alive or dead. Each turn, cells"));
	Print(1,15,PSTR("evolves according to four rules:"));

	Print(1,17,PSTR("1.Any live cell with fewer than two "));
	Print(1,18,PSTR("  live neighbours dies"));

	Print(1,19,PSTR("2.Any live cell with two or three live"));
	Print(1,20,PSTR("  neighbours lives on to the next turn"));

	Print(1,21,PSTR("3.Any live cell with more than three"));
	Print(1,22,PSTR("  live neighbours dies"));

	Print(1,23,PSTR("4.Any dead cell with exactly three"));
	Print(1,24,PSTR("  live neighbours becomes a live cell"));

	Print(15,26,PSTR("PRESS START"));

	while(1){
		if(ReadJoypad(0)==BTN_START){
			while(ReadJoypad(0)!=0);
			return;
		}
	}
}
示例#13
0
/**
 * Called by the assembler initialization routines, should not be called directly.
 */
void InitConsole(void){

#if INTRO_LOGO ==1 
	InitMusicPlayer(initPatches);	
	SetTileTable(uzeboxlogo);
	SetFontTable(uzeboxlogo);
	
	//draw logo
	ClearVram();
	WaitVsync(15);

	TriggerFx(0,0xff,true);
	DrawMap(LOGO_X_POS,12,map_uzeboxlogo);
	WaitVsync(3);
	DrawMap(LOGO_X_POS,12,map_uzeboxlogo2);
	WaitVsync(2);
	DrawMap(LOGO_X_POS,12,map_uzeboxlogo);
	WaitVsync(40);

	ClearVram();
	WaitVsync(20);
#endif
}
示例#14
0
int main(){


SetTileTable(tiles);			//Set the tileset to use (set this first)
SetFontTilesIndex(TILES_SIZE);	//Set the tile number in the tilset that contains the first font
ClearVram();					//Clear the screen (fills the vram with tile zero)

long sectorStart;

sdCardInitNoBuffer();

sectorStart = sdCardFindFileFirstSectorFlash(fileName);

if(sectorStart == 0){
	Print(0,0,PSTR("FILE HELLWRLD.TXT NOT FOUND ON SD CARD"));
} else {

    sdCardCueSectorAddress(sectorStart);


    /*

    HELLO WORLD FROM THE SD CARD
    VERTICAL TEXT
    DOUBLE SPACES
    DOUBLE LINE SPACING DOUBLE LINE SPACING  DOUBLE LINE SPACING DOUBLE LINE SPACING
    RUN2SPANXFOR16BITINDEX

	*/

    // sdCardDirectReadSimple(uint8_t *dest, uint16_t count);
    // sdDirectRead(uint8_t *dest, uint16_t count, uint8_t span, uint8_t run);
    //
    //
    // HELLO WORLD FROM THE SD CARD
    // Read 28 bytes of test straight to VRAM
    // sdCardDirectReadSimple(address, length) == sdDriectReadSimple(address, length, 0, 0)
    // That is SPAN = 0 RUN = 0

    sdCardDirectReadSimple(&vram[COORD(0,0)], 28);    // HELLO WORLD
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // VERTICAL TEXT
    // SPAN = 39
    // RUN = 1
    //
    // Every 1 (RUN) byte skip 39 (SPAN) bytes
    //
    // Screen width = 40 so 39 is screen width - 1

    sdCardDirectRead(&vram[COORD(0,2)], 13, 39, 1);   // VERTICAL TEXT
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // DOUBLE SPACES
    // SPAN = 1
    // RUN = 1
    //
    // Every 1 (RUN) byte skip 1 (SPAN) bytes

    sdCardDirectRead(&vram[COORD(3,2)], 13, 1, 1);    // DOUBLE SPACES
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // DOUBLE SPACES
    // SPAN = 39
    // RUN = 80
    //
    // Every 40 (RUN) bytes skip 39 (SPAN) bytes
    // 40 is one whole line of text
    // 39 is (40-1)

    sdCardDirectRead(&vram[COORD(0,17)], 80, 39, 40); // DOUBLE LINE SPACING
    sdCardSkipBytes(1);                           // Skip the CR/LF

    // 16 bit modes
    // SPAN = 38
    // RUN = 2
    //
    // Every 2 (RUN) bytes skip 38 (SPAN) bytes
    // 2 bytes = 16 bits.  So modes with a 16 bit tile index could use this to fill in a column
    // 38 is (40-2)

    sdCardDirectRead(&vram[COORD(20,4)], 22, 38, 2);  // 16 BIT MODES
}

while(1);

}
示例#15
0
int main(){
	SetTileTable(cTesterTiles);
	SetSpritesTileTable(cursor);
	ClearVram();

	EnableSnesMouse(0,map_cursor);

	//Print the basic stuff on the screen
	DrawMap2(5,26,map_copyright);
	DrawMap2(0,13,map_divider);
	//Detect controller types
	cType[0] = 255; 
	cType[1] = 255; 
	//The controller vars
	int btnHeld[2] = {0,0};
	int btnPressed[2] = {0,0};
	int btnReleased[2] = {0,0};
	int btnPrev[2] = {0,0};
	//Main loop
	while(1){
		//20fps
		WaitVsync(1);
		//Update the controller vars
		btnHeld[0] = ReadJoypad(0);
		btnHeld[1] = ReadJoypad(1);
		btnPressed[0] = btnHeld[0] & (btnHeld[0] ^ btnPrev[0]);
		btnPressed[1] = btnHeld[1] & (btnHeld[1] ^ btnPrev[1]);
		btnReleased[0] = btnPrev[0] & (btnHeld[0] ^ btnPrev[0]);
		btnReleased[1] = btnPrev[1] & (btnHeld[1] ^ btnPrev[1]);
		//Check if controllers changed
		if((DetectControllers() & 3) != cType[0]){
			cType[0] = DetectControllers() & 3;
			Fill(0,0,30,13,0);
			if(cType[0] == GAMEPAD){
				DrawMap2(9,2,map_gamepad);
			}
			else if(cType[0] == MOUSE){
				DrawMap2(12,2,map_mouse);
				DrawMap2(1,4,map_warning);
			}
			else if(cType[0] == NOTHING){
				DrawMap2(9,6,map_nocontroller);
			}
		}
		if((DetectControllers() & 12) / 4 != cType[1]){
			cType[1] = (DetectControllers() & 12) / 4;
			Fill(0,14,30,12,0);
			if(cType[1] == GAMEPAD){
				DrawMap2(9,15,map_gamepad);
				SetSpriteVisibility(false);
			}
			else if(cType[1] == MOUSE){
				DrawMap2(12,15,map_mouse);
				SetSpriteVisibility(true);
				EnableSnesMouse(0,map_cursor);
			}
			else if(cType[1] == NOTHING){
				DrawMap2(9,19,map_nocontroller);
				SetSpriteVisibility(false);
			}
		}
		//Update the buttons
		for(unsigned int i = 0; i < 2; i++){
			if(cType[i] == MOUSE){
				//Check pressed buttons
				if(btnPressed[i] & BTN_MOUSE_LEFT){
					DrawMap2(14,4 + 13*i,map_pmouseb);
				}
				if(btnPressed[i] & BTN_MOUSE_RIGHT){
					DrawMap2(16,4 + 13*i,map_pmouseb);
				}
				//Check released
				if(btnReleased[i] & BTN_MOUSE_LEFT){
					DrawMap2(14,4 + 13*i,map_mouseb);
				}
				if(btnReleased[i] & BTN_MOUSE_RIGHT){
					DrawMap2(16,4 + 13*i,map_mouseb);
				}
			}
			else if(cType[i] == GAMEPAD){
				//Check pressed
				if(btnPressed[i] & BTN_UP){
					DrawMap2(11,6 + 13*i,map_pdpad);
				}
				if(btnPressed[i] & BTN_DOWN){
					DrawMap2(11,8 + 13*i,map_pdpad);
				}
				if(btnPressed[i] & BTN_LEFT){
					DrawMap2(10,7 + 13*i,map_pdpad);
				}
				if(btnPressed[i] & BTN_RIGHT){
					DrawMap2(12,7 + 13*i,map_pdpad);
				}
				if(btnPressed[i] & BTN_START){
					DrawMap2(16,6 + 13*i,map_pstart);
				}
				if(btnPressed[i] & BTN_SELECT){
					DrawMap2(14,6 + 13*i,map_pstart);
				}
				if(btnPressed[i] & BTN_A){
					DrawMap2(20,7 + 13*i,map_pbutton);
				}
				if(btnPressed[i] & BTN_B){
					DrawMap2(19,8 + 13*i,map_pbutton);
				}
				if(btnPressed[i] & BTN_X){
					DrawMap2(19,6 + 13*i,map_pbutton);
				}
				if(btnPressed[i] & BTN_Y){
					DrawMap2(18,7 + 13*i,map_pbutton);
				}
				if(btnPressed[i] & BTN_SL){
					DrawMap2(10,4 + 13*i,map_pbumper);
				}
				if(btnPressed[i] & BTN_SR){
					DrawMap2(18,4 + 13*i,map_pbumper);
				}
				if(btnReleased[i] & BTN_UP){
					DrawMap2(11,6 + 13*i,map_dpad);
				}
				if(btnReleased[i] & BTN_DOWN){
					DrawMap2(11,8 + 13*i,map_dpad);
				}
				if(btnReleased[i] & BTN_LEFT){
					DrawMap2(10,7 + 13*i,map_dpad);
				}
				if(btnReleased[i] & BTN_RIGHT){
					DrawMap2(12,7 + 13*i,map_dpad);
				}
				if(btnReleased[i] & BTN_START){
					DrawMap2(16,6 + 13*i,map_start);
				}
				if(btnReleased[i] & BTN_SELECT){
					DrawMap2(14,6 + 13*i,map_start);
				}
				if(btnReleased[i] & BTN_A){
					DrawMap2(20,7 + 13*i,map_button);
				}
				if(btnReleased[i] & BTN_B){
					DrawMap2(19,8 + 13*i,map_button);
				}
				if(btnReleased[i] & BTN_X){
					DrawMap2(19,6 + 13*i,map_button);
				}
				if(btnReleased[i] & BTN_Y){
					DrawMap2(18,7 + 13*i,map_button);
				}
				if(btnReleased[i] & BTN_SL){
					DrawMap2(10,4 + 13*i,map_bumper);
				}
				if(btnReleased[i] & BTN_SR){
					DrawMap2(18,4 + 13*i,map_bumper);
				}
			}
		}
		btnPrev[0] = btnHeld[0];
		btnPrev[1] = btnHeld[1];
	}
} 
示例#16
0
u8 Title(){
	ClearTextVram();

	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);
	DrawMap2(8,3,map_title1);
	DrawMap2(4,6,map_title2);
	DrawMap2(24,13,map_title3);

	Print(8,15,PSTR("PLAY"));
	Print(8,16,PSTR("HOW TO PLAY"));
//	Print(8,17,PSTR("OPTIONS"));

	Print(13,26,PSTR("V1.1 \\ 2013 Uze"));

	u8 option=0;
	u8 animFrame=0,animDelay=0;
	u8 x=6,y=15;
	u16 joy,prevJoy=0;
	while(1){
		WaitVsync(1);
		joy=ReadJoypad(0);
		AnimateCursor(x,y+option);
		/*
		if(animDelay==15){
			//clear othercursor  location
			SetTile(x,y+(option^1),0);
			SetTile(x+1,y+(option^1),0);

			animDelay=0;
			animFrame++;
			if(animFrame==4)animFrame=0;
			switch(animFrame){
				case 0:
					SetTile(x,y+option,1);
					SetTile(x+1,y+option,2);
					break;
				case 1:
					SetTile(x,y+option,3);
					SetTile(x+1,y+option,4);
					break;
				case 2:
					SetTile(x,y+option,5);
					SetTile(x+1,y+option,6);
					break;
				default:
					SetTile(x,y+option,7);
					SetTile(x+1,y+option,8);
					break;
			}
		}
		animDelay++;
		*/

		if(prevJoy==0){
			if (joy==BTN_SELECT || joy==BTN_UP || joy==BTN_DOWN){
				option^=1;
				animDelay=15;
			}else if(joy==BTN_START){
				while(ReadJoypad(0)!=0);
				return option;
			}
		}
		prevJoy=joy;
	}

}
示例#17
0
int main(){


	SetUserPostVsyncCallback(&VsyncCallBack);



	while(1){
		vmode=0;
		vmode_text_lines=SCREEN_TILES_V;
		paused=true;
		u8 option=0;


		do{
			option=Title();
			if(option==1){
				DisplayHowToPlay();
			}
		}while(option!=0);

		ClearVram();

		SetTileTable(font);
		SetFontTilesIndex(0);
		CreateStatusBar();


		//SetTile(0,0,91);
		//SetTile(1,0,92);
		//Print(1,0,PSTR("Started  Generation:       SELECT=Menu"));


		vmode_text_lines=1;
		//vmode=1;
		vmode_grid_col=9;//82;
		vmode_page=0;

		cursor_x=44;
		cursor_y=25;

		//R-pentamino
		//PutPixel(40,30,1,0);
		//PutPixel(41,30,1,0);
		//PutPixel(39,31,1,0);
		//PutPixel(40,31,1,0);
		//PutPixel(40,32,1,0);



		//u16 joy;

		inMainLoop=true;
		bool gameEnd=false;
		while(1){

			WaitVsync(1);

			if(!paused){
				ComputeNextStep();
				vmode_page^=1;
				gen++;

			}
		
			if(keyAction!=ACTION_NONE){
				switch(keyAction){
					case ACTION_STARTSTOP:
						paused=!paused;
						keyAction=ACTION_NONE;
						break;
					case ACTION_OPENMENU:
						if(OpenMenu()==1){
							gameEnd=true;
							inMainLoop=false;
						}
						keyAction=ACTION_NONE;
						break;
				}

			}

			UpdateStatusBar();
			if(gameEnd)break;
		}
	}

} 
示例#18
0
u8 OpenMenu(){

	ClearTextVram();
	
	SetTileTable(tiles);
	SetFontTilesIndex(TILES_SIZE);

	//Show object types
	Print(6,2,PSTR("Select life object to insert"));
	Print(5,3,PSTR("at the current cursor position"));

	Print(7,7,PSTR("Glider"));
	Print(7,8,PSTR("Lightweight spaceship (LWSS)"))	;
	Print(7,9,PSTR("R-Pentamino"));
	Print(7,10,PSTR("Gosper glider gun"));

	Print(7,11,PSTR("Clear field"));
	Print(7,12,PSTR("Exit game"));


	//slide in menu
	WaitVsync(1);
	Fill(0,0,40,1,0);
	for(u8 i=1;i<29;i++){
		WaitVsync(1);
		vmode_text_lines=i;
	}


	s8 option=0,x=5,y=7;
	u16 joy,prevJoy=0;
	while(1){
		WaitVsync(1);
		joy=ReadJoypad(0);
		if(prevJoy==0){
			if (joy==BTN_UP){
				if(option>0) option--;

			}else if (joy==BTN_DOWN){
				if(option<5)option++;

			}else if(joy==BTN_SELECT){
				break;
			}else if(joy==BTN_START){
				switch(option){
					case 0:
						glider(cursor_x,cursor_y);
						break;

					case 1:
						lwss(cursor_x,cursor_y);
						break;
	
					case 2:
						rPentamino(cursor_x,cursor_y);
						break;					

					case 3:
						gliderGun(cursor_x,cursor_y);
						break;	

					case 4:
						ClearVram();
						break;

					default:						
						while(ReadJoypad(0)!=0);
						return 1;  //signal game end, back to main menu
				}
	
				break;
			}
		}
		prevJoy=joy;
		AnimateCursor(x,y+option);
	}

	while(ReadJoypad(0)!=0);

	//close menu
	for(u8 i=29;i>0;i--){
		WaitVsync(1);
		vmode_text_lines=i;
	}
	ClearTextVram();
	SetTileTable(font);
	SetFontTilesIndex(0);
	CreateStatusBar();
	
	return 0;
}
示例#19
0
int main(){	
	TriggerFx(0,0,0);


	ClearVram();
	InitMusicPlayer(patches);
	SetMasterVolume(0x40);
	StartSong(midisong);

	SetSpritesTileTable(mario_sprites_tileset);
	SetFontTilesIndex(SMB_TILESET_SIZE);
	SetTileTable(smb_tileset);

    Screen.scrollHeight = 23;
	

    Screen.overlayHeight=4;
    Screen.overlayTileTable=smb_tileset;
	DrawMap2(0,Screen.scrollHeight,map_hud);
	
	unsigned char c;
	for(int y=0;y<22;y++){
		for(int x=0;x<30;x++){
			c=pgm_read_byte(&(map_main[(y*MAP_MAIN_WIDTH)+x+2]));
			SetTile(x,y+1,c);
		}	
	}


	dx=0;
	sx=50;
	sy=169-32+8;
	sprDir=1;

	goombaX[0]=17; //159;
	goombaDir[0]=-1;
	goombaAnim[0]=0;
	goombaSpr[0]=0;
	goombaSprIndex[0]=6;

	goombaX[1]=65 ;//201;
	goombaDir[1]=1;
	goombaAnim[1]=0;
	goombaSpr[1]=0;
	goombaSprIndex[1]=10;


	MapSprite2(0,map_rwalk1,0);
	MapSprite2(6,map_rgoomba1,SPRITE_FLIP_X);
	MapSprite2(10,map_rgoomba2,0);



	g=0;
	MoveSprite(0,sx,sy,2,3);
	Scroll(0,-1);

	MoveSprite(goombaSprIndex[0],goombaX[0],176,2,2);
	MoveSprite(goombaSprIndex[1],goombaX[1],176,2,2);

	Screen.scrollY=0;
	Screen.overlayHeight=4;//OVERLAY_LINES;

	
	while(1){
		WaitVsync(1);
	

		processControls();

		if((active&1)!=0){
			PerformActions();
			MoveSprite(0,sx,sy+dy,2,3);
		}else{
			MoveSprite(0,sx,230,2,3);
		}



		//animate goombas
		for(g=0;g<2;g++){
		

				if(goombaX[g]<=0 && goombaDir[g]==-1){
					goombaDir[g]=1;
				}
		
				if(goombaX[g] >= (215+15) && goombaDir[g]==1){
					goombaDir[g]=-1;
			
				}
		
				goombaX[g]+=goombaDir[g];
				goombaAnim[g]++;

				if(goombaAnim[g]==8){
					goombaSpr[g]^=1;
					goombaAnim[g]=0;
				}

				if(goombaSpr[g]==0){
					MapSprite2(goombaSprIndex[g],map_rgoomba1,goombaDir[g]!=1?SPRITE_FLIP_X:0);
				}else{
					MapSprite2(goombaSprIndex[g],map_rgoomba2,goombaDir[g]!=1?SPRITE_FLIP_X:0);
				}

				MoveSprite(goombaSprIndex[g],goombaX[g],176-32+8,2,2);
			

		}
	

	}		
	
}
示例#20
0
文件: gghost.c 项目: kivan117/gghost
/**
 * \brief The main game loop. This just cycles endlessly, it uses the game's 'state' to determine which screen to show and what to do.
 */
int main(){
	//looping back and forth forever (cards against humanity reference)
	while(1)
	{
		//some basic prep work performed once before our custom intro
		if(game_state == INTRO)
		{
			initialSetup();
			initIntro();
		}
		//perform custom intro
		while(game_state == INTRO)
		{
			//wait until the next frame
			WaitVsync(1);
			drawIntro();
			processIntro();
		}
		//prep the main menu
		if(game_state == MAIN_MENU)
		{
			FadeOut(0,true);
			ClearVram();
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawMainMenu();
			FadeIn(0,false);
		}
		//draw menu and handle input
		while(game_state == MAIN_MENU)
		{
			WaitVsync(1);
			drawMenuCursor();
			processMainMenu();
		}
		if(game_state== GAME)
		{
			//run our setup for the main game
			ClearVram();
			FadeOut(0,true);
			gameSetup();
			FadeIn(0,false);
		}
		//when we're in the gameplay portion, draw and accept input for the game
		while(game_state == GAME)
		{
			WaitVsync(1);
			processScrollSpeed(); //scrolls screen as appropriate
			updateCity(); //offsets city for parallax
			processControls(); //accepts and processes controller input
			processPlayerMotion(); //update player position
			processSprites(); //updates and moves player image to player position
		}
		if(game_state == HIGH_SCORES)
		{
			FadeOut(0,true);
			SetTileTable(title_tiles);
			SetFontTilesIndex(TITLE_TILES_SIZE);
			drawLocalHighScoreMenu(); //draw up the high score screen
			FadeIn(0,false);
			deathclock=120; //reset death timer to 2 seconds
			if(score > topscores[9])
			{
			    LoadScore(0, 9); //load top 10 saved high scores
			    SaveScore(score); //save our current score if it's high enough
			    drawLocalHighScoreMenu(); //draw up the high score screen
			}
		}
		//draw and accepts input for the local high score screen
		while(game_state == HIGH_SCORES)
		{
			WaitVsync(1);
			processHighScoreMenu();
		}
    }
}