Esempio n. 1
0
cui_menu menu_home(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); 
	
	UI_button button_loader;
	UI_InitBtn(&button_loader, 200, 200, "Loader");
	button_loader.img = GRRLIB_LoadTexture(button_png);
	button_loader.font = font;
	
	UI_button button_menu;
	UI_InitBtn(&button_menu, 400, 200, "Wii menu");
	button_menu.img = GRRLIB_LoadTexture(button_png);
	button_menu.font = font;
	

	while(!done)
	{		
		GRRLIB_FillScreen(0x000000FF);
		GRRLIB_PrintfTTF (15, 0, font, "HOME Menu", 96, 0xFFFFFFFF);
		GRRLIB_Line(0, 100, 640, 100, 0xFFFFFFFF);
		UI_DrawBtn(&button_loader);
		UI_DrawBtn(&button_menu);
		cui_cursor_display(p_game->cursor);
		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		UI_UpdateBtn(&button_loader, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_menu, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if ( pressed & WPAD_BUTTON_HOME ){
			done = true;
		}
		
		if(button_loader.click){
			done=true;
			next_state=CUI_MENU_EXIT;
		}
		
		if(button_menu.click){
			SYS_ResetSystem(SYS_RETURNTOMENU, 0, 0);
		}
		
		GRRLIB_Render();
		
	}
	
	GRRLIB_FreeTexture(button_loader.img);
	GRRLIB_FreeTexture(button_menu.img);
	free(button_loader.text);
	free(button_menu.text);
	
	return next_state;
}
Esempio n. 2
0
static void initLayoutMenu() {
	tex_menuback=GRRLIB_LoadJPG(playback_jpg, playback_jpg_size);
	tex_layout=GRRLIB_LoadTexture(layoutback_png);
	tex_smalltile=GRRLIB_LoadTexture(smalltile_png);
	tex_shade=GRRLIB_LoadTexture(shade_png);
	tex_plus=GRRLIB_LoadTexture(HSplusButton_png);
	tex_minus=GRRLIB_LoadTexture(HSminusButton_png);
	curpage = 0;

	curmenunum = LAYOUT_MENU;
}
Esempio n. 3
0
static void initSoundMenu() {
	tex_menuback=GRRLIB_LoadJPG(soundback_jpg, soundback_jpg_size);
	tex_menufore=GRRLIB_LoadTexture(soundfore_png);

	tex_uball=GRRLIB_LoadTexture(unselectedball_png);
	tex_sball=GRRLIB_LoadTexture(selectedball_png);

	int strsize=GRRLIB_GetStringWidth(CUR_FONT(false),curtext[LNG_GAME_BACK]);
	soundhs[2][0]=600-strsize;
	soundhs[2][2]=strsize;

	curmenunum = SOUND_MENU;
}
Esempio n. 4
0
static void initLangMenu() {
//    curtext[0] = 0;
	tex_menuback=GRRLIB_LoadJPG(mainback_jpg, mainback_jpg_size);
	tex_menufore=GRRLIB_LoadTexture(mainfore_png);
	tex_flags=0;
	tex_languages=0;
	tex_flags=GRRLIB_LoadTexture(flags_png);
	tex_languages=GRRLIB_LoadTexture(languages_png);
	tex_plus=GRRLIB_LoadTexture(HSplusButton_png);
	tex_minus=GRRLIB_LoadTexture(HSminusButton_png);
	curpage = 0;

	curmenunum = LANG_MENU;
}
Esempio n. 5
0
static void initMainMenu() {
	int x,strsize;

	tex_menuback=GRRLIB_LoadJPG(mainback_jpg, mainback_jpg_size);
	tex_menufore=GRRLIB_LoadTexture(mainfore_png);

    tex_shanghi=0;
	tex_shanghi=GRRLIB_LoadTexture(shanghi_png);

	for(x=0;x<5;x++) {
		strsize=GRRLIB_GetStringWidth(CUR_FONT(0),curtext[x]);
		mainhs[x][0]=320-strsize/2;
		mainhs[x][2]=strsize;
	}

	curmenunum = MAIN_MENU;
}
Esempio n. 6
0
static void initPlayMenu() {
	int x;

	tex_menuback=GRRLIB_LoadJPG(playback_jpg, playback_jpg_size);
	tex_menufore=GRRLIB_LoadTexture(playfore_png);

	tex_shade=GRRLIB_LoadTexture(shade_png);

	int strsize=GRRLIB_GetStringWidth(CUR_FONT(false),curtext[LNG_GAME_BACK]);
	playhs[3][0]=600-strsize;
	playhs[3][2]=strsize;

	// if we only have one line then half the selectable hight
	for(x=0;x<3;x++) {
		if(strcmp(curtext[LNG_PMENU_1PLAYER+1+x*2]," ")==0)
			playhs[x][3]/=2;
	}

	curmenunum = PLAY_MENU;
}
Esempio n. 7
0
cui_menu menu_credits(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
		
	UI_button button_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		
		GRRLIB_PrintfTTF2 (20, 60, font, 20, 0xFFFFFFFF, "%s", "ChessUi -- a chess interface for Wii --");
		GRRLIB_PrintfTTF2 (20, 80, font, 20, 0xFFFFFFFF, "%s", "Presented & programmed by TheDrev");
		GRRLIB_PrintfTTF2 (20, 100, font, 20, 0xFFFFFFFF, "%s", "Using the FirstChess engine by Pham Hong Nguyen ");
		GRRLIB_PrintfTTF2 (20, 120, font, 20, 0xFFFFFFFF, "%s", "and piece graphismes by Wapcaplet");
		GRRLIB_PrintfTTF2 (20, 140, font, 20, 0xFFFFFFFF, "%s", "and also the GRRLIB graphic library");
		GRRLIB_PrintfTTF2 (20, 160, font, 20, 0xFFFFFFFF, "%s", "see http://wiibrew.org/wiki/Chessui for more details");
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTTF(font);
	free(button_return.text);
	GRRLIB_FreeTexture(button_return.img);
	
	return next_state;
}
Esempio n. 8
0
File: main.c Progetto: capz/GRRLIB
int main() {
    float rot=0;
    float i;
    int circsize=150;
    char text[]="GRRLIB ROXX ";

    GRRLIB_Init();
    PAD_Init();


    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font3d);
    GRRLIB_InitTileSet(tex_font, 64, 64, 32);
    GRRLIB_SetHandle (tex_font, tex_font->tilew/2, tex_font->tileh+circsize);

    GRRLIB_texImg *tex_screen;
    tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight);

    GRRLIB_Settings.antialias = true;

    while(1) {
        PAD_ScanPads();
        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);

// we say thant we will want to capture to a texture all the following
        GRRLIB_CompoStart();

            for(i=0;i<360;i+=30) {
// We draw some letters
                GRRLIB_DrawTile((rmode->fbWidth/2)-(tex_font->tilew/2), (rmode->efbHeight/2)-(tex_font->tileh+circsize), tex_font, rot+i, 1, 1, 0xFFFFFFFF, text[(int)(i/30)]-32);
            }

// we say we want to capture now, (the buffer will be cleared after the capture)
        GRRLIB_CompoEnd(0, 0, tex_screen);

        rot-=0.6;

// we now draw 3 times  the captured buffer playing with color
        GRRLIB_DrawImg(0, 0, tex_screen, 0, 1, 1, 0xFF00FFFF);
        GRRLIB_DrawImg(50, 50, tex_screen, 0, 1, 1, 0xFFFF00FF);
        GRRLIB_DrawImg(100, 100, tex_screen, 0, 1, 1, 0xFFFFFFFF);

        GRRLIB_Render();
    }

    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    exit(0);
}
Esempio n. 9
0
/**
 * Load a texture from a file.
 * @param filename The JPEG, PNG or Bitmap filename to load.
 * @return A GRRLIB_texImg structure filled with image information.
 *         If an error occurs NULL will be returned.
 */
GRRLIB_texImg*  GRRLIB_LoadTextureFromFile(const char *filename) {
    GRRLIB_texImg  *tex;
    unsigned char  *data;

    // return NULL it load fails
    if (GRRLIB_LoadFile(filename, &data) <= 0)  return NULL;

    // Convert to texture
    tex = GRRLIB_LoadTexture(data);

    // Free up the buffer
    free(data);

    return tex;
}
Esempio n. 10
0
static void initTilesetMenu() {
	tex_menuback=GRRLIB_LoadJPG(playback_jpg, playback_jpg_size);
	tex_layout=GRRLIB_LoadTexture(layoutback_png);
	tex_border=GRRLIB_LoadTexture(border_png);
	tex_shade=GRRLIB_LoadTexture(shade_png);

	tex_tiles[0]=GRRLIB_LoadTexture(ts_default_png);
	tex_tiles[1]=GRRLIB_LoadTexture(ts_simple_png);
	tex_tiles[2]=GRRLIB_LoadTexture(ts_old_png);
	tex_tiles[3]=GRRLIB_LoadTexture(ts_spooky_png);
	tex_tiles[4]=GRRLIB_LoadTexture(ts_egypt_png);
	tex_tiles[5]=GRRLIB_LoadTexture(ts_space_png);

	tex_bk[0]=GRRLIB_LoadJPG(gameback_jpg, gameback_jpg_size);
	tex_bk[1]=tex_bk[0];
	tex_bk[2]=tex_bk[0];
	tex_bk[3]=GRRLIB_LoadJPG(bk_spooky_jpg, bk_spooky_jpg_size);
	tex_bk[4]=GRRLIB_LoadJPG(bk_egypt_jpg, bk_egypt_jpg_size);
	tex_bk[5]=GRRLIB_LoadJPG(bk_space_jpg, bk_space_jpg_size);

	curmenunum = TILESET_MENU;
}
Esempio n. 11
0
static void initOptionMenu() {
	int x,strsize;

	tex_menuback=GRRLIB_LoadJPG(optionsback_jpg, optionsback_jpg_size);
	tex_menufore=GRRLIB_LoadTexture(optionsfore_png);

	for(x=0;x<7;x++) {
		strsize=GRRLIB_GetStringWidth(CUR_FONT(false),x==6?curtext[LNG_GAME_BACK]:curtext[LNG_OMENU_CTILESET+x]);
		if(x==6)
			opths[x][0]=600-strsize;
		else
			opths[x][0]=320-strsize/2;

		opths[x][2]=strsize;
	}

	curmenunum = OPTIONS_MENU;
}
Esempio n. 12
0
int main() {

    // Initializing GRRLIB
    GRRLIB_Init();

    // Initializing Wiimotes
    WPAD_Init();
    // IR init
    rmode = VIDEO_GetPreferredMode(NULL);
    GXRModeObj *rmode = IR_Init();
    WPAD_SetVRes(WPAD_CHAN_ALL,rmode->fbWidth,rmode->xfbHeight);
    WPAD_SetDataFormat(WPAD_CHAN_0,WPAD_FMT_BTNS_ACC_IR);

    //IR pointer
    ir_t irPointer;

    // Data textures
    GRRLIB_texImg * texFont = GRRLIB_LoadTexture(font_png);
    GRRLIB_InitTileSet(texFont, 8, 16, 0);
    GRRLIB_texImg* pointer = GRRLIB_LoadTexture(pointer_png);
    GRRLIB_SetMidHandle(pointer,true);

    // Objects
    Button left;
    left.initButton(0, maxY/2, 15, 60);
    Button right;
    right.initButton(maxX-15, maxY/2, 15, 60);	
    Circle move;
    move.initCircle(maxX/2, maxY/2, 10);

    // Globals variables
    bool finProgramme = false;	
    int pass = 0;
    float b=0.0;
    float speed = 3;
    int scoreL = 0;
    int scoreR = 0;

    while (!finProgramme){


        WPAD_ScanPads();  //Scan wiimotes
        WPAD_IR(WPAD_CHAN_0, &irPointer);

        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) finProgramme = true;

        //==================== DRAW START ========================
        GRRLIB_Rectangle(left.x, left.y, left.width, left.height, 0xFF0000FF, 1);
        GRRLIB_Rectangle(right.x, right.y, right.width, right.height, 0x00FF00FF, 1);
        GRRLIB_Circle(move.x, move.y, move.radius, CLR_WHITE, 2);	  
        //GRRLIB_DrawImg(irPointer.x, irPointer.y, pointer, 0, 1, 1, CLR_WHITE);

        //GRRLIB_DrawImg(0,0,titlescreen,0,1,1,CLR_UNKNOW);
        char* posX =(char*)malloc(sizeof(char));
        char* posY =(char*)malloc(sizeof(char));
        char* showScoreL = (char*)malloc(sizeof(char));
        char* showScoreR = (char*)malloc(sizeof(char));
        sprintf(posX,"%.3f",irPointer.x);
        sprintf(posY,"%.3f",irPointer.y);
        sprintf(showScoreL, "%d", scoreL);
        sprintf(showScoreR, "%d", scoreR);
        GRRLIB_Printf(20 + 15, 16 + 15, texFont, CLR_WHITE, 2, posX);
        GRRLIB_Printf(20 + 15, 16 + 60, texFont, CLR_WHITE, 2, posY);
        GRRLIB_Printf(300, 50, texFont, 0xFF0000FF, 2, showScoreL);
        GRRLIB_Printf(340, 50, texFont, 0x00FF00FF, 2, showScoreR);
        free(posX);
        free(posY);
        free(showScoreL);
        free(showScoreR);
        GRRLIB_Render();
        //================== DRAW END ==============================

        // Calculate the new positions, speeds, etc…
        isMoving(move, right, left, pass, speed, b);

        // Move the player's pointer
        bMove(right, irPointer);
        // Move the IA player
        ia(left, move, speed);

        // If the ball reaches one side of the screen,
        // Start a new game and count the points !
        if(move.x - move.radius > maxX) {
            scoreL += 1;
            move.x = maxX/2;
            move.y = maxY/2;
            b = 0.0;
            pass = 0;
            speed = 3;
        }
        if (move.x + move.radius < 0) {
            scoreR += 1;
            move.x = maxX/2;
            move.y = maxY/2;
            b = 0.0;
            pass = 0;
            speed = 3;
        }
    }

    // Clean memory
    GRRLIB_Exit();

    exit(0);
}
Esempio n. 13
0
cui_menu menu_play(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size); 
	bool is_debug = false;

	char coords[5];
	char calculated_coords[5];
	
	strcpy(coords, "d2d20");
	strcpy(calculated_coords, "d2d20");
	
	while(!done){
		WPAD_IR(0, &ir);
		WPAD_ScanPads();
		
		u32 pressed = WPAD_ButtonsDown(0);
		u32 released = WPAD_ButtonsUp(0);
		
		if(egg_check_s1_code(pressed, released)){
			is_debug = true;
			p_game->board->tile_color1 = 0xc66300FF;
			p_game->board->tile_color2 = 0x632100FF;
			p_game->board->piece_color1 = 0x4242CCFF;
			p_game->board->piece_color2 = 0x444411FF;
			cui_board_init(p_game->board);
			if(voice) AESND_PlayVoice(voice, VOICE_STEREO8, warp, warp_size, VOICE_FREQ32KHZ, 1, false);
		}

		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}
		
		if ( pressed & WPAD_BUTTON_MINUS){
			switch(menu_option(p_game)){
				case CUI_MENU_OPTION_GFX:menu_option_gfx(p_game);break;
				case CUI_MENU_OPTION_SND:menu_option_snd(p_game);break;
				default:break;
			}
		}
		
		int index_offset_x = (p_game->cursor->hotspot_x - 40 / 2)/ 40 - 140 / 40;
		int index_offset_y = p_game->cursor->hotspot_y / 40 - 80 / 40;
		
		if (pressed & WPAD_BUTTON_B) {
			p_game->cursor->is_grabbing = true;
			
			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[0] = 'a' + index_offset_x;
				coords[1] = '8' - index_offset_y;
			}
				
		}
		else if(released & WPAD_BUTTON_B){
			p_game->cursor->is_grabbing = false;

			if(index_offset_x >= 0 && index_offset_x < 8 && index_offset_y >= 0 && index_offset_y < 8){
				coords[2] = 'a' + index_offset_x;
				coords[3] = '8' - index_offset_y;
				coords[4] = 0;

				if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, move_pcm, move_pcm_size, VOICE_FREQ48KHZ, 1, false);
				
				if(calculate_coords(coords, calculated_coords, p_game->engine)){
					cui_board_read_core(p_game->board, p_game->engine);
				}
				
			}
		}
		
		cui_cursor_update(p_game->cursor, ir.x, ir.y, ir.angle);
		
		
		if(p_game->tex_wallpaper)GRRLIB_DrawImg(0, -50, p_game->tex_wallpaper, 1, 1, 1, 0XFFFFFFFF);
		
		cui_board_display(p_game->board, tex_pieces, tex_tile, font, index_offset_x, index_offset_y);
		cui_cursor_display(p_game->cursor);
		
		if(is_debug){
			GRRLIB_PrintfTTF (20, 00, font, coords, 16, 0x424242FF);
			GRRLIB_PrintfTTF2 (20, 20, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x, ir.y);
			GRRLIB_PrintfTTF2 (20, 40, font, 16, 0xFFFFFFFF, "x:%.2f y:%.2f", ir.x/40, ir.y/40);
			GRRLIB_PrintfTTF2 (20, 60, font, 16, 0xFFFFFFFF, "x:%d y:%d", index_offset_x, index_offset_y);
			GRRLIB_PrintfTTF (20, 80, font, p_game->cursor->is_grabbing?"GRAB":"POINT", 16, 0xFFFFFFFF);
			
			GRRLIB_Rectangle(p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, 4, 4, 0xFF4242FF, 1);
		}
	
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(tex_pieces);
	GRRLIB_FreeTexture(tex_tile);
	GRRLIB_FreeTTF(font);
		
	return next_state;
}
Esempio n. 14
0
cui_menu menu_main(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);
	GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png);
	
	UI_button button_newgame;
	UI_InitBtn(&button_newgame, 280, 120, "New game");
	button_newgame.img = tex_btn;
	button_newgame.font = font;
	
	UI_button button_options;
	UI_InitBtn(&button_options, 280, 200, "Options");
	button_options.img = tex_btn;
	button_options.font = font;
	
	UI_button button_credit;
	UI_InitBtn(&button_credit, 280, 280, "credit");
	button_credit.img = tex_btn;
	button_credit.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		GRRLIB_PrintfTTF (5, 5, font, "ChessUI", 96, 0x424242FF);
		UI_UpdateBtn(&button_newgame, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_options, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_credit, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if(button_newgame.click){
			done=true;
			next_state=CUI_MENU_PLAY;
		}

		if(button_options.click){
			done=true;
			next_state=CUI_MENU_OPTION;
		}
		
		if(button_credit.click){
			done=true;
			next_state=CUI_MENU_CREDITS;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		
		if ( pressed & WPAD_BUTTON_A ){

			if(voice) AESND_PlayVoice(voice, VOICE_STEREO16, button_click_pcm, button_click_pcm_size, VOICE_FREQ48KHZ, 1, false);
		}
		
		cui_board_demo(p_game->board, tex_pieces, tex_tile, font);
		UI_DrawBtn(&button_newgame);
		UI_DrawBtn(&button_options);
		UI_DrawBtn(&button_credit);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTTF(font);
	GRRLIB_FreeTexture(tex_btn);
	free(button_newgame.text);
	free(button_options.text);
	free(button_credit.text);
	return next_state;
}
Esempio n. 15
0
int main(int argc, char **argv) {
	InitSD();
	FILE * file = fopen("sd:/hello.txt", "w");
	if (file == NULL)
		exit(0);
	fprintf(file, "hello, there!\n");
	fclose(file);

	// initialize the sound system.
	//ASND_Init();

	// Initialise the Graphics & Video subsystem
	GRRLIB_Init();
	GRRLIB_Settings.antialias = true;

	tex_Calibri = GRRLIB_LoadTexture(Calibri_18);

	GRRLIB_InitTileSet(tex_Calibri, 27, 37, 32);

	// Initialize the Wiimotes
	WPAD_Init();

	mainMenu();

	Ship *ship;
	ship = (Ship*) malloc(NUM_SHIPS * sizeof(Ship));
	ship = initializeShips(NUM_SHIPS, ship);
	Planet* planet;
	planet = (Planet*) malloc(NUM_PLANETS * sizeof(Planet));

	planet[0].x = 200;
	planet[0].y = 200;
	planet[0].m = 700;
	planet[0].r = 60;
	planet[0].color = 0xFFFFFFFF;
	planet[0].owner = NO_OWNER;
	planet[0].health = PLANET_HEALTH;
	planet[0].currentUpgrade = 0;
	planet[1].x = 400;
	planet[1].y = 400;
	planet[1].m = 300;
	planet[1].r = 30;
	planet[1].color = 0x00FFFFFF;
	planet[1].owner = NO_OWNER;
	planet[1].health = PLANET_HEALTH;
	planet[1].currentUpgrade = 0;
	planet[2].x = 1000;
	planet[2].y = 400;
	planet[2].m = 1000;
	planet[2].r = 200;
	planet[2].color = 0xFF2200FF;
	planet[2].owner = NO_OWNER;
	planet[2].health = PLANET_HEALTH;
	planet[2].currentUpgrade = 0;
	planet[3].x = 1400;
	planet[3].y = 1200;
	planet[3].m = 700;
	planet[3].r = 51;
	planet[3].color = 0x29AF1BFF;
	planet[3].owner = NO_OWNER;
	planet[3].health = PLANET_HEALTH;
	planet[3].currentUpgrade = 0;
	planet[4].x = 1850;
	planet[4].y = 1850;
	planet[4].m = 100;
	planet[4].r = 20;
	planet[4].color = 0xFF7777FF;
	planet[4].owner = NO_OWNER;
	planet[4].health = PLANET_HEALTH;
	planet[4].currentUpgrade = 0;
	// initialize planet's bullet arrays
	int i = 0;
	for (i = 0; i < NUM_PLANETS; i++) {
		planet[i].bullets = (struct Bullet *) malloc(sizeof(Bullet)
				* PLANET_BULLET_NUM);
		if (planet[i].bullets == NULL) {
			exit(0);
		}
		planet[i].numBullets = 0;
	}

	ship = initializeShips(NUM_SHIPS, ship);

	u8 frame_rate;

	initializeTextures();
	int buttons;
	initializeGrid();

	//ASND_Init();
	//ASND_SetVoice(5,VOICE_STEREO_16BIT,8000, 0, &betamaster_raw, betamaster_raw_size, 255, 255, NULL);
	/*
	 MODPlay_Init(&play);
	 MODPlay_SetMOD(&play, paradox_mod);
	 MODPlay_SetVolume(&play, 63, 63);
	 MODPlay_Start(&play);
	 */
	while (1) {

		profiler(1);
		WPAD_ScanPads(); // Scan the Wiimotes
		buttons = WPAD_ButtonsDown(0);
		// If [HOME] was pressed on the first Wiimote, break out of the loop
		if (buttons & WPAD_BUTTON_HOME)
			break;

		update(ship, planet);
		doMechanics(ship, planet);
		render(ship, planet);

		frame_rate = calculateFPS();

		GRRLIB_Printf(20, 20, tex_Calibri, 0xFFFFFFFF, .5, "FPS: %d",
				frame_rate);
		GRRLIB_Printf(20, 40, tex_Calibri, 0xFFFFFFFF, .5, "%d",
		                                ship[0].bullets[0].exploded);
		//int endProfile = profiler(0);
		GRRLIB_Render();
		frameCount++;

	}

	GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
	for (i = 0; i < NUM_SHIPS; i++) {
		free(ship[i].bullets);
	}
	free(ship);
	GRRLIB_FreeTexture(tex_Calibri);
	freeStarMemory();
	exit(0); // Use exit() to exit a program, do not use 'return' from main()
}
Esempio n. 16
0
enum e_cui_menu menu_option_gfx(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	u32 option_tile_color_1 = p_game->board->tile_color1;
	u32 option_tile_color_2 = p_game->board->tile_color2;
	u32 option_piece_color_1 = p_game->board->piece_color1;
	u32 option_piece_color_2 = p_game->board->piece_color2;
	
	GRRLIB_texImg *tex_tile = GRRLIB_LoadTexture(keyboard_key_png);
	GRRLIB_texImg *tex_pieces = GRRLIB_LoadTexture(chess_classic_png);
	GRRLIB_texImg *tex_up = GRRLIB_LoadTexture(scrollbar_arrowup_png);
	GRRLIB_texImg *tex_down = GRRLIB_LoadTexture(scrollbar_arrowdown_png);
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	
	int i,j;
	UI_button button_color[4][8];		//tile 1, tile 2, piece 1, piece 2 | R-+, G-+, B-+, A-+,
	for(i=0;i<4;i++){
		for(j=0;j<8;j++){
			UI_InitBtn(&button_color[i][j], 120 + j*64, 64 + i*80, NULL);
			button_color[i][j].img = j%2==0?tex_down:tex_up;
		}
	}
		
	UI_button button_return;
	UI_InitBtn(&button_return, 500, 400, "apply");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	UI_button button_cancel;
	UI_InitBtn(&button_cancel, 350, 400, "cancel");
	button_cancel.img = GRRLIB_LoadTexture(button_png);
	button_cancel.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		
		u32* color_to_modify=NULL;
		u32 mask;
		for(i=0;i<4;i++){
			for(j=0;j<8;j++){
				UI_UpdateBtn(&button_color[i][j], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
				if(button_color[i][j].click){
					switch(i){
						case 0:color_to_modify = &option_tile_color_1;break;
						case 1:color_to_modify = &option_tile_color_2;break;
						case 2:color_to_modify = &option_piece_color_1;break;
						case 3:color_to_modify = &option_piece_color_2;break;
					}
					if(j==0 || j==1)mask=0x06000000;
					if(j==2 || j==3)mask=0x00060000;
					if(j==4 || j==5)mask=0x00000600;
					if(j==6 || j==7)mask=0x00000006;
					*color_to_modify+=j%2==0?-mask:mask;
				}
			}
		}


		
		UI_UpdateBtn(&button_cancel, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		if(button_return.click){
			if((option_tile_color_1 != p_game->board->tile_color1) || (option_tile_color_2 != p_game->board->tile_color2)){
				p_game->board->tile_color1 = option_tile_color_1;
				p_game->board->tile_color2 = option_tile_color_2;
				cui_board_init(p_game->board);
			}
			
			if(option_tile_color_1 != p_game->board->piece_color1)p_game->board->piece_color1=option_piece_color_1;
			if(option_tile_color_2 != p_game->board->piece_color2)p_game->board->piece_color2=option_piece_color_2;
					
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if(button_cancel.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		GRRLIB_DrawImg(380, 80+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380, 180+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380+80, 80+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380+80, 180+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380+160, 80+140, tex_tile, 0, 2, 2, option_tile_color_1);
		GRRLIB_DrawImg(380+160, 180+140, tex_tile, 0, 2, 2, option_tile_color_2);
		GRRLIB_DrawImg(380, 80, tex_pieces, 0, 2, 2, option_piece_color_2);
		GRRLIB_DrawImg(380, 180, tex_pieces, 0, 2, 2, option_piece_color_1);
		
		
		GRRLIB_PrintfTTF (145, 0, font, "RED              GREEN              BLUE             ALPHA", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40, font, "Tiles color #1", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80, font, "Tiles color #2", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80*2, font, "Pieces color #1", 20, 0xFFFFFFFF);
		GRRLIB_PrintfTTF (15, 40+80*3, font, "Pieces color #2", 20, 0xFFFFFFFF);

		for(i=0;i<4;i++){
			for(j=0;j<8;j++){
				UI_DrawBtn(&button_color[i][j]);
			}
		}


		UI_DrawBtn(&button_return);
		UI_DrawBtn(&button_cancel);
		
		GRRLIB_Line(235, 25, 235, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*2, 25, 235+64*2, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*4, 25, 235+64*4, 350, 0xFFFFFFFF);
		GRRLIB_Line(235+64*6, 25, 235+64*6, 350, 0xFFFFFFFF);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(tex_tile);
	GRRLIB_FreeTexture(tex_pieces);
	GRRLIB_FreeTexture(tex_up);
	GRRLIB_FreeTexture(tex_down);
	GRRLIB_FreeTTF(font); 
	
	free(button_return.text);
	free(button_cancel.text);
	
	return next_state;	
}
Esempio n. 17
0
int main() {
    int startx=0, starty=0;
    int x=0, y=0;
    int dirx=0, diry=0;
    int cptx=0, cpty=0;
    int bgx=-32, bgy=-32;
    float idperso=0;
    int i=0;
    float sinnonameno=0, oldsinnonameno=0;
    float camZ=1400.0f;
    float a=0;

    GRRLIB_Init();
    GRRLIB_Settings.antialias = false;
    WPAD_Init();
    GRRLIB_ClipDrawing(0,0,rmode->fbWidth,rmode->efbHeight);
    GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1);
    GRRLIB_InitTileSet(tex_tile1, TileMap1Width, TileMap1Height, 0);
    GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso);
    GRRLIB_InitTileSet(tex_perso, 64, 64, 0);
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
    GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno);
    GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0);

    GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME)  break;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_PLUS)  camZ+=20.0f;
        if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_MINUS)  camZ-=20.0f;

        if((dirx==0) && (diry==0)) {
            if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { diry=-4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { diry=4; idperso=15;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { dirx=-4 ; idperso=1;}
            else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { dirx=4 ; idperso=8;}
        }

        if((dirx==0) && (diry==0)) {
            idperso=0;
        }

        if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
        }
        else{
            dirx=0;
            diry=-4;
        }

        if(dirx<0) {
            if((Map1Info[7+starty][12+startx]==8) || (Map1Info[7+starty][12+startx]==2) || (Map1Info[8+starty][12+startx]==8) || (Map1Info[8+starty][12+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>7)
                    idperso=1;
            }
        }

        if(dirx>0) {
            if((Map1Info[7+starty][9+startx]==8) || (Map1Info[7+starty][9+startx]==2) || (Map1Info[8+starty][9+startx]==8) || (Map1Info[8+starty][9+startx]==2)) {
                dirx=0;
            }
            else {
                idperso++;
                if(idperso>14)
                    idperso=8;
           }
        }

        if(diry<0) {
            if((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) {
                diry=0;
            }
        }

        if(diry!=0) {
            idperso++;
            if(idperso>22)
                idperso=16;
        }

        cptx+=dirx;
        if(dirx>0)
            bgx++;
        else if(dirx<0)
            bgx--;
        if((bgx>-1) || (bgx<-63))
            bgx=-32;

        if(cptx==32) {
            cptx=0;
            dirx=0;
            startx--;
        }
        else if(cptx==-32) {
            cptx=0;
            dirx=0;
            startx++;
        }

        cpty+=diry;
        if(diry>0)
            bgy++;
        else if(diry<0)
            bgy--;
        if((bgy>-1) ||(bgy<-63))
            bgy=-32;

        if(cpty==32) {
            cpty=0;
            diry=0;
            starty--;
        }
        else if(cpty==-32) {
            cpty=0;
            if(((Map1Info[9+starty][10+startx]==1) || (Map1Info[9+starty][11+startx]==1)) || ((Map1Info[9+starty][10+startx]==43521) || (Map1Info[9+starty][11+startx]==43521))) {
                diry=0;
            }
            starty++;
        }
        GRRLIB_DrawImg(bgx, bgy, tex_bg, 0, 1, 1, 0xFFFFFFFF);

        for(y=0;y<=(17);y++) {
            for(x=0;x<=(21);x++) {
            if(Map1Data[y+starty][x+startx] != 0) {
                GRRLIB_DrawTile(x*TileMap1Width+cptx-TileMap1Width,y*TileMap1Height+cpty-TileMap1Height,tex_tile1,0,1,1,0xFFFFFFFF,Map1Data[y+starty][x+startx]-1);
            }
            }
        }
        GRRLIB_DrawTile(TileMap1Width*9,TileMap1Height*6,tex_perso,0,1,1,0xFFFFFFFF,(int)idperso);

        oldsinnonameno=sinnonameno;
        for(i=0; i<8; i++) {
            GRRLIB_DrawTile(TileMap1Width*(6+i),(TileMap1Height*10)+sin(sinnonameno)*64,tex_nonameno,0,1,1,0xFFFFFFFF,i);
            sinnonameno+=0.4F;
        }
        sinnonameno=oldsinnonameno+0.08F;

        GRRLIB_Screen2Texture(0, 0, tex_screen, GX_TRUE);


        GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);
        GRRLIB_3dMode(0.1,3000,45,1,0);
        GRRLIB_SetTexture(tex_screen,0);
        GRRLIB_ObjectView(0,0,0, a,a*2,a*3,1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 16);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-rmode->fbWidth/2,-rmode->efbHeight/2,-rmode->fbWidth/2);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();

        a+=0.2f;

        GRRLIB_Render();
    }

    GRRLIB_FreeTexture(tex_tile1);
    GRRLIB_FreeTexture(tex_perso);
    GRRLIB_FreeTexture(tex_bg);
    GRRLIB_FreeTexture(tex_nonameno);
    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_Exit();
    exit(0);
}
Esempio n. 18
0
int main(int argc, char **argv) {

  GRRLIB_Init();	
	
  // Initialise the attached controllers
  WPAD_Init();
  WPAD_SetDataFormat(WPAD_CHAN_0, WPAD_FMT_BTNS_ACC_IR);
	
  // Initialise the audio subsystem
  AESND_Init(NULL);
	
  MODPlay_Init(&play);
  MODPlay_SetMOD(&play,bg_music);
  MODPlay_SetVolume(&play,63,63);
  MODPlay_Start(&play);

  cui_cursor cursor;
  cursor.tex[0]=GRRLIB_LoadTexture(player1_point_png);
  cursor.tex[1]=GRRLIB_LoadTexture(player1_grab_png);
  cursor.is_grabbing=false; 
	
  cui_board board;
	
  ENGINE engine = FIRSTCHESS;
  if(engine == TSCP){
    int i;
    for (i=0; i < CUI_TILE_NB; i++) {
      board.piece[i]=init_piece[i];
      if(init_color[i] == 1){
	board.color[i]=CUI_BLACK;
      }else if (init_color[i] == 6){
	board.color[i]=CUI_EMPTY;
      }else if (init_color[i] == 0){
	board.color[i]=CUI_WHITE;
      }
    }
			
    init_hash();
    init_board();
    open_book();
    gen();
  }


  cui_board_read_core(&board, engine);

  GRRLIB_SetBackgroundColour(0x030, 0x30, 0x42, 0xFF);
	
  board.tile_color1 = 0xAAAAAAFF;
  board.tile_color2 = 0x444444FF;
  board.piece_color1 = 0xAAAAAAFF;
  board.piece_color2 = 0x444444FF;
	
  cui_board_init(&board);

  cui_game game;
  game.board = &board;
  game.engine = engine; 
  game.cursor = &cursor;
  game.is_mute = false;
  GRRLIB_texImg *tex_wallpaper = GRRLIB_LoadTexture(wall_jpg);
  game.tex_wallpaper = tex_wallpaper;
			
	
  voice = AESND_AllocateVoice(aesnd_callback);
  AESND_SetVoiceVolume(voice, 0xFF, 0xFF);
  AESND_SetVoiceStream(voice, true);

  cui_menu current_state = CUI_MENU_MAIN;
	 
  while(current_state != CUI_MENU_EXIT) {
    switch(current_state){
    case CUI_MENU_MAIN:	current_state=menu_main(&game);break;
    case CUI_MENU_PLAY:	current_state=menu_play(&game);break;
    case CUI_MENU_OPTION:current_state=menu_option(&game);break;
    case CUI_MENU_OPTION_GENERAL:current_state=menu_option_general(&game);break;
    case CUI_MENU_OPTION_GFX:current_state=menu_option_gfx(&game);break;
    case CUI_MENU_OPTION_SND:current_state=menu_option_snd(&game);break;
    case CUI_MENU_CREDITS:current_state=menu_credits(&game);break;
    case CUI_MENU_PAUSE:current_state=menu_pause(&game);break;
    case CUI_MENU_HOME:current_state=menu_home(&game);break;
    case CUI_MENU_EXIT:current_state=menu_exit(&game);break;
    default:break;
    }
  }
	
  GRRLIB_FreeTexture(tex_wallpaper);
  GRRLIB_FreeTexture(cursor.tex[0]);
  GRRLIB_FreeTexture(cursor.tex[1]);
  GRRLIB_Exit();
  return 0;
}
Esempio n. 19
0
static void setLanguage() {
	if(!tex_letters) {
		tex_japletters=GRRLIB_LoadTexture(japan_png);
		tex_japwhiteletters=GRRLIB_LoadTexture(japanwhite_png);
		tex_numbers=GRRLIB_LoadTexture(gamenumbers_png);

		tex_numbers=GRRLIB_LoadTexture(gamenumbers_png);
		GRRLIB_SetFont(tex_numbers,20, 24, "1234567890:x-", 13, 1, numwidths, 0);

		GRRLIB_SetFont(tex_japwhiteletters,44,48,japanese_map,13,8, japanwidths,3);
		GRRLIB_SetFont(tex_japletters,44,48,japanese_map,13,8, japanwidths,4);

		tex_letters=GRRLIB_LoadTexture(letters_png);
		tex_whiteletters=GRRLIB_LoadTexture(letterswhite_png);

		GRRLIB_SetFont(tex_whiteletters,44,48,latin_map,13,4, latinwidths,1);
		GRRLIB_SetFont(tex_letters,44,48,latin_map,13,4, latinwidths,2);
	}

	switch(opt_lang) {
		case ENGLISH :
			curtext =  (char **)english_lng;
			break;
//		case FRENCH :
//			parseMenu((char *)french_lng, french_lng_size);
//			break;
//		case ITALIAN :
//			parseMenu((char *)italian_lng, italian_lng_size);
//			break;
//		case DUTCH :
//			parseMenu((char *)dutch_lng, dutch_lng_size);
//			break;
		case GERMAN :
			curtext = (char **)german_lng;
			break;
//		case SPANISH :
//			parseMenu((char *)spanish_lng, spanish_lng_size);
//			break;
//		case CATALAN :
//			parseMenu((char *)catalan_lng, catalan_lng_size);
//			break;
//		case JAPANESE :
//			parseMenu((char *)japanese_lng, japanese_lng_size);
//			break;
//		case PORTUGUESE :
//			parseMenu((char *)portuguese_lng, portuguese_lng_size);
//			break;
//		case HUNGARIAN :
//			parseMenu((char *)hungarian_lng, hungarian_lng_size);
//			break;
//		case FINNISH :
//			parseMenu((char *)finnish_lng, finnish_lng_size);
//			break;
//		case SWEDISH :
//			parseMenu((char *)swedish_lng, swedish_lng_size);
//			break;
//		case DANISH :
//			parseMenu((char *)danish_lng, danish_lng_size);
//			break;
//		case NORWEGIAN :
//			parseMenu((char *)norwegian_lng, norwegian_lng_size);
//			break;
        default:
			curtext = (char **)english_lng;
			break;
	}
}
Esempio n. 20
0
enum e_cui_menu menu_option_snd(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
	GRRLIB_texImg *tex_btn = GRRLIB_LoadTexture(button_png);
	
	UI_button button_sounds;
	UI_InitBtn(&button_sounds, 200, 280, "Mute");
	button_sounds.img = tex_btn;
	button_sounds.font = font;
	
	UI_button button_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = tex_btn;
	button_return.font = font;
	
	
	
	int i;
	UI_button button_type[4];
	for(i=0;i<4;i++){
		char text[7];
		sprintf(text, "TYPE %c", 'A'+i);
		UI_InitBtn(&button_type[i], 50+150*i, 100, text);
		button_type[i].img = tex_btn;
		button_type[i].font = font;	
	}

	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		for(i=0;i<4;i++){
			UI_UpdateBtn(&button_type[i], p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		}
		
		UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		for(i=0;i<4;i++){
			if(button_type[i].click){
				switch(i){
					case 0:MODPlay_SetMOD(&play,bg_music);MODPlay_Start(&play);break;
					case 1:MODPlay_SetMOD(&play,bg_music_b);MODPlay_Start(&play);break;
					case 2:MODPlay_SetMOD(&play,bg_music_c);MODPlay_Start(&play);break;
					case 3:MODPlay_SetMOD(&play,bg_music_d);MODPlay_Start(&play);break;
				}
			}
		}
		
		if(button_sounds.click){
			p_game->is_mute = !p_game->is_mute;
			AESND_Pause(p_game->is_mute);
		}
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		for(i=0;i<4;i++){
			UI_DrawBtn(&button_type[i]);
		}
	
		UI_DrawBtn(&button_sounds);
		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	

	free(button_sounds.text);
	free(button_return.text);
	free(button_type[0].text);
	free(button_type[1].text);
	free(button_type[2].text);
	free(button_type[3].text);
	GRRLIB_FreeTexture(tex_btn);
	GRRLIB_FreeTTF(font); 
	
	return next_state;
}
Esempio n. 21
0
int main() {
    // Perso init position
	int startPosX = 9;
	int startPosY = 6;
	
	// Perso size
	int persoHalfHeight = 1;
	int persoHeight     = 2;
	int persoHalfWidth  = 1;
	int persoWidth      = 2;
	
	// Map position
	int posX = startPosX;
    int posY = startPosY;
	
    int cptx = 0, cpty = 0;
    int bgx = -32, bgy = -32;
	
	
	// Counters used to process each tile of the map
    int x = 0;
    int y = 0;
	
	// Directions X/Y, defined by controls
    int dirx = 0;
    int diry = 0;
	
	// Frame number to draw of the perso
    float idperso = 0;
	
	// Counter of letters displaying on top layer 
    int i = 0;
	// Used to move letters following a sinusoidal signal
    float sinnonameno    = 0;
	float oldsinnonameno = 0;


    ////////////////
	// SYSTEM INITS
	////////////////

    // Init Video mode, aspect ratio, FIFO buffer, FAT system, so on.
    GRRLIB_Init();
		
	// Init Controls (Wiimote, Balance board, Sensor bar, so on.)
    WPAD_Init();
	

    /////////////////////////////
	// LOAD TEXTURES / TILESETS
    /////////////////////////////
		
	// Load texture from image (c array)
    GRRLIB_texImg *tex_tile1 = GRRLIB_LoadTexture(tile1);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_tile1, TileMapWidth, TileMapHeight, 0);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_perso = GRRLIB_LoadTexture(perso);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_perso, 64, 64, 0);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_bg = GRRLIB_LoadTexture(bg);
	
	// Load texture from image (c array)
    GRRLIB_texImg *tex_nonameno = GRRLIB_LoadTexture(nonameno);
	// Handle the texture to be used (set number of tiles, start position, offset position, so on)
    GRRLIB_InitTileSet(tex_nonameno, 32, 32, 0);

    // Load texture to draw text (native printf doesn't work with GRRLib)
    GRRLIB_texImg *tex_BMfont1 = GRRLIB_LoadTexture(BMfont1);
	// Handle the texture to be used, in order to draw characters from the fonttype
    GRRLIB_InitTileSet(tex_BMfont1, 32, 32, 32);


    ////////////////
    // ENDLESS LOOP
	////////////////
    while(1) {
	    // Get status of Wii controller
        WPAD_ScanPads();
		
		// If HOME button is pressed, the loop is interrupted. 0 is the Wiimote channel (Wiimote number 1 out of 4).
		// WPAD_ButtonsXXX returns a hexadecimal value representing all buttons down. The mask on HOME button allows to check if this buttons is pressed
		// (HOME button hexadecimal value: 0x0080)
        if (WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) {
          break;
		}

        
        // Set directions X/Y values and perso frame to display, depending controls
        
        if ((dirx == 0) && (diry == 0)) {
            if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_LEFT) { // If LEFT button is held : go bottom
			  diry    = -4; // move perso 4px on bottom
			  idperso = 15; // select frame 15 of the perso (back)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_RIGHT) { // If RIGHT button is held : go top
			  diry    = 4;  // move perso 4px on top
			  idperso = 15; // select frame 15 of the perso (back)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_DOWN) { // If DOWN button is held : go right
			  dirx    = -4; // move perso 4px on right
			  idperso = 1;  // select frame 1 of the perso (watching on his right)
			} else if (WPAD_ButtonsHeld(0) & WPAD_BUTTON_UP) { // If UP button is held : go left
			  dirx    = 4;  // move perso 4px on left
			  idperso = 8;  // select frame 4 of the perso (watching on his left)
			}
        }


        // If no movement, select frame 0 of the perso (front of the screen)
        if ((dirx == 0) && (diry == 0)) {
            idperso = 0;
        }


        if 	(
		        (
				    // Checks if ground at bottom (grey ground only)
		            (Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)
			    ) 
			    || 
			    (
				    // Checks if ladder at bottom. Allow to move freely on ladders
					(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 10064) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 10064)
				)
		    ) 
		{
			// Does nothing there
        } else { 
		    // Any case: fall
            dirx = 0; 
            diry = -4;
        }


        // Debug (got the values at this step, but printed later)
        int printDirX = dirx;
		int printDirY = diry;
		int printPosX = posX;
		int printPosY = posY;


        if (dirx < 0) { // If goes on RIGHT
		    // Checks collide on right to column
            if 	(
			
					(Map1Info[posY + persoHalfHeight][posX + persoWidth + 1] == 8) 
					|| 
					(Map1Info[posY + persoHalfHeight][posX + persoWidth + 1] == 2) 
					|| 
					(Map1Info[posY + persoHeight][posX + persoWidth + 1] == 8) 
					|| 
					(Map1Info[posY + persoHeight][posX + persoWidth + 1] == 2)
				) 
			{
                dirx = 0;
            } else {
				// Animation walking on right
                idperso++;
                if (idperso > 7) {
                    idperso = 1;
				}
            }
        } else if (dirx > 0) { // If goes on LEFT
			// Checks collide on left to column
            if	(
			
			        (Map1Info[posY + persoHalfHeight][posX] == 8) 
					|| 
					(Map1Info[posY + persoHalfHeight][posX] == 2) 
					|| 
					(Map1Info[posY + persoHeight][posX] == 8) 
					|| 
					(Map1Info[posY + persoHeight][posX] == 2)
				) 
			{
                dirx = 0;
            } else {
				// Animation walking on left
                idperso++;
                if (idperso > 14) {
                    idperso = 8;
				}
           }
        }


        // Jumping
        if (diry < 0) { 
		    // Checks if bottom tile is grey ground
            if ((Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) || (Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)) {
                diry = 0;
            }
        }
		
		// Animation while jumping / falling / climbing a ladder
        if (diry != 0) {
            idperso++;
            if (idperso > 22) {
                idperso = 16;
			}
        }



		
		// Move the background horizontally
        if (dirx > 0) {
			bgx++;
        } else if (dirx < 0) {
            bgx--;
		}
        if ((bgx > -1) || (bgx < -63)) {
            bgx = -32;
		}


        // Move the map horizontally depending perso movements.
		// This allows to display map 4pixels per 4pixels, instead of tile per tile
        cptx += dirx;
        if (cptx == TileMapWidth) {
            cptx = 0;
            dirx = 0;
            posX--;
        } else if (cptx == -TileMapWidth) {
            cptx = 0;
            dirx = 0;
            posX++;
        }

        
		// Move the background vertically
        if (diry > 0) {
            bgy++;
        } else if (diry < 0) {
            bgy--;
		}
        if ((bgy > -1) || (bgy < -63)) {
            bgy = -32;
		}


        // Move the map vertically depending perso movements
		// This allows to display map 4pixels per 4pixels, instead of tile per tile
        cpty += diry;
        if (cpty == TileMapHeight) {
            cpty = 0;
            diry = 0;
            posY--;
        } else if (cpty == -TileMapHeight) {
            cpty = 0;
			
			// We check if perso is on the ground or on a ladder.
			// It allows to let the animation of fall/jump to continue to run instead.
            if	(
					(
						(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 1) 
						|| 
						(Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 1)
					) 
					|| 
					(
						(Map1Info[posY + persoHeight + 1][posX + persoWidth] == 10064) 
						|| 
						(Map1Info[posY + persoHeight + 1][posX + persoHalfWidth] == 10064)			
					)
				) 
			{
                diry = 0;
            }
			
            posY++;
        }
		
		
		//////////////////////////
		// DRAWING THE BACKGROUND
		//////////////////////////
		
        GRRLIB_DrawImg(bgx,       // X of upper left corner
		               bgy,       // Y of upper left corner
					   tex_bg,    // texture
					   0,         // rotation
					   1,         // scale X
					   1,         // scale Y
					   0xFFFFFFFF // color
					  );


		////////////////////////////////
		// DRAWING EACH TILE OF THE MAP
        ////////////////////////////////

        // Reminder:
		//   TileMapWidth  = 32px
		//   TileMapHeight = 32px

        // Process 17 tiles on height of the screen (17 x 32px = 512px)
        for (y = 0; y <= (16); y++) {
			// Process 22 tiles on width of the screen (22 * 32 = 704px)
            for (x = 0; x <= (21); x++) {
			    // Only displays tiles with content (others are "transparent" on the screen)
                if (Map1Data[y + posY - startPosY][x + posX - startPosX] != 0) {
                    GRRLIB_DrawTile(x * TileMapWidth + cptx - TileMapWidth, 					// X position to draw (upper left)
					                y * TileMapHeight + cpty - TileMapHeight,					// Y position to draw (upper left)
									tex_tile1,													// texture of the tileset
									0,															// rotation
									1,															// scale X
									1,															// scale Y
									0xFFFFFFFF,													// color
									Map1Data[y + posY - startPosY][x + posX - startPosX] - 1 	// Frame to display (from the tileset)
								   );
                }
            }
        }
		
		
		/////////////////////
		// DRAWING THE PERSO
		/////////////////////
		
        GRRLIB_DrawTile(TileMapWidth * startPosX,  // horizontal center of the screen
						TileMapHeight * startPosY, // vertical center of the screen
						tex_perso, 				    // texture of the tileset
						0, 						    // rotation
						1, 						    // scale X
						1, 						    // scale Y
						0xFFFFFFFF, 			    // color
						(int)idperso			    // Frame to display (from the tileset)
					   );

        
		
		///////////////////////////////////
		// LETTERS MOVING ON A SIN SIGNAL
		///////////////////////////////////
		oldsinnonameno = sinnonameno;
        for (i = 0; i < 8; i++) {
            GRRLIB_DrawTile(TileMapWidth * (6 + i), 
			                (TileMapHeight * 10) + sin(sinnonameno) * 64, 
							tex_nonameno, 
							0, 												// rotation
							1, 												// scale X
							1, 												// scale Y
							0xFFFFFFFF, 									// color
							i
						   );
            sinnonameno += 0.4F;
        }
        sinnonameno = oldsinnonameno + 0.08F;
		

        // Debugging
		
		GRRLIB_Printf(0, 0, tex_BMfont1, 0xFFFFFFFF, 1, "X:%d Y:%d SX:%d SY:%d", printDirX, printDirY, printPosX, printPosY);
		GRRLIB_Printf(0, 32, tex_BMfont1, 0xFFFFFFFF, 1, "CX:%d CY:%d", cptx, cpty);
		
				
		/////////////
		// RENDERING
		/////////////
		
		GRRLIB_Render();
    }


    // Free textures
    GRRLIB_FreeTexture(tex_tile1);
    GRRLIB_FreeTexture(tex_perso);
    GRRLIB_FreeTexture(tex_bg);
    GRRLIB_FreeTexture(tex_nonameno);
	GRRLIB_FreeTexture(tex_BMfont1);
	
	
	// Free screen access / frame buffers / FIFO to allow 
	// next app to handle the system without any trouble
    GRRLIB_Exit();

    exit(0);
}
Esempio n. 22
0
File: main.c Progetto: capz/GRRLIB
int main() {
    int i;
    int screen_index = 0;
    float t=0;
    const int R=81;
    const int r=71;
    const int d=120;
    float f=0;
    float ff=0;
    float spr=0;
    int n=1;
    float a=0;
    float cubeZ=10.0f;
    float camZ=30.0f;;

    GRRLIB_Init();
    PAD_Init();

    GRRLIB_Settings.antialias = false;

    GRRLIB_texImg *tex_screen[9];
    for(i=0; i<9; i++) {
        tex_screen[i] = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
    }

    GRRLIB_texImg *tex_girl = GRRLIB_LoadTexture(girl);
    GRRLIB_texImg *tex_logo = GRRLIB_LoadTexture(logo);
    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    for(i=0;i<=255;i+=1) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }
    for(i=255;i>=0;i-=2) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY 3D CUBE");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);

    while(1) {
        PAD_ScanPads();
        GRRLIB_Camera3dSettings(0.0f,0.0f,camZ, 0,1,0, 0,0,0);

        GRRLIB_2dMode();
        GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF);

        GRRLIB_3dMode(0.1, 1000, 45, 1, 0);
        GRRLIB_SetBlend(GRRLIB_BLEND_ALPHA);


        cubeZ+=0.02f;
        GRRLIB_ObjectView((float)(((R + r-ff)*cos(t-f) - d*cos(((R + r-f)/r)*t)))/20.0f,(float)(((R + r-ff)*sin(t) - d*sin(((R + r)/r)*t)-f))/20.0f,sin(cubeZ)*10, a,a*2,a*3,1,1,1);
        GRRLIB_SetTexture(tex_girl, 0);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();

        a+=0.5f;

        GRRLIB_2dMode();
        GRRLIB_Screen2Texture(0, 0, tex_screen[screen_index], GX_FALSE);
        GRRLIB_Printf((640-(16*6*5))/2+5, 200+5, tex_font, 0x00000088, 5, "%06d",(int)spr);
        GRRLIB_Printf((640-(16*6*5))/2, 200, tex_font, 0xFFEEEE88, 5, "%06d",(int)spr);

        GRRLIB_Render();
        screen_index++;
        screen_index %= 9;
        spr+=0.1f;
        t+=0.01f;

        if(t>n*2*M_PI) {
            n++;
            f+=0.01f;
        }

        if(f>2*M_PI) {
            f=0;
            ff+=0.02f;
        }


        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);
    }
    GRRLIB_FreeTexture(tex_logo);
    GRRLIB_FreeTexture(tex_girl);
    GRRLIB_FreeTexture(tex_font);
    for(i=0; i<9; i++) {
        GRRLIB_FreeTexture(tex_screen[i]);
    }
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    return 0;
}
Esempio n. 23
0
int main() {
    float a = 0;
    float objscal = 0.5f;
    int objqual = 20;

    GRRLIB_Init();
    WPAD_Init();

    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(Rockwell_Condensed_12_Bold);
    GRRLIB_InitTileSet(tex_font, 12, 19, 32);


    GRRLIB_Settings.antialias = true;

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);


    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) break;

        GRRLIB_Camera3dSettings(0.0f, 0.0f,13.0f, 0,1,0, 0,0,0);

        GRRLIB_SetLightAmbient(0x333333FF);
        GRRLIB_SetLightDiff(0,(guVector){0.0f,0.0f,0.0f},20.0f,1.0f,0x00FFFFFF);
        GRRLIB_SetLightDiff(1,(guVector){0.0f,13.0f,3.0f},20.0f,1.0f,0xFF00FFFF);
        GRRLIB_SetLightDiff(2,(guVector){0.0f,-13.0f,3.0f},20.0f,1.0f,0xFFFF00FF);
        GRRLIB_SetLightDiff(3,(guVector){13.0f,0.0f,3.0f},20.0f,1.0f,0xFF0000FF);
        GRRLIB_SetLightDiff(4,(guVector){-13.0f,0.0f,3.0f},20.0f,1.0f,0x00FF00FF);

        GRRLIB_3dMode(0.1,1000,45,0,1);

        GRRLIB_ObjectViewInv(1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, -1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, 1.0f, 1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);

        GRRLIB_ObjectViewInv(1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, -1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);
        GRRLIB_ObjectViewInv(-1.0f, 1.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawSphere(objscal,objqual,objqual,true,0xFFFFFFFF);

        GRRLIB_ObjectView(0.0f, 0.0f, -1.0f, a, a*2, a*3, 1.0f, 1.0f, 1.0f);
        GRRLIB_DrawCube(3.0, true, 0xFFFFFF44);

        a+=0.6f;

        // Switch To 2D Mode to display text
        GRRLIB_2dMode();
        GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "LIGHT SAMPLE CODE 2");

        GRRLIB_Render();
    }
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB

    exit(0);
}
Esempio n. 24
0
int main() {
    float a=0;
    int cubeZ=5;
    int i=0;
    float sinx=0, oldsinx=0;

    GRRLIB_Init();
    WPAD_Init();

    GRRLIB_texImg *tex_screen = GRRLIB_CreateEmptyTexture(rmode->fbWidth,rmode->efbHeight);
    GRRLIB_InitTileSet(tex_screen, rmode->fbWidth, 1, 0);

    GRRLIB_texImg *tex_girl= GRRLIB_LoadTexture(girl);

    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    GRRLIB_Settings.antialias = true;

    GRRLIB_SetBackgroundColour(0x00, 0x00, 0x00, 0xFF);
    GRRLIB_Camera3dSettings(0.0f,0.0f,13.0f, 0,1,0, 0,0,0);

    while(1) {
        GRRLIB_2dMode();
        WPAD_ScanPads();
        if(WPAD_ButtonsDown(0) & WPAD_BUTTON_HOME) exit(0);
        if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_A) cubeZ++;
        if(WPAD_ButtonsHeld(0) & WPAD_BUTTON_B) cubeZ--;

        GRRLIB_3dMode(0.1,1000,45,1,0);
        GRRLIB_SetTexture(tex_girl,0);
        GRRLIB_ObjectView(0,0,cubeZ, a,a*2,a*3,1,1,1);
        GX_Begin(GX_QUADS, GX_VTXFMT0, 24);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(-1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(-1.0f,1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);

            GX_Position3f32(1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,-1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,0.0f);
            GX_Position3f32(-1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(1.0f,1.0f);
            GX_Position3f32(1.0f,-1.0f,1.0f);
            GX_Color1u32(0xFFFFFFFF);
            GX_TexCoord2f32(0.0f,1.0f);
        GX_End();
        GRRLIB_Screen2Texture(0,0,tex_screen,1);
        a+=0.5f;

        // Switch To 2D Mode to display text
        GRRLIB_2dMode();
        oldsinx=sinx;
        for(i=0; i<rmode->efbHeight; i++) {
            GRRLIB_DrawTile(0+sin(sinx)*60,i,tex_screen,0,1,1,0xFFFFFFFF,i);
            sinx+=0.02f;
        }
        sinx=oldsinx+0.02f;

        GRRLIB_Printf((640-(16*29))/2, 20, tex_font, 0xFFFFFFFF, 1, "PRESS A OR B TO ZOOM THE CUBE");

        GRRLIB_Render();
    }
    GRRLIB_FreeTexture(tex_girl);
    GRRLIB_FreeTexture(tex_font);
    GRRLIB_FreeTexture(tex_screen);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    exit(0);
}
Esempio n. 25
0
File: main.c Progetto: capz/GRRLIB
int main() {
    u32 paddown;
    s8 page = 0;

    // Font texture
    GRRLIB_texImg *text_font1 = GRRLIB_LoadTexture(font1);
    GRRLIB_InitTileSet(text_font1, 32, 36, 32);

    // Load the original texture and create empty texture of the same size as the original one
    GRRLIB_texImg *tex_pirate   = GRRLIB_LoadTexture(pirate);
    GRRLIB_texImg *tex_gray     = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_sepia    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_invert   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur1    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur2    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur3    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur4    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur5    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_blur6    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel1   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel2   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel3   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel4   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel5   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_pixel6   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter1 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter2 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter3 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter4 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter5 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_scatter6 = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_fliph    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_flipv    = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);
    GRRLIB_texImg *tex_fliphv   = GRRLIB_CreateEmptyTexture(tex_pirate->w, tex_pirate->h);

    // Let's precalculate the grayscale texture
    GRRLIB_BMFX_Grayscale(tex_pirate, tex_gray);
    GRRLIB_FlushTex(tex_gray);

    // Let's precalculate the sepia texture
    GRRLIB_BMFX_Sepia(tex_pirate, tex_sepia);
    GRRLIB_FlushTex(tex_sepia);

    // Let's precalculate the inverted color texture
    GRRLIB_BMFX_Invert(tex_pirate, tex_invert);
    GRRLIB_FlushTex(tex_invert);

    // Let's precalculate 6 differents blur texture with 6 differents blur factor
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur1, 1);
    GRRLIB_FlushTex(tex_blur1);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur2, 2);
    GRRLIB_FlushTex(tex_blur2);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur3, 3);
    GRRLIB_FlushTex(tex_blur3);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur4, 4);
    GRRLIB_FlushTex(tex_blur4);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur5, 5);
    GRRLIB_FlushTex(tex_blur5);
    GRRLIB_BMFX_Blur(tex_pirate, tex_blur6, 6);
    GRRLIB_FlushTex(tex_blur6);

    // Let's precalculate 6 differents pixelate texture with 6 differents pixelate factor
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel1, 1);
    GRRLIB_FlushTex(tex_pixel1);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel2, 2);
    GRRLIB_FlushTex(tex_pixel2);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel3, 3);
    GRRLIB_FlushTex(tex_pixel3);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel4, 4);
    GRRLIB_FlushTex(tex_pixel4);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel5, 5);
    GRRLIB_FlushTex(tex_pixel5);
    GRRLIB_BMFX_Pixelate(tex_pirate, tex_pixel6, 6);
    GRRLIB_FlushTex(tex_pixel6);

    // Let's precalculate 6 differents pixelate texture with 6 differents pixelate factor
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter1, 2);
    GRRLIB_FlushTex(tex_pixel1);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter2, 4);
    GRRLIB_FlushTex(tex_pixel2);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter3, 6);
    GRRLIB_FlushTex(tex_pixel3);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter4, 8);
    GRRLIB_FlushTex(tex_pixel4);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter5, 10);
    GRRLIB_FlushTex(tex_pixel5);
    GRRLIB_BMFX_Scatter(tex_pirate, tex_scatter6, 12);
    GRRLIB_FlushTex(tex_pixel6);

    // Let's precalculate for flipping the texture
    GRRLIB_BMFX_FlipH(tex_pirate, tex_fliph);
    GRRLIB_FlushTex(tex_fliph);
    GRRLIB_BMFX_FlipV(tex_pirate, tex_flipv);
    GRRLIB_FlushTex(tex_flipv);
    GRRLIB_BMFX_FlipV(tex_fliph, tex_fliphv);
    GRRLIB_FlushTex(tex_fliphv);

    GRRLIB_Init();
    PAD_Init();

    while(1) {
        PAD_ScanPads();
        paddown = PAD_ButtonsDown(0);

        GRRLIB_FillScreen(0xFFFFFFFF);

        switch(page)
        {
            case 1:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "GRAYSCALE FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_gray, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 2:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "SEPIA FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_sepia, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 3:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "INVERT FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_invert, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 4:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "FLIPH AND FLIPV FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_fliph, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_flipv, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_fliphv, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 5:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "BLUR FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_blur1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_blur2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_blur3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_blur4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_blur5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_blur6, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 6:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "PIXELATE FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_pixel1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_pixel2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_pixel3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_pixel4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_pixel5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_pixel6, 0, 1, 1, 0xFFFFFFFF);
                break;
            case 7:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "SCATTER FX");

                GRRLIB_DrawImg(10, 60, tex_pirate, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60, tex_scatter1, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60, tex_scatter2, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*3, 60, tex_scatter3, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10, 60+tex_pirate->h*1, tex_scatter4, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*1, 60+tex_pirate->h*1, tex_scatter5, 0, 1, 1, 0xFFFFFFFF);
                GRRLIB_DrawImg(10+tex_pirate->w*2, 60+tex_pirate->h*1, tex_scatter6, 0, 1, 1, 0xFFFFFFFF);
                break;
            default:
                GRRLIB_Printf(10, 10, text_font1, 0X000000FF, 1, "WELCOME TO THE");
                GRRLIB_Printf(10, 40, text_font1, 0X000000FF, 1, "GRRLIB FX DEMO.");
                GRRLIB_Printf(10, 80, text_font1, 0X000000FF, 1, "TO QUIT PRESS THE");
                GRRLIB_Printf(10, 120, text_font1, 0X000000FF, 1, "HOME BUTTON.");
                GRRLIB_Printf(10, 160, text_font1, 0X000000FF, 1, "USE + OR - TO MOVE");
                GRRLIB_Printf(10, 200, text_font1, 0X000000FF, 1, "ACROSS PAGES.");
        }

        GRRLIB_Render();
        if(paddown & PAD_BUTTON_START) {
            break;
        }
        if(paddown & PAD_BUTTON_X) {
            page--;
            if(page < 0) page = 7;
        }
        if(paddown & PAD_BUTTON_Y) {
            page++;
            if(page > 7) page = 0;
        }
    }
    GRRLIB_FreeTexture(tex_pirate);
    GRRLIB_FreeTexture(tex_gray);
    GRRLIB_FreeTexture(tex_sepia);
    GRRLIB_FreeTexture(tex_invert);
    GRRLIB_FreeTexture(tex_fliph);
    GRRLIB_FreeTexture(tex_flipv);
    GRRLIB_FreeTexture(tex_fliphv);
    GRRLIB_FreeTexture(tex_blur1);
    GRRLIB_FreeTexture(tex_blur2);
    GRRLIB_FreeTexture(tex_blur3);
    GRRLIB_FreeTexture(tex_blur4);
    GRRLIB_FreeTexture(tex_blur5);
    GRRLIB_FreeTexture(tex_blur6);
    GRRLIB_FreeTexture(tex_pixel1);
    GRRLIB_FreeTexture(tex_pixel2);
    GRRLIB_FreeTexture(tex_pixel3);
    GRRLIB_FreeTexture(tex_pixel4);
    GRRLIB_FreeTexture(tex_pixel5);
    GRRLIB_FreeTexture(tex_pixel6);
    GRRLIB_FreeTexture(tex_scatter1);
    GRRLIB_FreeTexture(tex_scatter2);
    GRRLIB_FreeTexture(tex_scatter3);
    GRRLIB_FreeTexture(tex_scatter4);
    GRRLIB_FreeTexture(tex_scatter5);
    GRRLIB_FreeTexture(tex_scatter6);
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    return 0;
}
Esempio n. 26
0
enum e_cui_menu menu_option(cui_game* p_game)
{
	cui_menu next_state = CUI_MENU_MAIN;
	bool done=false;
	
	GRRLIB_ttfFont* font = GRRLIB_LoadTTF(font_ttf, font_ttf_size);  
/*
	UI_button button_general;
	UI_InitBtn(&button_general, 280, 120, "General");
	button_general.img = GRRLIB_LoadTexture(button_png);
	button_general.font = font;
*/	
	UI_button button_graphics;
	UI_InitBtn(&button_graphics, 280, 200, "Graphics");
	button_graphics.img = GRRLIB_LoadTexture(button_png);
	button_graphics.font = font;
	
	UI_button button_sounds;
	UI_InitBtn(&button_sounds, 280, 280, "Sounds");
	button_sounds.img = GRRLIB_LoadTexture(button_png);
	button_sounds.font = font;
	
	UI_button button_return;
	UI_InitBtn(&button_return, 400, 400, "Return");
	button_return.img = GRRLIB_LoadTexture(button_png);
	button_return.font = font;
	
	while(!done){		
		cui_game_update_cursor(p_game->cursor);
		u32 pressed = WPAD_ButtonsDown(0);
		
		//UI_UpdateBtn(&button_general, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_graphics, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_sounds, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		UI_UpdateBtn(&button_return, p_game->cursor->hotspot_x, p_game->cursor->hotspot_y, pressed & WPAD_BUTTON_A);
		
		/*if(button_general.click){
			done=true;
			next_state=CUI_MENU_OPTION_GENERAL;
		}*/

		if(button_graphics.click){
			done=true;
			next_state=CUI_MENU_OPTION_GFX;
		}
		
		if(button_sounds.click){
			done=true;
			next_state=CUI_MENU_OPTION_SND;
		}
		
		if(button_return.click){
			done=true;
			next_state=CUI_MENU_MAIN;
		}
		
		if ( pressed & WPAD_BUTTON_HOME ){
			if(!p_game->is_mute)AESND_Pause(true);
			if(menu_home(p_game) == CUI_MENU_EXIT){done=true;next_state=CUI_MENU_EXIT;}	
			if(!p_game->is_mute)AESND_Pause(false);
		}

		
		//UI_DrawBtn(&button_general);
		UI_DrawBtn(&button_graphics);
		UI_DrawBtn(&button_sounds);
		UI_DrawBtn(&button_return);
		
		cui_cursor_display(p_game->cursor);
		
		GRRLIB_Render();
	}
	
	GRRLIB_FreeTexture(button_graphics.img);free(button_graphics.text);
	GRRLIB_FreeTexture(button_sounds.img);free(button_sounds.text);
	GRRLIB_FreeTexture(button_return.img);free(button_return.text);
	
	GRRLIB_FreeTTF(font);
	
	//GRRLIB_F(font);
	
	return next_state;
}
Esempio n. 27
0
int main(int argc, char* argv[])
{
    u8 *tex_ptrone=GRRLIB_LoadTexture(handpointerred_png);
    u8 *tex_ptrtwo=GRRLIB_LoadTexture(handpointergreen_png);
    u8 *tex_back=GRRLIB_LoadJPG(bigmenuback_jpg, bigmenuback_jpg_size);
    u8 *tex_fore=GRRLIB_LoadTexture(credits_png);

    fatInitDefault();
    GRRLIB_InitVideo();
    WPAD_Init();

    SYS_SetResetCallback(WiiResetPressed);
    SYS_SetPowerCallback(WiiPowerPressed);
    WPAD_SetPowerButtonCallback(WiimotePowerPressed);
    rmode = VIDEO_GetPreferredMode(NULL);

    AESND_Init(NULL);
    MODPlay_Init(&mod_track);
    Init_Voice();

    AESND_Pause(0);                // the sound loop is running now

                                 // set the MOD song
    if (MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod) < 0 ) {
        MODPlay_Unload (&mod_track);
    } else {
        // set the music volume to the minimum so we don't hear the music before saved volume is known
        MODPlay_SetVolume( &mod_track, 0,0);
        MODPlay_Start (&mod_track);// Play the MOD
    }

    WPAD_SetDataFormat(WPAD_CHAN_ALL, WPAD_FMT_BTNS_ACC_IR);

    WPAD_SetVRes(WPAD_CHAN_ALL, rmode->fbWidth, rmode->xfbHeight);

    initMain();

    MODPlay_SetVolume( &mod_track, opt_music, opt_music);

    while( HWButton == 0) {
        WPAD_ScanPads();
        u32 wpad_one_down = WPAD_ButtonsDown(0);
        u32 wpad_two_down = WPAD_ButtonsDown(1);

        u32 type;
        WPADData *wd_one, *wd_two;
        WPAD_ReadPending(WPAD_CHAN_ALL, countevs);
        WPAD_Probe(WPAD_CHAN_ALL, &type);

        wd_one = WPAD_Data(0);
        wd_two = WPAD_Data(1);

        switch(main_mode) {
            case STARTUP :
                GRRLIB_FillScreen(0xFF000000);
                GRRLIB_DrawImg(0, 0, 640, 480, tex_back, 0, 1, 1, alpha>255?255:alpha);
                GRRLIB_DrawImg(68,308, 256, 80, tex_fore, 0, 1, 1, alpha>255?255:alpha);
                if(alpha++>394 || wpad_one_down > 0) {
                    main_mode=MENU;
                    if(tex_back) free(tex_back);
                    if(tex_fore) free(tex_fore);
                    initMenu();
                }
                break;
            case MENU :
                GRRLIB_FillScreen(0xFF000000);
                int menuopt = menuWiimote(wd_one,wpad_one_down);
                if(menuopt==EXIT) {
                    if(tex_ptrone) free(tex_ptrone);
                    if(tex_ptrtwo) free(tex_ptrtwo);
                }

                if(menuopt>NOTHING) {
                    processMenuOption(menuopt);
                    if(main_mode==GAME) {
                        MODPlay_Unload (&mod_track);
                        if(opt_tileset==SPOOKY)
                            MODPlay_SetMOD (&mod_track, graveyard_mod);
                        else
                        if(opt_tileset==EGYPTIAN)
                            MODPlay_SetMOD (&mod_track, egypt_crap_mod);
                        else
                        if(opt_tileset==SIMPLE)
                            MODPlay_SetMOD (&mod_track, childhood_mod);
                        else
                        if(opt_tileset==SPACE)
                            MODPlay_SetMOD (&mod_track, nebulos_mod);
                        else
                            MODPlay_SetMOD (&mod_track, sushi_mod);
                        MODPlay_SetVolume( &mod_track, opt_music, opt_music);
                        MODPlay_Start (&mod_track);
                    }
                    else
                        drawMenu(wd_one);
                }
                else
                    drawMenu(wd_one);
                break;
            case GAME :
                if(gameWiimote(wd_one,wpad_one_down,wd_two,wpad_two_down)) {
                    // we are exiting the game back to the menu
                    main_mode=MENU;
                    MODPlay_Unload (&mod_track);
                    MODPlay_SetMOD (&mod_track, dojo_dan_oriental_mod);
                    MODPlay_SetVolume( &mod_track, opt_music, opt_music);
                    MODPlay_Start (&mod_track);
                    killGame();
                    initMenu();
                }
                else {
                    drawGame();
                }
                break;
        }

        // alternate which pointer is on top every frame to not give the advantage to player one in two player mode
        static int ticktock=0;

        ticktock++;

        if(wd_two->ir.valid && ticktock%2==0) {
            if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) {
                // don't display second pointer in one player mode
            }
            else
                GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF);
        }

        if(wd_one->ir.valid) {
            GRRLIB_DrawColImg(wd_one->ir.x - 9,wd_one->ir.y - 7,68,80,tex_ptrone,0,1,1,0xEEFFFFFF);
        }

        if(wd_two->ir.valid && ticktock%2!=0) {
            if(main_mode==GAME && whatGameMode()==ONE_PLAYER_GAME) {
                // don't display second pointer in one player mode
            }
            else
                GRRLIB_DrawColImg(wd_two->ir.x - 9,wd_two->ir.y - 7,68,80,tex_ptrtwo,0,1,1,0xEEFFFFFF);
        }

        if(wd_one->btns_h & WPAD_BUTTON_1) {
            GRRLIB_ScrShot("MahjonggWii_Screen_%y%m%d_%H%M%S.png",time(NULL));
        }

        GRRLIB_Render();
    }

    // we are exiting, free the mallocs
    switch( main_mode) {
        case GAME:
            killGame();

    }
    if(tex_ptrone) free(tex_ptrone);
    if(tex_ptrtwo) free(tex_ptrtwo);
    killMenuLanguages();
    MODPlay_Unload (&mod_track);
    Free_Voice();
    WPAD_Shutdown();
    GRRLIB_Stop();
    saveConfig(FILE_CFG);
    SYS_ResetSystem(HWButton, 0, 0);

    return 0;
}
Esempio n. 28
0
File: main.c Progetto: capz/GRRLIB
int main() {
    int i;
    int screen_index = 0;
    float t = 0;
    const int R = 81;
    const int r = 71;
    const int d = 120;
    float f = 0;
    float ff = 0;
    float spr = 0;
    int n = 1;


    GRRLIB_Init();
    PAD_Init();

    GRRLIB_Settings.antialias = false;

    GRRLIB_texImg *tex_screen[10];
    for(i=0; i<10; i++) {
        tex_screen[i] = GRRLIB_CreateEmptyTexture(rmode->fbWidth, rmode->efbHeight);
    }

    GRRLIB_texImg *tex_ball = GRRLIB_LoadTexture(ball);
    GRRLIB_texImg *tex_logo = GRRLIB_LoadTexture(logo);
    GRRLIB_texImg *tex_font = GRRLIB_LoadTexture(font);
    GRRLIB_InitTileSet(tex_font, 16, 16, 32);


    for(i=0;i<=255;i+=1) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY SPRITES");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }
    for(i=255;i>=0;i-=2) {
        GRRLIB_Printf((640-(16*16))/2, 200, tex_font, 0xFFFFFF00|i, 1, "HOW MANY SPRITES");
        GRRLIB_Printf((640-(16*20))/2, 216, tex_font, 0xFFFFFF00|i, 1, "CAN YOU DISPLAY WITH");
        GRRLIB_DrawImg((640-352)/2, 248, tex_logo, 0, 1, 1, 0xFFFFFF00|i);
        GRRLIB_Printf((640-(16*28))/2, 480-16, tex_font, 0xFFFFFF00|i, 1, "BY NONAMENO FROM GRRLIB TEAM");
        GRRLIB_Render();
    }

    while(1) {
        PAD_ScanPads();

        GRRLIB_DrawImg(0, 0, tex_screen[screen_index], 0, 1, 1, 0xFFFFFFFF);
        GRRLIB_DrawImg(((R + r-ff)*cos(t-f) - d*cos(((R + r-f)/r)*t))+rmode->fbWidth/2-32, ((R + r-ff)*sin(t) - d*sin(((R + r)/r)*t)-f)+rmode->efbHeight/2-32, tex_ball, 1, 1, 1, 0xFFFFFFFF);
        GRRLIB_Screen2Texture(0, 0, tex_screen[screen_index], GX_FALSE);
        GRRLIB_Printf((640-(16*6*5))/2+5, 200+5, tex_font, 0x00000088, 5, "%06d",(int)spr);
        GRRLIB_Printf((640-(16*6*5))/2, 200, tex_font, 0xFFEEEE88, 5, "%06d",(int)spr);

        GRRLIB_Render();
        screen_index++;
        screen_index %= 10;
        spr+=0.1f;
        t+=0.01f;

        if(t>n*2*M_PI) {
            n++;
            f+=0.01f;
        }

        if(f>2*M_PI) {
            f=0;
            ff+=0.02f;
        }


        if(PAD_ButtonsDown(0) & PAD_BUTTON_START) exit(0);

    }
    GRRLIB_FreeTexture(tex_logo);
    GRRLIB_FreeTexture(tex_ball);
    GRRLIB_FreeTexture(tex_font);
    for(i=0; i<10; i++) {
        GRRLIB_FreeTexture(tex_screen[i]);
    }
    GRRLIB_Exit(); // Be a good boy, clear the memory allocated by GRRLIB
    return 0;
}