TRANSITION *create_transition(GAMESTATE * from, GAMESTATE * to, double duration) { TRANSITION *t = malloc(sizeof(TRANSITION)); t->from = from; t->to = to; t->duration = duration; t->progress = 0.0f; t->from_bmp = al_create_bitmap(screen_width, screen_height); al_set_target_bitmap(t->from_bmp); if (from) { from->draw(); } else { al_clear_to_color(al_map_rgb(0, 0, 0)); } al_set_target_backbuffer(screen); t->to_bmp = al_create_bitmap(screen_width, screen_height); al_set_target_bitmap(t->to_bmp); if (to) { to->draw(); } else { al_clear_to_color(al_map_rgb(0, 0, 0)); } al_set_target_backbuffer(screen); return t; }
static void redraw(ALLEGRO_COLOR color1, ALLEGRO_COLOR color2) { al_set_target_backbuffer(display1); al_clear_to_color(color1); al_flip_display(); al_set_target_backbuffer(display2); al_clear_to_color(color2); al_flip_display(); }
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 Blitter::commit(void) { al_set_target_bitmap(scale_buffer); al_draw_scaled_bitmap(main_buffer,0,0, BUFFER_WIDTH, BUFFER_HEIGHT,0,0, BUFFER_WIDTH*PRESCALE, BUFFER_HEIGHT*PRESCALE,0); al_set_target_backbuffer(display); al_clear_to_color(al_map_rgb(0,0,0)); int adjusted_width = display_width; int adjusted_height = display_height; // determine scaling information to preserve aspect ratio if (display_width > display_height * (4.0 / 3.0)) { adjusted_width = display_height * (4.0 / 3.0); } else if (display_height > display_width * 0.75) { adjusted_height = display_width * 0.75; } al_draw_scaled_bitmap(scale_buffer,0,0, BUFFER_WIDTH*PRESCALE, BUFFER_HEIGHT*PRESCALE, (display_width - adjusted_width) / 2, (display_height - adjusted_height) / 2, adjusted_width, adjusted_height,0); al_flip_display(); al_set_target_bitmap(main_buffer); al_clear_to_color(al_map_rgb(0,0,0)); }
static void flip(void) { al_set_target_backbuffer(display); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_bitmap(dbuf, 0.0, 0.0, 0); al_flip_display(); }
Tileset::Tileset(ALLEGRO_COLOR cl) { spritesheet_ = al_create_bitmap(64, 64); al_set_target_bitmap(spritesheet_); al_clear_to_color(cl); al_set_target_backbuffer(al_get_current_display()); }
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 Object::generate_error_bitmap() { if(testBit(ISMEM_BITMAP)) { bitmap = create_memory_bitmap(); } else { bitmap = al_create_bitmap(w, h); } ALLEGRO_COLOR background = al_color_html("#3f51b5"); ALLEGRO_COLOR shadow = al_color_html("#1a237e"); ALLEGRO_COLOR sign = al_color_html("#ffeb3b"); al_set_target_bitmap(bitmap); al_clear_to_color(background); // Shadow (3 triangles) al_draw_filled_triangle(w / 2.0f, h / 4.0f, w, (h * 3.0f) / 4.0f, w / 2.0f, h, shadow); al_draw_filled_triangle(w, (h * 3.0f) / 4.0f, w, h, w / 2.0f, h, shadow); al_draw_filled_triangle(w / 2.0f, h / 4.0f, w / 2.0f, h, w / 4.0f, (h * 3.0f) / 4.0f, shadow); // Alert sign triangle al_draw_filled_triangle(w / 2.0f, h / 4.0f, ((w * 3.0f) / 4), ((h * 3.0f) / 4.0f), w / 4.0f, ((h * 3.0f) / 4.0f), sign); // Exclamation point al_draw_filled_rectangle((w * 15.0f) / 32.0f, ((h * 14.0f) / 32.0f), ((w * 17.0f) / 32.0f), ((h * 19.0f) / 32.0f), background); al_draw_filled_rectangle((w * 15.0f) / 32.0f, (h * 5.0f) / 8.0f, (w * 17.0f) / 32.0f, (h * 11.0f) / 16.0f, background); al_set_target_backbuffer(al_get_current_display()); }
VisualBullet(float x_in, float y_in, float dir[2], float acc[2]) : Bullet(x_in, y_in, dir, acc) { ALLEGRO_DISPLAY *old = al_get_current_display(); bmp_p = al_create_bitmap(10, 10); al_set_target_bitmap(bmp_p); al_clear_to_color(al_map_rgb(255, 0, 255)); //viola al_set_target_backbuffer(old); }
void equipAligner::render(){ al_set_target_backbuffer(this->display); al_clear_to_color(al_map_rgb(44,44,44)); al_draw_bitmap(availableBodyParts[selectedBodyPart].bodyPartImage->image,(800/2)-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginX,100-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginY,0); if (selectedBodyPart==2) { al_draw_bitmap(cache_head_eyes->image,((800/2)-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginX)+cache_head_eyes->imageRelativeX+availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginX-cache_head_eyes->imageOriginX,(100-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginY)+availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginY+cache_head_eyes->imageRelativeY-cache_head_eyes->imageOriginY,0); al_draw_bitmap(cache_head_mouth->image,((800/2)-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginX)+cache_head_mouth->imageRelativeX+availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginX-cache_head_mouth->imageOriginX,(100-availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginY)+availableBodyParts[selectedBodyPart].bodyPartImage->imageOriginY+cache_head_mouth->imageRelativeY-cache_head_mouth->imageOriginY,0); } if (aligningImage!=NULL) { al_draw_tinted_bitmap(aligningImage,al_map_rgba_f(imageAlignAlpha,imageAlignAlpha,imageAlignAlpha,imageAlignAlpha),((800/2)-aligningImageProperties.originX)+aligningImageProperties.offsetX,(100-aligningImageProperties.originY)+aligningImageProperties.offsetY,0); } int spacing = 800/availableBodyParts.size(); int xx=0; for(int i=0; i<availableBodyParts.size(); i++) { if (i==selectedBodyPart) { al_draw_filled_rectangle(xx,300,xx+al_get_bitmap_width(availableBodyParts[i].bodyPartImage->image),300+al_get_bitmap_height(availableBodyParts[i].bodyPartImage->image),al_map_rgba(200,200,200,120)); } al_draw_bitmap(availableBodyParts[i].bodyPartImage->image,xx,300,0); if (i==2) { al_draw_bitmap(cache_head_eyes->image,xx+cache_head_eyes->imageRelativeX+availableBodyParts[i].bodyPartImage->imageOriginX-cache_head_eyes->imageOriginX,300+availableBodyParts[i].bodyPartImage->imageOriginY+cache_head_eyes->imageRelativeY-cache_head_eyes->imageOriginY,0); al_draw_bitmap(cache_head_mouth->image,xx+cache_head_mouth->imageRelativeX+availableBodyParts[i].bodyPartImage->imageOriginX-cache_head_mouth->imageOriginX,300+availableBodyParts[i].bodyPartImage->imageOriginY+cache_head_mouth->imageRelativeY-cache_head_mouth->imageOriginY,0); } xx+=spacing; } al_flip_display(); }
static mrb_value target_setter(mrb_state *mrb, mrb_value self) { mrb_value o; struct mrb_data_type const *dt; mrb_get_args(mrb, "o", &o); if (mrb_type(o) != MRB_TT_DATA) { goto type_error; } dt = DATA_TYPE(o); if (dt == &mrbal_bitmap_data_type) { ALLEGRO_BITMAP *b; Check_Destroyed(mrb, o, bitmap, b); al_set_target_bitmap(b); } else if (dt == &mrbal_display_data_type) { ALLEGRO_DISPLAY *d; Check_Destroyed(mrb, o, display, d); al_set_target_backbuffer(d); } else { type_error: mrb_raisef(mrb, E_TYPE_ERROR, "expected %S or %S", mrb_str_new_static(mrb, mrbal_bitmap_data_type.struct_name, strlen(mrbal_bitmap_data_type.struct_name)), mrb_str_new_static(mrb, mrbal_display_data_type.struct_name, strlen(mrbal_display_data_type.struct_name))); } return o; }
int main(void) { ALLEGRO_DISPLAY *display; ALLEGRO_BITMAP *icons[NUM_ICONS]; ALLEGRO_EVENT_QUEUE *queue; int u, v; if (!al_init()) { abort_example("Could not init Allegro.\n"); } al_install_keyboard(); al_init_image_addon(); display = al_create_display(320, 200); if (!display) { abort_example("Error creating display\n"); } al_clear_to_color(al_map_rgb_f(0, 0, 0)); al_flip_display(); /* First icon 16x16: Read from file. */ icons[0] = al_load_bitmap("data/cursor.tga"); if (!icons[0]) { abort_example("icons.tga not found\n"); } /* Second icon 32x32: Create it. */ al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); icons[1] = al_create_bitmap(32, 32); al_set_target_bitmap(icons[1]); for (v = 0; v < 32; v++) { for (u = 0; u < 32; u++) { al_put_pixel(u, v, al_map_rgb_f(u / 31.0, v / 31.0, 1)); } } al_set_target_backbuffer(display); al_set_display_icons(display, NUM_ICONS, icons); queue = al_create_event_queue(); al_register_event_source(queue, al_get_keyboard_event_source()); al_register_event_source(queue, al_get_display_event_source(display)); for (;;) { ALLEGRO_EVENT event; al_wait_for_event(queue, &event); if (event.type == ALLEGRO_EVENT_KEY_DOWN && event.keyboard.keycode == ALLEGRO_KEY_ESCAPE) { break; } if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE) { break; } } al_uninstall_system(); return 0; }
bool InputField::Bitmap() { // al_set_target_bitmap(bmp); al_set_target_bitmap(as_bitmap); al_clear_to_color(bckground_color); //float tx = (text_width <= width ? 0 : width - text_width); float tx = (text_width <= width ? (center == true ? (width - text_width)/2 : 0) : width - text_width); al_draw_text(font, text_color, tx, (height - text_height) / 2.0f, 0, text.c_str()); if(detectingbutton->is_button_clicked() == true) { if(bling > 30) { al_draw_line(tx + text_width -2, (height - text_height) / 2.0f, tx + text_width -2, (height + text_height) / 2.0f, text_color, 2); if(bling > 60) { bling = 0; } } bling++; } /*al_set_target_bitmap(as_bitmap); al_clear_to_color(al_map_rgba(0,0,0,0)); al_draw_bitmap(bmp, 0, 0, 0);*/ al_draw_rounded_rectangle(0, 0, width, height, 5, 5, outline_color, 2); al_set_target_backbuffer(al_get_current_display()); return true; }
static duk_ret_t js_Font_drawZoomedText(duk_context* ctx) { int x = duk_require_int(ctx, 0); int y = duk_require_int(ctx, 1); float scale = duk_require_number(ctx, 2); const char* text = duk_to_string(ctx, 3); ALLEGRO_BITMAP* bitmap; font_t* font; color_t mask; int text_w, text_h; duk_push_this(ctx); font = duk_require_sphere_obj(ctx, -1, "Font"); duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx); duk_pop(ctx); if (!screen_is_skipframe(g_screen)) { text_w = get_text_width(font, text); text_h = get_font_line_height(font); bitmap = al_create_bitmap(text_w, text_h); al_set_target_bitmap(bitmap); draw_text(font, mask, 0, 0, TEXT_ALIGN_LEFT, text); al_set_target_backbuffer(screen_display(g_screen)); al_draw_scaled_bitmap(bitmap, 0, 0, text_w, text_h, x, y, text_w * scale, text_h * scale, 0x0); al_destroy_bitmap(bitmap); } return 0; }
void Map::drawTile(const Tile &t, std::shared_ptr<ALLEGRO_BITMAP> ptr) { std::shared_ptr<ALLEGRO_BITMAP> bm; Tileset* ts = nullptr; switch(t.getBiome()) { case GRASS: ts = &grass_; break; case SWAMP: ts = &swamp_; break; case ROCK: ts = &rock_; break; default: break; }; al_set_target_bitmap(bm_); bm = *ts << t.topleft(); al_draw_bitmap(bm.get(), t.getx() * 32, t.gety() * 32, 0); bm = *ts << t.topright(); al_draw_bitmap(bm.get(), t.getx() * 32 + 16, t.gety() * 32, 0); bm = *ts << t.botleft(); al_draw_bitmap(bm.get(), t.getx() * 32, t.gety() * 32 + 16, 0); bm = *ts << t.botright(); al_draw_bitmap(bm.get(), t.getx() * 32 + 16, t.gety() * 32 + 16, 0); if(ptr != nullptr) { al_draw_bitmap(ptr.get(), t.getx() * 32, t.gety() * 32, 0); } #ifdef _DEBUG t.asObject().drawHull(glm::vec2(0., 0.)); #endif //_DEBUG al_set_target_backbuffer(al_get_current_display()); }
void AllegroEngine::DoRender() { al_set_target_backbuffer(root); al_clear_to_color(al_map_rgb(0,0,0)); Render(root); al_flip_display(); }
void bg_init() { bg = al_create_bitmap(MAP_SIZE, MAP_SIZE); tab.resize(MAP_SIZE); for (int i = 0; i < MAP_SIZE; ++i) tab[i].resize(MAP_SIZE); for (int i = 0; i < 20; ++i) stack.push_back(std::make_pair(rand() % MAP_SIZE, rand() % MAP_SIZE)); al_set_target_backbuffer(okno); }
static SCM reset_draw_target (SCM game_smob) { Game *game = check_game (game_smob); al_set_target_backbuffer (game->display); return SCM_UNSPECIFIED; }
void init_error_bitmap() { // Error bitmap. int bmp_error_w, bmp_error_h; al_get_text_dimensions(al_create_builtin_font(), "ERROR", NULL, NULL, &bmp_error_w, &bmp_error_h); bmp_error = al_create_bitmap(bmp_error_w, bmp_error_h); al_set_target_bitmap(bmp_error); { al_clear_to_color(al_map_rgba(64, 0, 0, 128)); al_draw_text(al_create_builtin_font(), al_map_rgb(255, 0, 0), 0, 0, 0, "ERROR"); } al_set_target_backbuffer(display); }
/* 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_backbuffer(display); dx = 81; dy = 63; start = al_get_time(); while (true) { /* Check for ESC key or close button event and quit in either case. */ if (!al_is_event_queue_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_get_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); }
void DrawGamestates(struct Game *game) { al_set_target_backbuffer(game->display); al_clear_to_color(al_map_rgb(0,0,0)); struct Gamestate *tmp = game->_priv.gamestates; while (tmp) { if ((tmp->loaded) && (tmp->started)) { (*tmp->api.Gamestate_Draw)(game, tmp->data); } tmp = tmp->next; } }
int main (int argc, char **argv) { g_type_init (); al_init (); al_init_image_addon (); al_set_new_display_option (ALLEGRO_RED_SIZE, 8, ALLEGRO_REQUIRE); al_set_new_display_option (ALLEGRO_GREEN_SIZE, 8, ALLEGRO_REQUIRE); al_set_new_display_option (ALLEGRO_BLUE_SIZE, 8, ALLEGRO_REQUIRE); al_set_new_display_option (ALLEGRO_ALPHA_SIZE, 8, ALLEGRO_REQUIRE); /* Nouveau = good */ /* al_set_new_display_option (ALLEGRO_AUX_BUFFERS, 4, ALLEGRO_REQUIRE); */ al_set_new_display_flags (ALLEGRO_WINDOWED | ALLEGRO_OPENGL); ALLEGRO_DISPLAY *disp; disp = al_create_display (640, 480); xassert (disp); g_xassert (al_get_opengl_extension_list ()->ALLEGRO_GL_ARB_depth_texture); g_xassert (al_get_opengl_extension_list ()->ALLEGRO_GL_ARB_framebuffer_object); al_set_target_backbuffer (disp); printf ("OPENGL %x\n", al_get_opengl_version ()); blender_bmp = al_load_bitmap ("../data/n1img0.bmp"); g_xassert (640 == al_get_bitmap_width (blender_bmp) && 480 == al_get_bitmap_height (blender_bmp)); blender_tex = al_get_opengl_texture (blender_bmp); g_xassert (blender_tex); GLint glvar; /* Query GL_MAX_DRAW_BUFFERS, GL_MAX_COLOR_ATTACHMENTS */ glGetIntegerv (GL_MAX_DRAW_BUFFERS, &glvar); xassert (4 <= glvar); glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &glvar); xassert (4 <= glvar); derp (); al_flip_display (); al_rest (2); return EXIT_SUCCESS; }
sprite::sprite(int x, int y, int w, int h, ALLEGRO_COLOR color) { bitmap = NULL; position.x = x; position.y = y; width = w; height = h; filename = ""; bitmap = al_create_bitmap(w,h); ALLEGRO_DISPLAY *tempDisp = al_get_current_display(); al_set_target_bitmap(bitmap); al_clear_to_color(color); al_set_target_backbuffer(tempDisp); }
void bg_draw() { al_set_target_bitmap(bg); std::vector<std::pair<int, int>> newstack; h = h+2.5; if (h > 360) h = 0; v = v - 1.0 / 144.9; if (v <= 0) bg_clear(); for (unsigned int i = 0; i < stack.size(); ++i) { int x = stack[i].first; int y = stack[i].second; float r, g, b; al_color_hsv_to_rgb(h, s, v, &r, &g, &b); al_draw_pixel(x, y, al_map_rgb_f(r,g,b)); if (x != 0 && tab[x - 1][y] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x - 1, y)); } tab[x - 1][y] = 1; } if (x != MAP_SIZE-1 && tab[x + 1][y] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x + 1, y)); } tab[x + 1][y] = 1; } if (y != 0 && tab[x][y-1] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x, y-1)); } tab[x][y-1] = 1; } if (y != MAP_SIZE-1 && tab[x][y+1] != 1) { float prob = 0.001*(rand() % 1000); if (prob > p) { newstack.push_back(std::make_pair(x, y+1)); } tab[x][y+1] = 1; } } stack = newstack; al_set_target_backbuffer(okno); }
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); }
static void draw(void) { const float sw = al_get_bitmap_width(bmp); const float sh = al_get_bitmap_height(bmp); const float dw = al_get_bitmap_width(dbuf); const float dh = al_get_bitmap_height(dbuf); const float dx = dw / 2.0; const float dy = dh / 2.0; float db_l; float db_r; float db; float scale; float disp; /* Whatever looks okay. */ if (rms_l > 0.0 && rms_r > 0.0) { db_l = 20 * log10(rms_l / 20e-6); db_r = 20 * log10(rms_r / 20e-6); db = (db_l + db_r) / 2.0; scale = db / 20.0; disp = (rms_l + rms_r) * 200.0; } else { db_l = db_r = db = scale = disp = 0.0; } al_set_target_bitmap(dbuf); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_draw_filled_rectangle(0, 0, al_get_bitmap_width(dbuf), al_get_bitmap_height(dbuf), al_map_rgba_f(0.8, 0.3, 0.1, 0.06)); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); al_draw_tinted_scaled_rotated_bitmap(bmp, al_map_rgba_f(0.8, 0.3, 0.1, 0.2), sw/2.0, sh/2.0, dx, dy - disp, scale, scale, theta, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_set_target_backbuffer(display); al_draw_bitmap(dbuf, 0, 0, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_draw_line(10, dh - db_l, 10, dh, al_map_rgb_f(1, 0.6, 0.2), 6); al_draw_line(20, dh - db_r, 20, dh, al_map_rgb_f(1, 0.6, 0.2), 6); al_flip_display(); theta -= (rms_l + rms_r) * 0.1; }
void draw_button(BUTTONPTR currentptr) { const int c = 2, d = 2, x = 0, y = 0; nscale(); static ALLEGRO_BITMAP *newbitm = NULL; if(newbitm == NULL) newbitm = al_create_bitmap(currentptr->bimage->width, currentptr->bimage->height); al_set_target_bitmap(newbitm); al_clear_to_color(al_map_rgba(0, 0, 0, 0)); if((currentptr->bdata.bflags & BDRAW) && !(currentptr->bdata.bflags & BLPRESSED)) { al_draw_tinted_bitmap(currentptr->bimage->button_image, currentptr->bdata.b_color, x, y, 0); al_draw_text(currentptr->btext.text_f, currentptr->btext.text_c, currentptr->bimage->width/d, currentptr->bimage->height/d-al_get_font_line_height(currentptr->btext.text_f)/d, ALLEGRO_ALIGN_CENTRE, currentptr->btext.text ); } else if((currentptr->bdata.bflags & BDRAW) && (currentptr->bdata.bflags & BLPRESSED)) { al_draw_tinted_bitmap(currentptr->bimage->button_image, currentptr->bdata.b_color, x, y, ALLEGRO_FLIP_VERTICAL); al_draw_text(currentptr->btext.text_f, currentptr->btext.text_c, currentptr->bimage->width/d+c, currentptr->bimage->height/d-al_get_font_line_height(currentptr->btext.text_f)/d+c, ALLEGRO_ALIGN_CENTRE, currentptr->btext.text ); } else { al_draw_tinted_bitmap(currentptr->bimage->button_image, currentptr->bdata.b_color, x, y, 0); al_draw_text(currentptr->btext.text_f, currentptr->btext.text_c, currentptr->bimage->width/d, currentptr->bimage->height/d-al_get_font_line_height(currentptr->btext.text_f)/d, ALLEGRO_ALIGN_CENTRE, currentptr->btext.text ); } scale(800.0, 600.0); al_set_target_backbuffer(get_game_data()->display); al_draw_bitmap(newbitm, currentptr->bdata.x, currentptr->bdata.y, 0); }
void Map::drawrock() { al_set_target_bitmap(bm_); for(int y = 0; y < tiles_.size(); y++) { for(int x = 0; x < tiles_[y].size(); x++) { BIOME b = tiles_[y][x].getBiome(); if(b == ROCK) { drawTile(tiles_[y][x], nullptr); } } } al_set_target_backbuffer(al_get_current_display()); }
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; }
sprite::sprite(int x, int y, int w, int h) { //ctor bitmap = NULL; position.x = x; position.y = y; width = w; height = h; filename = ""; ALLEGRO_DISPLAY *tempDisp = al_get_current_display(); bitmap = al_create_bitmap(w,h); al_set_target_bitmap(bitmap); al_clear_to_color(al_map_rgb(255,255,255)); al_set_target_backbuffer(tempDisp); }