Пример #1
0
void lose() {
	fillPalette(gameOverScreen_palette, 0, GAMEOVERSCREEN_PALETTE_SIZE);
	drawImage4(0, 0, 240, 160, gameOver);
	drawString4(90, 130, "TRY AGAIN?", PALETTE[2]);
	drawString4(60, 145, "PRESS <START> TO RESTART", PALETTE[2]);
	state = 2;
}
Пример #2
0
void win() {
	fillPalette(startScreen_palette, 0, STARTSCREEN_PALETTE_SIZE);
	drawImage4(0, 0, 240, 160, start);
	drawString4(90, 130, "YOU WIN!", PALETTE[2]);
	drawString4(60, 145, "PRESS <START> TO RESTART", PALETTE[2]);
	state = 2;
}
Пример #3
0
int main() {
	setMode(MODE_4 | BG2_ENABLE);
	startGame();
	while(1) {
		if (KEY_DOWN_NOW(KEY_START) && state == 0) {			
			state = 1;
			numOfLives = 3;
			loadAvatar();
			fillPalette(GPalette_palette, 0, GPALETTE_PALETTE_SIZE);
			PALETTE[200] = BLACK;
			PALETTE[201] = WHITE;
			PALETTE[202] = RED;
			PALETTE[203] = GREEN;
			PALETTE[204] = BLUE;
			
			for (int i = 0; i < 5; i++) {
				homeFlags[i] = 0;
			}
		}
		if (state == 1) {
			drawBG();
			char liveStr[7];
		if (numOfLives >= 0) {
			sprintf(liveStr, "%d", numOfLives);
			drawString4(10, 147, "LIVES LEFT:  ", PALETTE[1]);
			drawString4(80, 147, liveStr, PALETTE[1]);
		}
			drawTrucks();
			drawCars();
			drawCrocodiles();
			drawWoods();
			drawFrog();
			collision();
			reset();
			delay(2);
			waitForVblank();
			flipPage();
		}
		if (state == 2) {
			while (1) {
				if (KEY_DOWN_NOW(KEY_START)) {
					state = 0;
					break;
				}
			}
		}
	}
	return 0;
}
Пример #4
0
//******************
//******************
uint8_t vobSubRead(char *filename,int index,VobSubInfo **info)
{
FILE            *file=NULL;
uint32_t        nb_lines;
VobSubInfo      *sub=NULL;
uint8_t         success=0;
uint32_t        line=0,l;
char            str[1024];
char            *dup;
int             language=0;

        if(!filename)
        {
                printf("Null file ?\n");
                return 0;
        }
        *info=NULL;
        file=fopen(filename,"rt");
        if(!file) 
        {
                printf("Could not open %s file\n",filename);
                return 0;
        }
        nb_lines=countLine(file,index);
        if(!nb_lines)
        {
                printf("Empty file\n");
                 goto subAbort;
        }
        // Try to read the file
        sub=new VobSubInfo;
        memset(sub,0,sizeof(VobSubInfo));
        //
        sub->nbLines=nb_lines;
        sub->lines=new vobSubLine[nb_lines];
        memset(sub->lines,0,sizeof(vobSubLine)*nb_lines);
        printf("Rebuilding %d lines of subs\n",nb_lines);
        
        while(line<nb_lines && !feof(file))
        {
                fgets(str,1023,file); 
                if(!strncmp(str,"palette:",7))
                {
                                 fillPalette(str,sub);
                                 sub->hasPalette=1;
                }
                else 
                {
                        if(!strncmp(str,"timestamp: ",10) && language)        
                        {
                                fillLine(str,sub,line);
                                line++;
                        }
                        else
                        {
                                if(!strncmp(str,"id:",3))       // Catch language/index
                                {
                                  int  l;
                                  char s[50];
                                  s[0]=0;
                                  l=999;
                                  sscanf(str,"id: %s index: %d",s,&l);
                                  printf("Found lang : %s index %d while searching %d\n",s,l,index);
                                  if(l==index)
                                  {
                                	  language=1;
                                	  printf("Match\n");
                                  }
                                  else language=0;                                                                              
                                
                                }
                                else
                                {
                                        if(!strncmp(str,"size:",5))       // Catch original screen dimension
                                        {
                                            sscanf(str,"size:%"SCNu32"x%"SCNu32"",&(sub->width),&(sub->height));
                                        }
                                
                                }
                                
                        }
                }
        }
subSuccess:        
        success=1;
        if(!sub->hasPalette)
        {
            for(int j=0;j<16;j++)
                sub->Palette[j]=j;   
        }
subAbort:        
        if(success)
        {
                *info=sub;
        }
        else
        {
                destroySubInfo( sub);        
        }
        fclose(file);
        return success;

}
Пример #5
0
void startGame() {
	fillPalette(startScreen_palette, 0, STARTSCREEN_PALETTE_SIZE);
	drawImage4(0, 0, 240, 160, start);
	drawString4(30, 140, "PRESS <START> TO PLAY", PALETTE[3]);
}