void Gamestate_Draw(struct Game *game, struct MenuResources* data) { al_set_target_bitmap(al_get_backbuffer(game->display)); al_clear_to_color(al_map_rgb(3, 213, 255)); al_draw_bitmap(data->bg, 0, 0, 0); al_draw_bitmap(data->monster, data->monster_pos, 10, 0); if (!data->starting) { al_draw_bitmap(data->title, 123, 25 - (pow(sin(data->title_pos), 2) * 16) - data->screen_pos, 0); } DrawMenuState(game, data); }
static void do_test2(ALLEGRO_COLOR src_col, ALLEGRO_COLOR dst_col, ALLEGRO_COLOR blend_col, int src_format, int dst_format, int src_mode, int dst_mode, int src_alpha, int dst_alpha, int operation) { ALLEGRO_COLOR reference, result, from_display; test_index++; if (test_only_index && test_index != test_only_index) return; reference = reference_implementation( src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation); result = test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, false); if (!same_color(reference, result)) { test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, true); printf("expected : "); print_color(reference); printf("\n"); printf("FAILED\n"); } else { printf(" OK"); fflush(stdout); } if (test_display) { dst_format = al_get_display_format(); from_display = al_get_pixel(al_get_backbuffer(), 0, 0); reference = reference_implementation( src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation); if (!same_color(reference, from_display)) { test(src_col, dst_col, blend_col, src_format, dst_format, src_mode, dst_mode, src_alpha, dst_alpha, operation, true); printf("displayed : "); print_color(from_display); printf("\n"); printf("expected : "); print_color(reference); printf("\n"); printf("(FAILED on display)\n"); } } }
/* Run the FPS test. */ static void run(void) { ALLEGRO_EVENT event; int frames = 0; double start; target = al_create_bitmap(W, H); al_set_target_bitmap(target); al_clear_to_color(al_map_rgba_f(1, 1, 0, 1)); al_set_target_bitmap(al_get_backbuffer()); dx = 81; dy = 63; start = al_current_time(); while (true) { /* Check for ESC key or close button event and quit in either case. */ if (!al_event_queue_is_empty(queue)) { while (al_get_next_event(queue, &event)) { switch (event.type) { case ALLEGRO_EVENT_DISPLAY_CLOSE: quit = true; goto done; case ALLEGRO_EVENT_KEY_DOWN: if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) quit = true; goto done; if (event.keyboard.keycode == ALLEGRO_KEY_SPACE) goto done; break; } } } draw(); print(0, 0, "FPS: %.1f", frames / (al_current_time() - start)); if (al_get_new_bitmap_flags() & ALLEGRO_FORCE_LOCKING) { print(0, al_get_font_line_height(myfont), "using forced bitmap locking"); } else { print(0, al_get_font_line_height(myfont), "drawing directly to bitmap"); } print(0, al_get_font_line_height(myfont) * 2, "Press SPACE to toggle drawing method."); al_flip_display(); frames++; } done: al_destroy_bitmap(target); }
//==================================================== DRAW_MENU ========================================================// void Menu_Draw(struct Game *game) { //RYSOWANIE TŁA Z MENU// al_draw_bitmap(game->menu.menu_bitmap,0,0,0); al_set_target_bitmap(al_get_backbuffer(game->display)); al_draw_bitmap_region(game->menu.mills, 0,game->menu.mills_y, 82,85, 799,485, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,0, 231,64, game->menu.cldpos1*1.2+300,0, 231,64, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos1+53,95, 213,44, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,108, 245,54, game->menu.cldpos1*1.5+723,24, 245,54, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,162, 190,41, game->menu.cldpos1*0.8+665,138, 190,41, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,0, 231,64, game->menu.cldpos2+475,175, 231*0.7,64*0.7, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos2*1.15+250,70, 213*0.9,44*0.9, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,108, 245,54, game->menu.cldpos2*1.1+22,220, 245*0.8,54*0.8, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,162, 190,41, game->menu.cldpos3+885,275, 190*0.7,41*0.7, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos3*0.7+520,290, 213*0.4,44*0.4, 0); al_draw_bitmap(game->menu.smok,0,95,0); //PRZYCISKI// if(game->gamestate==0){ al_draw_bitmap_region(game->menu.buttons, 0,0, 195,43, 635,41, 0); //new game if(game->play.dragon_lives>0) al_draw_bitmap_region(game->menu.buttons, 0,43, 195,43, 635,119, 0); //resume game else al_draw_bitmap_region(game->menu.buttons, 0,215, 195,43, 635,119, 0); //resume game przygaszony al_draw_bitmap_region(game->menu.buttons, 0,86, 195,43, 635,197, 0); //options al_draw_bitmap_region(game->menu.buttons, 0,129, 195,43, 635,275, 0); //quit } //WYNIKI I INSTRUKCJA GRY// if(game->gamestate==2){ al_draw_bitmap_region(game->menu.buttons, 195,0, 132,211, 698,41, 0); //tablica wyników al_draw_bitmap_region(game->menu.buttons, 0,258, 498,211, 118,41, 0); //tablica informacji o grze al_draw_bitmap_region(game->menu.buttons, 0,172, 195,43, 635,275, 0); //przycisk 'menu' al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,84, ALLEGRO_ALIGN_LEFT, "1. %i", game->table[0]); // stara poprawiona wysokość = 77 i co 20 al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,104, ALLEGRO_ALIGN_LEFT, "2. %i", game->table[1]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,124, ALLEGRO_ALIGN_LEFT, "3. %i", game->table[2]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,144, ALLEGRO_ALIGN_LEFT, "4. %i", game->table[3]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,164, ALLEGRO_ALIGN_LEFT, "5. %i", game->table[4]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,184, ALLEGRO_ALIGN_LEFT, "6. %i", game->table[5]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,204, ALLEGRO_ALIGN_LEFT, "7. %i", game->table[6]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,224, ALLEGRO_ALIGN_LEFT, "8. %i", game->table[7]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,61, ALLEGRO_ALIGN_LEFT, "Press or to move up and or to move down."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,81, ALLEGRO_ALIGN_LEFT, "Press or right click mouse to fire a fiery bullet!"); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,101, ALLEGRO_ALIGN_LEFT, "To pause game or enter menu press ."); //al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,121, ALLEGRO_ALIGN_LEFT, ""); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,141, ALLEGRO_ALIGN_LEFT, "You've got three lives."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,161, ALLEGRO_ALIGN_LEFT, "Avoid thrown pitchforks - they will kill you!"); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,181, ALLEGRO_ALIGN_LEFT, "Flying into a cloud of flour disables you for a while."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,201, ALLEGRO_ALIGN_LEFT, "Do not fly too low - you will fall and die."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,221, ALLEGRO_ALIGN_LEFT, "Shepherd boys fire exploding sheep defragmentators!"); } //BITMAPA KURSORA// al_draw_bitmap(game->menu.cursor,game->pos_x, game->pos_y, 0); }
void MenuScreen::render() { m_game->m_camera2.bind(); al_clear_to_color(al_map_rgb(63,63,116)); al_set_target_bitmap(al_get_backbuffer(m_game->display())); al_draw_text(m_game->m_fontBig, al_map_rgb(203, 219, 252), 15, 11, 0, "Pheee"); al_draw_text(m_game->m_fontBig, al_map_rgb(203, 219, 252), 15, 31, 0, "Strew"); al_draw_text(m_game->m_fontBig, al_map_rgb(203, 219, 252), 15, 51, 0, "Quest"); }
ALLEGRO_BITMAP* getScaledImage(ALLEGRO_BITMAP* src, float scaleFactorX, float scaleFactorY) { ALLEGRO_BITMAP* dest = NULL; float originalWidth=al_get_bitmap_width(src); float originalHeight=al_get_bitmap_height(src); //dest = imageLibrary.createImage(originalWidth*scaleFactorX, originalHeight*scaleFactorY); dest = al_create_bitmap(originalWidth*scaleFactorX, originalHeight*scaleFactorY); if(!dest) { playerLog("Failed to create destination image in copyScaledImage()-function..'.\n"); } al_set_target_bitmap(dest); al_draw_scaled_bitmap(src, 0, 0, originalWidth, originalHeight, 0, 0, originalWidth*scaleFactorX, originalHeight*scaleFactorY, 0); al_set_target_bitmap(al_get_backbuffer(display)); return dest; }
void* Load(struct Game *game) { struct LoadingResources *data = malloc(sizeof(struct LoadingResources)); al_clear_to_color(al_map_rgb(0,0,0)); data->loading_bitmap = al_create_bitmap(game->viewport.width, game->viewport.height); data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png") ); al_set_target_bitmap(data->loading_bitmap); al_clear_to_color(al_map_rgb(0,0,0)); al_draw_bitmap(data->bg, 0, 0, 0); al_draw_filled_rectangle(0, game->viewport.height/2 - 1, game->viewport.width, game->viewport.height/2 + 1, al_map_rgba(32,32,32,32)); al_set_target_bitmap(al_get_backbuffer(game->display)); return data; }
bool Game::initialize() { m_pNetwork->initialize(); m_pFrameTimer = al_create_timer(1.0 / FPS); if (!m_pFrameTimer) { return false; } m_pNetworkTimer = al_create_timer(0.06); if (!m_pNetworkTimer) { return false; } if (!m_pGraphics->initialize()) { al_destroy_timer(m_pFrameTimer); return false; } if (!m_pPlatform[0]->initialize() || !m_pPlatform[1]->initialize() || !m_pBall->initialize()) { al_destroy_timer(m_pFrameTimer); return false; } m_pEventQueue = al_create_event_queue(); if (!m_pEventQueue) { al_destroy_timer(m_pFrameTimer); return false; } al_register_event_source(m_pEventQueue, al_get_display_event_source(m_pGraphics->getDisplay())); al_register_event_source(m_pEventQueue, al_get_timer_event_source(m_pFrameTimer)); al_register_event_source(m_pEventQueue, al_get_timer_event_source(m_pNetworkTimer)); al_register_event_source(m_pEventQueue, al_get_keyboard_event_source()); al_set_target_bitmap(al_get_backbuffer(m_pGraphics->getDisplay())); al_clear_to_color(al_map_rgb(0, 0, 0)); al_flip_display(); al_start_timer(m_pFrameTimer); al_start_timer(m_pNetworkTimer); return true; }
void KinectPlayer::Render() { // if (!mPlayerPresent) { // return; // } std::vector<UserData> users; mUserTracking.GetUsers(users); if (users.empty()) { return; } al_set_target_bitmap(mBitmap); al_clear_to_color(al_map_rgb(0x00, 0x00, 0x00)); al_convert_mask_to_alpha(mBitmap, al_map_rgb(0x00, 0x00, 0x00)); xn::SceneMetaData scene_meta; mUserTracking.GetUserPixels(users[0], scene_meta); const XnRGB24Pixel* pRgbBuf = mKinect.GetImageData(); const XnLabel* pLabelBuf = scene_meta.Data(); ALLEGRO_LOCKED_REGION* lock = al_lock_bitmap(mBitmap, al_get_bitmap_format(mBitmap), ALLEGRO_LOCK_WRITEONLY); al_set_target_bitmap(mBitmap); for (int y = 0; y < mBitmapHeight; y++) { for (int x = 0; x < mBitmapWidth; x++, pLabelBuf++, pRgbBuf++) { if (*pLabelBuf == users[0].GetId()) { al_put_pixel(x, y, al_map_rgb(pRgbBuf->nRed, pRgbBuf->nGreen, pRgbBuf->nBlue)); } } } al_unlock_bitmap(mBitmap); const int screen_x_res = al_get_display_width(al_get_current_display()); const int screen_y_res = al_get_display_height(al_get_current_display()); al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); al_draw_scaled_bitmap(mBitmap, 0, 0, mBitmapWidth, mBitmapHeight, GetXPos(), GetYPos(), GetWidth(), GetHeight(), 0); }
void FadeOut(int velocidade, int TamanhoAlfa) { ALLEGRO_BITMAP *buffer; buffer = al_create_bitmap(LARGURA_TELA, ALTURA_TELA); al_set_target_bitmap(buffer); al_draw_bitmap(al_get_backbuffer(Display), 0, 0, 0); al_set_target_bitmap(al_get_backbuffer(Display)); if (velocidade <= 0) velocidade = 1; else if (velocidade > 15) velocidade = 15; int alfa; for (alfa = 0; alfa <= TamanhoAlfa; alfa += velocidade) { al_clear_to_color(al_map_rgba(0, 0, 0, 0)); al_draw_tinted_bitmap(buffer, al_map_rgba(255 - alfa, 255 - alfa, 255 - alfa, alfa), cameraPosition[0], cameraPosition[1], 0); al_flip_display(); al_rest(0.005); // Não é necessário caso haja controle de FPS } al_destroy_bitmap(buffer); }
void Console_Load(struct Game *game) { game->_priv.font_console = NULL; game->_priv.console = NULL; game->_priv.font_console = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),al_get_display_height(game->display)*0.025,0 ); if (al_get_display_height(game->display)*0.025 >= 16) { game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/PerfectDOSVGA437.ttf"),16,0 ); } else { game->_priv.font_bsod = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"), al_get_display_height(game->display)*0.025,0 ); } game->_priv.console = al_create_bitmap((al_get_display_width(game->display) / 320) * 320, al_get_font_line_height(game->_priv.font_console)*5); game->_priv.font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"), 0 ,0 ); al_set_target_bitmap(game->_priv.console); al_clear_to_color(al_map_rgba(0,0,0,80)); al_set_target_bitmap(al_get_backbuffer(game->display)); }
ALLEGRO_BITMAP * Starfield::makeStarfield(int numStars, ALLEGRO_DISPLAY *display) { ALLEGRO_BITMAP * bit = al_create_bitmap(ScreenWidth, ScreenHeight); al_set_target_bitmap(bit); //al_clear_to_color(al_map_rgb(0, 0, 0)); int i; for(i = 0; i < numStars; i++) { al_put_pixel(qrand() % ScreenWidth, qrand() % ScreenHeight, al_map_rgb(255,255,255)); } al_set_target_bitmap(al_get_backbuffer(display)); return bit; }
void take_screenshot(SCREENSHOT * ss) { char buf[64]; ALLEGRO_BITMAP *bmp2 = NULL; snprintf(buf, sizeof(buf), "%s%04d.%s", ss->name, ss->counter, ss->ext); bmp2 = al_create_bitmap(screen_width, screen_height); al_set_target_bitmap(bmp2); al_draw_bitmap(al_get_backbuffer(screen), 0, 0, 0); al_set_target_backbuffer(screen); al_save_bitmap(buf, bmp2); al_destroy_bitmap(bmp2); next_screenshot(ss); }
void Overlay::Flip() { //do the starting timer stuff clock_t starttime = clock(); al_lock_mutex(front_mutex); { al_unlock_bitmap(front); if(al_get_bitmap_width(front) != ssState.ScreenW || al_get_bitmap_height(front) != ssState.ScreenH){ al_destroy_bitmap(front); int32_t flags = al_get_new_bitmap_flags(); if(al_get_current_display() != NULL){ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP | ALLEGRO_ALPHA_TEST); } front = al_create_bitmap(ssState.ScreenW, ssState.ScreenH); al_set_new_bitmap_flags(flags); } al_set_target_bitmap(front); al_draw_bitmap(back, 0, 0, 0); front_data = al_lock_bitmap(front, al_get_bitmap_format(front), ALLEGRO_LOCK_READONLY); } front_updated = true; al_unlock_mutex(front_mutex); if(al_get_bitmap_width(back) != ssState.ScreenW || al_get_bitmap_height(back) != ssState.ScreenH){ al_destroy_bitmap(back); int32_t flags = al_get_new_bitmap_flags(); if(al_get_current_display() != NULL){ al_set_new_bitmap_flags(al_get_bitmap_flags(al_get_backbuffer(al_get_current_display()))); } back = al_create_bitmap(ssState.ScreenW, ssState.ScreenH); al_set_new_bitmap_flags(flags); } al_set_target_bitmap(back); //do the ending timer stuff clock_t donetime = clock(); ssTimers.overlay_time = (donetime - starttime)*0.1 + ssTimers.overlay_time*0.9; }
void Progress(struct Game *game, float p) { if (p<0.15) { draw(game,game->loading.image1); } else if (p<0.4) { draw(game,game->loading.image2); } else if (p<0.65) { draw(game,game->loading.image3); } else { draw(game,game->loading.image4); } if (game->debug) { printf("%f\n", p); fflush(stdout); } al_set_target_bitmap(al_get_backbuffer(game->display)); al_draw_bitmap(game->loading.loading_bitmap,0,0,0); al_draw_filled_rectangle(0, game->viewportHeight*0.985, p*game->viewportWidth, game->viewportHeight, al_map_rgba(255,255,255,255)); DrawConsole(game); al_flip_display(); }
Player::Player(float _x, float _y, int _w, int _h) { sprite = al_create_bitmap(_w, _h); al_set_target_bitmap(sprite); al_clear_to_color(al_map_rgb(255, 255, 255)); al_set_target_bitmap(al_get_backbuffer(display)); w = _w; h = _h; x = _x; y = _y; vspeed = 0; gravity = 0.5; }
/* Function: al_destroy_bitmap */ void al_destroy_bitmap(ALLEGRO_BITMAP *bitmap) { if (!bitmap) { return; } /* As a convenience, implicitly untarget the bitmap on the calling thread * before it is destroyed, but maintain the current display. */ if (bitmap == al_get_target_bitmap()) { ALLEGRO_DISPLAY *display = al_get_current_display(); if (display) al_set_target_bitmap(al_get_backbuffer(display)); else al_set_target_bitmap(NULL); } _al_set_bitmap_shader_field(bitmap, NULL); _al_unregister_destructor(_al_dtor_list, bitmap); if (!al_is_sub_bitmap(bitmap)) { ALLEGRO_DISPLAY* disp = _al_get_bitmap_display(bitmap); if (al_get_bitmap_flags(bitmap) & ALLEGRO_MEMORY_BITMAP) { destroy_memory_bitmap(bitmap); return; } /* Else it's a display bitmap */ if (bitmap->locked) al_unlock_bitmap(bitmap); if (bitmap->vt) bitmap->vt->destroy_bitmap(bitmap); if (disp) _al_vector_find_and_delete(&disp->bitmaps, &bitmap); if (bitmap->memory) al_free(bitmap->memory); } al_free(bitmap); }
void save_highscore(char str_score[]) { int i,j,pos=-1; bool play_again=false; al_set_target_bitmap(al_get_backbuffer(display)); al_draw_text(big_font,al_map_rgb(255,0,0), 400, 300,ALLEGRO_ALIGN_CENTRE, "Game Over!!!!!"); al_draw_text(big_font, al_map_rgb(0,0,255), 400, 400,ALLEGRO_ALIGN_CENTRE, str_score); al_flip_display(); al_rest(1); al_clear_to_color(al_map_rgb(0,0,0)); al_flip_display(); if (score > player[9].score) { strcpy(player[9].name,input()); player[9].score = score; for(i=0; i<10; i++) { for(j=0; j<9; j++) { if(player[j].score<player[j+1].score) { _tmp=player[j]; player[j]=player[j+1]; player[j+1]=_tmp; } } } FILE *fptr=NULL; fptr=fopen("data/score.dat","w"); for(i=0; i<10; i++) fprintf(fptr,"%s\n%d\n",player[i].name,player[i].score); fclose(fptr); } else { level_running=false; game_running=false; } print_highscore(); }
ALLEGRO_BITMAP bouncer(ALLEGRO_BITMAP) { ALLEGRO_BITMAP *bouncer = NULL; bouncer = al_create_bitmap(squareSize, squareSize); if(!bouncer) { fprintf(stderr, "failed to create bouncer bitmap!\n"); al_destroy_display(display); al_destroy_timer(timer); done = true; } al_set_target_bitmap(bouncer); al_clear_to_color(al_map_rgb(255, 0, 255)); al_set_target_bitmap(al_get_backbuffer(display)); }
int AllegroApp::Exec() { int retcode = Init(); if( retcode != 0 ) return retcode; while(!doexit) { ALLEGRO_EVENT ev; al_wait_for_event(event_queue, &ev); HandleEvent(ev); if( redraw && al_is_event_queue_empty(event_queue) ) { al_set_target_bitmap(al_get_backbuffer(display)); redraw = false; Draw(); al_flip_display(); } } }
grafika::grafika() { al_init(); al_install_keyboard(); al_init_image_addon(); al_init_font_addon(); al_init_ttf_addon(); font=al_load_ttf_font("C:\\WINDOWS\\Fonts\\times.ttf",15,0); okno = al_create_display( 800, 600); al_set_window_title(okno,"Samoloty"); al_set_target_bitmap(al_get_backbuffer(okno)); menu=al_load_bitmap("menu.png"); strzalka=al_load_bitmap("strzalka.bmp"); al_convert_mask_to_alpha( strzalka, al_map_rgb( 255, 255, 255 ) ); font_menu_glowne=al_load_ttf_font("C:\\WINDOWS\\Fonts\\times.ttf",35,0); }
/* Draw our example scene. */ static void draw(void) { float xs, ys, a; double dt = 0; double t = al_current_time(); if (last_time > 0) { dt = t - last_time; } last_time = t; al_set_target_bitmap(target); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA, al_map_rgba_f(1, 1, 1, 1)); al_draw_filled_rectangle(x, y, x + RW, y + RH, al_map_rgba_f(1, 0, 0, 1)); al_draw_filled_rectangle(0, 0, W, H, al_map_rgba_f(1, 1, 0, 0.1)); x += dx * dt; if (x < 0) { x = 0; dx = -dx; } if (x + RW > W) { x = W - RW; dx = -dx; } y += dy * dt; if (y < 0) { y = 0; dy = -dy; } if (y + RH > H) { y = H - RH; dy = -dy; } al_set_target_bitmap(al_get_backbuffer()); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgba_f(1, 1, 1, 1)); al_clear_to_color(al_map_rgba_f(0, 0, 1, 1)); xs = 1 + 0.2 * sin(t * ALLEGRO_PI * 2); ys = 1 + 0.2 * sin(t * ALLEGRO_PI * 2); a = t * ALLEGRO_PI * 2 / 3; al_draw_rotated_scaled_bitmap(target, W / 2, H / 2, 320, 240, xs, ys, a, 0); }
Overlay::~Overlay() { { CoreSuspender suspend; df::global::enabler->renderer = parent; } al_destroy_mutex(front_mutex); al_destroy_bitmap(front); al_destroy_bitmap(back); front = back = NULL; if(al_get_current_display() == NULL){ al_set_target_bitmap(NULL); } else { al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); } }
GridFillAnimater::GridFillAnimater(int x, int y, int x0, int y0, int size, ALLEGRO_COLOR color) { ALLEGRO_BITMAP* tmp; this->setFrameDur(30); _x = x; _y = y; for (int i = 3; i >= 0; i--) { tmp = al_create_bitmap(GRID_SIZE + 6, GRID_SIZE + 6); al_set_target_bitmap(tmp); al_clear_to_color(al_map_rgb(0, 0, 0)); al_draw_filled_rectangle(3 - i, 3 - i, GRID_SIZE + 3 + i, GRID_SIZE + 3 + i, color); al_convert_mask_to_alpha(tmp, al_map_rgb(0, 0, 0)); this->addFrame(tmp); } al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); }
int main(void) { int hash[HASH_DIMENSION][HASH_DIMENSION]; int playerRound, x; int line, column; ALLEGRO_DISPLAY *display; ALLEGRO_EVENT_QUEUE *eventQueue; for(line = 0; line < HASH_DIMENSION; line++) for(column = 0; column < HASH_DIMENSION; column++) hash[line][column] = -1; if (!AllegroStart()) return -1; if (!ImageStart()) return -1; if (!MouseStart()) return -1; if (!DisplayStart(&display)) return -1; if (!EventQueueStart(&eventQueue)) return -1; al_register_event_source(eventQueue, al_get_display_event_source(display)); al_register_event_source(eventQueue, al_get_mouse_event_source()); al_set_target_bitmap(al_get_backbuffer(display)); playerRound = rand() % 2; RenderHash(hash); while ( !GameOver(hash) ) { if ( playerRound == COMPUTER )playerRound = PlayComputer(hash); else playerRound = PlayPlayer(hash, &eventQueue, &display); RenderHash(hash); } if (IsWinner(hash, COMPUTER)) al_show_native_message_box(display,"Computador Venceu", "", "Computador Venceu", "Ok",1); else if (IsWinner(hash, PLAYER)) al_show_native_message_box(display,"Você Venceu", "", "Você Venceu", "Ok",1); else al_show_native_message_box(display,"Deu Velha", "", "Deu Velha", "Ok",1); return 0; }
ALLEGRO_BITMAP* Map::Render(float startx, float starty, float width, float height, ALLEGRO_DISPLAY* d) { if (lastsx == startx && lastsy == starty && lastw == width && lasth == height) return cache_area; if (cache_area) al_destroy_bitmap(cache_area); cache_area = al_create_bitmap(width, height); al_set_target_bitmap(cache_area); al_draw_bitmap_region(cache_map, startx*TILE_SIZE, starty*TILE_SIZE, width, height, 0, 0, 0); al_set_target_bitmap(al_get_backbuffer(d)); lastsx = startx; lastsy = starty; lastw = width; lasth = height; return cache_area; }
void CMainMap::draw(ALLEGRO_DISPLAY* display, CData *gameData) { ALLEGRO_BITMAP* image = NULL; long xTilePos, yTilePos; ALLEGRO_FONT* font = NULL; // draw all map tiles as map background vector <CTile*>::iterator it; CTile* tile = NULL; image = gameData->getResources()->getGraphic(RESG_MAPTILE)->getImage(RESG_IMG_STYLE_STD); font = gameData->getFont(RESFONT_STD); ALLEGRO_COLOR color = al_map_rgb(255,255,255); al_set_target_bitmap(al_get_backbuffer(display)); for (it = m_mapTiles.begin() ; it != m_mapTiles.end(); ++it) { ostringstream ostr; if (tile = *it) { //image = tile->getImage(); // eigentlich richtig, wenn die Tiles unterschiedlich sind xTilePos = m_tileWidth * tile->m_idX; yTilePos = m_tileHeight * tile->m_idY; al_draw_bitmap(image, xTilePos, yTilePos, 0); ostr << "[" << tile->m_idX << "," << tile->m_idY << "]"; al_draw_text(font,color, xTilePos + 45, yTilePos + 45 ,ALLEGRO_ALIGN_CENTRE, ostr.str().c_str()); } } image = m_activeGraphic->getImage(RESG_IMG_STYLE_STD); al_draw_bitmap(image, m_tileWidth * m_mapTiles[m_activeTileID]->m_idX, m_tileHeight * m_mapTiles[m_activeTileID]->m_idY, 0); // draw menu // a) use menu icons // b) catch mouse // c) show menu popup // d) select build tile and place it on the map }
int main(){ al_init(); float velocity[2] = {2.0, 3.0}; float acceleration[2] = {5.0, 10.8}; VisualBullet b1 (10, 20, velocity, acceleration); display = al_create_display(640, 480); al_set_target_bitmap(al_get_backbuffer(display)); for (int i=0; i<20; i++){ b1.draw(); b1.tick(); al_flip_display(); al_rest(0.1); } al_rest(1.0); al_destroy_display(display); return 1; }
void blocks_initialize(ALLEGRO_DISPLAY* display) { unsigned short blocks_in_row = 0; unsigned short row = 1; unsigned short count = 1; while (row <= BLOCKS_ROWS) { block_create((blocks_in_row * BLOCK_W), (unsigned short) ((SCREEN_H/2) - (row * BLOCK_H))); ++blocks_in_row; ++count; if (blocks_in_row * BLOCK_W > SCREEN_W) { ++row; blocks_in_row = 0; } } struct listNode* current = first; while (current != NULL) { current->bitmap = al_create_bitmap(BLOCK_W, BLOCK_H); al_set_target_bitmap(current->bitmap); al_clear_to_color(al_map_rgb(234,225,100)); current = current->next; } al_set_target_bitmap(al_get_backbuffer(display)); /* Change drawing target to screen buffer */ al_flip_display(); /* Print buffer to screen */ }
static bool wgl_resize_helper(ALLEGRO_DISPLAY *d, int width, int height) { ALLEGRO_DISPLAY_WGL *wgl_disp = (ALLEGRO_DISPLAY_WGL *)d; ALLEGRO_DISPLAY *ogl_disp = (ALLEGRO_DISPLAY *)d; ALLEGRO_DISPLAY_WIN *win_disp = (ALLEGRO_DISPLAY_WIN *)d; int full_w, full_h; ALLEGRO_MONITOR_INFO mi; int adapter = al_get_new_display_adapter(); if (adapter < 0) adapter = 0; al_get_monitor_info(adapter, &mi); full_w = mi.x2 - mi.x1; full_h = mi.y2 - mi.y1; if ((d->flags & ALLEGRO_FULLSCREEN_WINDOW) && (full_w != width || full_h != height)) { win_disp->toggle_w = width; win_disp->toggle_h = height; return true; } win_disp->can_acknowledge = false; if (d->flags & ALLEGRO_FULLSCREEN) { ALLEGRO_BITMAP *target_bmp; _AL_VECTOR disp_bmps; bool was_backbuffer = false; size_t i; target_bmp = al_get_target_bitmap(); if (target_bmp->vt) was_backbuffer = ((ALLEGRO_BITMAP_OGL*)target_bmp)->is_backbuffer; /* Remeber display bitmaps. */ _al_vector_init(&disp_bmps, sizeof(ALLEGRO_BITMAP*)); for (i = 0; i < _al_vector_size(&d->bitmaps); i++) { ALLEGRO_BITMAP **dis = _al_vector_ref(&d->bitmaps, i); ALLEGRO_BITMAP **mem = _al_vector_alloc_back(&disp_bmps); *mem = *dis; } /* This flag prevents from switching to desktop resolution in between. */ _wgl_do_not_change_display_mode = true; destroy_display_internals(wgl_disp); _wgl_do_not_change_display_mode = false; d->w = width; d->h = height; if (!create_display_internals(wgl_disp)) return false; /* Reupload bitmaps. */ while (_al_vector_is_nonempty(&disp_bmps)) { ALLEGRO_BITMAP **back = _al_vector_ref_back(&disp_bmps); _al_convert_to_display_bitmap(*back); _al_vector_delete_at(&disp_bmps, _al_vector_size(&disp_bmps) - 1); } /* We have a new backbuffer now. */ if (was_backbuffer) al_set_target_bitmap(al_get_backbuffer(d)); } else { RECT win_size; WINDOWINFO wi; win_size.left = 0; win_size.top = 0; win_size.right = width; win_size.bottom = height; wi.cbSize = sizeof(WINDOWINFO); GetWindowInfo(win_disp->window, &wi); AdjustWindowRectEx(&win_size, wi.dwStyle, false, wi.dwExStyle); if (!SetWindowPos(win_disp->window, HWND_TOP, 0, 0, win_size.right - win_size.left, win_size.bottom - win_size.top, SWP_NOMOVE|SWP_NOZORDER)) return false; PostMessage(win_disp->window, WM_USER+0, 0, 0); d->w = width; d->h = height; if (!(d->flags & ALLEGRO_FULLSCREEN_WINDOW)) { win_disp->toggle_w = width; win_disp->toggle_h = height; } _al_ogl_resize_backbuffer(ogl_disp->ogl_extras->backbuffer, width, height); setup_gl(d); } return true; }