void AnimatedSprite::draw(float offx, float offy) { if (!image || !visible) return; if (rot != 0 || scale != 1) { if (hFlip && vFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_HORIZONTAL | ALLEGRO_FLIP_VERTICAL); else if (hFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_HORIZONTAL); else if (vFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_VERTICAL); else al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, 0); } else { if (hFlip && vFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_HORIZONTAL | ALLEGRO_FLIP_VERTICAL); else if (hFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_HORIZONTAL); else if (vFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_VERTICAL); else al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, 0); } }
void Animator::UpdateBuffer() { FRAME current = AnimationList[cur_anim].GetCurrentFrame(); al_set_target_bitmap(buffer.GetBitmap()); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_bitmap_region(framesheet,framew*current.column, frameh*current.row, framew, frameh,.0f,.0f,0); if(enableBlur || enableColorDecomposition){ FRAME previous = AnimationList[cur_anim].GetFrame(AnimationList[cur_anim].current_frame-1); al_set_target_bitmap(blurBuffer.GetBitmap()); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_bitmap_region(framesheet,framew*previous.column, frameh*previous.row, framew, frameh,.0f,.0f,0); FRAME previous2 = AnimationList[cur_anim].GetFrame(AnimationList[cur_anim].current_frame-2); al_set_target_bitmap(blurBuffer2.GetBitmap()); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_bitmap_region(framesheet,framew*previous2.column, frameh*previous2.row, framew, frameh,.0f,.0f,0); } //ToBatchRenderer(); updatebuffer = false; return; }
void Gamestate_Draw(struct Game *game, struct dosowiskoResources* data) { if (!data->fadeout) { char t[255] = ""; strcpy(t, data->text); if (data->underscore) { strncat(t, "_", 1); } else { strncat(t, " ", 1); } al_set_target_bitmap(data->bitmap); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_text(data->font, al_map_rgba(255,255,255,10), game->viewport.width/2, game->viewport.height*0.4167, ALLEGRO_ALIGN_CENTRE, t); double tg = tan(-data->tan/384.0 * ALLEGRO_PI - ALLEGRO_PI/2); int fade = data->fadeout ? 255 : data->fade; al_set_target_bitmap(data->pixelator); al_clear_to_color(al_map_rgb(35, 31, 32)); al_draw_tinted_scaled_bitmap(data->bitmap, al_map_rgba(fade, fade, fade, fade), 0, 0, al_get_bitmap_width(data->bitmap), al_get_bitmap_height(data->bitmap), -tg*al_get_bitmap_width(data->bitmap)*0.05, -tg*al_get_bitmap_height(data->bitmap)*0.05, al_get_bitmap_width(data->bitmap)+tg*0.1*al_get_bitmap_width(data->bitmap), al_get_bitmap_height(data->bitmap)+tg*0.1*al_get_bitmap_height(data->bitmap), 0); al_draw_bitmap(data->checkerboard, 0, 0, 0); al_set_target_backbuffer(game->display); al_draw_bitmap(data->pixelator, 0, 0, 0); } }
void Board::Draw() { /* drawing main matrix */ for (unsigned int i = 2; i < matrix.size(); i++) { for (unsigned int j = 0; j < matrix[i].size(); j++) { if (matrix[i][j].isOccupied) switch (matrix[i][j].color) { default: case YellowCell: al_draw_bitmap(yellow_cell, 275 + j*25, i*25, NULL); break; case BlueCell: al_draw_bitmap(blue_cell, 275 + j*25, i*25, NULL); break; case PurpleCell: al_draw_bitmap(purple_cell, 275 + j*25, i*25, NULL); break; case GreenCell: al_draw_bitmap(green_cell, 275 + j*25, i*25, NULL); break; case RedCell: al_draw_bitmap(red_cell, 275 + j*25, i*25, NULL); break; } } } /* drawing animations */ int animationFrames = 20; for (unsigned int i = 0; i < clearedLineAnimationCoords.size(); i++) { /* if animation ended... */ if (clearedLineAnimationCoords[i].frame == animationFrames) { /* ...delete AnimElem and...*/ clearedLineAnimationCoords.erase(clearedLineAnimationCoords.begin()+i); /* ...decrement i to make up to the increment after break */ i--; break; } else { /* processing vector info */ double y1 = clearedLineAnimationCoords[i].y1; double y2 = clearedLineAnimationCoords[i].y1 + 25; double yEffectDispersion = 20 + sqrt(clearedLineAnimationCoords[i].frame * 10); double alpha = (int)(clearedLineAnimationCoords[i].frame * 255.0 / animationFrames); ALLEGRO_COLOR effectColor1 = al_map_rgba(255*alpha, 0*alpha, 0*alpha, alpha); ALLEGRO_COLOR effectColor2 = al_map_rgba(255*alpha, 255*alpha, 0*alpha, alpha); ALLEGRO_COLOR effectColor3 = al_map_rgba(255*alpha, 255*alpha, 255*alpha, alpha); /* drawing frame */ al_draw_filled_rectangle(0, y1 - yEffectDispersion, ScreenWidth, y2 + yEffectDispersion, effectColor1); al_draw_filled_rectangle(0, y1 - yEffectDispersion + 20, ScreenWidth, y2 + yEffectDispersion - 20, effectColor2); al_draw_filled_rectangle(0, y1 - yEffectDispersion + 50, ScreenWidth, y2 + yEffectDispersion - 50, effectColor3); /* incrementing frame to play next */ clearedLineAnimationCoords[i].frame++; } } }
void Enemy::draw() { al_draw_filled_ellipse(posx_+width_/2, posy_- height_/2+5, width_/2, height_/2, al_map_rgba(0,0,0,50)); if (lastHurt_ + 0.5 < al_get_time()) al_draw_bitmap_region(picture_, animationState_*pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_ - posz_, 0); else al_draw_tinted_bitmap_region(picture_, al_map_rgba(200,100,100,100), animationState_*pic_width_, 0, pic_width_, pic_height_, posx_, posy_ - pic_height_ - posz_, 0); }
void Animation::Draw(ALLEGRO_DISPLAY *display) { if(sourceRect != NULL) al_draw_tinted_bitmap(sourceRect, al_map_rgba(255, 255, 255, alpha), position.first, position.second, NULL); if(text != "") al_draw_text(font, al_map_rgba(255, 255, 255, alpha), position.first, position.second, NULL, text.c_str()); }
void ui_setstyle_default(void) { ui_setstyle("resources/vera-mono-12.png", al_map_rgba(255, 255, 255, 200), al_map_rgba(230, 230, 230, 200), al_map_rgba(200, 200, 200, 200), al_map_rgba(170, 170, 170, 200), al_map_rgba(150, 0, 0, 200)); }
void obj_AI_Bubble::Draw() { //al_draw_scaled_rotated_bitmap(image, 104, 104, (x-_camX)*(1/_zoom), (y-_camY)*(1/_zoom), (1.0f/96.0f) * radius, (1.0f/96.0f) * radius,0, 0); //al_draw_scaled_bitmap(image, 0, 0, 208, 208, x-(104*(1/96.f)*radius*(1/_zoom)), y-(104*(1/96.f)*radius*(1/_zoom)),208*(1/96.f)*radius*(1/_zoom),208*(1/96.f)*radius*(1/_zoom),0); al_draw_tinted_scaled_rotated_bitmap(imageRed,al_map_rgba(r,r,r,r),104,104,x,y,(1/96.f)*radius,(1/96.f)*radius,0,0); al_draw_tinted_scaled_rotated_bitmap(imageGreen,al_map_rgba(g,g,g,g),104,104,x,y,(1/96.f)*radius,(1/96.f)*radius,0,0); al_draw_scaled_rotated_bitmap(image,104,104,x,y,(1.0/96.f)*radius,(1.0/96.f)*radius,0,0); }
bool Player::load(void) { ALLEGRO_STATE state; al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP | ALLEGRO_STATE_BLENDER); bitmap = al_load_bitmap(getResource("gfx/ship.tga")); if (!bitmap) { debug_message("Error loading %s\n", getResource("gfx/ship.tga")); return false; } trans_bitmap = al_create_bitmap(al_get_bitmap_width(bitmap), al_get_bitmap_height(bitmap)); if (!trans_bitmap) { debug_message("Error loading %s\n", getResource("gfx/ship_trans.tga")); al_destroy_bitmap(bitmap); return false; } /* Make a translucent copy of the ship */ al_set_target_bitmap(trans_bitmap); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_tinted_bitmap(bitmap, al_map_rgba(255, 255, 255, 160), 0, 0, 0); al_restore_state(&state); trail_bitmap = al_load_bitmap(getResource("gfx/trail.tga")); if (!trail_bitmap) { debug_message("Error loading %s\n", getResource("gfx/trail.tga")); al_destroy_bitmap(bitmap); al_destroy_bitmap(trans_bitmap); return false; } icon = al_load_bitmap(getResource("gfx/ship_icon.tga")); if (!icon) { debug_message("Error loading %s\n", getResource("gfx/icon.tga")); al_destroy_bitmap(bitmap); al_destroy_bitmap(trans_bitmap); al_destroy_bitmap(trail_bitmap); return false; } highscoreBitmap = al_create_bitmap(300, 200); al_set_target_bitmap(highscoreBitmap); al_clear_to_color(al_map_rgba(0, 0, 0, 0)); al_restore_state(&state); draw_radius = al_get_bitmap_width(bitmap)/2; radius = draw_radius / 2; newGame(); reset(); return true; }
void thmreset() { tmh.c_text = al_map_rgba(255,255,255,0); tmh.c_outline = al_map_rgba(0,200,0,255); tmh.c_background = al_map_rgba(255,0,0,255); tmh.c_clicking = al_map_rgba(0,0,0,125); tmh.thickness = 2; tmh.added_thickness = 2; tmh.roundx = 2; tmh.roundy = 2; }
void entityErrorBox::render(float oX,float oY) { al_draw_tinted_bitmap(errorBG,al_map_rgba_f(1*alpha,1*alpha,1*alpha,alpha),x-204,y,0); al_draw_text(errorFont,al_map_rgba(101*alpha,5*alpha,5*alpha,alpha*255),x-204+9,y+2,0,"Error!"); al_draw_text(errorFont,al_map_rgba(101*alpha,5*alpha,5*alpha,alpha*255),x,y+24,ALLEGRO_ALIGN_CENTRE,errorText.c_str()); ALLEGRO_MOUSE_STATE mS; al_get_mouse_state(&mS); if (gameEngine::globalFunctions::pointInRegion(mS.x,mS.y,x-204+384,y+8,x-204+384+16,y+8+16)) { //Hovering over the x button al_draw_text(errorFont,al_map_rgba(101*alpha,5*alpha,5*alpha,alpha*255),x-204+384,y+2,0,"X"); }else { //Not hovering al_draw_text(errorFont,al_map_rgba(108*alpha,10*alpha,10*alpha,alpha*255),x-204+384,y+2,0,"X"); } }
void drawenemy(Game *game, int i) { Enemy enemy; enemy = game->room->enemies[i]; al_draw_filled_ellipse(enemy.posx+enemy.szer/2,enemy.posy-enemy.grub/2 + 5,enemy.szer/2, enemy.grub/2, al_map_rgba(0,0,0,50)); if (enemy.lasthurt > al_get_time() - 0.3) al_draw_tinted_bitmap_region(enemy.picture, al_map_rgba(100,100,100,100),enemy.picposx,enemy.picposy, enemy.szer, enemy.wys, enemy.posx, enemy.posy-enemy.wys, 0); else al_draw_bitmap_region(enemy.picture,enemy.picposx,enemy.picposy, enemy.szer, enemy.wys, enemy.posx, enemy.posy-enemy.wys, 0); }
void Animation::Draw(ALLEGRO_DISPLAY *display) { if(sourceRect != NULL) al_draw_tinted_bitmap(sourceRect,al_map_rgba(0,0,0,alpha), position[0], position[1], NULL); else if(image != NULL) al_draw_tinted_bitmap(image,al_map_rgba(0,0,0,alpha), position[0], position[1], NULL); if(text != "") al_draw_text(font, al_map_rgba(255,0,0,alpha),position[0], position[1], NULL, text.c_str()); }
void draw_background(int x, int y) { ALLEGRO_COLOR c[] = { al_map_rgba(0x66, 0x66, 0x66, 0xff), al_map_rgba(0x99, 0x99, 0x99, 0xff) }; for (int i = 0; i < 320 / 16; i++) { for (int j = 0; j < 200 / 16; j++) { al_draw_filled_rectangle(x + i * 16, y + j * 16, x + i * 16 + 16, y + j * 16 + 16, c[(i + j) & 1]); } } }
/* Draw the checkerboard background. */ static void draw_background(void) { ALLEGRO_COLOR c[2]; int i, j; c[0] = al_map_rgba(0xaa, 0xaa, 0xaa, 0xff); c[1] = al_map_rgba(0x99, 0x99, 0x99, 0xff); for (i = 0; i < 640 / 16; i++) { for (j = 0; j < 480 / 16; j++) { al_draw_filled_rectangle(i * 16, j * 16, i * 16 + 16, j * 16 + 16, c[(i + j) & 1]); } } }
void record_reset(record *r) { if (r != NULL) { r->display_color = al_map_rgba(0, 0, 0, 0); } else { error_message("record null pointer"); } }
void my_clear_bitmap(MBITMAP *b) { ALLEGRO_BITMAP *target = al_get_target_bitmap(); m_set_target_bitmap(b); m_clear(al_map_rgba(0, 0, 0, 0)); al_set_target_bitmap(target); }
Display::Display(int width, int height) { //-------------------------------------------------------------------------- // Initialisation //http://liballeg.org/a5docs/5.0.10/getting_started.html //-------------------------------------------------------------------------- //initialisation de l'addon pour dessiner les primitives al_init_primitives_addon(); //on creer la fenetre d'affichage window = al_create_display(width, height); //on met le font noir al_clear_to_color(al_map_rgba(0, 0, 0, 255)); //met a jour le display manuellement al_flip_display(); //on place la fenetre en haut a gauche de l'ecran al_set_window_position(window, 0, 0); //Init du font al_init_font_addon(); al_init_ttf_addon(); font = al_load_ttf_font("Browning.ttf", 100, 0); font2 = al_load_ttf_font("Browning.ttf", 25, 0); score = "0"; }
/* Function: al_convert_mask_to_alpha */ void al_convert_mask_to_alpha(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR mask_color) { ALLEGRO_LOCKED_REGION *lr; int x, y; ALLEGRO_COLOR pixel; ALLEGRO_COLOR alpha_pixel; ALLEGRO_STATE state; if (!(lr = al_lock_bitmap(bitmap, ALLEGRO_PIXEL_FORMAT_ANY, 0))) { ALLEGRO_ERROR("Couldn't lock bitmap."); return; } al_store_state(&state, ALLEGRO_STATE_TARGET_BITMAP); al_set_target_bitmap(bitmap); alpha_pixel = al_map_rgba(0, 0, 0, 0); for (y = 0; y < bitmap->h; y++) { for (x = 0; x < bitmap->w; x++) { pixel = al_get_pixel(bitmap, x, y); if (memcmp(&pixel, &mask_color, sizeof(ALLEGRO_COLOR)) == 0) { al_put_pixel(x, y, alpha_pixel); } } } al_unlock_bitmap(bitmap); al_restore_state(&state); }
void Display::displayText(std::string text, Coordinates position){ const char* textTemp = text.c_str(); //Ne fonctionne pas tout le temps a verifier al_draw_text(font, (al_map_rgba(255, 0, 0, 255)), position.getX(), position.getY(), ALLEGRO_ALIGN_CENTRE, textTemp); al_flip_display(); }
void MapDisp::InitialiseGui() { cursor = new Mouse(); cursor->AllowBoxing = true; testButton = new Button(); testButton->Position.X = 4; testButton->Position.Y = 4; testButton->Size.X = 200; testButton->Size.Y = 32; testButton->Text = "Quit"; testButton->FontSize = 16; testButton->BorderWidth = 2; Controls.push_back( testButton ); nextWave = new Panel(); nextWave->Position.X = CurrentConfiguration->ScreenWidth - 224; nextWave->Position.Y = 4; nextWave->Size.X = 220; nextWave->Size.Y = 96; nextWave->Background = al_map_rgba( 64, 128, 64, 128 ); nextWave->Border = al_map_rgb( 96, 192, 96 ); nextWave->BorderWidth = 2; nextWave->Title = "Next Wave"; nextWave->HasTitle = true; Controls.push_back( nextWave ); }
void Player::draw() { if(weaponPickup != -1 && currentWeaponIndex != -1) { currentWeapon->draw(); } int blackoutAlpha = (int)(((LOSE_TIME - loseTimer)/LOSE_TIME)*255.0f); /* if(blackoutAlpha > 255) { blackoutAlpha = 255; } if(blackoutAlpha < 0) { blackoutAlpha = 0; } */ //This allows the death screen to be shown if (blackoutAlpha > 255 || blackoutAlpha < 0) { blackoutAlpha = 0; } al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_draw_filled_rectangle(0, 0, 1280, 720, al_map_rgba(100, 0, 0, blackoutAlpha)); hurtOverlay.setTransparency(health + sin(time*4.0f)*(1.0f-health)/2); hurtOverlay.draw(); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); if(displayHealthTimer > 0) { for(int i = 0; i < healthpacks; i++) { al_draw_bitmap(healthBitmap, 50.0 + 90*i, 580, 0); } } }
void TParticle::Draw(double a_dCamX,double a_dCamY) { double DrawX=int(m_pEngine->m_nScreenMidX+(m_dX-a_dCamX)); double DrawY=int(m_pEngine->m_nScreenMidY+(m_dY-a_dCamY)); // only draw what we see // float r=1.0; // float g=0.2; // float b=0.8; // float a=m_nLife/50; if ((DrawX>=0)&&(DrawX<m_pEngine->m_nScreenWidth)&&(DrawY>=0)&&(DrawY<m_pEngine->m_nScreenHeight)) { int r,g,b; switch (m_Effect) { case EFF_NORMAL: r = (m_nLife*6)+15; g = 100; if (r<g) g=r; b=0; break; case EFF_PROBE: r = g = b = (m_nLife*6)+15; break; } al_draw_filled_circle(DrawX, DrawY, 1, al_map_rgba(r,g,b,m_nLife*5)); } }
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(); }
/* ---------------------------------------------------------------------------- * Draws a button widget. */ void menu_button::draw(const float time_spent) { if(!font || !enabled) return; al_draw_rounded_rectangle( center.x - size.x * 0.5, center.y - size.y * 0.5, center.x + size.x * 0.5, center.y + size.y * 0.5, 16, 16, al_map_rgba(255, 255, 255, 32), 2 ); if(selected) { draw_bitmap( bmp_icon, point(center.x - size.x * 0.5 + 16, center.y), point(16, 16), sin(time_spent * ICON_SWAY_TIME_SCALE) * ICON_SWAY_DELTA ); draw_bitmap( bmp_icon, point(center.x + size.x * 0.5 - 16, center.y), point(16, 16), sin(time_spent * ICON_SWAY_TIME_SCALE) * ICON_SWAY_DELTA ); } int text_x = center.x; if(text_align == ALLEGRO_ALIGN_LEFT) { text_x = center.x - size.x * 0.5 + 32; } else if(text_align == ALLEGRO_ALIGN_RIGHT) { text_x = center.x + size.x * 0.5 - 32; } draw_text_lines( font, text_color, point(text_x, center.y), text_align, 1, text ); }
void tela_boot_jogo (Jogo* jogo) { ALLEGRO_EVENT_QUEUE *event_queue = NULL; ALLEGRO_TIMER *timer = NULL; ALLEGRO_EVENT ev; int alfa = 0; int velocidade = 5; ALLEGRO_BITMAP* minerva = al_load_bitmap("resources/minerva.png"); if (minerva == NULL) { puts("Erro ao carregar o arquivo \"resources/minerva.png\""); puts("Erro ao carregar o arquivo resources/minerva.png"); exit(0); } event_queue = al_create_event_queue(); timer = al_create_timer(1.0 / 30); al_register_event_source(event_queue, al_get_display_event_source(jogo->display)); al_register_event_source(event_queue, al_get_timer_event_source(timer)); al_install_keyboard(); al_register_event_source(event_queue, al_get_keyboard_event_source()); al_rest(1); al_start_timer(timer); while (true) { alfa += velocidade; al_wait_for_event(event_queue, &ev); if (ev.type == ALLEGRO_EVENT_TIMER) { if (alfa > 0 && alfa < 255) { al_clear_to_color(al_map_rgb(0,0,0)); al_draw_tinted_bitmap(minerva, al_map_rgba(alfa, alfa, alfa, alfa), (jogo->largura - al_get_bitmap_width(minerva))/2, (jogo->altura - al_get_bitmap_height(minerva))/2, 0); al_flip_display(); } if (alfa > 350) velocidade = -velocidade; if (alfa < 0) break; } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) { break; } } al_destroy_timer(timer); al_destroy_event_queue(event_queue); al_destroy_bitmap(minerva); }
void CInitState::Draw(CGameEngine* game) { al_clear_to_color(al_map_rgb(255, 255, 255)); al_draw_tinted_bitmap(bg, al_map_rgba(255, 255, 255, alpha), 200, 187, 0); al_flip_display(); }
animation::animation(ALLEGRO_BITMAP * spriteSheet,ALLEGRO_BITMAP * bottomSpriteSheet, int xOffset,int yOffset,int width, int height, int xBottomOffset, int yBottomOffset,int bottomWidth, int bottomHeight,int speedTemp) :speed_(speedTemp),xOffset_(xOffset),yOffset_(yOffset),oneThrough_(false),xBottomOffset_(xBottomOffset),yBottomOffset_(yBottomOffset),split_(true) { int bitmapWidth = al_get_bitmap_width(spriteSheet); int bitmapHeight = al_get_bitmap_height(spriteSheet); if(bitmapHeight % height != 0 or bitmapWidth % width != 0) { //Malformed settings.ini or malformed sprite sheet fprintf(stderr, "NIGGERFAGGOT?\n"); }else { for(int i = 0; i < bitmapWidth / width; ++i) { for(int j = 0; j < bitmapHeight / height; ++j) { ALLEGRO_BITMAP * tempBitmap = al_create_bitmap(width,height); al_set_target_bitmap(tempBitmap); al_clear_to_color(al_map_rgba(100,100,99,0)); al_draw_bitmap_region(spriteSheet,i*width, j*height, width, height, 0, 0, 0); frames_.push_back(tempBitmap); } } } int bottomSheetWidth = al_get_bitmap_width(bottomSpriteSheet); int bottomSheetHeight = al_get_bitmap_height(bottomSpriteSheet); if(bottomSheetHeight % bottomHeight != 0 or bottomSheetWidth % bottomWidth != 0) { //Malformed settings.ini or malformed sprite sheet fprintf(stderr, "tehfuckrlysdf? %i\n", bottomSheetWidth); exit(1); }else if(bottomSpriteSheet != NULL) { for(int j = 0; j < bottomSheetHeight / bottomHeight; ++j) { for(int i = 0; i < bottomSheetWidth / bottomWidth; ++i) { ALLEGRO_BITMAP * tempBitmap = al_create_bitmap(bottomWidth,bottomHeight); al_set_target_bitmap(tempBitmap); al_clear_to_color(al_map_rgba(100,100,99,0)); al_draw_bitmap_region(bottomSpriteSheet,i*bottomWidth, j*bottomHeight, bottomWidth, bottomHeight, 0, 0, 0); bottomFrames_.push_back(tempBitmap); } } } }
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) { struct GamestateResources *data = malloc(sizeof(struct GamestateResources)); data->timeline = TM_Init(game, "main"); data->bitmap = al_create_bitmap(game->viewport.width, game->viewport.height); data->checkerboard = al_create_bitmap(game->viewport.width, game->viewport.height); data->pixelator = al_create_bitmap(game->viewport.width, game->viewport.height); al_set_target_bitmap(data->checkerboard); al_lock_bitmap(data->checkerboard, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY); int x, y; for (x = 0; x < al_get_bitmap_width(data->checkerboard); x=x+2) { for (y = 0; y < al_get_bitmap_height(data->checkerboard); y=y+2) { al_put_pixel(x, y, al_map_rgba(0,0,0,64)); al_put_pixel(x+1, y, al_map_rgba(0,0,0,0)); al_put_pixel(x, y+1, al_map_rgba(0,0,0,0)); al_put_pixel(x+1, y+1, al_map_rgba(0,0,0,0)); } } al_unlock_bitmap(data->checkerboard); al_set_target_backbuffer(game->display); (*progress)(game); data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"), (int)(game->viewport.height*0.1666 / 8) * 8 ,0 ); (*progress)(game); data->sample = al_load_sample( GetDataFilePath(game, "dosowisko.flac") ); data->sound = al_create_sample_instance(data->sample); al_attach_sample_instance_to_mixer(data->sound, game->audio.music); al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE); (*progress)(game); data->kbd_sample = al_load_sample( GetDataFilePath(game, "kbd.flac") ); data->kbd = al_create_sample_instance(data->kbd_sample); al_attach_sample_instance_to_mixer(data->kbd, game->audio.fx); al_set_sample_instance_playmode(data->kbd, ALLEGRO_PLAYMODE_ONCE); (*progress)(game); data->key_sample = al_load_sample( GetDataFilePath(game, "key.flac") ); data->key = al_create_sample_instance(data->key_sample); al_attach_sample_instance_to_mixer(data->key, game->audio.fx); al_set_sample_instance_playmode(data->key, ALLEGRO_PLAYMODE_ONCE); (*progress)(game); return data; }
void GameLobbyAddLocalStage::Render() { FRAMEWORK->ProgramStages->Previous()->Render(); al_draw_filled_rectangle( 0, 0, DISPLAY->GetWidth(), DISPLAY->GetHeight(), al_map_rgba( 0, 0, 0, 128 ) ); editform->Render(); // al_draw_filled_rectangle( 0, 240 - optionfont->GetFontHeight() - 4, DISPLAY->GetWidth(), 240 + optionfont->GetFontHeight() + 4, al_map_rgb( 192, 192, 192 ) ); // optionfont->DrawString( 400, 240 - optionfont->GetFontHeight() - 4, "Enter Player's Name", FontHAlign::CENTRE, al_map_rgb( 0, 0, 0 ) ); // optionfont->DrawString( 400, 240 - optionfont->GetFontHeight() - 4, player->Name, FontHAlign::CENTRE, al_map_rgb( 0, 0, 0 ) ); }