static void redraw(void) { ALLEGRO_COLOR color; int w = al_get_display_width(display); int h = al_get_display_height(display); int pw = al_get_bitmap_width(picture); int ph = al_get_bitmap_height(picture); int th = al_get_font_line_height(font); float cx = (w - pw) * 0.5; float cy = (h - ph) * 0.5; ALLEGRO_COLOR white = al_map_rgb_f(1, 1, 1); color = al_map_rgb_f(0.8, 0.7, 0.9); al_clear_to_color(color); color = al_map_rgb(255, 0, 0); al_draw_line(0, 0, w, h, color, 0); al_draw_line(0, h, w, 0, color, 0); al_draw_bitmap(picture, cx, cy, 0); al_draw_textf(font, white, w / 2, cy + ph, ALLEGRO_ALIGN_CENTRE, "Press Space to toggle fullscreen"); al_draw_textf(font, white, w / 2, cy + ph + th, ALLEGRO_ALIGN_CENTRE, "Press Enter to toggle window size"); al_draw_textf(font, white, w / 2, cy + ph + th * 2, ALLEGRO_ALIGN_CENTRE, "Window: %dx%d (%s)", al_get_display_width(display), al_get_display_height(display), (al_get_display_flags(display) & ALLEGRO_FULLSCREEN_WINDOW) ? "fullscreen" : "not fullscreen"); al_flip_display(); }
void draw_level_map(al_defs* al, level* lvl, const int counter, char *name) { al_clear_to_color(al_map_rgb(0,0,0)); al_draw_text(al->logo_font, al_map_rgb(255,255,255), al->width/2, 5, ALLEGRO_ALIGN_CENTRE, "sokoban"); int i,j; for (i = 0; i < lvl->h; i++) { for (j = 0; j < lvl->w; j++) { draw_tile(al, i, j, lvl); } } int wy = 0.8f * al->height; //al_draw_line(0,wy,640,wy,al_map_rgb(255,0,0),1.0); //debug al_draw_textf(al->menu_font, al_map_rgb(255,255,255), 30, wy+10, ALLEGRO_ALIGN_LEFT, "Steps: %d",counter); al_draw_textf(al->menu_font, al_map_rgb(255,255,255), al->width-30, wy+10, ALLEGRO_ALIGN_RIGHT, "Map: %s",name); al_draw_textf(al->hint_font, al_map_rgb(255,255,255), 10, al->height-20, ALLEGRO_ALIGN_LEFT, "R - reset Esc - return to the main menu"); al_flip_display(); }
void mapper_tilemap_render(void) { int i; float lx, ty, scale; if(mapper_tilemap) { for(i = 0; i < mapper_tilemap->layers; i++) { if(!t3f_key[ALLEGRO_KEY_L] || i == mapper_current_layer) { t3f_render_tilemap(mapper_tilemap, mapper_tileset, i, mapper_tick, mapper_camera.x, mapper_camera.y, mapper_camera.z, t3f_color_white); } } al_hold_bitmap_drawing(false); if(!mapper_tilemap_hover_fail) { scale = mapper_tilemap->layer[mapper_current_layer]->scale; lx = mapper_tilemap_hover_x * mapper_tileset->width * scale + mapper_tilemap->layer[mapper_current_layer]->x - mapper_camera.x + 0.5; ty = mapper_tilemap_hover_y * mapper_tileset->height * scale + mapper_tilemap->layer[mapper_current_layer]->y - mapper_camera.y + 0.5; al_draw_rectangle(lx, ty, lx + (float)mapper_tileset->width * scale - 1.0 + 0.5, ty + (float)mapper_tileset->height * scale - 1.0 + 0.5, al_map_rgba_f(0.0, 1.0, 0.0, 0.5), 1.0); } t3f_draw_animation(mapper_tileset->tile[mapper_current_tile]->ap, al_map_rgba_f(1.0, 1.0, 1.0, 0.5), mapper_tick, t3f_mouse_x + 16, t3f_mouse_y + 16, 0, 0); al_draw_textf(mapper_font, t3f_color_white, 0, 416, 0, "Layer Position = (%4.2f, %4.2f, %4.2f)", mapper_tilemap->layer[mapper_current_layer]->x, mapper_tilemap->layer[mapper_current_layer]->y, mapper_tilemap->layer[mapper_current_layer]->z); al_draw_textf(mapper_font, t3f_color_white, 0, 432, 0, "Camera Position = (%4.2f, %4.2f, %4.2f)", mapper_camera.x, mapper_camera.y, mapper_camera.z); al_draw_textf(mapper_font, t3f_color_white, 0, 448, 0, "Current Layer = %d", mapper_current_layer); al_draw_textf(mapper_font, t3f_color_white, 0, 464, 0, "Current Tile = %d", mapper_current_tile); } else { al_draw_textf(mapper_font, t3f_color_white, 0, 0, 0, "Please create or load a tilemap."); } }
void Player::die(void) { shake(); reset(); lives--; if (lives <= 0) { // game over isDestructable = false; invincibleCount = 20000; ALLEGRO_BITMAP *old_target = al_get_target_bitmap(); al_set_target_bitmap(highscoreBitmap); int w = al_get_bitmap_width(highscoreBitmap); int h = al_get_bitmap_height(highscoreBitmap); ResourceManager& rm = ResourceManager::getInstance(); ALLEGRO_FONT *large_font = (ALLEGRO_FONT *)rm.getData(RES_LARGEFONT); ALLEGRO_FONT *small_font = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT); al_draw_textf(large_font, al_map_rgb(255, 255, 255), w/2, h/2-16, ALLEGRO_ALIGN_CENTRE, "GAME OVER"); al_draw_textf(small_font, al_map_rgb(255, 255, 255), w/2, h/2+16, ALLEGRO_ALIGN_CENTRE, "%d Points", score); al_set_target_bitmap(old_target); } else { hp = 1; isDestructable = false; invincibleCount = 3000; } }
void MonopolyGame::drawText(ALLEGRO_COLOR col, int x, int y, const char *msg, ...) { char buffer[256]; va_list ap; va_start( ap, msg ); vsprintf( buffer, msg, ap ); va_end( ap ); // First print the shadow, which is slightly off-centered. int offset = 2; al_draw_textf( m_fontCollection[0], al_map_rgb( 0, 0, 0 ), x + offset, y + offset, NULL, buffer ); // Finally we print the foreground text. al_draw_textf( m_fontCollection[0], col, x, y, NULL, buffer ); }
void CaveGame::Render(){ al_draw_bitmap(caveBackground,0,0,0); al_draw_bitmap(koala, koalaX, koalaY, 0); for(int i=0; i<10;i++) for(int k=0;k<8;k++) if(isObj[i][k]){ int numImage = (int)(intoxication/300) % 3; al_draw_bitmap_region(objImage[i][numImage], objW[i][numImage] * ((t/2) % objFrames[i][numImage]), 0, objW[i][numImage], objH[i][numImage], objX[i][k], objY[i][k], 0); } al_draw_rectangle(1,1,600,49,al_map_rgb(10,200,10),2); al_draw_filled_rectangle(2,2,health-2, 50, al_map_rgb(0,220,0)); if(intoxication <= 300){ al_draw_rectangle(1,53,299,99,al_map_rgb(180,70,180),2); al_draw_filled_rectangle(2,54, intoxication, 98, al_map_rgb(200,50,200)); }else if(intoxication <= 600){ al_draw_rectangle(1,53,299,69,al_map_rgb(180,70,180),2); al_draw_rectangle(1,73,299,109,al_map_rgb(180,70,180),2); al_draw_filled_rectangle(2,54, 298, 68, al_map_rgb(200,50,200)); al_draw_filled_rectangle(2,74, intoxication-302, 108, al_map_rgb(200,50,200)); al_draw_textf(font36, al_map_rgb(0,100,200), width, 40, ALLEGRO_ALIGN_RIGHT, "Score per second: %i", timeAtIntox*6); }else{ al_draw_rectangle(1,53,299,69,al_map_rgb(180,70,180),2); al_draw_rectangle(1,73,299,89,al_map_rgb(180,70,180),2); al_draw_rectangle(1,93,299,129,al_map_rgb(180,70,180),2); al_draw_filled_rectangle(2,54, 298, 68, al_map_rgb(200,50,200)); al_draw_filled_rectangle(2,74, 298, 88, al_map_rgb(200,50,200)); al_draw_filled_rectangle(2,94, intoxication-602, 128, al_map_rgb(200,50,200)); al_draw_textf(font36, al_map_rgb(0,100,200), width, 40, ALLEGRO_ALIGN_RIGHT, "Score per second: %i", timeAtIntox*6); } al_draw_text(font36, al_map_rgb(10,200,10),5,5,0,"Health"); al_draw_textf(font36, al_map_rgb(0,100,200), width, 0, ALLEGRO_ALIGN_RIGHT, "Score: %i", score); }
static void level_draw(void) { #ifndef NDEBUG static char* comp_names[] = { "Body", "Collider", "Propulsion", "Health", "Timer", "Behavior", "Keyboard_listener", "Mouse_listener" }; al_draw_textf(main_font, al_map_rgb(255,0,0), 0, 0, 0, "#entities: %d", ecs_entities->length); // component counts for (int i = 0; i < NUM_COMPONENT_TYPES; i++) { list *comp_list = ecs_component_store[i]; al_draw_textf(main_font, al_map_rgb(200,0,200), 0, 300 + 40 * i, 0, "#%s: %d", comp_names[i], comp_list->length); } // draw hitrects list_node *node = ecs_component_store[ECS_COMPONENT_COLLIDER]->head; for (; node; node = node->next) { rectangle r = ((ecs_component*)node->value)->collider.rect; al_draw_rectangle(r.x, r.y, r.x + r.w, r.y + r.h, al_map_rgba_f(0,1,0,0.5), 2); } #endif }
void buy_tower(Tipo &tipo, ALLEGRO_FONT *fonte) //Info compra { al_draw_textf(fonte, al_map_rgb(0, 0, 0), l_celula, 14 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower price: %i bitcoins", tipo.price); al_draw_textf(fonte, al_map_rgb(0, 0, 0), l_celula, 15 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower fire power: %i", tipo.fire_power); al_draw_textf(fonte, al_map_rgb(0, 0, 0), l_celula, 16 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower range: %i", tipo.range); al_draw_textf(fonte, al_map_rgb(0, 0, 0), l_celula, 17 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower fire rate: %.2fs", tipo.fire_rate); }
void __character_intro_8 () { al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.4, 0.6, 0.3, 0.4)); al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Silk of Nature"); al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: ???"); al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: ???"); al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: ???"); }
void movida::draw() { gameWorld->draw(); gameInterface->draw(); al_draw_textf(gameFont, al_map_rgb(255,255,255), 10, 10,ALLEGRO_ALIGN_LEFT, "State: %i", status::instance()->gameState); al_draw_textf(gameFont, al_map_rgb(255,255,255), 10, 30,ALLEGRO_ALIGN_LEFT, "Mouse %i/%i", (int)mouseX, (int)mouseY ); }
void show_tower_information(Torre torre[], int t, ALLEGRO_FONT *fonte) //Monstra as informaçoes da torre selecionada { al_draw_circle(torre[t].x, torre[t].y, torre[t].range, al_map_rgb(10, 110, 10), 0); al_draw_textf(fonte, al_map_rgb(0, 0, 0), 5 * l_celula, 19 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower type: %i", torre[t].n); al_draw_textf(fonte, al_map_rgb(0, 0, 0), 5 * l_celula, 20 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower fire power: %i", torre[t].fire_power); al_draw_textf(fonte, al_map_rgb(0, 0, 0), 5 * l_celula, 21 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower range: %i", torre[t].range); al_draw_textf(fonte, al_map_rgb(0, 0, 0), 5 * l_celula, 22 * a_celula, ALLEGRO_ALIGN_LEFT, "Tower fire rate: %.2fs", torre[t].fire_rate); al_draw_textf(fonte, al_map_rgb(0, 0, 0), 5 * l_celula, 23 * a_celula, ALLEGRO_ALIGN_LEFT, "Upgrade: %i", torre[t].upgrade); }
void __character_intro_1 () { al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.7, 0.5, 0.4, 0.4)); al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Simpleton"); al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: Simpleton,s Scatter"); al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: Simpleton,s Cloud"); al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: Simpleton,s Reflection"); al_draw_textf(global.font_menu, 130, 270, ALLEGRO_ALIGN_LEFT, "Special Ability: Simpleton,s walk"); }
void __character_intro_2 () { al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.9, 0.6, 0.5, 0.4)); al_draw_textf(global.font_menu, 320, 130, ALLEGRO_ALIGN_CENTRE, "Hellfire"); al_draw_textf(global.font_menu, 130, 180, ALLEGRO_ALIGN_LEFT, "Weapon: Hellfire"); al_draw_textf(global.font_menu, 130, 210, ALLEGRO_ALIGN_LEFT, "Bomb: Hellfire Tide"); al_draw_textf(global.font_menu, 130, 240, ALLEGRO_ALIGN_LEFT, "Ability: Hellfire Wave"); al_draw_textf(global.font_menu, 130, 270, ALLEGRO_ALIGN_LEFT, "Special Ability: Annihilation"); }
void ShopState::draw(Engine* engine){ for(int i = 0; i < MAX_BUTTONS; i++){ if(buttonList[i] != NULL && buttonList[i]->checkActive()){ buttonList[i]->draw(); } } al_draw_rotated_bitmap(playerImage, playerWidth/2, playerHeight/2, playerX+playerWidth/2, playerY+playerHeight/2, -atan2(playerCenterX - mouseX, playerCenterY - mouseY), NULL); for(int i = 0; i < MAX_BULLETS; i++){ if(bulletList[i] != NULL && bulletList[i]->checkActive()){ bulletList[i]->draw(); } } al_draw_textf(defaultFont, al_map_rgb(50, 150, 50), 0, 400, NULL, "%d$", playerMoney); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32, NULL, "Health: %f", playerHealth); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*2, NULL, "Max Health: %f", playerMaxHealth); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*3, NULL, "Speed: %f", playerBulletSpeed); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*4, NULL, "Bullets: %d", playerShots); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*5, NULL, "Weapon Spread Arc: %f*", playerBulletSpread*360); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*6, NULL, "Damage: %d", playerDamage); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*7, NULL, "Bullet Speed: %d", playerBulletSpeed); al_draw_textf(defaultFont, al_map_rgb(122, 122, 122), 0, 400+32*8, NULL, "Fire Rate: %d", playerFiringSpeed); }
void hora(ALLEGRO_FONT *font){ time_t t; // dibuja la hora int hour, minutes; t = time(NULL); hour = localtime(&t)->tm_hour; minutes = localtime(&t)->tm_min; if(minutes<10) al_draw_textf(font, al_map_rgb(0,0,0), 200, 50, ALLEGRO_ALIGN_CENTRE,"%d:0%d",hour,minutes); else al_draw_textf(font, al_map_rgb(0,0,0), 200, 50, ALLEGRO_ALIGN_CENTRE,"%d:%d",hour,minutes); }
bool CharacterSelection::run () { bool to_paint; ALLEGRO_EVENT event; while (1) { do { al_wait_for_event(global.queue, &event); switch (event.type) { case ALLEGRO_EVENT_DISPLAY_CLOSE: Utils::terminate(); break; case ALLEGRO_EVENT_TIMER: to_paint = true; n_frame ++; break; case ALLEGRO_EVENT_KEY_DOWN: case ALLEGRO_EVENT_KEY_REPEAT: switch (event.keyboard.keycode) { case ALLEGRO_KEY_ESCAPE: case ALLEGRO_KEY_X: return false; case ALLEGRO_KEY_LEFT: character = (CharacterID)((character + N_CHARACTER - 1) % N_CHARACTER); break; case ALLEGRO_KEY_RIGHT: character = (CharacterID)((character + 1) % N_CHARACTER); break; case ALLEGRO_KEY_ENTER: case ALLEGRO_KEY_Z: return true; } }; } while (!al_event_queue_is_empty(global.queue)); if (to_paint) { al_clear_to_color(global.color_black); al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(1.0, 1.0, 1.0, 0.3)); al_draw_bitmap(global.bitmap_char_big[(int)character], 0, 0, 0); al_set_blender(ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(0.7, 0.7, 1.0, 0.9)); al_draw_textf(global.font_menu_title, al_get_display_width() / 2, 20, ALLEGRO_ALIGN_CENTRE, "Character Selection"); al_draw_textf(global.font_menu_title, 80, 420, ALLEGRO_ALIGN_CENTRE, "[-"); al_draw_textf(global.font_menu_title, 320, 420, ALLEGRO_ALIGN_CENTRE, "%d\\%d", (int)character + 1, N_NORMAL_CHARACTER); al_draw_textf(global.font_menu_title, 560, 420, ALLEGRO_ALIGN_CENTRE, "-]"); CHARACTER_INTRO[(int)character](); al_flip_display(); } } }
void LevelGraphic::draw() { if (nivel_activo()) { al_draw_bitmap(bmp,0,0,0); switch (get_estado()) { case INICIALIZADO: if (font_transito) { al_draw_textf(font_transito,al_map_rgb(8,8,138),300 ,270 ,ALLEGRO_ALIGN_CENTRE , "%s: %d","nivel", get_level()); } else { printf("error al cargar el font\n"); } break; case CREADO: if (font) { al_draw_textf(font,al_map_rgb(8,8,138),get_x() ,get_y() ,ALLEGRO_ALIGN_LEFT , "%s: %d",title.c_str(), get_level()); } else { printf("error al cargar el font\n"); } break; case DESTRUIDO: if (last_level()){ if (font_transito) { al_draw_textf(font_transito,al_map_rgb(8,8,138),300 ,270 ,ALLEGRO_ALIGN_CENTRE , "%s","Game over"); } else { printf("error al cargar el font\n"); } } else { if (font_transito) { al_draw_textf(font_transito,al_map_rgb(8,8,138),300 ,270 ,ALLEGRO_ALIGN_CENTRE , "%s","Sigue jugando"); } else { printf("error al cargar el font\n"); } } break; default: break; } } // al_draw_text(font, al_map_rgb(255, 0, 255), 50, 50, 0, "Hello World"); }
void updatesScorePlayers() { if(mode == MULTI){ al_draw_textf(openSans12, WHITE, SCREEN_WIDTH*0.1, GAME_HEIGHT + 10, 0, "Joueur 1 : %d", player1.score); al_draw_textf(openSans12, WHITE, SCREEN_WIDTH*0.1, GAME_HEIGHT + 50, 0, "Joueur 2 : %d", player2.score); } else{ al_draw_textf(openSans12, WHITE, SCREEN_WIDTH*0.1, GAME_HEIGHT + 10, 0, "Joueur : %d", player1.score); al_draw_textf(openSans12, WHITE, SCREEN_WIDTH*0.1, GAME_HEIGHT + 50, 0, "Machine : %d", player2.score); } al_flip_display(); }
void drawPontos (ALLEGRO_FONT *fonte_pontos, listaQuestao *questionario, telaAlternativa *posicaoAlt, bonecoJog *jogador){ // Print na tela da quantidade de pontos do jogador al_draw_textf(fonte_pontos, al_map_rgb(157, 11 , 43), posicaoAlt->pontos_x, posicaoAlt->pontos_y, ALLEGRO_ALIGN_CENTRE , "pontos: %d ", questionario->pontos); al_draw_textf(fonte_pontos, al_map_rgb(157, 11 , 43), posicaoAlt->tempo_x, posicaoAlt->tempo_y, ALLEGRO_ALIGN_CENTRE , "tempo: %d s ", questionario->tempo); al_draw_textf(fonte_pontos, al_map_rgb(157, 11 , 43), posicaoAlt->acertos_x, posicaoAlt->acertos_y, ALLEGRO_ALIGN_CENTRE , "%d / 2 ", questionario->matarFantasma); al_draw_text(fonte_pontos, al_map_rgb(157, 11 , 43), jogador->forca_x - 20, jogador->forca_y -5, ALLEGRO_ALIGN_CENTRE , "força" ); al_draw_text(fonte_pontos, al_map_rgb(157, 11 , 43), posicaoAlt->pontos_x, jogador->forca_y -5, ALLEGRO_ALIGN_CENTRE , "vida" ); //---------------------------------------------------------------- }
void render() { al_clear_to_color(al_map_rgb(0, 0, 0)); al_draw_line(width / 2, 0, width / 2, height, al_map_rgb(123, 123, 123), width / 500); al_draw_text(font, al_map_rgb(123, 255, 255), width / 2, height - 30, ALLEGRO_ALIGN_CENTER, "Press 'P' to PAUSE"); al_draw_filled_rectangle(player1.x, player1.y, player1.x + player1.size_x, player1.y + player1.size_y, al_map_rgb(255, 255, 255)); al_draw_filled_rectangle(player2.x, player2.y, player2.x - player2.size_x, player2.y + player2.size_y, al_map_rgb(255, 255, 255)); al_draw_filled_circle(ball.x, ball.y, ball.size, al_map_rgb(255, 255, 255)); al_draw_textf(scorefont, al_map_rgb(255, 255, 255), width / 4, height / 12, ALLEGRO_ALIGN_CENTER, "%d", player1.score); al_draw_textf(scorefont, al_map_rgb(255, 255, 255), width - width / 4, height / 12, ALLEGRO_ALIGN_CENTER, "%d", player2.score); al_flip_display(); }
void demo_render(void) { int i; t3f_select_camera(&demo_camera); al_clear_to_color(al_map_rgb(0, 0, 64)); if(demo_tilemap && demo_tilemap->tileset) { for(i = 0; i < 3; i++) { t3f_render(demo_tilemap, i, demo_tick, &demo_camera); } } draw_animation(platform_ani, demo_tick, platform.x - demo_camera.x, platform.y - demo_camera.y, -demo_camera.z, 0); if(collision) { t3f_set_blender(al_map_rgba(255, 255, 255, 64)); } draw_animation(sprite_ani[player.state], player.frame, player.x - demo_camera.x, player.y - demo_camera.y, -demo_camera.z, 0); if(collision) { t3f_unset_blender(); } if(demo_tilemap && demo_tilemap->tileset) { for(i = 3; i < demo_tilemap->layers; i++) { t3f_render(demo_tilemap, i, demo_tick, &demo_camera); } } // al_font_textprintf(demo_font, 0, 0, "Camera Pos - (%f, %f, %f)", demo_camera.x, demo_camera.y, demo_camera.z); al_draw_textf(demo_font, 0, 0, 0, "CT - (%d, %d)", t3f_get_collision_tile_x(demo_collision_tilemap, player.x), t3f_get_collision_tile_y(demo_collision_tilemap, player.y)); al_flip_display(); }
void update_timer(int t, Board *b) { ALLEGRO_BITMAP *bmp = al_get_target_bitmap(); al_set_target_bitmap(*b->time_panel.b[0]->bmp); al_clear_to_color(b->time_panel.b[0]->bg_color); al_draw_textf(default_font, WHITE_COLOR, b->time_panel.b[0]->w/2, 0, ALLEGRO_ALIGN_CENTER, "%02d:%02d:%02d", (int)t/3600, ((int)t/60) % 60 , (int)t%60); al_set_target_bitmap(bmp); }
void title_render(void) { al_clear_to_color(al_map_rgba_f(0.0, 0.0, 0.0, 1.0)); al_draw_textf(font[FONT_GAME], al_map_rgba_f(1.0, 1.0, 1.0, 1.0), 320, 0, ALLEGRO_ALIGN_CENTRE, "High Score: %06d", high_score); t3f_draw_animation(animation[ANIMATION_TITLE], al_map_rgba_f(1.0, 1.0, 1.0, 1.0), state_ticks, 320 - al_get_bitmap_width(animation[ANIMATION_TITLE]->bitmap[0]) / 2, 60, 0, 0); hyperlink_page_render(menu[current_menu]); }
void About(struct Game *game, struct MenuResources* data) { ALLEGRO_TRANSFORM trans; al_identity_transform(&trans); al_use_transform(&trans); if (!game->_priv.font_bsod) { game->_priv.font_bsod = al_create_builtin_font(); } al_set_target_backbuffer(game->display); al_clear_to_color(al_map_rgb(0,0,170)); char *header = "TICKLE MONSTER"; al_draw_filled_rectangle(al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header)/2 - 4, (int)(al_get_display_height(game->display) * 0.32), 4 + al_get_display_width(game->display)/2 + al_get_text_width(game->_priv.font_bsod, header)/2, (int)(al_get_display_height(game->display) * 0.32) + al_get_font_line_height(game->_priv.font_bsod), al_map_rgb(170,170,170)); al_draw_text(game->_priv.font_bsod, al_map_rgb(0, 0, 170), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32), ALLEGRO_ALIGN_CENTRE, header); char *header2 = "A fatal exception 0xD3RP has occured at 0028:M00F11NZ in GST SD(01) +"; al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+2*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, header2); al_draw_textf(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+3*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "%p and system just doesn't know what went wrong.", (void*)game); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+5*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "About screen not implemented!"); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+6*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "See http://dosowisko.net/ticklemonster/"); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+7*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "Made for Ludum Dare 33 by Sebastian Krzyszkowiak"); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+9*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to terminate this error."); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+10*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Press any key to destroy all muffins in the world."); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2 - al_get_text_width(game->_priv.font_bsod, header2)/2, (int)(al_get_display_height(game->display) * 0.32+11*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_LEFT, "* Just kidding, please press any key anyway."); al_draw_text(game->_priv.font_bsod, al_map_rgb(255,255,255), al_get_display_width(game->display)/2, (int)(al_get_display_height(game->display) * 0.32+13*al_get_font_line_height(game->_priv.font_bsod)*1.25), ALLEGRO_ALIGN_CENTRE, "Press any key to continue _"); al_use_transform(&game->projection); }
void StartMenu::draw(){ al_draw_bitmap(background, 0, 0, 0); al_draw_rectangle(mouseX-5, mouseY-5, mouseX+5, mouseY+5, al_map_rgb(255,0,0), 5); //testing purposes al_draw_text(font36, al_map_rgb(100,0,100), 25,25,0, "Press Space to make game Lobby"); al_draw_textf(font36, al_map_rgb(100,0,100), 25,60,0, "This is the START MENU."); int tempY = windowHeight/2 - (fontHeight * 2); if(selected == START_GAME_HOST) al_draw_text(font36, al_map_rgb(0,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Host game"); else al_draw_text(font36, al_map_rgb(255,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Host game"); tempY += fontHeight; if(selected == START_GAME_CLIENT) al_draw_text(font36, al_map_rgb(0,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Connect to game"); else al_draw_text(font36, al_map_rgb(255,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Connect to game"); tempY += fontHeight; if(selected == HELP) al_draw_text(font36, al_map_rgb(0,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Help"); else al_draw_text(font36, al_map_rgb(255,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Help"); tempY += fontHeight; if(selected == EXIT) al_draw_text(font36, al_map_rgb(0,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Exit"); else al_draw_text(font36, al_map_rgb(255,0,255), windowWidth/2, tempY, ALLEGRO_ALIGN_CENTRE, "Exit"); }
void Card::Draw(float angle /*= 0.0*/, bool mouseHovered /*= false*/, bool drawBack/*=false*/) // angle must be in radians { float sx = _rank * _frameSize.X; float sy = _suit * _frameSize.Y; if (drawBack) { static Bitmap backTemp(BITMAP_GAME_CARDS_BACK_SPRITE, Vector2D(GetPosition().X + 1, GetPosition().Y + 1),Vector2D(1,1),Vector2D(_frameSize.X - 1, _frameSize.Y - 1),Vector2D(0,0),Vector2D(1.0 + mouseHovered*0.3, 1.0 + mouseHovered*0.3),al_map_rgb(255,255,255),angle); backTemp.Draw(); backTemp.SetDestinationCoordinates(GetPosition()).SetTint(al_map_rgb(_backColorRGB, _backColorRGB, _backColorRGB)).Draw(); backTemp.SetDestinationCoordinates(Vector2D(GetPosition().X + 1, GetPosition().Y + 1)).SetTint(al_map_rgb(255,255,255)).Draw(); } else { if (mouseHovered) // score top left { _bitmap.SetScale(Vector2D(1.3,1.3)).Draw(); _bitmap.SetScale(Vector2D(1,1)); al_draw_filled_rectangle(GetPosition().X + _frameSize.X*1.3 -25, GetPosition().Y + 4, GetPosition().X+_frameSize.X*1.3 - 4, GetPosition().Y + 25, al_map_rgb(255,255,255)); al_draw_textf(Fonts::GetFont(20), al_map_rgb(0,0,0), GetPosition().X+_frameSize.X*1.3 - 4 , GetPosition().Y, ALLEGRO_ALIGN_RIGHT, "%i", _score); } else _bitmap.Draw(); } }
void Player::render_extra(void) { ResourceManager& rm = ResourceManager::getInstance(); if (lives <= 0) { int w = al_get_bitmap_width(highscoreBitmap); int h = al_get_bitmap_height(highscoreBitmap); al_draw_bitmap(highscoreBitmap, (BB_W-w)/2, (BB_H-h)/2, 0); return; } al_draw_bitmap(icon, 2, 2, 0); ALLEGRO_FONT *small_font = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT); al_draw_textf(small_font, al_map_rgb(255, 255, 255), 20, 2, 0, "x%d", lives); al_draw_textf(small_font, al_map_rgb(255, 255, 255), 2, 18, 0, "%d", score); }
// Renders the path to the screen and some information about the generated path void Path::DrawPath() { if(!m_path.empty()) { for(int i = 0; i < m_path.size() - 1; i++) al_draw_line(m_path.at(i)->GetPos().x, m_path.at(i)->GetPos().y, m_path.at(i+1)->GetPos().x, m_path.at(i+1)->GetPos().y, al_map_rgb(0,0,0), 2); } if(m_playerPath) { al_draw_textf(m_font, al_map_rgb(0,0,0), 1020, 400, 0, "%s", m_pathMessage.c_str()); al_draw_textf(m_font, al_map_rgb(0,0,0), 1020, 430, 0, "Operations to find path: %i", m_numOperations); al_draw_textf(m_font, al_map_rgb(0,0,0), 1020, 445, 0, "Time taken to find path: %i milliseconds", m_pathCalcTime); } }
void update_survivaltime(ALLEGRO_BITMAP *image, float x, float y, int nflags, ALLEGRO_COLOR color) { static int counter = 0; GDATAPTR game = get_game_data(); if(game->paused); else if(lives <= 0); else counter++; if(counter >= 60) { counter = 0; seconds++; } if(seconds >= 60) { seconds = 0; minutes++; } if(survival_time != NULL) free(survival_time); survival_time = (char*)malloc(7*sizeof(char)); if(minutes < 10 && seconds < 10) sprintf(survival_time, "0%d:0%d", minutes, seconds); else if(minutes < 10) sprintf(survival_time, "0%d:%d", minutes, seconds); else if(seconds < 10) sprintf(survival_time, "%d:0%d", minutes, seconds); else sprintf(survival_time, "%d:%d", minutes, seconds); al_draw_textf(game->font, color, x, y, nflags, "Survival Time: %s", survival_time); }
int do_gui(const std::vector<Widget *>& widgets, unsigned int selected) { ResourceManager& rm = ResourceManager::getInstance(); ALLEGRO_BITMAP *bg = (ALLEGRO_BITMAP *)rm.getData(RES_BACKGROUND); Input *input = (Input *)rm.getData(RES_INPUT); ALLEGRO_BITMAP *logo = (ALLEGRO_BITMAP *)rm.getData(RES_LOGO); int lw = al_get_bitmap_width(logo); int lh = al_get_bitmap_height(logo); ALLEGRO_FONT *myfont = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT); bool redraw = true; for (;;) { input->poll(); float ud = input->ud(); if (ud < 0 && selected) { selected--; my_play_sample(RES_FIRELARGE); al_rest(0.200); redraw = true; } else if (ud > 0 && selected < (widgets.size()-1)) { selected++; my_play_sample(RES_FIRELARGE); al_rest(0.200); redraw = true; } if (input->b1()) { if (!widgets[selected]->activate()) return selected; } if (input->esc()) return -1; if (!redraw) { al_rest(0.010); continue; } /* draw */ al_draw_scaled_bitmap(bg, 0, 0, al_get_bitmap_width(bg), al_get_bitmap_height(bg), 0, 0, BB_W, BB_H, 0); al_draw_bitmap(logo, (BB_W-lw)/2, (BB_H-lh)/4, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); al_draw_textf(myfont, al_map_rgb(255, 255, 0), BB_W/2, BB_H/2, ALLEGRO_ALIGN_CENTRE, "z/y to start"); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); for (unsigned int i = 0; i < widgets.size(); i++) { widgets[i]->render(i == selected); } al_flip_display(); redraw = false; } }