static void ase_rectbox(BITMAP *bmp, int x1, int y1, int x2, int y2, int flags) { int bg, fg, top, bottom, aux; if (flags & D_DISABLED) { bg = makecol(192, 192, 192); fg = makecol(128, 128, 128); top = 255; bottom = 128; } else { bg = makecol(255, 255, 255); fg = makecol(0, 0, 0); top = 255; bottom = (flags & D_GOTFOCUS)? 224: 194; } if (flags & D_SELECTED) { aux = top; top = bottom; bottom = aux; } rect(bmp, x1, y1, x2, y2, fg); ase_rectedge(bmp, x1+1, y1+1, x2-1, y2-1, (flags & D_SELECTED)? makecol(128, 128, 128): makecol(255, 255, 255), (flags & D_SELECTED)? makecol(255, 255, 255): makecol(128, 128, 128)); ase_rectgouraud(bmp, x1+2, y1+2, x2-2, y2-2, top, bottom); if (flags & D_GOTFOCUS) { if (flags & D_SELECTED) ase_rectdotted(bmp, x1+3, y1+3, x2-2, y2-2, fg, bg); else ase_rectdotted(bmp, x1+2, y1+2, x2-3, y2-3, fg, bg); } }
Cutbit::Cutbit(const std::vector <BITMAP*>& vec) : bitmap(0), xl(0), yl(0), x_frames(0), y_frames(0) { if (vec.empty()) return; else if (vec.size() == 1) { bitmap = create_bitmap(vec[0]->w, vec[0]->h); if (bitmap) { xl = bitmap->w; yl = bitmap->h; x_frames = 1; y_frames = 1; ::blit(vec[0], bitmap, 0, 0, 0, 0, bitmap->w, bitmap->h); } // do not cut } else { xl = vec[0]->w; yl = vec[0]->h; for (std::vector <BITMAP*> ::const_iterator itr = vec.begin(); itr != vec.end(); ++itr) if ((*itr)->w != xl || (*itr)->h != yl) return; x_frames = vec.size(); y_frames = 1; bitmap = create_bitmap((xl+1) * vec.size() + 1, yl + 2); if (bitmap) { clear_to_color(bitmap, makecol(127, 0, 127)); for (int fr = 0; fr < (int) vec.size(); ++fr) { ::blit(vec[fr], bitmap, 0, 0, (xl+1)*fr+1, 1, xl, yl); // Do not cut, all important things from cut_bitmap are done } } } }
void Level::draw(BITMAP *bmp) { // textprintf(bmp, font, 0, 8, makecol(255, 255, 255), "%02fx%02f", m_scroll.x, m_scroll.y); clear_to_color(bmp, makecol(0, 180, 190)); BITMAP *bg1 = MEDIA_BITMAP(BG_PCX); BITMAP *bg2 = MEDIA_BITMAP(BG2_PCX); BITMAP *bg3 = MEDIA_BITMAP(BG3_PCX); draw_bg(bmp, bg1, -m_scroll.x/3, m_h*TILE_H-m_scroll.y-bg1->h-8); draw_bg(bmp, bg2, -m_scroll.x/2, m_h*TILE_H-m_scroll.y-bg2->h); draw_bg(bmp, bg3, -m_scroll.x/4, -m_scroll.y); int i, j, x, y, outx, outy; int x1, y1, x2, y2; get_first_visible_tile(x1, y1); x2 = x1 + LEVEL_W; y2 = y1 + LEVEL_H; outy = static_cast<int>(-std::fmod(std::floor(m_scroll.y), TILE_H)); for (y=y1; y<=y2; ++y) { outx = static_cast<int>(-std::fmod(std::floor(m_scroll.x), TILE_W)); for (x=x1; x<=x2; ++x) { if (x < 0 || x >= m_w || y < 0 || y >= m_h) break; Tile bg = m_tiles_bg[y*m_w+x]; Tile fg = m_tiles_fg[y*m_w+x]; Level::draw_tile(bmp, bg, outx, outy); Level::draw_tile(bmp, fg, outx, outy); outx += TILE_W; } outy += TILE_W; } }
void Hook2::animate_ropeseg( Frame *space, Vector2 pos1, Vector2 pos2, int ropecol ) { STACKTRACE; int ix1, iy1, ix2, iy2; Vector2 co; co = corner(pos1); ix1 = int(co.x); iy1 = int(co.y); co = corner(pos2); ix2 = int(co.x); iy2 = int(co.y); int dx, dy; dx = iround(min_delta(ix2, ix1, map_size.x)); dy = iround(min_delta(iy2, iy1, map_size.y)); ix2 = ix1 + dx; iy2 = iy1 + dy; // simulate visibility of a glittering line in the sun ... double a, colscale; a = atan2((float)dy,(float)dx); colscale = fabs(sin(a)); // flat lying = less visible. int col, r, g, b; col = ropecol; r = iround(getr(col) * colscale); g = iround(getg(col) * colscale); b = iround(getb(col) * colscale); col = makecol(r, g, b); // draw the line line(space->surface, ix1, iy1, ix2, iy2, col); space->add_line(ix1, iy1, ix2, iy2); }
/* Nom : america Entrées : Sorties : Date de dernière modification : 28/04 Nature de la dernière modification : création Version : 1.0 */ void america(BITMAP* img[BMP_NB],t_hero tab[MAX_HERO],t_game* level, int x, int i, int nb,SAMPLE* son[SON_NB]) { int blanc = makecol(255,255,255); // plateforme int anim_here = 11; int max_here = 13; if (anim_here + nb < max_here) { if (x > tab[i].x) masked_blit(img[anim_here+nb], img[7], 0,0, tab[i].x, tab[i].y, img[anim_here+nb]->w, img[anim_here+nb]->h); else draw_sprite_h_flip(img[7], img[anim_here], tab[i].x, tab[i].y); sound(son,level,7); } if (anim_here + nb == max_here) { if (x > tab[i].x) masked_blit(img[13], level->fore, 0,0, tab[i].x, tab[i].y, img[13]->w, img[13]->h); else draw_sprite_h_flip(level->fore, img[13], tab[i].x, tab[i].y); rectfill(level->collision, tab[i].x-10, tab[i].y-10, tab[i].x + img[anim_here+nb]->w , tab[i].y + img[anim_here+nb]->h, blanc); tab[i].transformation = 2; tab[i].activated = 0; } }
/* draws the spline paths */ void draw_splines(void) { int i; acquire_screen(); clear_to_color(screen, makecol(255, 255, 255)); textout_centre_ex(screen, font, "Spline curve path", SCREEN_W/2, 8, palette_color[255], palette_color[0]); textprintf_centre_ex(screen, font, SCREEN_W/2, 32, palette_color[255], palette_color[0], "Curviness = %.2f", fixtof(curviness)); textout_centre_ex(screen, font, "Up/down keys to alter", SCREEN_W/2, 44, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "Space to walk", SCREEN_W/2, 68, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "C to display control points", SCREEN_W/2, 92, palette_color[255], palette_color[0]); textout_centre_ex(screen, font, "T to display tangents", SCREEN_W/2, 104, palette_color[255], palette_color[0]); for (i=1; i<node_count-2; i++) draw_spline(nodes[i], nodes[i+1]); for (i=1; i<node_count-1; i++) { draw_node(i); if (show_tangents) { line(screen, nodes[i].x - fixtoi(fixcos(nodes[i].tangent) * 24), nodes[i].y - fixtoi(fixsin(nodes[i].tangent) * 24), nodes[i].x + fixtoi(fixcos(nodes[i].tangent) * 24), nodes[i].y + fixtoi(fixsin(nodes[i].tangent) * 24), palette_color[1]); } } release_screen(); }
void CGame::AddPlayers(){ int i; //loop counter srand(time(NULL)); // seed random for colors int limit = 255; //used to when getting a random number between 0 and 255-1 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0); //display copyright crap printf("Scarbble v1, Copyright (C) 2001 Joshua Stewart\n" "Scarbble comes with ABSOLUTELY NO WARRANTY;\n" "This is free software, and you are welcome to\n" "redistribute it under certain conditions.\n\n"); printf("\n\nPlease enter the number of players [2-4]: "); fflush(stdin); scanf("%d",&numplayers); //check valid number of players while (numplayers < 2 || numplayers > 4) { printf("\n\tScarbble requires between 2 to 4 players.."); printf("\n\nPlease enter the number of players [2-4]: "); fflush(stdin); //dodgy as hell.. you shouldnt fflush input streams..my bad :( scanf("%d",&numplayers); } for (i=0; i<numplayers;i++) { printf("\n\n\tPlease enter player %d's name: ",i+1); fflush(stdin); scanf("%21[^\n]",players[i].name); // generate a random color for the player // we cant do this in the player constructor because allegro isnt initialised at that point players[i].color = makecol(rand()%limit,rand()%limit,rand()%limit); } }
void color_poly_sideways2( BITMAP *bmp, polytype *poly, float x, float y, float z ){ float half_w=bmp->w/2; float half_h=bmp->h/2; int i ; int *pt; pt = malloc(sizeof(int) * poly->pts ); set_trans_blender( 0,0,0, poly->a ); 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; } polygon( bmp, poly->pts/2, pt, makecol(poly->r,poly->g,poly->b) ); free(pt); }
void draw_all_stations(station *stacje, int n, BITMAP *bufor) { for (int i = 0; i < n; i++) { if (!stacje[i].zywa) continue; clear_to_color(stacje[i].budynek_rot, makecol(255, 0, 255)); rotate_sprite(stacje[i].budynek_rot, stacje[i].budynek, (stacje[i].budynek_rot->w - stacje[i].budynek->w) / 2, (stacje[i].budynek_rot->h - stacje[i].budynek->h) / 2, itofix((int) (256.0 * stacje[i].a / (2.0 * pi)))); masked_blit(stacje[i].budynek_rot, bufor, 0, 0, ex(stacje[i].h * sin(stacje[i].a)) / 2 - stacje[i].budynek_rot->w / 2, ey(stacje[i].h * cos(stacje[i].a)) / 2 - stacje[i].budynek_rot->h / 2, stacje[i].budynek_rot->w, stacje[i].budynek_rot->h); } }
void optionsScreen::draw() { clear(infoImg->getBitmap()); // output the string to the screen textout(infoImg->getBitmap(), font, edittext.c_str(), 0, 10, makecol(255,255,255)); // output some stats using Allegro's printf functions textprintf(infoImg->getBitmap(), font, 0, 20, makecol(255,255,255), "length: %d", edittext.length()); textprintf(infoImg->getBitmap(), font, 0, 30, makecol(255,255,255), "capacity: %d", edittext.capacity()); textprintf(infoImg->getBitmap(), font, 0, 40, makecol(255,255,255), "empty?: %d", edittext.empty()); if(insert) textout(infoImg->getBitmap(), font, "Inserting", 0, 50, makecol(255,255,255)); else textout(infoImg->getBitmap(), font, "Replacing", 0, 50, makecol(255,255,255)); // draw the caret vline(infoImg->getBitmap(), caret * 8, 8, 18, makecol(255,255,255)); renderer.blitToScreen(); }
void interfaceHighScore::displayHighScore() { // Buffer hsBackground BITMAP *buffer; buffer = create_bitmap(640, 480); draw_sprite(buffer, this->hsBackground, 0, 0); // Display highscore title. textout_centre_ex(buffer, this->hsFont, "SKOR TERTINGGI", 320, 50, makecol(0,0,0), -1); // Iterate highScoreData, display each name and score list<score *>::iterator it = this->highScoreData.begin(); for(int i=0; i < this->highScoreData.size(); i++) { // Display each name textprintf_ex(buffer, this->hsFont, HIGHSCORE_ITEM_START_X, HIGHSCORE_ITEM_START_Y + i * HIGHSCORE_ITEM_HEIGHT, makecol(255,255,255), -1, (*it)->readPlayerName().c_str()); textprintf_ex(buffer, this->hsFont, HIGHSCORE_ITEM_START_X + HIGHSCORE_SCORENUMBER, HIGHSCORE_ITEM_START_Y + i * HIGHSCORE_ITEM_HEIGHT, makecol(255,255,255), -1, "%05d", (*it)->readScore()); ++it; } blit(buffer, screen, 0, 0, 0, 0, 640, 480); }
// print board void printbd(int *board) { int i; scare_mouse(); line(screen, 20, 20, 420, 20, makecol(0, 0, 0)); line(screen, 20, 20, 20, 420, makecol(0, 0, 0)); line(screen, 420, 20, 420, 420, makecol(0, 0, 0)); line(screen, 20, 420, 420, 420, makecol(0, 0, 0)); // vertical lines for (i = 0; i < 8; ++i) line(screen, 70 + 50*i, 20, 70 + 50*i, 420, makecol(0, 0, 0)); // horizontal lines for (i = 0; i < 8; ++i) line(screen, 20, 70 + 50*i, 420, 70 + 50*i, makecol(0, 0, 0)); // pieces for (i = 0; i < 100; ++i) { if (board[i] == 1) { circlefill(screen, 50*file(i), 45 + 50*rank(i), 15, makecol(0, 0, 0)); } if (board[i] == -1) { circlefill(screen, 50*file(i), 45 + 50*rank(i), 15, makecol(255, 255, 255)); } } unscare_mouse(); }
int main( void ) { /* first, set up Allegro and the graphics mode */ allegro_init(); /* initialize Allegro */ install_keyboard(); /* install the keyboard for Allegro to use */ install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL ); set_color_depth( 16 ); /* set the color depth to 16-bit */ set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */ ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */ bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */ buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */ boing = load_sample( "boing.wav" ); /* load the sound file */ ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */ ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */ barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */ barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */ srand( time( NULL ) ); /* seed the random function ... */ direction = rand() % 4; /* and then make a random initial direction */ while ( !key[KEY_ESC] )/* until the escape key is pressed ... */ { moveBall(); /* move the ball */ respondToKeyboard(); /* respond to keyboard input */ /* now, perform double buffering */ clear_to_color( buffer, makecol( 255, 255, 255 ) ); blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h ); blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h ); blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h ); blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h ); clear_bitmap( buffer ); } /* end while */ destroy_bitmap( ball ); /* destroy the ball bitmap */ destroy_bitmap( bar ); /* destroy the bar bitmap */ destroy_bitmap( buffer ); /* destroy the buffer bitmap */ destroy_sample( boing ); /* destroy the boing sound file */ return 0; } /* end function main */
void SplashScreen::draw(BITMAP* dest) { clear_to_color(dest, makecol(255,255,255)); if (mFrameCounter > 50 && mFrameCounter <= 100) { float l = ((100 - mFrameCounter) * (100 - mFrameCounter)) / (50.0 * 50.0); int w = mDarkbitsLogoBitmap->w * (1 + 20 * l); int h = (mDarkbitsLogoBitmap->h * mDarkbitsLogoBitmap->w) / w; masked_stretch_blit(mDarkbitsLogoBitmap, dest, 0, 0, mDarkbitsLogoBitmap->w, mDarkbitsLogoBitmap->h, 160 - w / 2, 120 - h / 2, w, h); } if (mFrameCounter > 100) { int w = mDarkbitsLogoBitmap->w; int h = (mDarkbitsLogoBitmap->h * mDarkbitsLogoBitmap->w) / w; masked_stretch_blit(mDarkbitsLogoBitmap, dest, 0, 0, mDarkbitsLogoBitmap->w, mDarkbitsLogoBitmap->h, 160 - w / 2, 120 - h / 2, w, h); } }
BITMAP *set_screen(int fullscreen) { const unsigned char vgargb[16][3] = { 0, 0, 0, /* 0 black */ 170, 0, 0, /* 1 red */ 0,170, 0, /* 2 green */ 170, 85, 0, /* 3 yellow */ 0, 0,170, /* 4 blue */ 170, 0,170, /* 5 magenta */ 0,170,170, /* 6 cyan */ 170,170,170, /* 7 white */ 85, 85, 85, 255, 85, 85, 85,255, 85, 255,255, 85, 85, 85,255, 255, 85,255, 85,255,255, 255,255,255 }; const unsigned char *rgb; if (!setgfxmode(fullscreen)) exit(1); clear_bitmap(screen); if (set_display_switch_callback(SWITCH_IN, got_focus_back) == -1) set_display_switch_mode(SWITCH_PAUSE); BITMAP *bmp = create_bitmap(8 * term_width, 400); clear_bitmap(bmp); set_clip_state(bmp, 0); set_clip_state(screen, 0); int i; for (i=0; i<16; i++) { rgb = &vgargb[i][0]; vgacolors[i] = makecol(rgb[0], rgb[1], rgb[2]); } return bmp; }
//this thread updates sprite 0 void* wormdraw_thread(void* data) { //get this thread id int my_thread_id = *((int*)data); //thread's main loop while(!GAMEOVER) { if(old_ticks>ticks) { //lock the mutex to protect variables if (pthread_mutex_lock(&threadsafe)) textout_ex(buffer,font,"ERROR: thread mutex was locked",0,0,WHITE,0); if(sprhandler->getbugs(my_thread_id)->alive==true) { //draw the sprites sprhandler->getbugs(my_thread_id)->drawframe(buffer); if(SHOWHEALTH==true) { textprintf_ex(buffer,font,sprhandler->getbugs(my_thread_id)->x, sprhandler->getbugs(my_thread_id)->y-5, makecol(255,0,0),-1,"%d",sprhandler->getbugs(my_thread_id)->health); } } //unlock the mutex if (pthread_mutex_unlock(&threadsafe)) textout_ex(buffer,font,"ERROR: thread mutex unlock error",0,0,WHITE,0); } } // terminate the thread pthread_exit(NULL); return NULL; }
void TileMap::drawFlags(BITMAP* dest, int x, int y, int flags) { if (flags & SOLID) { rect(dest, x, y, x + 15, y + 15, makecol(0, 0, 0)); rect(dest, x + 1, y + 1, x + 14, y + 14, makecol(255, 255, 255)); rect(dest, x + 2, y + 2, x + 13, y + 13, makecol(0, 0, 0)); } if (flags & PLATFORM) { rect(dest, x, y, x + 15, y + 3, makecol(0, 0, 0)); hline(dest, x + 1, y + 1, x + 14, makecol(255, 255, 255)); } if (flags & ICE) { rect(dest, x + 7, y + 3, x + 9, y + 12, makecol(0, 0, 0)); vline(dest, x + 8, y + 4, y + 11, makecol(0, 255, 255)); } }
void PrimaryWindow::RenderScoreIndicator() { const int fontWidth = 8; const int fontHeight = 14; const int fontSpacing = 2; const int letterWidth = fontWidth + fontSpacing; const int numberOfDigitsToDisplay = 8; const int digitBufferSize = numberOfDigitsToDisplay + 1; const int indicatorWidth = letterWidth * numberOfDigitsToDisplay; const int xOffset = (SCREEN_W / 2) - (indicatorWidth / 2); const int yOffset = (SCREEN_H - 18) + (9 - (fontHeight / 2)); const int scoreColor = makecol(255, 255, 255); char scoreDigitBuffer[digitBufferSize]; snprintf(scoreDigitBuffer, digitBufferSize, "%08d", playerScore_); for (int i = 0, xPos = xOffset; i < numberOfDigitsToDisplay; i++) { int digit = (int)scoreDigitBuffer[i]; this->RenderDigit(digit - 48, xPos, yOffset, fontWidth, fontHeight, scoreColor); xPos += letterWidth; } }
bool PrimaryWindow::LoadContentForPlayerShot() { // the shot is dead by default playerShotAlive_ = false; // the player's shots have a 4 pixel radius playerShotRadius_ = 4; // the player fires cyan shots playerShotColor_ = makecol(0, 255, 255); // position the shot at the top-center of the player's ship playerShotX_ = playerX_ + (playerWidth_ / 2); // reset its Y position to the top of the player playerShotY_ = (float)(playerY_ - playerShotRadius_); // shot velocity is set once // all shots are fired at 20 pixels per frame playerShotDY_ = 20.0f; return true; }
/** * Returns a custom color for bullets * * @param int : 0 or 1 or 2 */ int Item::get_color(int index, int n) { int cr = 0, cg = 0, cb = 0; int _type = index; switch (n){ case 0: cr = obdata_get_array_int(_type, "bulletRGB", 0); cg = obdata_get_array_int(_type, "bulletRGB", 1); cb = obdata_get_array_int(_type, "bulletRGB", 2); break; case 1: cr = obdata_get_array_int(_type, "glowRGB", 0); cg = obdata_get_array_int(_type, "glowRGB", 1); cb = obdata_get_array_int(_type, "glowRGB", 2); break; case 2: cr = obdata_get_array_int(_type, "trailRGB", 0); cg = obdata_get_array_int(_type, "trailRGB", 1); cb = obdata_get_array_int(_type, "trailRGB", 2); break; } return makecol(cr,cg,cb); }
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 c_node::draw_allegro (c_drawtarget &drawtarget, c_layer &layer_any) { auto layer = dynamic_cast<c_layer_allegro&>(layer_any); BITMAP *frame = layer.m_frame; const auto & gui = * drawtarget.m_gui; const int vx = gui.view_x(m_x), vy = gui.view_y(m_y); // position in viewport - because camera position c_osi2_switch::draw_allegro (drawtarget, layer_any); auto color = makecol(0,0,64); // TODO is this ok? _UNUSED(color); //////////////////////////////////////////////////////////////////// if (layer.m_layer_nr == e_layer_nr_object) { //BITMAP *fg1; //const char *file1; //file1 = "dat/server_48x48.png"; //set_color_conversion(COLORCONV_NONE); //fg1 = load_png(file1, NULL); // TODO: optmize/cache and share across objects set_alpha_blender(); draw_trans_sprite(frame, c_bitmaps::get_instance().m_node, vx - c_bitmaps::get_instance().m_node->w / 2, vy - c_bitmaps::get_instance().m_node->h / 2); } //////////////////////////////////////////////////////////////////// }
const iq::tile_ptr tilemap::void_tile(std::map<std::string, iq::tile_ptr> &tiles) const { iq::BITMAP_ptr bitmap; std::map<std::string, iq::tile_ptr>::iterator it; std::string k = "void:-1"; iq::tile_ptr tile; if((it = tiles.find(k)) != tiles.end()) return it->second; bitmap.reset(create_bitmap(this->tilesize, this->tilesize), destroy_bitmap); if(bitmap.get() == NULL) throw std::runtime_error("Failed to allocate void tile."); rectfill(bitmap.get(), 0, 0, this->tilesize, this->tilesize, makecol(255, 0, 255)); tile.reset(new iq::tile(bitmap)); tiles[k] = tile; return tile; }
void Intro::onDraw( BITMAP* aBuffer ) { if (myTextsIndex == 11 && myFrameCounter < 100) { if (myFrameCounter % 5 == 0) { clear_to_color(aBuffer, makecol(rand() % 255, rand() % 255, rand() % 255)); } if (myFrameCounter % 20 == 0) { Sound::playSample("data/sounds/grenadeexplode.wav"); } } else { clear_to_color(aBuffer, 0); if (myTextsIndex < myTexts.size()) { myFont->drawCenter(aBuffer, myTexts[myTextsIndex], 0, 0, 320, 240, myTextsCharecter); } } }
int obtention_couleurblindee(t_listePerso *lp)// ni noire ni magenta ni d'une autre couleur d'une hitbox déjà existante { int couleur,probleme; int i; do { probleme=0; couleur=makecol(1+rand()%255,1+rand()%255,1+rand()%255); for (i=0; i<MAXI; i++) { if (lp->perso[i]!=NULL) { if (couleur == lp->perso[i]->color) // si la couleur qu'on crée existe déjà { probleme=1; } } } } while(probleme==1); return couleur; }
int main() { int exit = 0; VEC2F a = vec2f(100.0, 100.0), b = vec2f(200.0, 120.0), c = vec2f(140.0, 300.0), p; init(); while(!exit) { if(keypressed()) { if(key[KEY_ESC]) { exit = 1; } } clear_to_color(buffer, 0); vec2f_line(buffer, a, b, makecol(255, 255, 255)); vec2f_line(buffer, b, c, makecol(255, 255, 255)); vec2f_line(buffer, c, a, makecol(255, 255, 255)); p = vec2f(mouse_x, mouse_y); VEC2F vab = VEC2F_DIFF(b, a), vac = VEC2F_DIFF(c, a), vap = VEC2F_DIFF(p, a); VEC2F vbc = VEC2F_DIFF(c, b), vbp = VEC2F_DIFF(p, b); float ab = VEC2F_DOT_PRODUCT(vab, vab), ac = VEC2F_DOT_PRODUCT(vac, vac), bc = VEC2F_DOT_PRODUCT(vbc, vbc); float k1 = VEC2F_DOT_PRODUCT(vab, vap), k2 = VEC2F_DOT_PRODUCT(vac, vap), k3 = VEC2F_DOT_PRODUCT(vbc, vap); if(k1 > 0.0 && k1 < ab && k2 > 0.0 && k2 < ac && k3 > 0.0 && k3 < bc) vec2f_point(buffer, p, 3, makecol(0, 255, 0)); else vec2f_point(buffer, p, 3, makecol(255, 0, 0)); vec2f_point(buffer, b, 3, makecol(0, 0, 255)); vec2f_point(buffer, c, 3, makecol(0, 0, 255)); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } destroy_bitmap(buffer); return 0; }
int main() { allegro_init(); install_keyboard(); set_color_depth( 32 ); set_gfx_mode( GFX_AUTODETECT_WINDOWED, 800, 600, 0, 0 ); clear_to_color( screen, makecol( 128, 128, 128 ) ); BITMAP * ludek = NULL; ludek = load_bmp( "Ok.bmp", default_palette ); if( !ludek ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie mogê za³adowaæ obrazka Ludek !" ); allegro_exit(); return 0; } blit( ludek, screen, 0, 0, 100, 100, ludek->w, ludek->h ); readkey(); destroy_bitmap( ludek ); allegro_exit(); return 0; }
//**************************************************************************************************************** int main() { allegro_init(); //zainicjowanie biblioteki allegro install_keyboard(); //aktywowanie klawiatury set_color_depth( 16 ); //ustawienie glebi kolorow na 16 bitow set_gfx_mode( GFX_AUTODETECT_WINDOWED, 1200, 800, 0, 0 ); //utworzenie okna o rozmiarze 1200x800 clear_to_color( screen, makecol( 128, 128, 128 ) ); //wyczyszczenie tla BITMAP * bufor=NULL; //utworzenie wskaźnika na bitmape naszego bufora bufor = create_bitmap( 1200, 800 ); //stworzenie bitmapy bufora o wielkosci naszego okna if( !bufor ){ //jesli sie nie udalo set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "Nie moge utworzyc bufora !" ); allegro_exit(); //zamykamy allegro return 0; //i konczymy dzialanie aplikacji } while(true){ // Glówna petla aplikacji int wskaz=menu(bufor); // wywolanie funkcji menu() i zapamietanie zwroconej przez nia wartosci if(wskaz==1){ //jesli menu() zwrocilo 1 startujemy gre if(game(bufor)){ //jesli gra zwroci jakis blad destroy_bitmap(bufor); allegro_exit(); //zamykamy allegro return 0; //i konczymy dzialanie aplikacji } }else if (wskaz==2){ //jesli menu() zwrocilo 2 o_grze(bufor); //wyswietlamy info o grze }else if (wskaz==3){ //jesli menu() zwrocilo 3 break; //konczymy glowna petle } } destroy_bitmap(bufor); //po skonczeniu glownej petli sprzatamy po sobie i konczymy allegro_exit(); return 0; }
void Configure(void) { clear(buffer); Widget configure_widgets[] = { { WIDGET_TEXT, ALIGN_CENTER, 95, 20, 0, 0, "Configuration", 0, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_TEXTBUTTON, ALIGN_CENTER, 95, 60, 0, 0, "Game Options", -1, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_TEXTBUTTON, ALIGN_CENTER, 95, 80, 0, 0, "Controls", -1, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_TEXTBUTTON, ALIGN_CENTER, 95, 100, 0, 0, "Graphics", -1, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_TEXTBUTTON, ALIGN_CENTER, 95, 120, 0, 0, "Sound", -1, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_BUTTON, ALIGN_CENTER, 95, 160, -1, 0, "OK", -1, -1, -1, -1, NULL, NULL, NULL, 0 }, { WIDGET_END, } }; int ret = 0; while (ret != 5 && ret >= 0) { configure_widgets[0].d1 = makecol(255, 255, 0); ret = GUI_Go(400-95, 300-105, 190, 210, configure_widgets, 1, 0); switch (ret) { case 1: ConfigureGameOptions(); break; case 2: ConfigureControls(); break; case 3: ConfigureGraphics(); break; case 4: ConfigureSound(); break; default: break; } } }
void GuiFrame::drawFrameImage(BITMAP *bmp, short frame_id) { FRAME_MASK *thisFrame = getFrameByID(frame_id); string title; if (thisFrame->state == FRAME_ACTIVE) title = thisFrame->label; else title = thisFrame->label; masked_stretch_blit((BITMAP*)resources.data[TOP].dat, bmp, 0, 0, 116, 4, thisFrame->x, thisFrame->y, thisFrame->w, 4); masked_stretch_blit((BITMAP*)resources.data[BOTTOM].dat, bmp, 0, 0, 116, 4, thisFrame->x, thisFrame->y+thisFrame->h-4, thisFrame->w, 4); masked_stretch_blit((BITMAP*)resources.data[LEFT].dat, bmp, 0, 0, 4, 120, thisFrame->x, thisFrame->y, 4, thisFrame->h); masked_stretch_blit((BITMAP*)resources.data[RIGHT].dat, bmp, 0, 0, 4, 120, thisFrame->x + thisFrame->w-4, thisFrame->y, 4, thisFrame->h); masked_blit((BITMAP*)resources.data[UP_LEFT].dat, bmp, 0, 0, thisFrame->x, thisFrame->y, 5, 5); masked_blit((BITMAP*)resources.data[UP_RIGHT].dat, bmp, 0, 0, thisFrame->x+thisFrame->w-5, thisFrame->y, 5, 5); masked_blit((BITMAP*)resources.data[DOWN_LEFT].dat, bmp, 0, 0, thisFrame->x, thisFrame->y+thisFrame->h-5, 5, 5); masked_blit((BITMAP*)resources.data[DOWN_RIGHT].dat, bmp, 0, 0, thisFrame->x+thisFrame->w-5, thisFrame->y+thisFrame->h-5, 5, 5); masked_stretch_blit((BITMAP*)resources.data[BAR].dat, bmp, 0, 0, 285, 14, thisFrame->x+4, thisFrame->y+4, thisFrame->w-8, 16); /* drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0); rectfill(bmp, thisFrame->x+4, thisFrame->y+20, thisFrame->w-8, thisFrame->y+thisFrame->h-5, makecol(180,180,180)); drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0); */ textprintf_ex(bmp, font, thisFrame->x+10, thisFrame->y+8, makecol(255, 255, 255), -1, "%s", title.c_str()); }