示例#1
0
文件: font.c 项目: BadToxic/3d-runner
// Draws a positiv float number from the right to the left.
void draw_float(struct Font *f, float number, unsigned int decimal_places, unsigned int x, unsigned int y) {

	if (decimal_places > 0) {
		unsigned int repeats = decimal_places;
		while (repeats > 0) {
			number *= 10;
			repeats--;
		}
		while (decimal_places > 0) {
			sf2d_draw_texture(f->num[(int)number % 10], x, y); x -= f->w;
			number /= 10;
			decimal_places--;
		}
		sf2d_draw_texture(f->dot, x, y); x -= f->w;
		
	}


	if (number >= 1) {
		while (number >= 1) {
			sf2d_draw_texture(f->num[(int)number % 10], x, y); x -= f->w;
			number /= 10;
		}
	}
	else {
		sf2d_draw_texture(f->num[0], x, y);
	}	
}
示例#2
0
void appDrawerIcon() //Draws the app drawer icon. Draws a different icon of the same size once hovered with the cursor.
{
	if (touch.px  >= 170 && touch.px  <= 210 && touch.py >= 145 && touch.py <= 190)
		sf2d_draw_texture(ic_allapps_pressed, 179, 158);
	
	else
		sf2d_draw_texture(ic_allapps, 179, 158);
}
示例#3
0
void background_draw(struct Background *b, float slider_state) {
	
	float x3d = b->z * slider_state;
	if (b->x <= -1 * (float)b->width - 32) {
		b->x += b->width;
	}
	
	// float xx = ((int)(b->x + x3d) % b->width) - b->width; 
	float xx = b->x + x3d;
	sf2d_draw_texture(b->sprite, xx, b->y);
	
	sf2d_draw_texture(b->sprite, xx + b->width, b->y);
	
}
示例#4
0
int lockScreen()
{
	lockscreenBg = sf2d_create_texture_mem_RGBA8(lockscreen_img.pixel_data, lockscreen_img.width, lockscreen_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	time_t unixTime = time(NULL);
	struct tm* timeStruct = gmtime((const time_t *)&unixTime);

	int hours = timeStruct->tm_hour;
	int minutes = timeStruct->tm_min;
	int day = timeStruct->tm_mday;
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));

	while (1)
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(background, 0, 0);
		sf2d_draw_texture(lockscreenBg, 0, 0);
		
		sftd_draw_textf(roboto, 142, 20, RGBA8(255, 255, 255, 255), 34, "0%2d : %02d", hours, minutes);
		sftd_draw_textf(roboto, 140, 80, RGBA8(255, 255, 255, 255), 10, "Monday");
		sftd_draw_textf(roboto, 200, 80, RGBA8(255, 255, 255, 255), 10, "%d", day);
		sftd_draw_textf(roboto, 220, 80, RGBA8(255, 255, 255, 255), 10, "October");
		
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		cursorController();
		
		sf2d_end_frame();
		
		if ((touch.px  >= 160 && touch.px  <= 235 && touch.py >= 210 && touch.py <= 240) && (kDown & KEY_A))
		{	
			sf2d_free_texture(lockscreenBg);
			return 1;
		}
			
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(lockscreenBg);
	
	return 0;
}
示例#5
0
//Draws the player sprite.
void player_draw(Player self) {
	if (self->player_texture == NULL) {
		
		if (self->frame_invincibility > 0) {
			sf2d_draw_fill_circle(self->x, self->y, self->radius, RGBA8(0xFF, 0x00, 0x08, 0xFF));
		} else {
			sf2d_draw_fill_circle(self->x, self->y, self->radius, RGBA8(0x5C, 0xFF, 0x71, 0xBB));
			
		}
		
		
	} else {
		switch (self->player_direction) { //ZZZ Set this up for textures.
			case NORTH:
				
			case EAST:
				
			case SOUTH:
				
			case WEST:
				
			default:
				sf2d_draw_texture(self->player_texture, self->x, self->y);
		}
	}
}
示例#6
0
void render(void) {
    // Start frame on the top screen
    sf2d_start_frame(GFX_TOP, GFX_LEFT);

    // Draw the background (or in this case, the room)
    sf2d_draw_texture(rooms[room].bg.tex,
                      rooms[room].bg.pos.x - (int)camera_pos.x,
                      rooms[room].bg.pos.y - (int)camera_pos.y);

    // Draw the player's sprite
    sf2d_draw_texture(curr_tex,
                      (int)player_pos.x - (int)camera_pos.x,
                      (int)player_pos.y - (int)camera_pos.y);

    sf2d_draw_rectangle(0, 0, 800, 240, RGBA8(0x00, 0x00, 0x00, 0xFF - (int)roomTimer));

    // End frame
    sf2d_end_frame();

    // Start frame on the bottom screen
    sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);

    // If the easter egg variable is true, then activate it
    if (easterEgg) {
        // Draw the easter egg
        sftd_draw_text(font, 10, 140,  RGBA8(255, 0, 0, 255), 16, "* You IDIOT.");
        sftd_draw_text(font, 10, 170,  RGBA8(255, 255, 255, 255), 16, "* Nah, this is just");
        sftd_draw_text(font, 10, 200,  RGBA8(255, 255, 255, 255), 16, "   a simple test.");
        int y = -10;
        // Debug stuff
        switch (easterPage) {
            case 0:
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 0, 0, 255), 12, "FPS: %f", sf2d_get_fps());
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 0, 0, 255), 12, "Sprite Timer: %f", sprTimer);
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 255, 255, 255), 12, "Player X: %f, Y: %f", player_pos.x, player_pos.y);
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 255, 255, 255), 12, "Camera X: %f, Y: %f", camera_pos.x, camera_pos.y);
                break;
            case 1:
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 255, 255, 255), 12, "Block Position: %lu", home->block_pos);
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 255, 255, 255), 12, "Block: %u", home->block);
                sftd_draw_textf(font, 10, y+=20, RGBA8(255, 0, 0, 255), 12, "Status: %li", home->status);
                break;
        }
    };
    // End frame
    sf2d_end_frame();
}
示例#7
0
//Draws the enemy
void enemy_draw(Enemy self) {
	if (!self) return;
	
	if (self->enemy_texture == NULL) {
		sf2d_draw_rectangle(self->x - self->radius, self->y - self->radius, self->radius, self->radius, RGBA8(0xFF, 0x00, 0x08, 0xFF));
	} else {
		sf2d_draw_texture(self->enemy_texture, self->x + self->radius, self->y + self->radius);
	}
}
示例#8
0
int batteryStatus(int x, int y)
{
	int batt = 100; //This is temporary until I find how to get battery status. I know 3DS doesn't use percentages, but only values from 1-5.

	sf2d_draw_texture(_100, 300, 2);
	sftd_draw_textf(roboto, x, y, RGBA8(255, 255, 255, 255), 12, "%d%%", batt);
	
	return 0;
}
示例#9
0
int FinishLine::DrawAndHit(Player* player,bool left){
    sf2d_draw_texture(this->texture,this->x-player->GetX()+PLAYER_X,this->y);
    char flag=0;
    flag = CollisionDetect(player);
    if(flag!=0){
        return FINISH;
    }
    return 0;
}
示例#10
0
void Editableoverlay::draw() {
    sf2d_draw_texture(texture, posx, posy);

    if( selected > 0 )
        sf2d_draw_texture(this->arrow, posx+texture->width-10-arrow->width, posy+10+arrow->height);
    
    if( selected < elements.size() - 1)
        sf2d_draw_texture_rotate(this->arrow, posx+texture->width-10-arrow->width+3, posy+texture->height-10-arrow->height, M_PI);
    
    int start = selected / todraw;
    int j = 0;
    for(unsigned int i = (start*todraw); i < elements.size() && j < todraw ; i++) {
        std::string towrite = elements[i];
        if( posx+5+sftd_get_text_width(font, 6, towrite.c_str()) >= this->getRightBorder() ) towrite = towrite.substr(0, 12) + "...";
        if( selected == i ) sftd_draw_text(font, posx+5, posy+10+(10*j), RGBA8(255, 255, 255, 255), 6, towrite.c_str());
        else sftd_draw_text(font, posx+5, posy+10+(10*j), RGBA8(0, 0, 0, 255), 6, towrite.c_str());
        j++;
    }    
}
示例#11
0
int Spike::DrawAndHit(Player *player,bool left){
    //Draw Spike
    sf2d_draw_texture(this->texture,this->x-player->GetX()+PLAYER_X,this->y);

    //Shitty hitbox 
    if(((player->GetX()+player->GetWidth()>=this->x && player->GetX()<=this->x+this->width)) &&
        player->GetY()+player->GetHeight()>=(this->y+(this->height/2)) && player->GetY()<=this->y+this->width ){
        return TOUCHED;
    }
    return 0;
}
示例#12
0
int dayNightWidget()
{
	time_t unixTime = time(NULL);
	struct tm* timeStruct = gmtime((const time_t *)&unixTime);

	int hours = timeStruct->tm_hour;
	int minutes = timeStruct->tm_min;
	int day = timeStruct->tm_mday;
	//int month = timeStruct->tm_mon;
	
	if (hours < 6)
		sf2d_draw_texture(dayWidget, 172, 60);
	else
		sf2d_draw_texture(nightWidget, 167, 60);
		
	sftd_draw_textf(roboto, 142, 20, RGBA8(255, 255, 255, 255), 34, "0%2d : %02d", hours, minutes);
	sftd_draw_textf(roboto, 130, 80, RGBA8(255, 255, 255, 255), 10, "Monday");
	sftd_draw_textf(roboto, 230, 80, RGBA8(255, 255, 255, 255), 10, "%d", day);
	sftd_draw_textf(roboto, 245, 80, RGBA8(255, 255, 255, 255), 10, "October");
	
	return 0;
}
示例#13
0
文件: texture.c 项目: ctruLua/ctruLua
/***
Draw a texture.
@function :draw
@tparam integer x X position
@tparam integer y Y position
@tparam[opt=0.0] number rad rotation of the texture around the hotspot (in radians)
@tparam[opt=0.0] number hotspotX the hostpot X coordinate
@tparam[opt=0.0] number hotspotY the hostpot Y coordinate
*/
static int texture_draw(lua_State *L) {
	texture_userdata *texture = luaL_checkudata(L, 1, "LTexture");
	int x = luaL_checkinteger(L, 2);
	int y = luaL_checkinteger(L, 3);
	float rad = luaL_optnumber(L, 4, 0.0f);
	float hotspotX = luaL_optnumber(L, 5, 0.0f);
	float hotspotY = luaL_optnumber(L, 6, 0.0f);

	if (rad == 0.0f && texture->scaleX == 1.0f && texture->scaleY == 1.0f && texture->blendColor == 0xffffffff) {
		sf2d_draw_texture(texture->texture, x - hotspotX, y - hotspotY);
	} else {
		sf2d_draw_texture_rotate_scale_hotspot_blend(texture->texture, x, y, rad, texture->scaleX, texture->scaleY, hotspotX, hotspotY, texture->blendColor);
	}

	return 0;
}
示例#14
0
int cursorController()
{
	//hidKeysHeld returns information about which buttons have are held down in this frame
	u32 kHeld = hidKeysHeld();
	
	//Read the touch screen coordinates
	if (kHeld & KEY_TOUCH) 
	{
		hidTouchRead(&touch);
		touch_x = touch.px;
		touch_y = touch.py;
	}

	sf2d_draw_texture(cursor, touch_x, touch_y);
	
	return 0;
}
示例#15
0
文件: gfx.c 项目: ctruLua/ctruLua
static int gfx_target___index(lua_State *L) {
	target_userdata *target = luaL_checkudata(L, 1, "LTarget");
	const char* name = luaL_checkstring(L, 2);
	
	if (strcmp(name, "texture") == 0) {
		texture_userdata *texture;
		texture = (texture_userdata*)lua_newuserdata(L, sizeof(*texture));
		luaL_getmetatable(L, "LTexture");
		lua_setmetatable(L, -2);
		
		texture->texture = &(target->target->texture);
		texture->scaleX = 1.0f;
		texture->scaleY = 1.0f;
		texture->blendColor = 0xffffffff;
		
		return 1;
	} else if (strcmp(name, "duck") == 0) {
		sf2d_rendertarget *target = sf2d_create_rendertarget(64, 64);
		for(int i=0;;i++) {
			sf2d_clear_target(target, 0xff000000);
			sf2d_start_frame_target(target);
			sf2d_draw_fill_circle(i%380, i%200, 10, 0xff0000ff);
			sf2d_end_frame();
			//sf2d_texture_tile32(&target->texture);
			
			sf2d_start_frame(GFX_TOP, GFX_LEFT);
			sf2d_draw_texture(&target->texture, 10, 10);
			sf2d_end_frame();
			sf2d_swapbuffers();
		}
	} else {
		for (u8 i=0;target_methods[i].name;i++) {
			if (strcmp(target_methods[i].name, name) == 0) {
				lua_pushcfunction(L, target_methods[i].func);
				return 1;
			}
		}
	}
	
	lua_pushnil(L);
	return 1;
}
示例#16
0
int aboutMenu()
{
	aboutBg = sf2d_create_texture_mem_RGBA8(about_img.pixel_data, about_img.width, about_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	highlight = sf2d_create_texture_mem_RGBA8(highlight_img.pixel_data, highlight_img.width, highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(aboutBg, 0, 0);
		
		sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][0]);
		sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][1]);
		sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][2]);
		//sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		sftd_draw_textf(roboto, 20, 168, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsAbout[language][5]);
		//sftd_draw_textf(roboto, 20, 183, RGBA8(0, 0, 0, 255), 12, "NinjaHax version: NULL");
		
		if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 58 && touch.py <= 105)
		{
			sf2d_draw_texture(highlight, 0, 56);
			sftd_draw_textf(roboto, 20, 68, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS Updates");
			sftd_draw_textf(roboto, 20, 83, RGBA8(0, 0, 0, 255), 12, "Click for, view or isntall available updates");
		}
		else if (touch.px  >= 0 && touch.px  <= 480 && touch.py >= 106 && touch.py <= 157)
		{
			sf2d_draw_texture(highlight, 0, 105);
			sftd_draw_textf(roboto, 20, 116, RGBA8(0, 0, 0, 255), 12, "Cyanogen3DS version: 0.01-20151019-UNOFFICIAL");
			sftd_draw_textf(roboto, 20, 132, RGBA8(0, 0, 0, 255), 12, "Model = NULL");
		}
		 
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1);
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			settingsMenu();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			sf2d_free_texture(aboutBg);
			sf2d_free_texture(highlight);
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	sf2d_free_texture(aboutBg);
	sf2d_free_texture(highlight);

	return 0;
}
示例#17
0
int settingsMenu()
{
	settingsBg = sf2d_create_texture_mem_RGBA8(settings_img.pixel_data, settings_img.width, settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	about_highlight = sf2d_create_texture_mem_RGBA8(about_highlight_img.pixel_data, about_highlight_img.width, about_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	display_highlight = sf2d_create_texture_mem_RGBA8(display_highlight_img.pixel_data, display_highlight_img.width, display_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	developeroptions_highlight = sf2d_create_texture_mem_RGBA8(developeroptions_highlight_img.pixel_data, developeroptions_highlight_img.width, developeroptions_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	performance_highlight = sf2d_create_texture_mem_RGBA8(performance_highlight_img.pixel_data, performance_highlight_img.width, performance_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	security_highlight = sf2d_create_texture_mem_RGBA8(security_highlight_img.pixel_data, security_highlight_img.width, security_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	wifi_highlight = sf2d_create_texture_mem_RGBA8(wifi_highlight_img.pixel_data, wifi_highlight_img.width, wifi_highlight_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);

	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));
	
	while (aptMainLoop())
	{
		hidScanInput();

		u32 kDown = hidKeysDown();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(settingsBg, 0, 0);
		
		sftd_draw_textf(roboto, 48, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][0]);
		sftd_draw_textf(roboto, 48, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][1]);
		sftd_draw_textf(roboto, 48, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][2]);
		sftd_draw_textf(roboto, 250, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][3]);
		sftd_draw_textf(roboto, 250, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][4]);
		sftd_draw_textf(roboto, 250, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][5]);
		
		settingsHighlight();
		
		digitalTime(350, 2); 
		batteryStatus(316, 2); 
		androidQuickSettings();
		cursorController();
		
		sf2d_end_frame();
		
		navbarControls(1); 
		
		if (kDown & KEY_Y)
			powerMenu(); 
		
		if (kDown & KEY_L)
			lockScreen();
		
		if (kDown & KEY_B)
		{
			settingsUnload();
			appDrawer();
		}
		
		if ((touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			appDrawer();
		}
		
		else if ((touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240) && (kDown & KEY_A))
		{
			settingsUnload();
			home();
		}
		
		sf2d_swapbuffers();
	}
	
	settingsUnload();
	
	return 0;
}
示例#18
0
int settingsHighlight()
{
	u32 kDown = hidKeysDown();

	if (touch.px  >= 0 && touch.px  <= 198 && touch.py >= 75 && touch.py <= 133)
	{
		sf2d_draw_texture(wifi_highlight, 0, 87);
		sftd_draw_textf(roboto, 48, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][0]);
		/*if (kDown & KEY_A)
		{
			settingsUnload();
		}*/
	}
	else if (touch.px  >= 0 && touch.px  <= 198 && touch.py >= 134 && touch.py <= 174)
	{
		sf2d_draw_texture(display_highlight, 0, 135);
		sftd_draw_textf(roboto, 48, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][1]);
		/*if (kDown & KEY_A)
		{
			settingsUnload();
		}*/
	}
	else if (touch.px  >= 0 && touch.px  <= 198 && touch.py >= 175 && touch.py <= 240)
	{
		sf2d_draw_texture(developeroptions_highlight, 0, 183);
		sftd_draw_textf(roboto, 48, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][2]);
		/*if (kDown & KEY_A)
		{
			settingsUnload();
		}*/
	}
	else if (touch.px  >= 203 && touch.px  <= 400 && touch.py >= 75 && touch.py <= 133)
	{
		sf2d_draw_texture(security_highlight, 199, 87);
		sftd_draw_textf(roboto, 250, 106, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][3]);
		/*if (kDown & KEY_A)
		{
			settingsUnload();
		}*/
	}
	else if (touch.px  >= 203 && touch.px  <= 400 && touch.py >= 134 && touch.py <= 174)
	{
		sf2d_draw_texture(performance_highlight, 203, 135);
		sftd_draw_textf(roboto, 250, 153, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][4]);
		/*if (kDown & KEY_A)
		{
			settingsUnload();
		}*/
	}
	else if (touch.px  >= 203 && touch.px  <= 400 && touch.py >= 175 && touch.py <= 240)
	{
		sf2d_draw_texture(about_highlight, 203, 183);
		sftd_draw_textf(roboto, 250, 202, RGBA8(0, 0, 0, 255), 12, "%s", lang_settingsMain[language][5]);
		if (kDown & KEY_TOUCH)
		{
			settingsUnload();
			aboutMenu();
		}
	}
	
	return 0;
}
示例#19
0
CtrUi::CtrUi(int width, int height) :
	BaseUi() {
	
	frame = 0;
	fullscreen = false;
	trigger_state = false;
	sf2d_init();
	current_display_mode.width = width;
	current_display_mode.height = height;
	current_display_mode.bpp = 32;
	const DynamicFormat format(
		32,
		0x000000FF,
		0x0000FF00,
		0x00FF0000,
		0xFF000000,
		PF::NoAlpha);
	Bitmap::SetFormat(Bitmap::ChooseFormat(format));
	main_surface = Bitmap::Create(width, height, true, 32);
	main_texture = sf2d_create_texture_mem_RGBA8(main_surface->pixels(),
	                                             main_surface->GetWidth(), main_surface->GetHeight(), 
	                                             TEXFMT_RGBA8, SF2D_PLACE_VRAM);
												 
	#ifdef SUPPORT_AUDIO
		audio_.reset(new CtrAudio());
	#endif
	
	#ifdef NO_DEBUG
	// Loading bottom screen keyboard
	u8* key_buffer = (u8*)&keyboard_bmp[0x36];
	u32 key_buffer_size = keyboard_bmp_size - 0x36;
	u8* key_buffer_rgba = (u8*)malloc((key_buffer_size/3)<<2);
	int z = 0;
	for(int i=0;i<key_buffer_size;i=i+3){
		key_buffer_rgba[z+2] = key_buffer[i];
		key_buffer_rgba[z+1] = key_buffer[i+1];
		key_buffer_rgba[z] = key_buffer[i+2];
		key_buffer_rgba[z+3] = 0xFF;
		z = z + 4;
	}
	keyboard_texture = sf2d_create_texture_mem_RGBA8(key_buffer_rgba,
	                                             320, 240, 
	                                             TEXFMT_RGBA8, SF2D_PLACE_RAM);
	free(key_buffer_rgba);
	
	// Disabling debug console
	devoptab_list[STD_OUT] = &dotab_null;
	devoptab_list[STD_ERR] = &dotab_null;
	consoleGetDefault()->frameBuffer = NULL;
	gfxSetScreenFormat(GFX_BOTTOM,GSP_BGR8_OES);
	gfxSetDoubleBuffering(GFX_BOTTOM,true);
	
	// Drawing keyboard once then unloading it
	for (int i=0;i<5;i++){ // If we don't print this a couple of time, image is corrupted
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		sf2d_draw_texture(keyboard_texture, 0, 0);
		sf2d_end_frame();
		sf2d_swapbuffers();
	}
	sf2d_free_texture(keyboard_texture);
	#endif
	
}
示例#20
0
int main() {
    cfguInit();
    CFGU_GetSystemModel(&MODEL_3DS);
	FILE * file;
	shouldRenderDebug = true;
	if ((file = fopen("settings.bin", "r"))) {
        fread(&shouldRenderDebug,sizeof(bool),1,file);
        fread(&shouldSpeedup,sizeof(bool),1,file);
        osSetSpeedupEnable(shouldSpeedup);
		fclose(file);
	}
    
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL, 0);
	
	currentMenu = MENU_TITLE;
	currentSelection = 0;
	quitGame = false;

	icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
	font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	bottombg = sfil_load_PNG_buffer(bottombg_png, SF2D_PLACE_RAM);
	
	dirtColor[0] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 0)); 
	dirtColor[1] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 1)); 
	dirtColor[2] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 2)); 
	dirtColor[3] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 3)); 
	dirtColor[4] = SWAP_UINT32(sf2d_get_pixel(icons, 16, 4)); 

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
	
	bakeLights();
	
	int i;
	for (i = 0; i < 5; ++i) {
		minimap[i] = sf2d_create_texture(128, 128, TEXFMT_RGBA8,
				SF2D_PLACE_RAM);
		sf2d_texture_tile32(minimap[i]);
	}
	
	sf2d_set_vblank_wait(true);

	sf2d_set_clear_color(0xFF000000);

	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
	k_accept.input = KEY_A;
	k_decline.input = KEY_B;
	k_delete.input = KEY_X;
	k_menuNext.input = KEY_R;
	k_menuPrev.input = KEY_L;

	if ((file = fopen("btnSave.bin", "rb"))) {
		fread(&k_up.input, sizeof(int), 1, file);
		fread(&k_down.input, sizeof(int), 1, file);
		fread(&k_left.input, sizeof(int), 1, file);
		fread(&k_right.input, sizeof(int), 1, file);
		fread(&k_attack.input, sizeof(int), 1, file);
		fread(&k_menu.input, sizeof(int), 1, file);
		fread(&k_pause.input, sizeof(int), 1, file);
		fread(&k_accept.input, sizeof(int), 1, file);
		fread(&k_decline.input, sizeof(int), 1, file);
		fread(&k_delete.input, sizeof(int), 1, file);
		fread(&k_menuNext.input, sizeof(int), 1, file);
		fread(&k_menuPrev.input, sizeof(int), 1, file);
		fclose(file);
	}
	
	if ((file = fopen("lastTP.bin", "r"))) {
		char fnbuf[256];
		fgets(fnbuf, 256, file); // get directory to texturepack
		loadTexturePack(fnbuf);   
		fclose(file);
	}

	tickCount = 0;
	initRecipes();
	defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(), hidKeysDown());

		if (quitGame) break;

		if (initGame > 0) setupGame(initGame == 1 ? true : false);

		if (currentMenu == 0) {
			tick();
			sf2d_start_frame(GFX_TOP, GFX_LEFT);

			offsetX = xscr;
			offsetY = yscr;
			sf2d_draw_rectangle(0, 0, 400, 240, 0xFF0C0C0C); //RGBA8(12, 12, 12, 255)); //You might think "real" black would be better, but it actually looks better that way
			renderLightsToStencil();

			renderBackground(xscr, yscr);
			renderEntities(player.x, player.y, &eManager);
			renderPlayer();
			
			resetStencilStuff();
			offsetX = 0;
			offsetY = 0;
			
			if(shouldRenderDebug){
			    sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(), player.x, player.y, eManager.lastSlot[currentLevel]);
			    drawText(fpsstr, 2, 225);
            }
			
			sf2d_end_frame();

            sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
                if(!shouldRenderMap){
                    sf2d_draw_texture(bottombg, 0, 0);
                    renderGui();
                } else {
                    renderZoomedMap();
                }
            sf2d_end_frame();
		} else {
			tickMenu(currentMenu);
			renderMenu(currentMenu, xscr, yscr);
		}

		sf2d_swapbuffers();
	}

	freeRecipes();

	freeLightBakes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
	freeSounds();
	csndExit();
    cfguExit();
	sf2d_fini();
	return 0;
}
示例#21
0
void player_draw(struct Player *p, float slider_state) {
	
	float x3d = p->z * slider_state;
	sf2d_draw_texture(p->sprite, p->x + x3d, p->y);
	
}
示例#22
0
void Helpbox::draw() {
    std::string towrite(button+": "+msg);
    int textsize = sftd_get_text_width(font, 6, towrite.c_str());
    sf2d_draw_texture(this->texture, this->posx, this->posy);
    sftd_draw_text(font, (this->posx)+(this->texture->width/2)-(textsize/2), this->posy+3,  RGBA8(0, 0, 0, 255), 6, towrite.c_str());
}
示例#23
0
文件: font.c 项目: BadToxic/3d-runner
void draw_time(struct Font *f, float seconds, unsigned int x, unsigned int y) {

	unsigned int c = (int)(seconds * (float)100) % 100;
	unsigned int s = (int)seconds % 60;
	unsigned int m = (int)((seconds - ((int)seconds % 60)) / 60) % 60;
	unsigned int h = (seconds - ((int)seconds % 3600)) / 3600;	
	
	sf2d_draw_texture(f->num[h / 10], x, y); x += f->w;
	sf2d_draw_texture(f->num[h % 10], x, y); x += f->w;
	
	sf2d_draw_texture(f->colon, x, y); x += f->w;
	
	sf2d_draw_texture(f->num[m / 10], x, y); x += f->w;
	sf2d_draw_texture(f->num[m % 10], x, y); x += f->w;
	
	sf2d_draw_texture(f->colon, x, y); x += f->w;
	
	sf2d_draw_texture(f->num[s / 10], x, y); x += f->w;
	sf2d_draw_texture(f->num[s % 10], x, y); x += f->w;
	
	sf2d_draw_texture(f->dot, x, y); x += f->w;
	
	sf2d_draw_texture(f->num[c / 10], x, y); x += f->w;
	sf2d_draw_texture(f->num[c % 10], x, y); x += f->w;
	
}
示例#24
0
int main()
{
	touchPosition touch;

	sf2d_init();
	sftd_init();

	sftd_font *text = sftd_load_font_mem(Roboto_ttf, Roboto_ttf_size);
	sftd_font *title = sftd_load_font_mem(RobotoThin_ttf, RobotoThin_ttf_size);

	sf2d_texture *logo = sfil_load_PNG_buffer(logo_png, SF2D_PLACE_RAM);
	sf2d_texture *record = sfil_load_PNG_buffer(record_png, SF2D_PLACE_RAM);
	sf2d_texture *stop = sfil_load_PNG_buffer(stop_png, SF2D_PLACE_RAM);

	sf2d_set_clear_color(RGBA8(0xFA, 0xFA, 0xFA, 0xFF));

	sharedmem = (u32*)memalign(0x1000, sharedmem_size);
	audiobuf = linearAlloc(audiobuf_size);

	MIC_Initialize(sharedmem, sharedmem_size, control, 0, 3, 1, 1);//See mic.h.

	// Threading stuff
	svcCreateEvent(&threadRequest,0);
	u32 *threadStack = memalign(32, STACKSIZE);
	svcCreateThread(&threadHandle, threadMic, 0, &threadStack[STACKSIZE/4], 0x3f, 0);

	while(aptMainLoop())
	{
		hidScanInput();
		hidTouchRead(&touch);

		u32 kDown = hidKeysDown();

		if (kDown & KEY_START)
			break; // break in order to return to hbmenu

		sf2d_start_frame(GFX_TOP, GFX_LEFT);
			sf2d_draw_texture(logo, 60, 70);
			sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
			sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
		sf2d_end_frame();

		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
			sf2d_draw_texture(record, 85, 85);
			sf2d_draw_texture(stop, 165, 85);
		sf2d_end_frame();

		svcSignalEvent(threadRequest);

		if(print == 1)
		{
			sf2d_start_frame(GFX_TOP, GFX_LEFT);
				sf2d_draw_texture(logo, 60, 70);
				sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
				sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
				sftd_draw_text(text, 130, 209, RGBA8(0, 0, 0, 222), 16, "Recording audio...");
			sf2d_end_frame();
		}

		if(recording == 2)
		{
			sf2d_start_frame(GFX_TOP, GFX_LEFT);
				sf2d_draw_texture(logo, 60, 70);
				sftd_draw_text(title, 177, 80, RGBA8(0, 0, 0, 222), 40, "Audio");
				sftd_draw_text(title, 175, 120, RGBA8(0, 0, 0, 222), 40, "Recorder");
				sftd_draw_text(text, 130, 209, RGBA8(0, 0, 0, 222), 16, "Saving audio...");
			sf2d_end_frame();
		}

		sf2d_swapbuffers();
	}

	MIC_Shutdown();

	sftd_free_font(text);
	sftd_free_font(title);
	sf2d_free_texture(logo);
	sf2d_free_texture(record);
	sf2d_free_texture(stop);

	// tell thread to exit
	threadExit = true;

	// signal the thread
	svcSignalEvent(threadRequest);

	// give it time to exit
	svcSleepThread(10000000ULL);

	// close handles and free allocated stack
	svcCloseHandle(threadRequest);
	svcCloseHandle(threadHandle);
	free(threadStack);

	free(sharedmem);
	linearFree(audiobuf);
	linearFree(nomute_audiobuf);

	sf2d_fini();
	sftd_fini();
	return 0;
}
示例#25
0
// --------------------------------------------------
Result BoxViewer::drawTopScreen()
// --------------------------------------------------
{
	if (hasRegularChild()) { if (this->child->drawTopScreen() == PARENT_STEP); else return CHILD_STEP; }

	// Draw the resume background
	sf2d_draw_texture(PHBanku::texture->resumeBackground, 0, 0);

	sftd_draw_wtext_white(11, 40, data->text(BankText::GameTrainer));
	sftd_draw_wtextf_white(91, 40, L"%S (%lu-%lu-%lu)", save->savedata.OTName, save->savedata.TID, save->savedata.SID, save->savedata.TSV);

	// If there is a current Pokémon
	if (vPkm.pkm && !vPkm.emptySlot)
	{
		{
		uint32_t x, y;

		sf2d_draw_texture_part(PHBanku::texture->ballIcons, 5, 5, (vPkm.ball % BALL_ROW_COUNT) * BALL_SIZE, (vPkm.ball / BALL_ROW_COUNT) * BALL_SIZE, BALL_SIZE, BALL_SIZE);

		x = 32;
		y = 16 - 2;
		// Is the Pokémon an egg?
		if (vPkm.pkm->isEggy)
		{
			sftd_draw_wtext_white(x, y, data->species(0));
		}
		else
		{
			// Is the Pokémon nicknamed?
			if (Pokemon::isNicknamed(vPkm.pkm))
			{
				sftd_draw_wtext_white(x, y, vPkm.NKName);
			}
			else
			{
				sftd_draw_wtext_white(x, y, vPkm.species);
			}
		}

		sftd_draw_wtextf_white(x + 168, y, L"%S%u", data->text(BankText::Level), vPkm.level);

		x = 11;
		y = 42 - 2;
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::DexNo));
		sftd_draw_text_white(x+50, y, "%03u", vPkm.pkm->speciesID);
		sftd_draw_wtext_white(x+80, y, vPkm.species);
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::OriginalTrainer));
		sftd_draw_wtext_white(x+50, y, vPkm.OTName);
		y += 15; // sftd_draw_text_white(x, (y += 15), "Stat");
		sftd_draw_wtext_white(x+90, y, data->text(BankText::Value));
		sftd_draw_wtext_white(x+128, y, data->text(BankText::IV));
		sftd_draw_wtext_white(x+158, y, data->text(BankText::EV));
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::HitPoint));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::HP]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::HP]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::HP]);
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::Attack));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::ATK]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::ATK]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::ATK]);
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::Defense));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::DEF]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::DEF]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::DEF]);
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::SpAttack));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::SPA]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::SPA]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::SPA]);
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::SpDefense));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::SPD]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::SPD]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::SPD]);
		sftd_draw_wtext_white(x, (y+=15), data->text(BankText::Speed));
		sftd_draw_text_white(x+98, y, "% 3u", vPkm.stats[Stat::SPE]);
		sftd_draw_text_white(x+130, y, "% 2u", vPkm.ivs[Stat::SPE]);
		sftd_draw_text_white(x+160, y, "% 3u", vPkm.evs[Stat::SPE]);
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::Nature));
		sftd_draw_wtext_white(x+70, y, vPkm.nature);
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::Ability));
		sftd_draw_wtext_white(x+70, y, vPkm.ability);
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::Item));
		sftd_draw_wtext_white(x+70, y, vPkm.item);

		x = 246;
		y = 147 - 15 - 2;
		sftd_draw_wtextf_white(x, (y += 15), L"%S   %S", data->text(BankText::HiddenPower), vPkm.hpType);
		sftd_draw_wtext_white(x, (y += 15), data->text(BankText::Moves));
		sftd_draw_wtext_white(x+10, (y += 15), vPkm.moves[0]);
		sftd_draw_wtext_white(x+10, (y += 15), vPkm.moves[1]);
		sftd_draw_wtext_white(x+10, (y += 15), vPkm.moves[2]);
		sftd_draw_wtext_white(x+10, (y += 15), vPkm.moves[3]);

		drawPokemonScale(vPkm.pkm, 256, 36, 3.0f);

		if (vPkm.pkm->isShiny)
		{
			sf2d_draw_texture_part(PHBanku::texture->boxTiles, 240, 135, 54, 64, 9, 9);
		}

		if (vPkm.isCured)
		{
			sf2d_draw_texture_part(PHBanku::texture->boxTiles, 260, 135, 72, 64, 9, 9);
		}
		else if (vPkm.isInfected)
		{
			sf2d_draw_texture_part(PHBanku::texture->boxTiles, 260, 135, 81, 64, 27, 9);
		}

		if (vPkm.gen > 0)
		{
			if (vPkm.gen == 6) // Kalos Born (Gen VI)
				sf2d_draw_texture_part(PHBanku::texture->boxTiles, 250, 135, 63, 64, 9, 9);
			else if (vPkm.gen == 5) // Gen V
				sf2d_draw_texture_part(PHBanku::texture->boxTiles, 250, 135, 72, 73, 9, 9);
			else if (vPkm.gen == 4) // Gen IV
				sf2d_draw_texture_part(PHBanku::texture->boxTiles, 250, 135, 63, 73, 9, 9);
			else if (vPkm.gen == 3) // Gen III
				sf2d_draw_texture_part(PHBanku::texture->boxTiles, 250, 135, 54, 73, 9, 9);
		}

		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 290 ,135, 9*0, 64 + 9*vPkm.circle, 9, 9);
		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 300 ,135, 9*1, 64 + 9*vPkm.triangle, 9, 9);
		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 310 ,135, 9*2, 64 + 9*vPkm.square, 9, 9);
		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 320 ,135, 9*3, 64 + 9*vPkm.heart, 9, 9);
		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 330 ,135, 9*4, 64 + 9*vPkm.star, 9, 9);
		sf2d_draw_texture_part(PHBanku::texture->boxTiles, 340 ,135, 9*5, 64 + 9*vPkm.diamond, 9, 9);
		}
	}

	if (hasOverlayChild()) { this->child->drawTopScreen(); }
	return SUCCESS_STEP;
}
示例#26
0
int main()
{
	sf2d_init();
	csndInit();
	noItem = newItem(ITEM_NULL,0);
	
	currentMenu = MENU_TITLE;
    currentSelection = 0;
	quitGame = false;

    icons = sfil_load_PNG_buffer(icons2_png, SF2D_PLACE_RAM);
    font = sfil_load_PNG_buffer(Font_png, SF2D_PLACE_RAM);
	
	//consoleInit(GFX_BOTTOM, NULL);
   // printf("Press 'Start' to exit.\n");

	loadSound(&snd_playerHurt, "resources/playerhurt.raw");
	loadSound(&snd_playerDeath, "resources/playerdeath.raw");
	loadSound(&snd_monsterHurt, "resources/monsterhurt.raw");
	loadSound(&snd_test, "resources/test.raw");
	loadSound(&snd_pickup, "resources/pickup.raw");
	loadSound(&snd_bossdeath, "resources/bossdeath.raw");
	loadSound(&snd_craft, "resources/craft.raw");
    
    int i;
    for(i = 0;i < 5;++i){
       minimap[i] = sf2d_create_texture(128,128,TEXFMT_RGBA8,SF2D_PLACE_RAM);
	   sf2d_texture_tile32(minimap[i]);
    }
    
    sf2d_set_vblank_wait(true);
	
	sf2d_set_clear_color(0xFF);
	
	/* Default inputs */
	k_up.input = KEY_DUP | KEY_CPAD_UP | KEY_CSTICK_UP;
	k_down.input = KEY_DDOWN | KEY_CPAD_DOWN | KEY_CSTICK_DOWN;
	k_left.input = KEY_DLEFT | KEY_CPAD_LEFT | KEY_CSTICK_LEFT;
	k_right.input = KEY_DRIGHT | KEY_CPAD_RIGHT | KEY_CSTICK_RIGHT;
	k_attack.input = KEY_A | KEY_B | KEY_L | KEY_ZR;
	k_menu.input = KEY_X | KEY_Y | KEY_R | KEY_ZL;
	k_pause.input = KEY_START;
    k_accept.input = KEY_A;
    k_decline.input = KEY_B;
    k_delete.input = KEY_X;
    FILE * file;
    
    /* If btnSave exists, then use that. */
    if ((file = fopen("btnSave.bin", "rb"))){
        fread(&k_up.input, sizeof(int), 1, file);
        fread(&k_down.input, sizeof(int), 1, file);
        fread(&k_left.input, sizeof(int), 1, file);
        fread(&k_right.input, sizeof(int), 1, file);
        fread(&k_attack.input, sizeof(int), 1, file);
        fread(&k_menu.input, sizeof(int), 1, file);
        fread(&k_pause.input, sizeof(int), 1, file);
        fread(&k_accept.input, sizeof(int), 1, file);
        fread(&k_decline.input, sizeof(int), 1, file);
        fread(&k_delete.input, sizeof(int), 1, file);
        fclose(file);
    }
	
	//screenShot = false;
	
    tickCount=0;
    initRecipes();
    defineTables();
	while (aptMainLoop()) {
		++tickCount;
		hidScanInput();
		tickKeys(hidKeysHeld(),hidKeysDown());

		//if (quitGame || hidKeysHeld() & KEY_SELECT) break;
		if (quitGame) break;
		//if (hidKeysDown() & (KEY_L | KEY_R)) screenShot = true;
	//	else screenShot = false;
        
        if(initGame > 0) setupGame(initGame == 1 ? true : false);
        
        if(currentMenu == 0){
            tick();
            sprintf(fpsstr, " FPS: %.0f, X:%d, Y:%d, E:%d", sf2d_get_fps(),player.x, player.y,eManager.lastSlot[currentLevel]);
		    sf2d_start_frame(GFX_TOP, GFX_LEFT);
                if(currentLevel == 0){ 
                    sf2d_draw_texture_part_scale(minimap[1],(-xscr/3)-256,(-yscr/3)-32,0,0,128,128,12.5,7.5);
                    sf2d_draw_rectangle(0,0,400,240, 0xDFDFDFAF);
                }
	            offsetX = xscr;offsetY = yscr;
		        renderBackground(xscr,yscr);
		        renderEntities(player.x, player.y, &eManager);
		        renderPlayer();
	            offsetX = 0;offsetY = 0;
		        renderItemWithText(player.p.activeItem, 10, 205);
		       // drawText(debugText,2,208);
		        drawText(fpsstr,2,225);
		    sf2d_end_frame();
		      
		    sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);	
		        if(currentLevel == 0 && airWizardHealthDisplay > 0){ 
                    sprintf(bossHealthText, "BOSS: %.0f%%", ((float)airWizardHealthDisplay/2000.0)*100);
                    drawText(bossHealthText,2,225);
                }
		        renderGui();
                sf2d_draw_texture(minimap[currentLevel], 192, 112);//y:56
            sf2d_end_frame();
        } else{ 
            tickMenu(currentMenu);
            renderMenu(currentMenu,xscr,yscr);
        }
        
		sf2d_swapbuffers();
	}
	
    freeRecipes();
	sf2d_free_texture(icons);
	sf2d_free_texture(minimap[0]);
	sf2d_free_texture(minimap[1]);
	sf2d_free_texture(minimap[2]);
	sf2d_free_texture(minimap[3]);
	sf2d_free_texture(minimap[4]);
    freeSounds();
    csndExit();
	sf2d_fini();
	return 0;
}
示例#27
0
int home()
{
	sf2d_set_clear_color(RGBA8(0, 0, 0, 0));

	ic_allapps_pressed = sf2d_create_texture_mem_RGBA8(ic_allapps_pressed_img.pixel_data, ic_allapps_pressed_img.width, ic_allapps_pressed_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	ic_launcher_browser = sf2d_create_texture_mem_RGBA8(ic_launcher_browser_img.pixel_data, ic_launcher_browser_img.width, ic_launcher_browser_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_messenger = sf2d_create_texture_mem_RGBA8(ic_launcher_messenger_img.pixel_data, ic_launcher_messenger_img.width, ic_launcher_messenger_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_apollo = sf2d_create_texture_mem_RGBA8(ic_launcher_apollo_img.pixel_data, ic_launcher_apollo_img.width, ic_launcher_apollo_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	ic_launcher_settings = sf2d_create_texture_mem_RGBA8(ic_launcher_settings_img.pixel_data, ic_launcher_settings_img.width, ic_launcher_settings_img.height, TEXFMT_RGBA8, SF2D_PLACE_RAM);
	
	// Main loop
	while (aptMainLoop())
	{

		//Scan all the inputs. This should be done once for each frame
		hidScanInput();
		
		//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
		u32 kDown = hidKeysDown();
		//hidKeysUp returns information about which buttons have been just released
		//u32 kUp = hidKeysUp();
		
		sf2d_start_frame(GFX_TOP, GFX_LEFT);
		
		sf2d_draw_texture(background, 0, 0);
		
		sf2d_draw_texture(ic_launcher_browser, 49, 145);
		sf2d_draw_texture(ic_launcher_messenger, 114, 145);
		sf2d_draw_texture(ic_launcher_apollo, 241, 145);
		sf2d_draw_texture(ic_launcher_settings, 306, 145);
		appDrawerIcon();

		dayNightWidget();
		
		navbarControls(0); //Displays navbar
		digitalTime(350, 2); //Displays digital time
		batteryStatus(316, 2); //Displays battery status
		cursorController();
		
		sf2d_end_frame();
		
		if ((touch.px  >= 170 && touch.px  <= 210 && touch.py >= 148 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			appDrawer(); //Open app drawer
		}
		
		if ((touch.px  >= 306 && touch.px  <= 351 && touch.py >= 145 && touch.py <= 190) && (kDown & KEY_A))
		{
			sf2d_free_texture(ic_allapps_pressed);
			settingsMenu(); //Open settings menu
		}
		
		if (kDown & KEY_Y)
			powerMenu(); //Open power menu
		
		if (kDown & KEY_L)
			lockScreen(); //Locks the screen

		// Flush and swap framebuffers
		sf2d_swapbuffers();
	}

	sf2d_free_texture(ic_allapps_pressed);
	
	return 0;
}
示例#28
0
int navbarControls(int type)
{
	if (type == 0)
	{
		if (touch.px  >= 84 && touch.px  <= 159 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(backicon, 70, 201);
		else
			sf2d_draw_texture(navbar, 70, 201);

		if (touch.px  >= 160 && touch.px  <= 235 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(homeicon, 70, 201);
		else
			sf2d_draw_texture(navbar, 70, 201);
	
		if (touch.px  >= 236 && touch.px  <= 311 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(multicon, 70, 201);
		else
			sf2d_draw_texture(navbar, 70, 201);
	}
	
	else if (type == 1)
	{
		sf2d_start_frame(GFX_BOTTOM, GFX_LEFT);
		
		if (touch.px  >= 44 && touch.px  <= 119 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(backicon, 30, 201);
		else
			sf2d_draw_texture(navbar, 30, 201);

		if (touch.px  >= 120 && touch.px  <= 195 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(homeicon, 30, 201);
		else
			sf2d_draw_texture(navbar, 30, 201);
	
		if (touch.px  >= 196 && touch.px  <= 271 && touch.py >= 201 && touch.py <= 240)
			sf2d_draw_texture(multicon, 30, 201);
		else
			sf2d_draw_texture(navbar, 30, 201);
			
		sf2d_end_frame();
	}
	
	return 0;
}