Example #1
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	
	}
Example #2
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);
}
void rendermap(MainStruct* mains, unsigned char nrplayers)
{
	for(int i = mains->x.p; i < mains->x.p+4; i++)
	{
		for(int u = mains->y.p; u < mains->y.p+8; u++)
		  DrawMap2(((i-mains->x.p)<<3),((u-mains->y.p)<<2) + nrplayers,graveyard_map[i][u]);
	}
}
Example #4
0
/**
 * \brief Draws Main Menu screen.
 */
void drawMainMenu()
{
	//setup cursor position for use with this menu screen
	menu_x = fakemod((drawX+9),VRAM_TILES_H);
	menu_y = 15;
	ClearVram(); //wipe screen
	drawFrame(); //draw up generic menu frame

	//draw fancy title. broken into pieces so it can be reused as much as possible to save space
	DrawMap2(fakemod((drawX+7),VRAM_TILES_H),4,title_gh);
	DrawMap2(fakemod((drawX+13),VRAM_TILES_H),4,title_o);
	DrawMap2(fakemod((drawX+16),VRAM_TILES_H),4,title_st);
	DrawMap2(fakemod((drawX+21),VRAM_TILES_H),4,title_y);
	DrawMap2(fakemod((drawX+9),VRAM_TILES_H),9,title_gh);
	DrawMap2(fakemod((drawX+15),VRAM_TILES_H),10,title_moon);
	DrawMap2(fakemod((drawX+18),VRAM_TILES_H),9,title_st);

	//draw menu options
	Print(fakemod((drawX+11),VRAM_TILES_H),15,PSTR("START GAME"));
	Print(fakemod((drawX+11),VRAM_TILES_H),17,PSTR("HI SCORES"));
	Print(fakemod((drawX+11),VRAM_TILES_H),19,PSTR("SOUND:"));
	//draw copyright info
	Print(fakemod((drawX+4),VRAM_TILES_H),24,PSTR("(C) 2015 JAMES ELLIOTT"));
	//draw on/off next to sound option
	refreshMainMenuSound();
}
Example #5
0
/**
 * Does complete refresh of game screen
 */
void refresh_game_screen() {
	ClearVram();
	DrawMap2(0, 0, tiles_screen);
	draw_field();
	draw_molecule(SCREEN_MOLECULE_X, SCREEN_MOLECULE_Y);
	draw_statistics();
	draw_name();
	draw_cursor();
}
Example #6
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;
			}	
		}
	}

}
Example #7
0
/**
 * \brief Draws the custom intro
 */
void drawIntro(void)
{
	ClearVram(); //wipe screen each frame
	frame_tick--;
	if(frame_tick == 0) //animation alarm has been reached, reset alarm and change sprite to next frame
	{
		frame_tick = 8; //reset alarm
		current_frame++; //move forward to next animation frame
		if(current_frame == max_frames)
		{
			current_frame=0;
		}
		current_sprite = player_sprites[current_frame]; //change our tracking variable to the correct sprite based on new frame
		MapSprite2(0, current_sprite, 0); //actually reassign the sprites in memory to the correct images
	}
	MoveSprite(0, player_x, player_y, 3, 3); //position ghost sprite
	DrawMap2(13,12,map_uzeboxlogo); //draw uzebox logo and name
    if((player_x > 104)&&(player_x<108)) //at the right moment, draw the shiny reflection on the logo
        DrawMap2(13,12,map_uzeboxlogo2);
}
Example #8
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;
		}
	}
}
char introscreen(GameStruct* game)
{
	unsigned char counter;
	unsigned int joypad;

	ClearVram();
	memset(sprites, 0, sizeof(struct SpriteStruct)*32);

	SetFontTilesIndex(49);
	screenSections[1].flags = SCT_PRIORITY_BG;
	screenSections[0].tileTableAdress = zombienator_title;
	screenSections[1].scrollX = screenSections[1].scrollY = 0;
	setoverlay(0);

	game->menupos = counter = 0;

	DrawMap2(0,6, title_map);
	for(int i = 0; i < 22; i++)
		SetTile(i, 10, 27 + i);

	for(;;)
	{
		WaitVsync(1);
		Fill(0,13, SCREEN_TILES_H, SCREEN_TILES_V - 13, 0);

		Print(5, 14, singlestr);
		Print(5, 15, multistr);
		Print(5, 16, highstr);
		Print(3, 14 + game->menupos, selectstr);
		joypad = 0;
		counter++;
		game->frames++;
		
		if(counter >= 15)
		{
			counter = 0;
			while(!(joypad&(BTN_START|BTN_SELECT|BTN_UP|BTN_DOWN)))
			{
				joypad = ReadJoypad(0);
				switch(joypad&(BTN_START|BTN_SELECT|BTN_UP|BTN_DOWN))
				{
					case BTN_START:
					case BTN_SELECT:
						if(game->menupos == 0)
							return 1;
						else if(game->menupos == 1)
							return 2;
						break;
					case BTN_UP:
						if(game->menupos > 0 )
							game->menupos--;
						else
							game->menupos = 2;
						break;
					case BTN_DOWN:
						if(game->menupos < 2)
							game->menupos++;
						else
							game->menupos = 0;
						break;
				}
			}
		}
	}


	return 0;
}
Example #10
0
/**
 * Main menu (level selection)
 */
void menu() {
	uint8_t scroll = 0;
	uint8_t delay = false;
	uint8_t e_traj_offset1 = 0;
	uint8_t e_traj_offset2 = ELECTRON_TRAJECTORY_LAST_STEP / 2;

	unsigned int joypad;

	ClearVram();
	hide_sprites();

	for (uint8_t sprite_id = 0; sprite_id < 6; sprite_id++) {
		sprites[sprite_id].tileIndex = TILE_FIRST_ELECTRON + sprite_id;
	}

	DrawMap2(2, 2, logo_logo_map);

	// credits
	Print(2, 23, PSTR("2011 UZEBOX ATOMIX"));
	Print(2, 24, PSTR("PROGRAM: MARTIN SUSTEK"));
	Print(2, 25, PSTR("LEVEL DESIGN: ANDREAS WUEST"));

	// initial scroll position
	scroll = (level - 1);
	if ((level - 1) < SCREEN_MENU_LEVEL_LINES) {
		scroll = 0;
	}
	if ((level - 1) > LEVEL_COUNT - SCREEN_MENU_LEVEL_LINES) {
		scroll = LEVEL_COUNT - SCREEN_MENU_LEVEL_LINES;
	}

	while (true) {
		WaitVsync(1);

		// electrons animation
		e_traj_offset1++;
		if (e_traj_offset1 > ELECTRON_TRAJECTORY_LAST_STEP) {
			e_traj_offset1 = 0;
		}
		e_traj_offset2++;
		if (e_traj_offset2 > ELECTRON_TRAJECTORY_LAST_STEP) {
			e_traj_offset2 = 0;
		}
		sprites[0].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_1x + e_traj_offset1));
		sprites[0].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_1y + e_traj_offset1));
		sprites[1].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_2x + e_traj_offset2));
		sprites[1].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_2y + e_traj_offset2));
		sprites[2].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_3x + e_traj_offset1));
		sprites[2].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_3y + e_traj_offset1));
		sprites[3].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_1x + e_traj_offset2));
		sprites[3].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_1y + e_traj_offset2));
		sprites[4].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_2x + e_traj_offset1));
		sprites[4].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_2y + e_traj_offset1));
		sprites[5].x = (SCREEN_ELECTRON_X + pgm_read_byte(e_traj_3x + e_traj_offset2));
		sprites[5].y = (SCREEN_ELECTRON_Y + pgm_read_byte(e_traj_3y + e_traj_offset2));

		for (uint8_t i = 0; i < SCREEN_MENU_LEVEL_LINES; i++) {
			uint8_t current_level = (i + 1 + scroll);
			if ((current_level > 0) && (current_level <= 50)) {
				uint8_t y = 11 + i;
				// level number
				PrintByte(3, y, current_level, false);

				// level name (shorten and pad with spaces)
				for (uint8_t j = 0; j < 24; j++) {
					char ch = pgm_read_byte(levels + (current_level - 1) * LEVEL_BYTE_SIZE + j);
					if (ch == '\0') {
						ch = ' ';
					}
					PrintChar(6 + j, y, ch);
				}

				// level done yet symbol
				if (eeprom_data.data[current_level / 8] & 1 << (current_level % 8)) {
					PrintChar(4, y, FONT_TICK);
				} else {
					PrintChar(4, y, ' ');
				}

				// cursor symbol
				if (current_level == level) {
					PrintChar(5, y, FONT_CURSOR);
				} else {
					PrintChar(5, y, ' ');
				}
			}
		}
		// molecule thumbnail
		draw_molecule(21, 2);

		// controls
		if (delay) {
			WaitVsync(4);
			delay = false;
		}
		joypad = ReadJoypad(0);
		if (joypad & BTN_UP) {
			if (level > 1) {
				play_sound(SOUND_MENU_MOVE);
				level--;
				if (scroll + 1 > level) {
					scroll--;
				}
				delay = true;
			} else {
				play_sound(SOUND_MENU_CANT_MOVE);
			}
		}
		if (joypad & BTN_DOWN) {
			if (level < LEVEL_COUNT) {
				play_sound(SOUND_MENU_MOVE);
				level++;
				if (scroll + SCREEN_MENU_LEVEL_LINES < level) {
					scroll++;
				}
				delay = true;
			} else {
				play_sound(SOUND_MENU_CANT_MOVE);
			}
		}
		if (joypad & BTN_START) {
			hide_sprites();
			play_sound(SOUND_MENU_SELECT);
			return;
		}

	}
}
Example #11
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];
	}
} 
Example #12
0
int main(){	

	unsigned char i,c,x,y,spr;
	
	ClearVram();
		
	//initialize stuff
	InitMusicPlayer(patches);
	SetMasterVolume(0xc0); //crank up the volume a bit since the sample is not too loud

	SetSpritesTileTable(cubes_tileset);
	SetSpritesOptions(SPR_OVERFLOW_CLIP);

	//To allocate/deallocate a player's voice
	//tracks[0].allocated=false;
	//tracks[1].allocated=false;
	//tracks[2].allocated=false;


	//start the beat loop
	TriggerNote(3,1,23,0xff);

	
 	//Define the screen sections. 

	for(i=0;i<9;i++){
		screenSections[i].tileTableAdress=spritedemo_tileset;
	}

	screenSections[0].height=76;	
	screenSections[0].flags=SCT_PRIORITY_SPR;

	screenSections[1].height=2;
	screenSections[1].vramBaseAdress=vram+(32*37);
	screenSections[1].flags=SCT_PRIORITY_BG;

	screenSections[2].height=3;
	screenSections[2].vramBaseAdress=vram+(32*37);
	screenSections[2].flags=SCT_PRIORITY_BG;
	screenSections[2].scrollY=2;

	screenSections[3].height=3;
	screenSections[3].vramBaseAdress=vram+(32*37);
	screenSections[3].flags=SCT_PRIORITY_BG;
	screenSections[3].scrollY=5;

	screenSections[4].height=40;
	screenSections[4].vramBaseAdress=vram+(32*32);
	screenSections[4].flags=SCT_PRIORITY_SPR;

	screenSections[5].height=3;
	screenSections[5].vramBaseAdress=vram+(32*38);
	screenSections[5].flags=SCT_PRIORITY_BG;

	screenSections[6].height=3;
	screenSections[6].vramBaseAdress=vram+(32*38);
	screenSections[6].flags=SCT_PRIORITY_BG;
	screenSections[6].scrollY=3;

	screenSections[7].height=2;
	screenSections[7].vramBaseAdress=vram+(32*38);
	screenSections[7].flags=SCT_PRIORITY_BG;
	screenSections[7].scrollY=6;

	screenSections[8].height=76;
	screenSections[8].flags=SCT_PRIORITY_SPR;
	screenSections[8].scrollY=132;

	Fill(0,37,32,1,1);
	Fill(0,38,32,1,2);


	for(y=0;y<30;y+=4){
		for(x=0;x<30;x+=5){
			DrawMap2(x,y,map_bg);
		}
	}

	DrawMap2(0,32,map_logo);

	for(i=22;i<32;i++){
		DrawMap2(i,32,map_bar);
	}
	
	srand(18);
	c=1;
	spr=1;
	for(i=0;i<7;i++){
		//randomize positions
		cubes[i].x=((unsigned char)(rand() % 110))+2;
		cubes[i].y=((unsigned char)(rand() % 180))+2;

		cubes[i].rotation=((unsigned char)(rand() % 7));

		if((unsigned char)(rand() % 16)<10){
			cubes[i].xdir=1;
		}else{
			cubes[i].xdir=-1;
		}

		if((unsigned char)(rand() % 16)<8){
			cubes[i].ydir=1;
		}else{
			cubes[i].ydir=-1;
		}


	}

	c=0;
	char w1=0,w2=0;
	while(1){

		//syncronize gameplay on vsync (30 hz)	
		WaitVsync(1);

		w2++;
		if(w2==3){
			sx3++;
			if(sx3>X_SCROLL_WRAP) sx3=0;		
			
			screenSections[1].scrollX=sx3;	
			screenSections[7].scrollX=sx3;	
			
			w2=0;
		}

		w1++;
		if(w1==2){
			sx2++;
			if(sx2>=X_SCROLL_WRAP) sx2=0;		
			
			screenSections[2].scrollX=sx2;	
			screenSections[6].scrollX=sx2;	
			
			w1=0;
		}

		sx++;
		if(sx>=X_SCROLL_WRAP) sx=0;

		screenSections[3].scrollX=sx;	
		screenSections[4].scrollX=sx;
		screenSections[5].scrollX=sx;	

		screenSections[0].scrollY++;
		screenSections[8].scrollY++;



		spr=1;
		for(i=0;i<7;i++){
	
			cubes[i].x+=cubes[i].xdir;
			cubes[i].y+=cubes[i].ydir;
			
			if(cubes[i].x>123 && cubes[i].xdir==1){
				cubes[i].xdir=-1;
			}
			if(cubes[i].x<9 && cubes[i].xdir==-1){
				cubes[i].xdir=1;
			}

			cubes[i].y+=cubes[i].ydir;
			if(cubes[i].y>=196 && cubes[i].ydir==1){
				cubes[i].ydir=-1;
			}
			if(cubes[i].y<10 && cubes[i].ydir==-1){
				cubes[i].ydir=1;
			}
		

			if(c==0){
				cubes[i].rotation++;
				if(cubes[i].rotation==14)cubes[i].rotation=0;

				sprites[spr+0].tileIndex=(cubes[i].rotation*2)+1;
				sprites[spr+1].tileIndex=(cubes[i].rotation*2)+1+1;
				sprites[spr+2].tileIndex=(cubes[i].rotation*2)+1+29;
				sprites[spr+3].tileIndex=(cubes[i].rotation*2)+1+30;
			}

			
				sprites[spr+0].x=cubes[i].x;
				sprites[spr+0].y=cubes[i].y;

				sprites[spr+1].x=cubes[i].x+6;
				sprites[spr+1].y=cubes[i].y;

				sprites[spr+2].x=cubes[i].x;
				sprites[spr+2].y=cubes[i].y+8;

				sprites[spr+3].x=cubes[i].x+6;
				sprites[spr+3].y=cubes[i].y+8;
		
			spr+=4;
			c+=128;
		}

		processControls();

		
	
	}
}
Example #13
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;
	}

}
Example #14
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);
			

		}
	

	}		
	
}