void BasiliskAreaHurt::animate(Frame *space) { STACKTRACE; if (state == 0) return; int i, j; double t = 1 - life_counter/(double)lifetime; double x0, y0, dx, dy; int xi, yi; Vector2 p0; drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); for (i=0; i<num; i++) { p0 = corner(xp[i]); x0 = p0.x; y0 = p0.y; p0 = unit_vector(xv[i]) * 3 * space_zoom; dx = p0.x; dy = p0.y; for (j=3; j>=0; j--) { if (space_zoom <= 1) set_trans_blender(0, 0, 0, iround(space_zoom * 255 * t * (4-j) / 4.0)); else set_trans_blender(0, 0, 0, iround(1 * 255 * t * (4-j) / 4.0)); xi = iround(x0 - dx * j); yi = iround(y0 - dy * j); putpixel(space->surface, xi, yi, color); space->add_pixel(xi, yi); } } drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); }
void AWgtSlider::draw() { int ly = y + (tabHeight() / 2) - lineThickness; rectfill(tguiBitmap, x, ly, x+width-1, ly+lineThickness, lineColor); rectfill(tguiBitmap, x, ly+lineThickness, x+width-1, ly+(lineThickness*2), shadowColor); if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); rect(tguiBitmap, x-1, ly-1, x+width, ly+(lineThickness*2)+1, aWgtFocusColor); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); } int tx = getStopPos(currStop) - (tabWidth() / 2); if (sliderTabBmp) { draw_sprite(tguiBitmap, sliderTabBmp, tx, y); } else { rect(tguiBitmap, tx, y, tx+sliderDefaultTabWidth-1, y+sliderDefaultTabHeight-1, shadowColor); rectfill(tguiBitmap, tx+1, y+1, tx+sliderDefaultTabWidth-2, y+sliderDefaultTabHeight-2, lineColor); } }
void AWgtCheckbox::draw() { int tx; int ty; if (checkCheckedBmp) { if (checked) draw_sprite(tguiBitmap, checkCheckedBmp, x, y); else draw_sprite(tguiBitmap, checkUncheckedBmp, x, y); tx = x + checkCheckedBmp->w + checkPadding; ty = y + ((checkCheckedBmp->h - text_height(aWgtFont)) / 2); } else { int w = text_height(aWgtFont); rect(tguiBitmap, x, y, x+w-1, y+w-1, shadowColor); rectfill(tguiBitmap, x+1, y+1, x+w-2, y+w-2, textColor); if (checked) { line(tguiBitmap, x+1, y+1, x+w-2, y+w-2, shadowColor); line(tguiBitmap, x+1, y+w-2, x+w-2, y+1, shadowColor); } tx = x + w + checkPadding; ty = y; } aWgtTextout(tguiBitmap, aWgtFont, text, tx, ty, textColor, shadowColor, shadowType); if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); rect(tguiBitmap, tx-2, ty-2, tx+text_length(aWgtFont, text)+2, ty+text_height(aWgtFont)+2, aWgtFocusColor); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); } }
void draw_bloodpools(void) { int i; float j; float dec; float alpha; float temp; for(i=0;i<BLOODPOOL_NUM;i++) if(bloodpool[i].used) if(object_is_in_player_los(bloodpool[i].x-bloodpool[i].size, bloodpool[i].y-bloodpool[i].size, bloodpool[i].size*2,bloodpool[i].size*2,0,0)) { temp = bloodpool[i].size*0.5; circlefill(virt, bloodpool[i].x-map_x, bloodpool[i].y-map_y, temp*2, bloodpool[i].color ); dec = (255)/(bloodpool[i].size*0.5); alpha = 255; drawing_mode(DRAW_MODE_TRANS,NULL,0,0); for(j=temp;j<bloodpool[i].size;j+=1) { set_trans_blender(0,0,0,(int)alpha); circle(virt, bloodpool[i].x-map_x, bloodpool[i].y-map_y, temp+j, bloodpool[i].color); alpha-=dec; if(alpha<0)alpha=0; } drawing_mode(DRAW_MODE_SOLID,NULL,0,0); } }
void AWgtButton::draw() { int color; if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); color = aWgtFocusColor; } else color = border_color; line(tguiBitmap, x+2, y, x+width-3, y, color); line(tguiBitmap, x, y+2, x, y+height-3, color); line(tguiBitmap, x+width-1, y+2, x+width-1, y+height-3, color); line(tguiBitmap, x+2, y+height-1, x+width-3, y+height-1, color); if (focus) drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); int faceHeight = height - 2; int i; for (i = 0; i < faceHeight; i++) { float ratio = (float)i / (float)faceHeight; int color; if (depressed) color = aWgtInterpolateColor(ratio, bottom_color, top_color); else color = aWgtInterpolateColor(ratio, top_color, bottom_color); line(tguiBitmap, x+1, y+1+i, x+width-2, y+1+i, color); } putpixel(tguiBitmap, x+1, y+1, border_color); putpixel(tguiBitmap, x+width-2, y+1, border_color); putpixel(tguiBitmap, x+width-2, y+height-2, border_color); putpixel(tguiBitmap, x+1, y+height-2, border_color); int tx = x + (width/2) - (text_length(aWgtFont, text)/2); int ty = y + (height/2) - (text_height(aWgtFont)/2); if (depressed) { tx += 2; ty += 2; color = aWgtDarken(text_color); } else color = text_color; aWgtTextout(tguiBitmap, aWgtFont, text, tx, ty, color, shadowColor, shadowType); }
// DRAW PRIMATIVE ROUTINGS // void messy_line( BITMAP *bmp, float x1, float y1, float x2, float y2, int c){ int i = 0; set_write_alpha_blender(); drawing_mode(DRAW_MODE_TRANS,0,0,0); set_trans_blender(0,0,0,LINE_WEIGHT); for ( i = 0; i < LINE_RETRIES; i++ ){ line( bmp, x1+POINT_ACCURACY, y1+POINT_ACCURACY,x2+POINT_ACCURACY, y2+POINT_ACCURACY, c ); } drawing_mode(DRAW_MODE_SOLID,0,0,0); }
void Explosion::draw(const GraphicsContext &gc) { int x = getx() - parent->getViewPort()->getx(); int y = gety() - parent->getViewPort()->gety(); drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0); set_trans_blender (0, 0, 0, 128); circlefill (gc.buffer, x, y, size, RED); circlefill (gc.buffer, x, y, size * 2 / 3, YELLOW); drawing_mode (DRAW_MODE_SOLID, NULL, 0, 0); }
}void draw_drawing_sideways2( BITMAP *bmp, drawingtype *drawing, float x, float y, float z ){ int i ; drawing_mode(DRAW_MODE_TRANS,0,0,0); for ( i = 0; i < drawing->num_polys; i++ ){ color_poly_sideways2( bmp, &drawing->poly[i], x, y, z ); } for ( i = 0; i < drawing->num_polys; i++ ){ draw_poly_sideways2( bmp, &drawing->poly[i], x, y, z ); } drawing_mode(DRAW_MODE_SOLID,0,0,0); }
void AWgtIcon::draw() { if (pressable && depressed) draw_sprite(tguiBitmap, downBmp, x, y); else if (pressable && tguiPointOnWidget(this, mouse_x, mouse_y)) draw_sprite(tguiBitmap, hoverBmp, x, y); else draw_sprite(tguiBitmap, normalBmp, x, y); if (focus) { drawing_mode(DRAW_MODE_MASKED_PATTERN, linePatternBmp, 0, 0); rect(tguiBitmap, x, y, x+width-1, y+height-1, aWgtFocusColor); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); } }
int InitScreen() { char *sb_dev, *driver; printnbits(); sb_dev = getenv("SB_OUTDEV"); if(!sb_dev) sb_dev = getenv("OUTDEV"); if(!sb_dev) sb_dev = "/dev/crt1"; driver = getenv("SB_OUTDRIVER"); if(!driver) driver = getenv("OUTDRIVER"); if (!driver ) driver = "hp98731"; fildes = gopen(sb_dev,OUTDEV,driver,INIT|INT_XFORM); interior_style(fildes,INT_SOLID,FALSE); intvdc_extent(fildes,0,0,SIZE, SIZE); mapping_mode(fildes,FALSE); drawing_mode(fildes,6); /* xor mode */ clear_control(fildes, CLEAR_VIEWPORT); fill_color(fildes, 1.0, 1.0, 1.0); return(fildes); }
void Tilemap::Draw(BITMAP* buffer) // Uncomment the code in here to turn fog of war on { for (int i=0; i<(int)tiles.size(); ++i) { for (int j=0; j<(int)tiles[i].size(); ++j) { //if (visible[i][j] > 0) tiles[i][j].Draw(buffer, Vector(tile_dim.XInt()*i, tile_dim.YInt()*j)); } } draw_sprite(buffer, grid, 0, 0); for (int i=0; i<(int)tiles.size(); ++i) { for (int j=0; j<(int)tiles[i].size(); ++j) { //if (visible[i][j] == 256) tiles[i][j].DrawObjects(buffer, Vector(tile_dim.XInt()*i, tile_dim.YInt()*j)); /*else { set_trans_blender(0, 0, 0, 256 - visible[i][j]); drawing_mode(DRAW_MODE_TRANS, 0, 0, 0); rectfill(buffer, tile_dim.XInt()*i, tile_dim.YInt()*j, tile_dim.XInt()*(i+1)-1, tile_dim.YInt()*(j+1)-1, Colour::Black()); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); }*/ } } if (need_to_draw_message) { int w = citizen_saved->w * message_scale; int h = citizen_saved->h * message_scale; int x = scr_w/2 - w/2; int y = scr_h/2 - h/2; stretch_sprite(buffer, citizen_saved, x, y, w, h); } if (need_to_draw_blood) { set_trans_blender(0, 0, 0, blood_alpha); drawing_mode(DRAW_MODE_TRANS, 0, 0, 0); draw_trans_sprite(buffer, blood, 0, 0); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); } if (!need_to_draw_blood && need_fresh_blood && blood != NULL) { clear_to_color(blood, Colour::MagicPink()); int how_many_splatters = 4 + rand() % 6; for (int i=0; i<how_many_splatters; ++i) draw_sprite(blood, GetBloodSplatter(), rand() % 540, rand() % 300); need_fresh_blood = false; } }
void CPanel::Draw(BITMAP *buffer) { rect(buffer,x,y,x + w,y + h,border_color); drawing_mode(DRAW_MODE_TRANS,NULL,0,0); set_trans_blender(0,0,0,alpha); rectfill(buffer,x + 1,y + 1,x + w - 1,y + h - 1,color); solid_mode(); alfont_textout_centre_aa_ex(buffer,font,caption,x + w/2,y,caption_color,-1); }
void Alleg4Surface::fillRect(gfx::Color color, const gfx::Rect& rc) { if (gfx::geta(color) < 255) { set_trans_blender(0, 0, 0, gfx::geta(color)); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } rectfill(m_bmp, rc.x, rc.y, rc.x+rc.w-1, rc.y+rc.h-1, to_allegro(bitmap_color_depth(m_bmp), color)); solid_mode(); }
void Alleg4Surface::drawLine(gfx::Color color, const gfx::Point& a, const gfx::Point& b) { if (gfx::geta(color) < 255) { set_trans_blender(0, 0, 0, gfx::geta(color)); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } line(m_bmp, a.x, a.y, b.x, b.y, to_allegro(bitmap_color_depth(m_bmp), color)); solid_mode(); }
void Alleg4Surface::drawVLine(gfx::Color color, int x, int y, int h) { if (gfx::geta(color) < 255) { set_trans_blender(0, 0, 0, gfx::geta(color)); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } vline(m_bmp, x, y, y+h-1, to_allegro(bitmap_color_depth(m_bmp), color)); solid_mode(); }
/* * call-seq: * drawing_mode(mode, pattern, x_anchor, y_anchor) -> nil * * Sets the graphics drawing mode. This only affects the geometric routines like * putpixel, lines, rectangles, circles, polygons, floodfill, etc, not the text * output, blitting, or sprite drawing functions. The mode should be one of the * following constants: * DRAW_MODE_SOLID - the default, solid color drawing * DRAW_MODE_XOR - exclusive-or drawing * DRAW_MODE_COPY_PATTERN - multicolored pattern fill * DRAW_MODE_SOLID_PATTERN - single color pattern fill * DRAW_MODE_MASKED_PATTERN - masked pattern fill * DRAW_MODE_TRANS - translucent color blending * * In DRAW_MODE_SOLID, pixels of the bitmap being drawn onto are simply replaced * by those produced by the drawing function. * * In DRAW_MODE_XOR, pixels are written to the bitmap with an exclusive-or * operation rather than a simple copy, so drawing the same shape twice will * erase it. Because it involves reading as well as writing the bitmap memory, * xor drawing is a lot slower than the normal replace mode. * * With the patterned modes, you provide a pattern bitmap which is tiled across * the surface of the shape. Allegro stores a pointer to this bitmap rather than * copying it, so you must not destroy the bitmap while it is still selected as * the pattern. The width and height of the pattern must be powers of two, but * they can be different, eg. a 64x16 pattern is fine, but a 17x3 one is not. * The pattern is tiled in a grid starting at point (x_anchor, y_anchor). * Normally you should just pass zero for these values, which lets you draw * several adjacent shapes and have the patterns meet up exactly along the * shared edges. Zero alignment may look peculiar if you are moving a patterned * shape around the screen, however, because the shape will move but the pattern * alignment will not, so in some situations you may wish to alter the anchor * position. * * When you select DRAW_MODE_COPY_PATTERN, pixels are simply copied from the * pattern bitmap onto the destination bitmap. This allows the use of * multicolored patterns, and means that the color you pass to the drawing * routine is ignored. This is the fastest of the patterned modes. * * In DRAW_MODE_SOLID_PATTERN, each pixel in the pattern bitmap is compared with * the mask color, which is zero in 256-color modes or bright pink for truecolor * data (maximum red and blue, zero green). If the pattern pixel is solid, a * pixel of the color you passed to the drawing routine is written to the * destination bitmap, otherwise a zero is written. The pattern is thus treated * as a monochrome bitmask, which lets you use the same pattern to draw * different shapes in different colors, but prevents the use of multicolored * patterns. * * DRAW_MODE_MASKED_PATTERN is almost the same as DRAW_MODE_SOLID_PATTERN, but * the masked pixels are skipped rather than being written as zeros, so the * background shows through the gaps. * * In DRAW_MODE_TRANS, the global color_map table or truecolor blender functions * are used to overlay pixels on top of the existing image. This must only be * used after you have set up the color mapping table (for 256 color modes) or * blender functions (for truecolor modes). Because it involves reading as well * as writing the bitmap memory, translucent drawing is very slow if you draw * directly to video RAM, so wherever possible you should use a memory bitmap * instead. */ VALUE a4r_API_drawing_mode(VALUE self, VALUE mode, VALUE pattern, VALUE x_anchor, VALUE y_anchor) { BITMAP *bitmap; if (pattern == Qnil) bitmap = NULL; else Data_Get_Struct(pattern, BITMAP, bitmap); drawing_mode(FIX2INT(mode), bitmap, FIX2INT(x_anchor), FIX2INT(y_anchor)); return Qnil; }
void EditboxVScrollView::drawExtraComponents() { int textheight = text_height(textfont); //draw the scrollbar draw_arrow_button(dbuf, toparrow_x-host->x, toparrow_y-host->y, 16, 16, true, toparrow_state*3); draw_arrow_button(dbuf, bottomarrow_x-host->x, bottomarrow_y-host->y, 16, 16, false, bottomarrow_state*3); if(!sbarpattern) { sbarpattern = create_bitmap_ex(bitmap_color_depth(screen),2,2); putpixel(sbarpattern, 0, 1, scheme[jcLIGHT]); putpixel(sbarpattern, 0, 1, scheme[jcLIGHT]); putpixel(sbarpattern, 0, 1, scheme[jcLIGHT]); putpixel(sbarpattern, 0, 1, scheme[jcLIGHT]); } drawing_mode(DRAW_MODE_COPY_PATTERN, sbarpattern, 0, 0); int barstart = toparrow_y + 16 - host->y; int barend = bottomarrow_y - host->y-1; if(barstart < barend) rectfill(dbuf, toparrow_x-host->x, barstart, toparrow_x-host->x+15, barend, 0); solid_mode(); //compute the bar button, based on view_y int totallen = (int)model->getLines().size()*textheight; int available = bottomarrow_y-(toparrow_y+16); if(available < 0) { baroff=barlen=0; } else { //area_height:totallen = barlen:available barlen = (available*area_height)/zc_max(totallen,area_height)+1; //clip to reasonable values barlen = zc_max(barlen, 8); baroff = zc_min(baroff, available-barlen); //view_y:(totallen-area_height) = baroff:(available-barlen) if(totallen <= area_height) baroff=0; else baroff = ((available-barlen)*view_y)/(totallen-area_height); } if(barlen > 0) { jwin_draw_button(dbuf, toparrow_x-host->x, toparrow_y+16-host->y+baroff, 16, barlen, false, 1); } }
void AnimFrame::Draw(BITMAP* bmp, Vector pos, float scale, bool vertical_flip, float rotation, int alpha) { BITMAP* graphic = (BITMAP*)global_datafile[graphic_id].dat; if (graphic == NULL) { erlog("Graphic ID out of bounds in frame draw", 3); return; } if (bmp == NULL) { erlog("Buffer out of bounds in frame draw", 3); return; } if (scale == 0.0 && vertical_flip == false && rotation == 0.0 && (alpha >= 256 || alpha < 0)) { draw_sprite(bmp, graphic, pos.XInt(), pos.YInt()); return; } if (alpha >= 256 || alpha < 0) { if (vertical_flip == false) { rotate_scaled_sprite(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); return; } rotate_scaled_sprite_v_flip(bmp, graphic, pos.XInt(), pos.YInt(), fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); return; } float fdiagonal = sqrt(static_cast<float>(graphic->w*graphic->w + graphic->h*graphic->h)); int diagonal = static_cast<int>(fdiagonal + 1); BITMAP* temp_bmp = create_bitmap(diagonal, diagonal); if (vertical_flip == false) { rotate_scaled_sprite(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); } else { rotate_scaled_sprite_v_flip(temp_bmp, graphic, 0, 0, fixmul(ftofix(rotation), radtofix_r), ftofix(scale)); } set_trans_blender(0, 0, 0, alpha); drawing_mode(DRAW_MODE_TRANS, 0, 0, 0); draw_trans_sprite(temp_bmp, bmp, pos.XInt(), pos.YInt()); drawing_mode(DRAW_MODE_SOLID, 0, 0, 0); }
void tur_draw_turret(BITMAP *dest, turret_t *turret) { int x, y; float bx, by; int i; x = turret->x * 32; y = turret->y * 32; /* XXX/DEBUG: SHOW ANGLE */ bx = x + turret->bitmap->w/2; by = y + turret->bitmap->h/2; drawing_mode(DRAW_MODE_TRANS,NULL,0,0); set_trans_blender(0,0,0,100); for (i = 0; i < turret->range; i += 10) { float result; result = fixtof(fixcos(turret->angle)); by -= result * 10; result = fixtof(fixsin(turret->angle)); bx += result * 10; //putpixel(dest, bx, by, makecol(255,255,0)); //putpixel(dest, bx+1, by, makecol(255,255,0)); } solid_mode(); /* ---- */ /* range */ drawing_mode(DRAW_MODE_TRANS,NULL,0,0); set_trans_blender(0,0,0,60); //circle(dest, turret->x * 32 + 16, turret->y * 32 + 16, turret->range, makecol(200,200,200)); /*circlefill(dest, turret->x * 32 + 16, turret->y * 32 + 16, turret->range, makecol(200,200,200));*/ solid_mode(); /* turret */ rotate_sprite(dest, turret->bitmap, turret->x * 32, turret->y * 32, turret->angle); }
int d_abitmap_textbox_proc (int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { int s = get_state (d); int height, bar = 1; int mode, x_anchor, y_anchor; BITMAP *pattern; height = (d->h - 8) / text_height (font); /* hack to make _draw_textbox draw transparent text */ mode = _drawing_mode; pattern = _drawing_pattern; x_anchor = _drawing_x_anchor; y_anchor = _drawing_y_anchor; drawing_mode (DRAW_MODE_MASKED_PATTERN, none, 0, 0); /* tell the object to sort of draw, but only calculate the listsize */ /* DONT DRAW anything */ _draw_textbox ((char *) d->dp, &d->d1, 0, d->d2, !(d->flags & D_SELECTED), 8, d->x, d->y, d->w - 2, d->h - 2, (d->flags & D_DISABLED), 0, 0, 0); if (d->d1 > height) bar = 11; else d->d2 = 0; abitmap_draw_area (d, B_TEXTBOX, 0, 0, bar == 11 ? d->w - 12 : d->w, d->h, 0, 0); if (bar == 11) abitmap_draw_scroller (d, d->d2, d->d1 + 1, height); /* now do the actual drawing */ _draw_textbox ((char *) d->dp, &d->d1, 1, d->d2, !(d->flags & D_SELECTED), 8, d->x, d->y, d->w - 2 - bar, d->h - 2, (d->flags & D_DISABLED), theme->bitmaps[B_TEXTBOX][s].color, -1, theme->bitmaps[B_TEXTBOX][s].color); _drawing_mode = mode; _drawing_pattern = pattern; _drawing_x_anchor = x_anchor; _drawing_y_anchor = y_anchor; return D_O_K; } return d_textbox_proc (msg, d, c); }
void renderStepLaneDMX(int x, int bgColor, int outlineColor) { line(rm.m_backbuf, x, 40, x, 434, outlineColor); line(rm.m_backbuf, x+1, 40, x+1, 434, outlineColor); line(rm.m_backbuf, x+32, 40, x+32, 434, outlineColor); line(rm.m_backbuf, x+33, 40, x+33, 434, outlineColor); if ( rm.useAlphaLanes ) { // if this worked without killing the fps, that would be nice //* drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); rectfill(rm.m_backbuf, x+2, 26, x+31, 444, bgColor); drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); set_alpha_blender(); // the game assumes the graphics are left in this mode //*/ // this was actually pretty good (the asset was a solid black rectangle) /* set_trans_blender(0,0,0,128); draw_trans_sprite(rm.m_backbuf, m_dmxTransLane, x+2, 26); set_alpha_blender(); // the game assumes the graphics are left in this mode //*/ // try this instead? /* int quad[8] = { x+2,26, x+2,444, x+31,444, x+31,26 }; drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); polygon(rm.m_backbuf, 4, quad, bgColor); set_alpha_blender(); // the game assumes the graphics are left in this mode //*/ } else { rectfill(rm.m_backbuf, x+2, 26, x+31, 444, bgColor); } }
void AllegroGraphics::setColor(const Color& color) { mColor = color; mAllegroColor = makecol(color.r, color.g, color.b); if (color.a != 255) { set_trans_blender(255, 255, 255, color.a); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } else { solid_mode(); } }
void Background::init() { texture = create_bitmap (TILEW, TILEH); assert (texture); int c1 = WHITE; int c2 = GREY; clear_to_color (texture, c1); circlefill(texture, TILEW / 2, TILEW / 2, 60, c2); circlefill (texture, TILEW / 2, TILEH / 2, 30, c1); drawing_mode (DRAW_MODE_TRANS, NULL, 0, 0); set_trans_blender (0, 0, 0, 160); rectfill (texture, 0, 0, TILEW, TILEH, BROWN); solid_mode(); }
void EditboxNoWrapView::drawExtraComponents() { EditboxVScrollView::drawExtraComponents(); int textheight; textheight = text_height(textfont); //draw the scrollbar draw_arrow_button_horiz(dbuf, leftarrow_x-host->x, leftarrow_y-host->y, 16, 16, true, leftarrow_state*3); draw_arrow_button_horiz(dbuf, rightarrow_x-host->x, rightarrow_y-host->y, 16, 16, false, rightarrow_state*3); drawing_mode(DRAW_MODE_COPY_PATTERN, sbarpattern, 0, 0); int hbarstart = leftarrow_x + 16 - host->x; int hbarend = rightarrow_x - host->x-1; if(hbarstart < hbarend) rectfill(dbuf, hbarstart, leftarrow_y-host->y, hbarend, leftarrow_y-host->y+15, 0); solid_mode(); //compute the bar button, based on view_y int totallen = view_width; int available = rightarrow_x-(leftarrow_x+16); if(available < 0) { hbaroff=hbarlen=0; } else { //area_width:totallen = barlen:available hbarlen = (available*area_width)/zc_max(totallen,area_width)+1; //clip to reasonable values hbarlen = zc_max(hbarlen, 8); hbaroff = zc_min(hbaroff, available-hbarlen); //view_x:(totallen-area_width) = baroff:(available-hbarlen) if(totallen <= area_width) hbaroff = 0; else hbaroff = ((available-hbarlen)*view_x)/(totallen-area_width); } if(hbarlen > 0) { jwin_draw_button(dbuf, leftarrow_x-host->x+hbaroff+16, leftarrow_y-host->y, hbarlen, 16, false, 1); } }
void draw_poly( BITMAP *bmp, polytype *poly, float x, float y, float z ){ int i ; float half_w = bmp->w/2; float half_h = bmp->h/2; int *pt; pt = malloc(sizeof(int) * poly->pts ); for ( i = 0; i < poly->pts; i++ ){ pt[i] = (((((float)(poly->pt[i]-128)/128.0) + x )/(z*Z_SCALE))*half_w)+half_w + PAINT_ACCURACY; i++; pt[i] = (((((float)(poly->pt[i]-128)/128.0) + y )/(z*Z_SCALE))*half_h)+half_h + PAINT_ACCURACY; } messy_polygon( bmp, poly->pts, pt, makecol(0,0,0) ); drawing_mode(DRAW_MODE_SOLID,0,0,0); free(pt); }
void draw_poly_sideways2( BITMAP *bmp, polytype *poly, float x, float y, float z ){ int i ; float half_w = bmp->w/2; float half_h = bmp->h/2; int *pt; pt = malloc(sizeof(int) * poly->pts ); for ( i = 0; i < poly->pts; i++ ){ float nz = (1 -(float)((poly->pt[i]-128)/128.0))+z-1; pt[i] = ((x/nz)*half_w)+half_w + PAINT_ACCURACY; pt[i] = min(bmp->w,max(0,pt[i])); if (( pt[i] < -16 ) || (pt[i] > bmp->w+16) ) return; i++; pt[i] = (((((float)(poly->pt[i]-128)/128.0) + y )/nz)*half_h)+half_h + PAINT_ACCURACY; pt[i] = min(bmp->h,max(0,pt[i])); if (( pt[i] < -16 ) || (pt[i] > bmp->h+16) ) return; } messy_polygon( bmp, poly->pts, pt, makecol(0,0,0) ); drawing_mode(DRAW_MODE_SOLID,0,0,0); free(pt); }
void SquareMap::drawLayer(BITMAP *dest, bool drawObstacle, TiledMapLayer *layer, int opacity) { Rectangle oldClip; TileType *tempTileType; Tile* tempTile; oldClip.clipToRect(dest); cameraScreenRect.rectToClip(dest); // Calculate the part of the map that needs to be drawn (visible part) Point start = screenToTile(Point(cameraScreenRect.x, cameraScreenRect.y)); Point end = screenToTile(Point(cameraScreenRect.x + cameraScreenRect.w - 1, cameraScreenRect.y + cameraScreenRect.h - 1)); start.x = MAX(0, MIN(mapWidth - 1, start.x)); start.y = MAX(0, MIN(mapHeight - 1, start.y)); if (opacity < 255) { set_trans_blender(0,0,0,opacity); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); } for (int y = start.y; y <= end.y; y++) { for (int x = start.x; x <= end.x; x++) { tempTile = layer->getTile(Point(x, y)); tempTileType = tempTile->getType(); if (tempTileType) { if (opacity < 255) { draw_trans_sprite( dest, tempTileType->getBitmap(), cameraScreenRect.x - cameraCoords.x + x * tileWidth, cameraScreenRect.y - cameraCoords.y + y * tileHeight ); } else { draw_sprite( dest, tempTileType->getBitmap(), cameraScreenRect.x - cameraCoords.x + x * tileWidth, cameraScreenRect.y - cameraCoords.y + y * tileHeight ); } } if (drawObstacle) { int tx = cameraScreenRect.x - cameraCoords.x + x * tileWidth; int ty = cameraScreenRect.y - cameraCoords.y + y * tileHeight; int tw = tileWidth; int th = tileHeight; int to = tempTile->obstacle; if (to & OB_TOP) { line(dest, tx + 2, ty + 2, tx + tw - 3, ty + 2, makecol(255,0,0)); line(dest, tx + 3, ty + 3, tx + tw - 2, ty + 3, makecol(0,0,0)); } if (to & OB_LEFT) { line(dest, tx + 2, ty + 2, tx + 2, ty + th - 3, makecol(255,0,0)); line(dest, tx + 3, ty + 3, tx + 3, ty + th - 2, makecol(0,0,0)); } if (to & OB_RIGHT) { line(dest, tx + tw - 3, ty + 2, tx + tw - 3, ty + th - 3, makecol(255,0,0)); line(dest, tx + tw - 2, ty + 3, tx + tw - 2, ty + th - 2, makecol(0,0,0)); } if (to & OB_BOTTOM) { line(dest, tx + 2, ty + th - 3, tx + tw - 3, ty + th - 3, makecol(255,0,0)); line(dest, tx + 3, ty + th - 2, tx + tw - 2, ty + th - 2, makecol(0,0,0)); } } } } if (opacity < 255) { drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } oldClip.rectToClip(dest); }
void startup_menu(void) { reset_menu_palette(); menu_select = 0; key_wait = 30; // int counter; menu_counter = 0; counter2 = 0; arena.difficulty = 0; int y1 = 170; int y2 = 190 + menu_select * 30; int y3 = 218 + menu_select * 30; int y4 = 218 + menu_select * 30; int anykey = 0; int i; //#define TEST_MUSIC #ifdef TEST_MUSIC arena.level = 3; init_beat_new_level(); #endif init_menu_circles(); while (TRUE) { #ifdef TEST_MUSIC run_beat(); #endif clear_to_color(display, COL_BACK1); run_menu_background(); menu_counter += 4; if (menu_counter >= 40) menu_counter = 0; counter2 ++; if (counter2 >= 256) counter2 = 0; // textprintf_centre_ex(display, font, 300, 190, -1, -1, "W H I T E B U T T E R F L Y"); draw_rle_sprite(display, white_RLE, 150, 150); int my = 300; y1 = my - 23; y2 = my - 10 + menu_select * 30; y3 = my + 19 + menu_select * 30; y4 = my + 150; // rectfill(display, 370, y1, 600, y2, COL_COL1); TRANS_MODE rectfill(display, 370, y2 + 9, 640, y3 - 2, TRANS_BLUE3); rect(display, 368, y2 + 7, 641, y3 - 0, TRANS_BLUE3); END_TRANS // rectfill(display, 370, y3, 600, y4, TRANS_DGREEN); textprintf_ex(display, font, 400, my, -1, -1, "START GAME"); switch(arena.difficulty) { case 0: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - NORMAL"); break; case 1: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - HARD"); break; case 2: textprintf_ex(display, font, 400, my + 30, -1, -1, "DIFFICULTY - PUNISHMENT"); break; } // textprintf_ex(display [2], font, 400, 260, -1, -1, "STAGE - %i", arena.starting_level); textprintf_ex(display, font, 400, my + 90, -1, -1, "SET KEYS"); textprintf_ex(display, font, 400, my + 120, -1, -1, "OPTIONS"); textprintf_ex(display, font, 400, my + 150, -1, -1, "EXIT"); // textprintf_ex(display, font, 40, 10, -1, -1, "%i", joy[0].stick[options.joy_stick].axis[0].pos); // textprintf_ex(display, font, 40, 30, -1, -1, "%i", joy[0].stick[options.joy_stick].axis[1].pos); /* if (options.joystick) textprintf_ex(display, font, 400, my + 120, -1, -1, "CALIBRATE JOYSTICK"); else { textprintf_ex(display, font, 400, my + 120, -1, -1, "NO JOYSTICK"); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); rectfill(display, 399, my + 110, 530, my + 135, CONVERT_WHITE_TO_GREY); drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } */ if (options.joystick) { if (options.key_or_joy == 1) textprintf_ex(display, font, 400, my + 60, -1, -1, "CONTROLS - JOYSTICK"); else textprintf_ex(display, font, 400, my + 60, -1, -1, "CONTROLS - KEYBOARD"); } else { textprintf_ex(display, font, 400, my + 60, -1, -1, "NO JOYSTICK"); drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); rectfill(display, 399, my + 50, 530, my + 75, CONVERT_WHITE_TO_GREY); drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } // textprintf_ex(display, font, 5, 5, -1, -1, "%i", any_joystick_input()); my = 330; y2 = my + 7 + arena.just_got_highscore * 30; y3 = my + 29 + arena.just_got_highscore * 30; if (arena.just_got_highscore > 0) { rectfill(display, 0, y2 - 5, 250, y3, COL_COL3); rect(display, -1, y2 - 5 - 2, 250 + 2, y3 + 2, COL_COL4); } // textprintf_right_ex(display, font, 137, my, -1, -1, "HIGH"); // textprintf_ex(display, font, 157, my, -1, -1, "SCORES"); textprintf_centre_ex(display, font, 147, my, -1, -1, "HIGHSCORES"); textprintf_right_ex(display, font, 137, my + 40, -1, -1, "NORMAL"); textprintf_ex(display, font, 157, my + 40, -1, -1, "%i", options.highscore [0]); textprintf_right_ex(display, font, 137, my + 70, -1, -1, "HARD"); textprintf_ex(display, font, 157, my + 70, -1, -1, "%i", options.highscore [1]); textprintf_right_ex(display, font, 137, my + 100, -1, -1, "PUNISHMENT"); textprintf_ex(display, font, 157, my + 100, -1, -1, "%i", options.highscore [2]); textprintf_right_ex(display, font, 600, 570, -1, -1, "COPYRIGHT 2009 LINLEY HENZELL"); // should print last score here... anykey = 0; for (i = KEY_A; i < KEY_CAPSLOCK + 1; i ++) { if (key [i]) { anykey = 1; } } if (anykey == 0 && (options.joystick == 0 || any_joystick_input() == 0)) key_wait = 0; if (key_wait == 0) { if (menu_command(MC_UP)) { menu_select --; if (menu_select < 0) menu_select = MENU_EXIT; if (menu_select == MENU_JOY_OR_KEYS && options.joystick == 0) menu_select = MENU_JOY_OR_KEYS - 1; key_wait = 7; } if (menu_command(MC_DOWN)) { menu_select ++; if (menu_select > MENU_EXIT) menu_select = 0; if (menu_select == MENU_JOY_OR_KEYS && options.joystick == 0) menu_select = MENU_KEYS; key_wait = 7; } if (menu_command(MC_LEFT)) { // if (menu_select == 2) // arena.starting_level = 1; if (menu_select == MENU_JOY_OR_KEYS) { if (options.key_or_joy == 0) options.key_or_joy = 1; else options.key_or_joy = 0; } if (menu_select == MENU_DIFFICULTY) { arena.difficulty --; if (arena.difficulty < 0) arena.difficulty = 0; } key_wait = 7; } if (menu_command(MC_RIGHT)) { // if (menu_select == 2) // arena.starting_level = 2; if (menu_select == MENU_JOY_OR_KEYS) { if (options.key_or_joy == 0) options.key_or_joy = 1; else options.key_or_joy = 0; } if (menu_select == MENU_DIFFICULTY) { arena.difficulty ++; if (arena.difficulty > 2) arena.difficulty = 2; } key_wait = 7; } // if (key [KEY_ESC]) // exit(0); if (menu_command(MC_SELECT)) { if (menu_select == MENU_EXIT) { goodbye_menu_circles(); return; } if (menu_select == MENU_KEYS) { key_wait = 10; define_keys(); key_wait = 10; } if (menu_select == MENU_OPTIONS) { key_wait = 10; set_options(); key_wait = 10; } /* if (menu_select == MENU_CALIBRATE) { jstick_calibrate(); key_wait = 20; ticked = 0; }*/ if (menu_select == MENU_START) { arena.level = 1;//arena.starting_level; ticked = 0; key_wait = 30; if (ship_select() == 1) { vsync(); // clear_bitmap(screen); // clear_bitmap(display); player.type = PTYPE_BASIC; // player.type = PTYPE_BOMBER; // player.type = PTYPE_ANENOME; // player.type = PTYPE_HAND; player.weapon_level = 0; int ship_select = select_a_ship(); if (ship_select != -1) { switch(ship_select) { default: case 0: player.type = PTYPE_BASIC; break; case 1: player.type = PTYPE_ANENOME; break; case 2: player.type = PTYPE_BOMBER; break; case 3: player.type = PTYPE_HAND; break; case 4: player.type = PTYPE_SQUID; break; } if (arena.level == 1) arena.from_start = 1; else arena.from_start = 0; arena.cleared = 0; arena.unlocked = 0; menu_counter = 0; goodbye_menu_circles(); new_game(); game_loop(); if (arena.level == 4) congratulations(); arena.target_palette = PAL_MENU; arena.shift_palette = 2; init_menu_circles(); // reset_menu_palette(); key_wait = 10; // was 1 // flower_dir *= -1; ticked = 0; } } else key_wait = 20; } else key_wait = 20; } } else key_wait --; do { thing ++; } while (ticked == 0); ticked = 0; if (arena.shift_palette > 0 && menu_counter % 12 == 0) { run_palette_shift(); build_new_palette(0, 0, 0, 0); set_palette(palet); if (arena.shift_palette == 1) arena.shift_palette = 0; } vsync(); blit(display, screen, 0, 0, 100, 0, 600, 600); }; }
void RenderingManager::dimScreen(int percent) { drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); rectfill(m_backbuf, 0, 0, 640, 480, makeacol(0, 0, 0, getValueFromRange(0, 255, percent))); set_alpha_blender(); // the game assumes the graphics are left in this mode }
int main() { BITMAP *backbuffer = NULL, *mysha; int count = 0; int old_time = 0, old_time2 = 0; int depth; int i; int use_alleg = 0; allegro_init(); install_keyboard(); install_timer(); set_config_file("examples.cfg"); depth = get_config_int("examples", "depth", 16); set_color_depth(depth); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) { set_color_depth(16); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) { set_color_depth(15); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) { set_color_depth(32); if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0)) { allegro_message("Unable to set 640x480 screen mode!\n"); return -1; } } } } mysha = load_bitmap("mysha.pcx", NULL); if (!mysha) { set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Unable to load mysha.pcx. Copy it from the allegro examples directory.\n"); return -2; } backbuffer = create_bitmap(SCREEN_W, SCREEN_H); if (!backbuffer) { destroy_bitmap(mysha); set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); allegro_message("Not enough memory to create backbuffer.\n"); return -3; } LOCK_FUNCTION(the_timer); LOCK_VARIABLE(chrono); stretch_blit(mysha, backbuffer, 0, 0, mysha->w, mysha->h, 0, 0, SCREEN_W, SCREEN_H); for (i = 0; i < 4; i++) { fade[i].x = (SCREEN_W/2) * (i & 1); fade[i].y = (SCREEN_H/2) * (i & 2) >> 1; fade[i].fact = rand() & 255; fade[i].dir = (rand() & 1) ? 1 : -1; fade[i].src = create_sub_bitmap(backbuffer, fade[i].x, fade[i].y, SCREEN_W/2, SCREEN_H/2); fade[i].color = makecol((i & 1) * 255, ((i & 2) >> 1) * 255, 0); } install_int(the_timer, 1); old_time = chrono; while (!key[KEY_ESC]) { if (use_alleg) { stretch_blit(mysha, backbuffer, 0, 0, mysha->w, mysha->h, 0, 0, SCREEN_W, SCREEN_H); } textprintf(backbuffer, font, 0, 0, makecol(255, 255, 255), "%s %.2f fps (%.3f avg)", use_alleg ? "Using Allegro" : "Using FBlend", (chrono - old_time2) == 0 ? 1000.0 : 1000 / ((double)chrono - old_time2), count * 1000.0 / chrono); if (use_alleg) { drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); for (i = 0; i < 4; i++) { set_trans_blender(0, 0, 0, 255 - fade[i].fact); rectfill(fade[i].src, 0, 0, fade[i].src->w - 1, fade[i].src->h - 1, fade[i].color); } drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); } else { for (i = 0; i < 4; i++) { fblend_fade_to_color(fade[i].src, screen, fade[i].x, fade[i].y, fade[i].color, fade[i].fact); } } if (key[KEY_SPACE]) { use_alleg = !use_alleg; key[KEY_SPACE] = 0; chrono = 0; count = 0; old_time = 0; old_time2 = 0; } count++; old_time2 = chrono; /* Draw the buffer */ if (use_alleg) { blit(backbuffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } for (i = 0; i < 4; i++) { fade[i].fact += fade[i].dir; if (fade[i].fact >= 255 || fade[i].fact <= 0) fade[i].dir = -fade[i].dir; fade[i].fact = MID(0, fade[i].fact, 255); } } for (i = 0; i < 4; i++) { destroy_bitmap(fade[i].src); } destroy_bitmap(backbuffer); destroy_bitmap(mysha); return 0; }