void game_screen() { alt_up_char_buffer_clear(char_buffer); char str1[50], str2[30], str3[50]; sprintf(str1, "Player 1: $%d", dealer->players[0].total_money); alt_up_char_buffer_string(char_buffer, str1, 5, 5); sprintf(str1, "Player 2: $%d", dealer->players[1].total_money); alt_up_char_buffer_string(char_buffer, str1, 5, 10); Bitmap* flop_card0_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[0])); Bitmap* flop_card1_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[1])); Bitmap* flop_card2_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[2])); Bitmap* turn_card_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[3])); Bitmap* river_card_bmp = load_bitmap(card_bitmap_name(dealer->cards_on_table[4])); draw_bitmap(flop_card0_bmp, 25, 60); draw_bitmap(flop_card1_bmp, 55, 60); draw_bitmap(flop_card2_bmp, 85, 60); draw_bitmap(turn_card_bmp, 115, 60); draw_bitmap(river_card_bmp, 145, 60); sprintf(str3, "Pot: $%d", dealer->pot); alt_up_char_buffer_string(char_buffer, str3, 5, 50); sprintf(str3, "Current Bet: $%d", dealer->current_bet); alt_up_char_buffer_string(char_buffer, str3, 5, 51); draw_to_screen(); }
/* ---------------------------------------------------------------------------- * 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 draw_fade (ALLEGRO_BITMAP *from, ALLEGRO_BITMAP *to, float factor) { factor = factor < 0 ? 0 : factor; clear_bitmap (black_screen, al_map_rgba_f (0, 0, 0, factor)); draw_bitmap (from, to, 0, 0, 0); draw_bitmap (black_screen, to, 0, 0, 0); }
void draw_door_grid_cache (ALLEGRO_BITMAP *bitmap, ALLEGRO_BITMAP *door_grid, ALLEGRO_BITMAP *door_grid_tip, int i) { int q = i / 8; int r = i % 8; int w = al_get_bitmap_width (door_grid); int j; draw_bitmap_region (door_grid, bitmap, 0, 7 - r, w, r + 1, 0, 0, 0); for (j = 0; j <= q; j++) draw_bitmap (door_grid, bitmap, 0, j * 8 + r + 1, 0); draw_bitmap (door_grid_tip, bitmap, 0, (q + 1) * 8 + r + 1, 0); }
static void draw_text(FT_Face face, FT_Vector * pen, FT_Matrix * matrix, const unsigned char *out, int len, int color, struct rectangle *box) { FT_ULong ch; FT_Error ans; FT_GlyphSlot slot = face->glyph; int i; for (i = 0; i < len; i += 2) { ch = (out[i] << 8) | out[i + 1]; if (ch == 10) continue; /* transform */ FT_Set_Transform(face, matrix, pen); /* get glyph image */ ans = FT_Load_Char(face, ch, FT_LOAD_NO_BITMAP); if (ans) continue; ans = FT_Render_Glyph(face->glyph, ft_render_mode_normal); if (ans) continue; /* draw bitmap */ if (!box) draw_bitmap(&slot->bitmap, slot->bitmap_left, screen_height - slot->bitmap_top); else set_text_box(&slot->bitmap, slot->bitmap_left, screen_height - slot->bitmap_top, box); /* increment pen position */ pen->x += slot->advance.x; pen->y += slot->advance.y; } }
void update_cache (enum em em, enum vm vm) { int x, y; int room_view_bkp = room_view; clear_bitmap (cache, TRANSPARENT_COLOR); con_caching = true; for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (mr.cell[x][y].room) { room_view = mr.cell[x][y].room; mr.dx = x; mr.dy = y; draw_room (mr.cell[x][y].cache, room_view, em, vm); } else draw_bitmap (room0, mr.cell[x][y].cache, 0, 0, 0); } con_caching = false; room_view = room_view_bkp; }
Py::Object FT2Font::draw_glyph_to_bitmap(const Py::Tuple & args) { _VERBOSE("FT2Font::draw_glyph_to_bitmap"); args.verify_length(3); if (image.width==0 || image.height==0) throw Py::RuntimeError("You must first set the size of the bitmap with set_bitmap_size"); long x = Py::Int(args[0]); long y = Py::Int(args[1]); if (!Glyph::check(args[2].ptr())) throw Py::TypeError("Usage: draw_glyph_to_bitmap(x,y,glyph)"); Glyph* glyph = static_cast<Glyph*>(args[2].ptr()); if ((size_t)glyph->glyphInd >= glyphs.size()) throw Py::ValueError("glyph num is out of range"); error = FT_Glyph_To_Bitmap(&glyphs[glyph->glyphInd], ft_render_mode_normal, 0, //no additional translation 1 //destroy image; ); if (error) throw Py::RuntimeError("Could not convert glyph to bitmap"); FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyphs[glyph->glyphInd]; draw_bitmap( &bitmap->bitmap, //x + bitmap->left, x, //y+bitmap->top y ); return Py::Object(); }
void MapWindow::DrawGPSStatus(Canvas &canvas, const RECT rc) { if (Basic().Connected && !Basic().NAVWarning && Basic().SatellitesUsed) // nothing to do, all OK return; TCHAR gpswarningtext1[] = TEXT("GPS not connected"); TCHAR gpswarningtext2[] = TEXT("GPS waiting for fix"); TextInBoxMode_t TextInBoxMode = {2}; TCHAR *txt=NULL; Bitmap *bmp=NULL; if (!Basic().Connected) { bmp = &MapGfx.hGPSStatus2; txt = gpswarningtext1; } else if (Basic().NAVWarning || (Basic().SatellitesUsed == 0)) { bmp = &MapGfx.hGPSStatus2; txt = gpswarningtext2; } else { return; // early exit } draw_bitmap(canvas, *bmp, rc.left + IBLSCALE(2), rc.bottom +IBLSCALE(Appearance.GPSStatusOffset.y - 22), 0, 0, 20, 20, false); TextInBox(canvas, gettext(txt), rc.left+IBLSCALE(24), rc.bottom+IBLSCALE(Appearance.GPSStatusOffset.y-19), TextInBoxMode, rc); }
void drawknight() { static int dx,dy; static int ion = 1; dx = startx; dy = starty; for(i = 0; i < 8; i++) { for(z = 0; z < 8; z++) { if(pos.row == i && pos.col == z) { draw_bitmap(data_bits, dx-5, dy, data_w, data_h, data_w, data_h, 0x00FFFFFFL); return; } dx += 35; counter++; if(counter >= 8) { counter = 0; dy += 35; dx = startx; ion = !ion; } } } }
extern "C" int draw_string_line( FT_Face face, DrawBuffer* db, int x, int y, const wchar_t* str ) { int error; int i, j, k; int len = wcslen(str); FT_GlyphSlot slot = face->glyph; printf( "BX BY Adv W H\n"); printf( "---- ---- ---- ---- ----\n"); for( i = 0; i < len; i++ ) { error = FT_Load_Glyph( face, FT_Get_Char_Index( face, *(str+i) ), FT_LOAD_RENDER ); printf( "%4d %4d %4d %4d %4d\n", (int) slot->metrics.horiBearingX / 64, (int) slot->metrics.horiBearingY / 64, (int) slot->metrics.horiAdvance / 64, (int) slot->metrics.width / 64, (int) slot->metrics.height / 64 ); draw_bitmap( x + slot->metrics.horiBearingX/64, y - slot->metrics.horiBearingY/64, db, slot->bitmap.width, slot->bitmap.rows, slot->bitmap.buffer ); x += ((slot->metrics.horiAdvance - slot->metrics.horiBearingX) / 64); } }
// your custom drawing function void quan::uav::osd::on_draw() { draw_text("Hello World",{-60,30}); draw_line ( {-120,-100}, {80,100}, colour_type::white ); // white draw_line ( {-100,-100}, {100,100}, colour_type::black ); // black draw_bitmap(get_bitmap(BitmapID::home_arrow),{50,-50}); }
bitmap_info* glyph_freetype_provider::get_char_image(character_def* shape_glyph, Uint16 code, const gameswf::tu_string& fontname, bool is_bold, bool is_italic, int fontsize, rect* bounds, float* advance) { face_entity* fe = get_face_entity(fontname, is_bold, is_italic); if (fe == NULL) { return NULL; } // form hash key int key = (fontsize << 16) | code; // try to find the stored image of character glyph_entity* ge = NULL; if (fe->m_ge.get(key, &ge) == false) { FT_Set_Pixel_Sizes(fe->m_face, fontsize, fontsize); if (FT_Load_Char(fe->m_face, code, FT_LOAD_RENDER)) { return NULL; } ge = new glyph_entity(); image::alpha* im = draw_bitmap(fe->m_face->glyph->bitmap); ge->m_bi = render::create_bitmap_info_alpha(im->m_width, im->m_height, im->m_data); delete im; ge->m_bounds.m_x_max = float(fe->m_face->glyph->bitmap.width) /float(ge->m_bi->get_width()); ge->m_bounds.m_y_max = float(fe->m_face->glyph->bitmap.rows) / float(ge->m_bi->get_height()); ge->m_bounds.m_x_min = float(fe->m_face->glyph->metrics.horiBearingX) / float(fe->m_face->glyph->metrics.width); ge->m_bounds.m_y_min = float(fe->m_face->glyph->metrics.horiBearingY) / float(fe->m_face->glyph->metrics.height); ge->m_bounds.m_x_min *= -ge->m_bounds.m_x_max; ge->m_bounds.m_y_min *= ge->m_bounds.m_y_max; float scale = 16.0f / fontsize; // hack ge->m_advance = (float) fe->m_face->glyph->metrics.horiAdvance * scale; // keep image of character fe->m_ge.add(key, ge); } if (bounds) { *bounds = ge->m_bounds; } if (advance) { *advance = ge->m_advance; } return ge->m_bi.get_ptr(); }
int gli_draw_string_uni(int x, int y, int fidx, unsigned char *rgb, glui32 *s, int n, int spw) { font_t *f = &gfont_table[fidx]; int dolig = ! FT_IS_FIXED_WIDTH(f->face); int prev = -1; glui32 c; int px, sx; if ( FT_Get_Char_Index(f->face, UNI_LIG_FI) == 0 ) dolig = 0; if ( FT_Get_Char_Index(f->face, UNI_LIG_FL) == 0 ) dolig = 0; while (n--) { bitmap_t *glyphs; int adv; c = *s++; if (dolig && n && c == 'f' && *s == 'i') { c = UNI_LIG_FI; s++; n--; } if (dolig && n && c == 'f' && *s == 'l') { c = UNI_LIG_FL; s++; n--; } getglyph(f, c, &adv, &glyphs); if (prev != -1) x += charkern(f, prev, c); px = x / GLI_SUBPIX; sx = x % GLI_SUBPIX; if (gli_conf_lcd) draw_bitmap_lcd(&glyphs[sx], px, y, rgb); else draw_bitmap(&glyphs[sx], px, y, rgb); if (spw >= 0 && c == ' ') x += spw; else x += adv; prev = c; } return x; }
void f_scroller_normal(signed int x, signed int y, const char *string) { while(*string!=0&&x<lcd_width) { draw_bitmap(x,y,f_width,8,ascii_table[*string++]); set_instruction(1,0); // clear byte before x+=f_width+space_char; } }
static void draw_item(int index, const uint32_t *icon, int icon_height, const char *line1, const char *line2) { int x = (index % 4) * SLOT_W; int y = 220 - (index / 4 + 1) * SLOT_H; draw_bitmap(icon, x + 34, y + 30, RGB(255,255,255), icon_height, true); draw_flowtext(line1, x, y + 2, SLOT_W, 28, RGB(255,255,255), 0, true); }
void start_video_effect (enum video_effect_type type, int duration) { ALLEGRO_BITMAP *screen = mr.cell[0][0].screen; video_effect.type = type; video_effect.duration = duration; clear_bitmap (effect_buffer, BLACK); clear_bitmap (black_screen, BLACK); draw_bitmap (screen, effect_buffer, 0, 0, 0); al_start_timer (video_timer); }
void Prog::blending_test(bool memory) { ALLEGRO_COLOR transparency = al_map_rgba_f(0, 0, 0, 0); int op = str_to_blend_mode(operations[4].get_selected_item_text()); int aop = str_to_blend_mode(operations[5].get_selected_item_text()); int src = str_to_blend_mode(operations[0].get_selected_item_text()); int asrc = str_to_blend_mode(operations[1].get_selected_item_text()); int dst = str_to_blend_mode(operations[2].get_selected_item_text()); int adst = str_to_blend_mode(operations[3].get_selected_item_text()); /* Initialize with destination. */ al_clear_to_color(transparency); // Just in case. al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); draw_bitmap(destination_image.get_selected_item_text(), "original", memory, true); /* Now draw the blended source over it. */ al_set_separate_blender(op, src, dst, aop, asrc, adst); draw_bitmap(source_image.get_selected_item_text(), draw_mode.get_selected_item_text(), memory, false); }
int main( int argc,char** argv ) { FT_Library library; FT_Face face; FT_GlyphSlot slot; FT_Matrix matrix; /* transformation matrix */ FT_Vector pen; /* untransformed origin */ FT_Error error; char* filename; char* text; double angle; int target_height; int n, num_chars; if ( argc != 3 ) { fprintf ( stderr, "usage: %s font sample-text\n", argv[0] ); exit( 1 ); } filename = argv[1]; /* first argument */ text = argv[2]; /* second argument */ num_chars = strlen( text ); angle = ( 0.0 / 360 ) * 3.14159 * 2; /* use 25 degrees */ target_height = HEIGHT; error = FT_Init_FreeType( &library ); /* initialize library */ error = FT_New_Face( library, argv[1], 0, &face ); /* create face object */ FT_Set_Pixel_Sizes(face, SIZE, 0); slot = face->glyph; matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L ); matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L ); matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L ); matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L ); pen.x = 0; pen.y =20; for ( n = 0; n < num_chars; n++ ) { FT_Set_Transform( face, &matrix, &pen ); wchar_t *chinese_char = L"AD11:12"; error = FT_Load_Char( face, chinese_char[n], FT_LOAD_RENDER ); if (error) continue; draw_bitmap(&slot->bitmap,slot->bitmap_left,target_height-target_height*10/100-slot->bitmap_top ); pen.x += slot->advance.x; pen.y += slot->advance.y; } show_image(); FT_Done_Face( face ); FT_Done_FreeType( library ); return 0; }
void f_scroller_func(signed int x, signed int y, const char *string, const char *func, unsigned char func_size) { byte=0; while(*string!=0&&x<lcd_width) { if(x>func_size) byte=x-func_size; // use abs() here else byte=x; draw_bitmap(x,y+func[byte],f_width,8,ascii_table[*string++]); set_instruction(1,0); // clear byte before x+=f_width+space_char; byte++; } }
UINT32 splash_state::screen_update_splash(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { /* set scroll registers */ m_bg_tilemap[0]->set_scrolly(0, m_vregs[0]); m_bg_tilemap[1]->set_scrolly(0, m_vregs[1]); draw_bitmap(bitmap, cliprect); m_bg_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0); splash_draw_sprites(bitmap, cliprect); m_bg_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0); return 0; }
UINT32 splash_state::screen_update_funystrp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) { /* set scroll registers */ m_bg_tilemap[0]->set_scrolly(0, m_vregs[0]); m_bg_tilemap[1]->set_scrolly(0, m_vregs[1]); draw_bitmap(bitmap, cliprect); m_bg_tilemap[1]->draw(screen, bitmap, cliprect, 0, 0); /*Sprite chip is similar but not the same*/ funystrp_draw_sprites(bitmap, cliprect); m_bg_tilemap[0]->draw(screen, bitmap, cliprect, 0, 0); return 0; }
Py::Object FT2Font::draw_glyphs_to_bitmap(const Py::Tuple & args) { _VERBOSE("FT2Font::draw_glyphs_to_bitmap"); args.verify_length(0); FT_BBox string_bbox = compute_string_bbox(); image.width = (string_bbox.xMax-string_bbox.xMin) / 64+2; image.height = (string_bbox.yMax-string_bbox.yMin) / 64+2; image.offsetx = (int)(string_bbox.xMin/64.0); if (angle==0) image.offsety = -image.height; else image.offsety = (int)(-string_bbox.yMax/64.0); size_t numBytes = image.width*image.height; delete [] image.buffer; image.buffer = new unsigned char [numBytes]; for (size_t n=0; n<numBytes; n++) image.buffer[n] = 0; for ( size_t n = 0; n < glyphs.size(); n++ ) { FT_BBox bbox; FT_Glyph_Get_CBox(glyphs[n], ft_glyph_bbox_pixels, &bbox); error = FT_Glyph_To_Bitmap(&glyphs[n], ft_render_mode_normal, 0, //&pos[n], 1 //destroy image; ); if (error) throw Py::RuntimeError("Could not convert glyph to bitmap"); FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyphs[n]; /* now, draw to our target surface (convert position) */ //bitmap left and top in pixel, string bbox in subpixel draw_bitmap( &bitmap->bitmap, bitmap->left-string_bbox.xMin/64, string_bbox.yMax/64-bitmap->top+1 ); } return Py::Object(); }
void stop_video_effect (void) { ALLEGRO_BITMAP *screen = mr.cell[0][0].screen; if (! al_get_timer_started (video_timer)) return; video_effect.type = VIDEO_NO_EFFECT; al_stop_timer (video_timer); al_set_timer_count (video_timer, 0); drop_all_events_from_source (event_queue, get_timer_event_source (video_timer)); clear_bitmap (screen, BLACK); draw_bitmap (effect_buffer, screen, 0, 0, 0); effect_counter = 0; }
/****************************************************************************** * splash_wnd_proc: Splash bitmap window procedure * * @param hwnd: handle to window * @param msg: message to be processed * @param wParam: parameter associated with message * @param lParam: parameter associated with message * ******************************************************************************/ static LRESULT CALLBACK splash_wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { HBITMAP hbitmap; switch(msg) { case WM_CREATE: g_pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER)); /* Only 24 bit images supported */ g_pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); g_pbmi->bmiHeader.biWidth = g_bitmap_width; g_pbmi->bmiHeader.biHeight = g_bitmap_height; g_pbmi->bmiHeader.biPlanes = 1; g_pbmi->bmiHeader.biBitCount = 24; g_pbmi->bmiHeader.biCompression = BI_RGB; g_pbmi->bmiHeader.biSizeImage = (g_bitmap_width * g_bitmap_height *4); g_pbmi->bmiHeader.biClrImportant = 0; break; case WM_CLOSE: DestroyWindow(hwnd); PostQuitMessage(0); break; case WM_DESTROY: DestroyWindow(hwnd); PostQuitMessage(0); break; case WM_PAINT: { PAINTSTRUCT paint_struct; HDC hdc = BeginPaint(hwnd, &paint_struct); RECT rect = paint_struct.rcPaint; draw_bitmap(hdc, &rect); EndPaint(hwnd, &paint_struct); } break; case P2_SFX_HIDE_WIN: ShowWindow(hwnd, SW_HIDE); break; default: return DefWindowProc(hwnd, msg, wParam, lParam); } return 0; }
static void draw_batteryicon() { // Get battery charge level in percents int level = __Get(V_BATTERY); level = (level - 3500) * 100 / 500; // Copy the icon base uint32_t icon[10]; memcpy(icon, battery_icon, sizeof(icon)); // Fill in the charge level int shift = 20 - 20 * level / 100; if (shift < 0) shift = 0; uint32_t p1 = (fillpat1 << shift) & fillmask; uint32_t p2 = (fillpat2 << shift) & fillmask; for (int i = 1; i < 9; i += 2) { icon[i] |= p1; icon[i + 1] |= p2; } draw_bitmap(icon, 370, 224, MENU_TEXT, 10, false); }
ALLEGRO_BITMAP * create_broken_floor_bitmap (enum em em, enum vm vm) { ALLEGRO_BITMAP *broken_floor_left = NULL, *broken_floor_right = NULL, *floor_base = NULL; switch (em) { case DUNGEON: switch (vm) { case CGA: broken_floor_left = dc_broken_floor_left; broken_floor_right = dc_broken_floor_right; floor_base = dc_floor_base; break; case EGA: broken_floor_left = de_broken_floor_left; broken_floor_right = de_broken_floor_right; floor_base = de_floor_base; break; case VGA: broken_floor_left = dv_broken_floor_left; broken_floor_right = dv_broken_floor_right; floor_base = dv_floor_base; break; } break; case PALACE: switch (vm) { case CGA: broken_floor_left = pc_broken_floor_left; broken_floor_right = pc_broken_floor_right; floor_base = pc_floor_base; break; case EGA: broken_floor_left = pe_broken_floor_left; broken_floor_right = pe_broken_floor_right; floor_base = pe_floor_base; break; case VGA: broken_floor_left = pv_broken_floor_left; broken_floor_right = pv_broken_floor_right; floor_base = pv_floor_base; break; } break; } int wl = al_get_bitmap_width (broken_floor_left); int wr = al_get_bitmap_width (broken_floor_right); int w = wl + wr; int hl = al_get_bitmap_height (broken_floor_left); int hr = al_get_bitmap_height (broken_floor_right); int hb = al_get_bitmap_height (floor_base); int h = max_int (hl, hr) + hb; ALLEGRO_BITMAP *bitmap = create_bitmap (w, h); clear_bitmap (bitmap, al_map_rgba (0, 0, 0, 0)); draw_bitmap (floor_base, bitmap, 0, 14, 0); draw_bitmap (broken_floor_left, bitmap, 0, 1, 0); draw_bitmap (broken_floor_right, bitmap, 32, 0, 0); validate_bitmap_for_mingw (bitmap); return bitmap; }
/** * Move and display the fontes */ void scrolltext_move_and_display (void) { Sint32 i; Uint32 angle, ycoord; float sin_value; fntscroll *schar; schar = schar_first; if (schar == NULL) { return; } scrolltext_angle = (scrolltext_angle + 3) & 127; angle = scrolltext_angle; /* process each fonte sprite */ for (i = 0; i < scrolltext_numof_chars; i++, schar = schar->next) { angle = (angle + 2) & 127; #ifdef UNDER_DEVELOPMENT if (schar == NULL && i < (scrolltext_numof_chars - 1)) { LOG_ERR ("schar->next is null %i/%i", i, scrolltext_numof_chars); break; } #endif /* horizontal displacement */ if (schar->dir_x) { schar->coor_x += schar->speed; } /* vertical displacement */ if (schar->dir_y) { schar->coor_y += schar->speed; } /* disable char sprite if not visible */ if ((Sint16) (schar->coor_x + 32) < offscreen_startx || (Sint16) (schar->coor_y + 32) < offscreen_starty || (Sint16) schar->coor_y > offscreen_starty + offscreen_height_visible || (Sint16) schar->coor_x > offscreen_startx + offscreen_width_visible) { scrolltext_del_schar (schar); continue; } sin_value = precalc_sin128[angle]; #ifdef UNDER_DEVELOPMENT ycoord = (Uint32) (schar->coor_y + sin_value * 24); #else ycoord = (Uint32) (schar->coor_y + sin_value * 8); #endif /* manage the flickering of the sprite */ if (schar->blink) { if (++schar->spr.anim_count <= 1) { continue; } schar->spr.anim_count = 0; } draw_bitmap (&fnt_scroll[schar->num_image], schar->coor_x, ycoord); } }
void draw_multi_rooms (void) { int x, y; mr_map_rooms (); if (anim_cycle == 0) { generate_wall_colors_for_room (0, room0_wall_color); } if (em == PALACE && vm == VGA && (has_mr_view_changed () || em != mr.last.em || vm != mr.last.vm)) generate_wall_colors (); if (has_mr_view_changed ()) { generate_stars (); generate_mirrors_reflex (); } if (mouse_pos.room != mr.last.mouse_pos.room || mouse_pos.floor != mr.last.mouse_pos.floor || mouse_pos.place != mr.last.mouse_pos.place) { if (is_valid_pos (&mouse_pos)) update_cache_pos (&mouse_pos, em, vm); if (is_valid_pos (&mr.last.mouse_pos)) update_cache_pos (&mr.last.mouse_pos, em, vm); } if (anim_cycle == 0 || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue) { update_room0_cache (em, vm); } if (anim_cycle == 0 || has_mr_view_changed () || em != mr.last.em || vm != mr.last.vm || hgc != mr.last.hgc || hue != mr.last.hue || level.number != mr.last.level) { update_cache (em, vm); } size_t i; for (i = 0; i < changed_pos_nmemb; i++) { /* printf ("%i,%i,%i\n", changed_pos[i].room, changed_pos[i].floor, changed_pos[i].place); */ update_cache_pos (&changed_pos[i], em, vm); } destroy_array ((void **) &changed_pos, &changed_pos_nmemb); clear_bitmap (screen, BLACK); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_background (mr.cell[x][y].screen, mr.cell[x][y].room); } if (! no_room_drawing) draw_bitmap (cache, screen, 0, 0, 0); for (y = mr.h - 1; y >= 0; y--) for (x = 0; x < mr.w; x++) { if (! mr.cell[x][y].room) continue; mr.dx = x; mr.dy = y; draw_animated_foreground (mr.cell[x][y].screen, mr.cell[x][y].room); } if (mr.select_cycles > 0) { al_hold_bitmap_drawing (false); int x0 = ORIGINAL_WIDTH * mr.x; int y0 = ROOM_HEIGHT * mr.y + 3; int x1 = x0 + ORIGINAL_WIDTH; int y1 = y0 + ROOM_HEIGHT; draw_rectangle (screen, x0, y0, x1, y1, RED, 1); mr.select_cycles--; } mr.dx = mr.dy = -1; mr_update_last_settings (); }
void MapWindow::DrawFinalGlide(Canvas &canvas, const RECT rc) { /* POINT Scale[18] = { {5,-50 }, {14,-60 }, {23, -50}, {5,-40 }, {14,-50 }, {23, -40}, {5,-30 }, {14,-40 }, {23, -30}, {5,-20 }, {14,-30 }, {23, -20}, {5,-10 }, {14,-20 }, {23, -10}, {5, 0 }, {14,-10 }, {23, 0}, };*/ POINT GlideBar[6] = { {0,0},{9,-9},{18,0},{18,0},{9,0},{0,0} }; POINT GlideBar0[6] = { {0,0},{9,-9},{18,0},{18,0},{9,0},{0,0} }; TCHAR Value[10]; int Offset; int Offset0; int i; if (task.Valid()){ const int y0 = ( (rc.bottom - rc.top )/2)+rc.top; // 60 units is size, div by 8 means 60*8 = 480 meters. Offset = ((int)Calculated().TaskAltitudeDifference)/8; Offset0 = ((int)Calculated().TaskAltitudeDifference0)/8; // TODO feature: should be an angle if in final glide mode if(Offset > 60) Offset = 60; if(Offset < -60) Offset = -60; Offset = IBLSCALE(Offset); if(Offset<0) { GlideBar[1].y = IBLSCALE(9); } if(Offset0 > 60) Offset0 = 60; if(Offset0 < -60) Offset0 = -60; Offset0 = IBLSCALE(Offset0); if(Offset0<0) { GlideBar0[1].y = IBLSCALE(9); } for(i=0;i<6;i++) { GlideBar[i].y += y0; GlideBar[i].x = IBLSCALE(GlideBar[i].x)+rc.left; } GlideBar[0].y -= Offset; GlideBar[1].y -= Offset; GlideBar[2].y -= Offset; for(i=0;i<6;i++) { GlideBar0[i].y += y0; GlideBar0[i].x = IBLSCALE(GlideBar0[i].x)+rc.left; } GlideBar0[0].y -= Offset0; GlideBar0[1].y -= Offset0; GlideBar0[2].y -= Offset0; if ((Offset<0)&&(Offset0<0)) { // both below if (Offset0!= Offset) { int dy = (GlideBar0[0].y-GlideBar[0].y) +(GlideBar0[0].y-GlideBar0[3].y); dy = max(IBLSCALE(3), dy); GlideBar[3].y = GlideBar0[0].y-dy; GlideBar[4].y = GlideBar0[1].y-dy; GlideBar[5].y = GlideBar0[2].y-dy; GlideBar0[0].y = GlideBar[3].y; GlideBar0[1].y = GlideBar[4].y; GlideBar0[2].y = GlideBar[5].y; } else { Offset0 = 0; } } else if ((Offset>0)&&(Offset0>0)) { // both above GlideBar0[3].y = GlideBar[0].y; GlideBar0[4].y = GlideBar[1].y; GlideBar0[5].y = GlideBar[2].y; if (abs(Offset0-Offset)<IBLSCALE(4)) { Offset= Offset0; } } // draw actual glide bar if (Offset<=0) { if (Calculated().LandableReachable) { canvas.select(MapGfx.hpFinalGlideBelowLandable); canvas.select(MapGfx.hbFinalGlideBelowLandable); } else { canvas.select(MapGfx.hpFinalGlideBelow); canvas.select(MapGfx.hbFinalGlideBelow); } } else { canvas.select(MapGfx.hpFinalGlideAbove); canvas.select(MapGfx.hbFinalGlideAbove); } canvas.polygon(GlideBar, 6); // draw glide bar at mc 0 if (Offset0<=0) { if (Calculated().LandableReachable) { canvas.select(MapGfx.hpFinalGlideBelowLandable); canvas.hollow_brush(); } else { canvas.select(MapGfx.hpFinalGlideBelow); canvas.hollow_brush(); } } else { canvas.select(MapGfx.hpFinalGlideAbove); canvas.hollow_brush(); } if (Offset!=Offset0) { canvas.polygon(GlideBar0, 6); } // JMW draw x on final glide bar if unreachable at current Mc // hpAircraftBorder if ((Calculated().TaskTimeToGo>0.9*ERROR_TIME) || ((GlidePolar::GetMacCready()<0.01) && (Calculated().TaskAltitudeDifference<0))) { canvas.select(MapGfx.hpAircraftBorder); POINT Cross[4] = { {-5, -5}, { 5, 5}, {-5, 5}, { 5, -5} }; for (i=0; i<4; i++) { Cross[i].x = IBLSCALE(Cross[i].x+9); Cross[i].y = IBLSCALE(Cross[i].y+9)+y0; } canvas.polygon(Cross, 2); canvas.polygon(&Cross[2], 2); } if (Appearance.IndFinalGlide == fgFinalGlideDefault){ _stprintf(Value,TEXT("%1.0f "), ALTITUDEMODIFY*Calculated().TaskAltitudeDifference); if (Offset>=0) { Offset = GlideBar[2].y+Offset+IBLSCALE(5); } else { if (Offset0>0) { Offset = GlideBar0[1].y-IBLSCALE(15); } else { Offset = GlideBar[2].y+Offset-IBLSCALE(15); } } TextInBoxMode_t TextInBoxMode = {1|8}; TextInBox(canvas, Value, 0, (int)Offset, TextInBoxMode, rc); } else if (Appearance.IndFinalGlide == fgFinalGlideAltA){ SIZE TextSize; int y = GlideBar[3].y; // was ((rc.bottom - rc.top )/2)-rc.top- // Appearance.MapWindowBoldFont.CapitalHeight/2-1; int x = GlideBar[2].x+IBLSCALE(1); const Bitmap *Bmp; POINT BmpPos; POINT BmpSize; _stprintf(Value, TEXT("%1.0f"), Units::ToUserAltitude(Calculated().TaskAltitudeDifference)); canvas.select(MapWindowBoldFont); TextSize = canvas.text_size(Value); canvas.white_brush(); canvas.white_pen(); canvas.rectangle(x, y, x + IBLSCALE(1) + TextSize.cx, y + Appearance.MapWindowBoldFont.CapitalHeight + IBLSCALE(2)); canvas.text(x + IBLSCALE(1), y + Appearance.MapWindowBoldFont.CapitalHeight - Appearance.MapWindowBoldFont.AscentHeight + IBLSCALE(1), Value); if (Units::GetUnitBitmap(Units::GetUserAltitudeUnit(), &Bmp, &BmpPos, &BmpSize, 0)){ draw_bitmap(canvas, *Bmp, x + TextSize.cx + IBLSCALE(1), y, BmpPos.x, BmpPos.y, BmpSize.x, BmpSize.y, false); } } } }
/** * The main loop of game * @return TRUE if it completed successfully or FALSE otherwise */ bool update_frame (void) { spaceship_struct *ship = spaceship_get (); #ifdef DEVELOPPEMENT /* 1 = phase grid editor enable (don't work) */ static bool grid_editor = FALSE; #endif /* global frame counter */ global_counter++; /* play start and congratulations animations files * ("movie_congratulation.gca" and "movie_introduction.gca") */ if (movie_playing_switch != MOVIE_NOT_PLAYED) { if (!movie_player ()) { LOG_ERR ("movie_player() failed!"); return FALSE; } else { return TRUE; } } display_clear_offscreen (); #ifdef __EMSCRIPTEN__ lock_surface_game (); lock_surface_options (); lock_surface_scores (); #endif /* restores the level of energy of the player spaceship */ spaceship_energy_restore (); /* phase grid and curve phase editor (don't work) */ #ifdef DEVELOPPEMENT if (grid_editor || curve_editor_enable) { if (grid_editor) { Grid_Edit (); } else { courbe_editeur (); } } else #endif /* pause or main menu enable */ if (!player_pause && menu_status == MENU_OFF && menu_section == NO_SECTION_SELECTED) { /* * handle the phases of the game */ /* phase 2: grids (enemy wave like Space Invaders) */ grid_handle (); /* phase 1: curves (little skirmish) */ curve_phase (); /* phase 3: meteor storm */ meteors_handle (); } /* draw the starfield background */ starfield_handle (); /* handle bonus: green, red, yellow, blue and purple gems */ bonus_handle (); /* handle protection satellites and extra gun of the player spaceship */ if (!gameover_enable && menu_section == NO_SECTION_SELECTED) { /* orbital protection satellites gravitate around player's spaceship */ satellites_handle (); /* extra gun positioned on the sides */ guns_handle (); } /* handle enemies */ if (!is_congratulations_enabled) { /* handling of all the possible types of enemies */ enemies_handle (); } else { /* congratulations, end of the game */ congratulations (); } /* spaceship temporary invincibility */ spaceship_invincibility (); /* handle the powerful electrical shocks */ electrical_shock (); /* draw the player's spaceship */ spaceship_draw (); /* handle explosions */ explosions_handle (); /* handle shots */ shots_handle (); /* wait until all enemies are dead before jumping on next phase */ if (num_of_enemies == 0 && !player_pause && menu_status == MENU_OFF && menu_section == NO_SECTION_SELECTED) { /* end of a guardian phase? */ if (!guardian_finished ()) { LOG_ERR ("guardian_finished() failed!"); return FALSE; } /* check if curve phase is finished */ curve_finished (); /* check if grid phase is finished */ grid_finished (); /* check if meteors phase is finished */ if (!meteors_finished ()) { LOG_ERR ("meteors_finished failed!"); return FALSE; } } /* display pixel mouse pointer */ #ifdef DEVELOPPEMENT if (mouse_here) { put_pixel (game_offscreen, mouse_x, mouse_y, 5); } #endif /* draw powerful circular shock wave propagated by the player spaceship */ shockwave_draw (); /* animations of the options box on the right options panel */ option_execution (); /* handle high score table, game over, about and order sections */ menu_sections_run (); /* display "PAUSE" chars sprites */ if (is_pause_draw) { text_pause_draw (); } /* player's spaceship come */ if (spaceship_appears_count > 0) { spaceship_appears_count--; /* accelerate the speed of the starfield */ starfield_speed += 0.028f; if (starfield_speed > 2.0) { starfield_speed = 2.0; } /* invincibility time */ spaceship_set_invincibility (SPACESHIP_INVINCIBILITY_TIME / 3); } /* player's spaceship disappearing to the bottom of the screen. */ if (spaceship_disappears && is_congratulations_enabled == 0) { /* decelerate the speed of the starfield */ starfield_speed -= 0.02f; if (starfield_speed <= 0.0) { starfield_speed = 0.0; ship->y_speed = 0.0; } else { /* accelerate the speed of the spaceship */ ship->y_speed += -0.15f; } } /* display number level */ text_level_draw (); /* display scrolltext in the main menu */ scrolltext_handle (); /* handle the main menu of Powermanga */ menu_handle (); /* [F1] spaceship_appears / [F2] spaceship disappears */ #ifdef DEVELOPPEMENT if (keys_down[K_F1]) { spaceship_disappears = 1; } if (keys_down[K_F2] && starfield_speed == 0.0) { spaceship_show (); } #endif /* handle "TLK Games" sprite logo */ if (tlk_logo_is_move) { draw_bitmap (&logotlk[tlk_logo_image_index], tlk_logo_xcoord, tlk_logo_ycoord); if (tlk_logo_is_next_image) { tlk_logo_image_index++; if (tlk_logo_image_index >= TLKLOGO_MAXOF_IMAGES) { tlk_logo_image_index = 0; } tlk_logo_is_next_image = FALSE; tlk_logo_ycoord--; } else { tlk_logo_is_next_image = TRUE; } if (tlk_logo_ycoord <= 32) { tlk_logo_is_move = FALSE; } } /* display text overlay (about, cheats menu and variables) */ text_overlay_draw (); /* handle the loss and the regression of the spaceship or cause game over */ spaceship_downgrading (); /* handle spaceship's energy level */ energy_gauge_spaceship_update (); /* handle guardian's energy level */ energy_gauge_guardian_update (); /* draw player's score into the top panel */ text_draw_score (); #ifdef DEVELOPPEMENT if (keys_down[K_E] && keys_down[K_G]) { /* [e]+[g] = enable the grid editor */ grid_editor = 1; } if (keys_down[K_E] && keys_down[K_C]) { /* [e]+[c] enable the curve editor */ curve_editor_enable = 1; } /* [p]+[g] back to the game */ if (keys_down[K_P] && keys_down[K_G]) { grid_editor = 0; curve_editor_enable = 0; } #endif /* control the spaceship movements */ if (!player_pause && !gameover_enable && menu_status == MENU_OFF && menu_section == NO_SECTION_SELECTED) { spaceship_control_movements (); } /* [P] or [Pause] enable/disable pause */ if (!keys_down[K_CTRL] && (keys_down[K_P] || keys_down[K_PAUSE])) { toggle_pause (); } keys_down[K_P] = FALSE; keys_down[K_PAUSE] = FALSE; /* clear flag pause key */ /* switch between full screen and windowed mode */ #ifdef POWERMANGA_SDL if ((keys_down[K_F] && !is_playername_input () && menu_section != SECTION_ORDER) || keys_down[K_F11]) { if (power_conf->fullscreen) { power_conf->fullscreen = FALSE; } else { power_conf->fullscreen = TRUE; } init_video_mode (); } keys_down[K_F] = FALSE; keys_down[K_F11] = FALSE; #endif /* control the speed of the spaceship */ spaceship_speed_control (); /* cheat code keys */ #ifdef UNDER_DEVELOPMENT special_keys (); #endif /* handle weapon's player spaceship */ #ifdef DEVELOPPEMENT if (!grid_editor && !curve_editor_enable && !spaceship_is_dead && !player_pause && menu_status == MENU_OFF && menu_section == NO_SECTION_SELECTED) #else if (!spaceship_is_dead && !player_pause && menu_status == MENU_OFF && menu_section == NO_SECTION_SELECTED) #endif { spaceship_weapons (); } #ifdef __EMSCRIPTEN__ unlock_surface_scores (); unlock_surface_options (); unlock_surface_game (); #endif return TRUE; }