void draw_tank (Sint16 x, Sint16 y, Uint8 color, Sint16 tank_cannon_angle, Sint16 zoom) { Sint16 x_rel = x - world_up_x; Sint16 y_rel = y - world_up_y; Sint16 tank_x1 = (x_rel * zoom) + (zoom / 4); Sint16 tank_y1 = (y_rel * zoom) + (zoom / 4); Sint16 tank_x2 = (x_rel * zoom) + (zoom - (zoom / 4)); Sint16 tank_y2 = (y_rel * zoom) + (zoom - (zoom / 4)); Sint16 tank_left_chain_x = tank_x1 - (zoom / 8); Sint16 tank_right_chain_x = tank_x2 + (zoom / 8); Sint16 tank_cannon_x = tank_x1 + (tank_x2 - tank_x1) / 2; Sint16 tank_cannon_y = tank_y1 + (tank_y2 - tank_y1) / 2; Sint16 tank_cannon_width = zoom / 8; Sint16 tank_cannon_length = zoom; /* draw tank */ boxRGBA (screen, tank_x1, tank_y1, tank_x2, tank_y2, unit_color[color].r, unit_color[color].g, unit_color[color].b, 255); boxRGBA (screen, tank_left_chain_x, tank_y1, tank_x1, tank_y2, 0, 0, 0, 255); boxRGBA (screen, tank_right_chain_x, tank_y1, tank_x2, tank_y2, 0, 0, 0, 255); filledCircleRGBA (screen, tank_cannon_x, tank_cannon_y, tank_cannon_width, 0, 0, 0, 255); draw_line_rotated (screen, tank_cannon_x, tank_cannon_y, tank_cannon_length, tank_cannon_angle, tank_cannon_width / 2, 0, 0, 0); update_screen (); }
void module::draw(SDL_Surface *screen, int x, int y) { boxRGBA(screen, x, y+10, x+w, y+h, 50, 50, 50, 255); boxRGBA(screen, x, y, x+w, y+10, 0, 0, 0, 255); th.paint_text_center(x+w/2, y, name, screen); }
int main() { int w = 1024; int h = 768; int bpp = 24; int ticks; int frame_delay = 0; int blit_delay = 0; int draw_delay = 0; int frames = 0; SDL_Surface *screen; SDL_Surface *input; SDL_Surface *img; putenv("SDL_VIDEO_WINDOW_POS"); putenv("SDL_VIDEO_CENTERED=1"); if(SDL_Init(SDL_INIT_VIDEO) < 0 || !SDL_GetVideoInfo()) { error("SDL_init"); return -1; } /* Create base screen. */ screen = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE | SDL_DOUBLEBUF); input = SDL_DisplayFormatAlpha(SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32, 0, 0, 0, 0)); //img = SDL_DisplayFormatAlpha(IMG_Load("Missiles.jpg")); printf("Created video screen %dx%d@%dbpp in %s mode.\n", screen->w, screen->h, screen->format->BitsPerPixel, screen->flags & SDL_HWSURFACE ? "hardware" : "software"); BlitTest(screen); boxRGBA(input, 0, 0, 600, 600, 0xff, 0, 0, 0xf0); while (1) { if (!(frames % 10)) { printf("%d - Frame: %d Blit: %d\n", frames, frame_delay / 10, blit_delay / 10); fflush(stdout); frame_delay = 0; blit_delay = 0; if (frames == 300) exit(0); } ticks = SDL_GetTicks(); int x; // for (x = 0; x < 500; x++) { boxRGBA(screen, 0, 0, w, h, 0xff, 0, 0, 0xff); // } // SDL_BlitSurface(input, NULL, screen, NULL); //SDL_BlitSurface(img, NULL, screen, NULL); blit_delay += SDL_GetTicks() - ticks; ticks = SDL_GetTicks(); SDL_Flip(screen); //SDL_UpdateRect(screen, 0, 0, 0, 0); frame_delay += SDL_GetTicks() - ticks; frames++; } }
// This is the emulator's version of WriteLights. The output window is updated // here. TODO: Reparameterize -> PIXELS_PER_ARM should come from (gData->size / 2). void UpdateEmuOutput(galaxyData_t *gData, outputMapping_e map) { // Vars int i; // A word on mapping... Layouts below are described as left to right. // pixelMap is generated as 20 .. 0, 21 .. 41 // gData is 0 .. 41 in FULL, and 0 .. 20, 20 .. 0 in MIRROR. if (map == MAP_MIRROR) { // Mirrored output. for (i = 0; i < PIXELS_PER_ARM ; i++) { // Pixmap 0 .. 20. gData 20 .. 0 boxRGBA(sdlRenderer, pixelMap[i].x - PIX_SIZE, pixelMap[i].y - PIX_SIZE, pixelMap[i].x + PIX_SIZE, pixelMap[i].y + PIX_SIZE, gData->pixels[PIXELS_PER_ARM - i - 1]->r, gData->pixels[PIXELS_PER_ARM - i - 1]->g, gData->pixels[PIXELS_PER_ARM - i - 1]->b, 255); // Pixmap 21 .. 41. gData 20 .. 0 boxRGBA(sdlRenderer, pixelMap[i + PIXELS_PER_ARM].x - PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].y - PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].x + PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].y + PIX_SIZE, gData->pixels[PIXELS_PER_ARM - i - 1]->r, gData->pixels[PIXELS_PER_ARM - i - 1]->g, gData->pixels[PIXELS_PER_ARM - i - 1]->b, 255); } } else { // Full output. for (i = 0; i < PIXELS_PER_ARM ; i++) { // Pixmap 0 .. 20. gData 20 .. 0 boxRGBA(sdlRenderer, pixelMap[i].x - PIX_SIZE, pixelMap[i].y - PIX_SIZE, pixelMap[i].x + PIX_SIZE, pixelMap[i].y + PIX_SIZE, gData->pixels[PIXELS_PER_ARM - i - 1]->r, gData->pixels[PIXELS_PER_ARM - i - 1]->g, gData->pixels[PIXELS_PER_ARM - i - 1]->b, 255); // Pixmap 21 .. 41. gData 21 .. 41 boxRGBA(sdlRenderer, pixelMap[i + PIXELS_PER_ARM].x - PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].y - PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].x + PIX_SIZE, pixelMap[i + PIXELS_PER_ARM].y + PIX_SIZE, gData->pixels[PIXELS_PER_ARM + i]->r, gData->pixels[PIXELS_PER_ARM + i]->g, gData->pixels[PIXELS_PER_ARM + i]->b, 255); } } // Render the scene to the window. SDL_RenderPresent(sdlRenderer); // Set the timer to emulate the serial transmission time. DelayMS((int) PACKET_TIME); }
void Game::UpdateDisplay() { //Draw background m_Background.DrawBackground(); #ifdef DRAW_BOARD_BACKGROUND #ifdef DRAW_EACH_SPOT int nWidth = GetGravnixBoardWidth(m_Gravnix), nHeight = GetGravnixBoardHeight(m_Gravnix); for(int nX=0; nX<nWidth; nX++) { for(int nY=0; nY<nHeight; nY++) { int nType = GetGravnixSpotValue(m_Gravnix, nX, nY); if( nType == 0 ) nType = GetGravnixBoardValue(m_Gravnix, nX, nY); if( nType == 0 ) { int x = m_BoardMetrics.GetXPos(nX), y = m_BoardMetrics.GetYPos(nY), nPieceSize = m_BoardMetrics.GetPieceSize(); boxRGBA(m_pScreen, x, y, x+nPieceSize, y+nPieceSize, GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B, 230); } } } #else boxRGBA(m_pScreen, m_BoardMetrics.GetLeft(), m_BoardMetrics.GetTop(), m_BoardMetrics.GetRight(), m_BoardMetrics.GetBottom(), GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B, 230); #endif #endif if( m_StartMessage.HasMessage() && m_StartMessage.Animate() ){ return; } if( !m_YouWinMessage.HasMessage() && !m_Pieces.Animate() ) { SDL_UpdateRect(m_pScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } #ifdef USE_GRAPHIC_YOU_WIN if( m_bGameOver ) { if( m_pWinGraphic == NULL ) { m_pWinGraphic = nSDL_LoadImage(image_HitoriYouWin); SDL_SetColorKey(m_pWinGraphic, SDL_SRCCOLORKEY, SDL_MapRGB(m_pWinGraphic->format, 255, 255, 255)); } SDL_Rect rectWin; rectWin.x = (SCREEN_WIDTH - m_pWinGraphic->w)/2; rectWin.y = (SCREEN_HEIGHT - m_pWinGraphic->h)/2; rectWin.w = m_pWinGraphic->w; rectWin.h = m_pWinGraphic->h; SDL_BlitSurface(m_pWinGraphic, NULL, m_pScreen, &rectWin); } #else if( m_YouWinMessage.HasMessage() && !m_YouWinMessage.Animate() ) #endif { //SDL_UpdateRect(m_pScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } }
void cDialog :: Update( void ) { if( !visible && stext ) { return; } boxRGBA( screen, rect_boarder_out.x - (int)cameraposx, rect_boarder_out.y - (int)cameraposy, rect_boarder_out.x + rect_boarder_out.w - (int)cameraposx, rect_boarder_out.y + rect_boarder_out.h - (int)cameraposy, boarder_out_color.r, boarder_out_color.g, boarder_out_color.b, 255 ); boxRGBA( screen, rect_boarder_in.x - (int)cameraposx, rect_boarder_in.y - (int)cameraposy, rect_boarder_in.x + rect_boarder_in.w - (int)cameraposx, rect_boarder_in.y + rect_boarder_in.h - (int)cameraposy, boarder_in_color.r, boarder_in_color.g, boarder_in_color.b, 255 ); boxRGBA( screen, rect_text_area.x - (int)cameraposx, rect_text_area.y - (int)cameraposy, rect_text_area.x + rect_text_area.w - (int)cameraposx, rect_text_area.y + rect_text_area.h - (int)cameraposy, text_area_color.r, text_area_color.g, text_area_color.b, 255 ); Draw( screen ); }
void SelectBgImg(void){ FILE *F; SDL_Surface *Img; SDL_Rect Rct; char Fls[256][256]; int I,J,C=1,Akt=0; Fls[0][0]='\0'; F=fopen("./bgimages.txt","r"); while ((!feof(F))&&(fgets(Fls[C],255,F)!=NULL)){ while ((strlen(Fls[C]))&&(Fls[C][strlen(Fls[C])-1]<' ')) Fls[C][strlen(Fls[C])-1]='\0'; if (Fls[C][0]!='\0'){ // fprintf(stdout,">%s\n",Fls[C]); if (!strcmp(Fls[C],Lvl[Level].BgFile)) Akt=C; C++; } } fclose(F); while ((!Fire)&&(!Quit)){ strcpy(Lvl[Level].BgFile,Fls[Akt]); Img=IMG_Load(Lvl[Level].BgFile); if (Img!=NULL){ Rct.w=Img->w; Rct.h=Img->h; for (I=0;I<400;I+=Rct.w) for (J=0;J<400;J+=Rct.h){ Rct.x=I; Rct.y=J; SDL_BlitSurface(Img,NULL,Lvl[Level].Bg,&Rct); } SDL_FreeSurface(Img); }else boxRGBA(Lvl[Level].Bg,0,0,399,399,0x40,0x40,0x40,0xFF); DrawGame(); boxRGBA(screen,0,0,200,200,32,32,32,0xFF); boxRGBA(screen,0,100,200,110,64,64,64,0xFF); stringRGBA(screen,1,1,"Select BgImage:",255,255,255,0xFF); for (I=0;I<19;I++) if ((Akt-9+I>=0)&&(Akt-9+I<C)) stringRGBA(screen,1,10+I*10,Fls[Akt-9+I],200,200,200,0xFF); SDL_UpdateRect(screen,0,0,200,200); while ((Fire)||(Up)||(Down)) SDL_PollEvent(&event); while ((!Fire)&&(!Up)&&(!Down)&&(!Quit)) SDL_PollEvent(&event); if ((Up)&&(Akt>0)) Akt--; if ((Down)&&(Akt<C-1)) Akt++; } DrawGame(); }
void Bear::drawSprite(SDL_Surface *screen) { int eye_y = get_y() + eye_y_diff; int eye_x = get_x() + eye_x_diff; int x = get_x(); int y = get_y(); //body boxRGBA(screen, x - width/2, y - height/2, x + width/2, y + height/2, 255, 0, 0, 150); //left eye boxRGBA(screen, eye_x - eye_dist/2 - eye_width , eye_y, x - eye_dist/2, eye_y - eye_height, 255, 255, 0, 255); //right eye boxRGBA(screen, eye_x + eye_dist/2 , eye_y, x + eye_dist/2 + eye_width, eye_y - eye_height, 255, 255, 0, 255); }
/* * Zeichne den Blockbereich dynamisch zur Breite. Da die Blöcke einzeln gezeichnet * werden, wurde die Rundungsdifferenz bei der Berechnung der Breite des Bereichs * berücksichtigt. */ void drawFieldBlocks() { // Wandle die Breite / Höhe in Index-Werte um int w = screenWidth-1; int h = screenHeight-1; /* Verlust durch Rundung in der Breite errechnen. Diese ergibt sich aus späterer * Blockberechnung. Daraus resultiert ein linker und rechter x-Wert. */ int widthFix = 0; for (int i = 0; i < FIELD_COLS; i++) { widthFix += (int)((w*0.5)/FIELD_COLS); } int xLeft = (int)(w-widthFix)/2; int xRight = w-xLeft-1; // beim Überstehenden Pixel ist zu prüfen, ob das bei jeder Aufl. auftaucht // Bereich für Blöcke boxRGBA(screen, xLeft, 0, xRight, h, 240, 240, 240, 80); // Setze Blöcke im Blockbereich, je nach Spalte/Zeile mit jew. Farbe for (int x=0; x < FIELD_COLS; x++) { for (int y=0; y < FIELD_ROWS; y++) { if (fieldBlocks[x][y] > 0) { // Der linke x-Wert wird mit übergeben, damit alle Blöcke daran ausgerichtet werden drawFieldBlock(x, y, fieldBlocks[x][y], xLeft); } } } }
void ConfigurationMenu::RenderMenu( SDL_Surface *surface ) { if ( visibility ) { boxRGBA( surface, 800 / 2 - 250, 480 / 2 - 150, 800 / 2 + 250, 480 / 2 + 150, 0, 0, 0, 255 ); rectangleRGBA( surface, 800 / 2 - 250, 480 / 2 - 150, 800 / 2 + 250, 480 / 2 + 150, 255, 255, 255, 255 ); rectangleRGBA( surface, 800 / 2 - 250 + 1, 480 / 2 - 150 + 1, 800 / 2 + 250 - 1, 480 / 2 + 150 - 1, 255, 255, 255, 255 ); aalineRGBA( surface, 800 / 2 - 225, 480 / 2 - 100, 800 / 2 + 225, 480 / 2 - 100, 255, 255, 255, 200 ); dialogTitleLabel.Render( surface ); traceLinesLabel.Render( surface ); traceLineBodyLabel.Render( surface ); traceLineSledLabel.Render( surface ); traceLineHatLabel.Render( surface ); traceLineHeadLabel.Render( surface ); traceLineArmLabel.Render( surface ); traceLineLegLabel.Render( surface ); traceLineBodyRadio.Render( surface ); traceLineSledRadio.Render( surface ); traceLineHatRadio.Render( surface ); traceLineHeadRadio.Render( surface ); traceLineArmRadio.Render( surface ); traceLineLegRadio.Render( surface ); lineSnapLabel.Render( surface ); lineSnapRadio.Render( surface ); } }
void filledRect(void *s_in, int x, int y, int w, int h, int r, int g, int b, int a) { SDL_Renderer* s = (SDL_Renderer*)s_in; boxRGBA(s, x, y, x+w, y+h, r, g, b, a); }
void Trail_Render(Trail* trail, SDL_Renderer* renderer) { int runningIndex = trail->updatePoint - 1; int numberUpdated = 0; if (runningIndex < 0) { runningIndex = trail->length - 1; } float scale = 1.0f; while(numberUpdated < trail->ocupation) { boxRGBA(renderer, trail->trailArray[runningIndex].x - (int)ceil((float)trail->width * scale), trail->trailArray[runningIndex].y - (int)ceil((float)trail->width * scale), trail->trailArray[runningIndex].x + (int)round((float)trail->width * scale), trail->trailArray[runningIndex].y + (int)round((float)trail->height * scale), 255, 255, 0, 255); scale -= 1.0f/ (float)trail->ocupation; if(scale <= 0.0f) { break; } ++numberUpdated; --runningIndex; if (runningIndex < 0) { runningIndex = trail->length - 1; } } }
int gui_options::draw() { boxRGBA(guibuffer,0,0,SCREEN_WIDTH,SCREEN_HEIGHT,220,220,220,255); // bg output_options(); return 0; }
void Map::draw() { for (int x = 0; x < MAP_WIDTH; x++) { for (int y = 0; y < MAP_HEIGHT; y++) { Tile *t = getMapTile(x,y); int drawX = cam.getMapDrawX(x); int drawY = cam.getMapDrawY(y); if (!t->drawMe()) { continue; } if (!t->isVisible()) { if (t->alpha > 128) t->alpha -= FOG_FADE_SPEED; // if (t->alpha < 128) continue; } if (!inFOV(x, y, zFocus)) continue; // if (z != zFocus) continue; //if (z < zFocus) continue; if (t->isVisible()) t->alpha += FOG_FADE_SPEED; // if (t->alpha < 255) { // boxRGBA(screen, drawX, drawY, 32, 32, 0, 0, 0, 255); // } boxRGBA(screen, drawX, drawY, drawX+31, drawY+31, 0, 0, 0, 255); drawtile(0, t->getGridX(), t->getGridY(), drawX, drawY, 0, false, t->alpha); } } }
void Game::drawFog(Surface & dest) { for (unsigned x = 0; x < Map::width(); x++) for (unsigned y = 0; y < Map::height(); y++) { SDL_Rect br; br.x = x * gfx::getScreenWidth() / Map::width(); br.y = y * gfx::getScreenHeight() / Map::height(); br.w = gfx::getScreenWidth() / Map::width() + 1; br.h = gfx::getScreenHeight() / Map::height() + 1; int rawDistance = Map::rawDistance(player->getTileX(), player->getTileY(), x, y); int distance = Map::distance(player->getTileX(), player->getTileY(), x, y); int alpha = (rawDistance - Map::fogDistance()) * 0xFF / Map::fogVisibility(); if ((rawDistance - Map::fogDistance()) * 0xFF / Map::fogVisibility() > 0xFF) { alpha = 0xFF; } else if ((rawDistance - Map::fogDistance()) * 0xFF / Map::fogVisibility() < 0x0) { alpha = 0x0; } if (rawDistance > Map::fogDistance()) { boxRGBA(dest(), br.x, br.y, br.x + br.w, br.y + br.h, 0, 0, 0, rawDistance > Map::fogDistance() + Map::fogVisibility() ? 0xFF : alpha); } } }
int main() { int running = 1; SDL_Event event; SDL_Surface *screen; putenv("SDL_VIDEO_WINDOW_POS=center"); putenv("SDL_VIDEO_CENTERED=1"); SDL_Init(SDL_INIT_EVERYTHING); SDL_WM_SetCaption("Hello World!",NULL); screen = SDL_SetVideoMode(800,600,32,SDL_HWSURFACE); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format,0,0,255)); boxRGBA(screen,10,10,100,100,0,255,0,255); SDL_Flip(screen); while(running){ SDL_WaitEvent(&event); if(event.type == SDL_QUIT) running = 0; } SDL_Quit(); return 0; }
void cEnemyStopper :: Draw( SDL_Surface *target ) { if( !Leveleditor_Mode ) { rect.x = (Sint16)startposx; rect.y = (Sint16)startposy; return; } rect.x = (Sint16)startposx; rect.y = (Sint16)startposy; if( !Visible_onScreen() ) { return; } SDL_Rect r = rect; r.x -= (Sint16)cameraposx; r.y -= (Sint16)cameraposy; r.w = rect.w; r.h = rect.h; boxRGBA( target, r.x, r.y, r.x + r.w, r.y + r.h, 0, 0, 255, 126 ); }
void Salmon::drawSprite(SDL_Surface *screen) { int x = get_x(); int y = get_y(); //body boxRGBA(screen, x - width/2, y - height/2, x + width/2, y + height/2, 200, 200, 200, 255); }
int _progressThread( void *data ) { ResearchEngine* researchEngine = (ResearchEngine*) data; int screenWidth = 1000; int screenHeight = 100; int r = researchEngine->getCurrentResearch(); int e = researchEngine->getCurrentEpoch(); SDL_Init( SDL_INIT_VIDEO ); SDL_Surface* screen = SDL_SetVideoMode( screenWidth, screenHeight, 0, SDL_HWSURFACE | SDL_DOUBLEBUF ); SDL_WM_SetCaption( "Reasearch progress", 0 ); SDL_Event event; bool quit = false; while( researchEngine->isRunning() && !quit) { if(r != researchEngine->getCurrentResearch() || e != researchEngine->getCurrentEpoch()){ r = researchEngine->getCurrentResearch(); e = researchEngine->getCurrentEpoch(); int barHeight = 30; int offset1 = 5; int offset2 = 50; int start = 5; float barWidth = (float)screenWidth - 5.0f; float progressA = barWidth * ((float)r / (float)researchEngine->getResearches()); float progressB = barWidth * ((float)e / (float)researchEngine->getEpochs()); boxRGBA(screen, 0, 0, screenWidth, screenHeight, 255, 255, 255, 255); rectangleRGBA(screen, start, offset1, barWidth, barHeight + offset1, 0, 0, 255, 255); boxRGBA(screen, start, offset1, progressA + start, barHeight + offset1, 0, 0, 255, 255); rectangleRGBA(screen, start, offset2, barWidth, barHeight + offset2, 0, 0, 255, 255); boxRGBA(screen, start, offset2, progressB + start, barHeight + offset2, 0, 0, 255, 255); SDL_Flip(screen); } if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { quit = true; } } } SDL_Quit(); return 0; }
void DrawGame(void){ int I,J; char Str[20]; SDL_Rect Rct; SDL_BlitSurface(Lvl[Level].Bg,NULL,screen,NULL); for (I=0;I<20;I++) for (J=0;J<20;J++) DrawSpr(Spr[Lvl[Level].M[I][J].BSpr].img,screen,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y); if (Shades){ // ClearSurface(Sh); boxRGBA(Sh,0,0,399,14,0,0,0,0xFF); boxRGBA(Sh,0,15,14,399,0,0,0,0xFF); boxRGBA(Sh,15,15,399,399,255,0,255,0xFF); for (I=0;I<20;I++) for (J=0;J<20;J++) DrawSpr(Spr[Lvl[Level].M[I][J].FSpr].sha,Sh,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y); SDL_BlitSurface(Sh,NULL,screen,NULL); } for (I=0;I<20;I++) for (J=0;J<20;J++){ DrawSpr(Spr[Lvl[Level].M[I][J].FSpr].img,screen,I*20+Lvl[Level].M[I][J].x,J*20+Lvl[Level].M[I][J].y); if (Lvl[Level].M[I][J].txt>=0){ sprintf(Str,"T%c",'0'+Lvl[Level].M[I][J].txt); stringRGBA(screen,I*20+2,J*20+6,Str,0xE0,0xE0,0xE0,150); } } // Stat: Level--- DrawSpr(SLevel,screen,1,400-16); R_Blit(SNumbers,screen,(Level/10)*11,0,11,15,15,400-16); R_Blit(SNumbers,screen,(Level%10)*11,0,11,15,26,400-16); // Stat: DeadLine--- if (Lvl[Level].DL){ DrawSpr(STime,screen,200-23,400-17); R_Blit(SNumbers,screen,(Lvl[Level].DL/100)*11,0,11,15,200-9,400-16); R_Blit(SNumbers,screen,((Lvl[Level].DL%100)/10)*11,0,11,15,200+2,400-16); R_Blit(SNumbers,screen,(Lvl[Level].DL%10)*11,0,11,15,200+13,400-16); } SDL_UpdateRect(screen,0,0,400,400); }
void RectanguloR(int x1, int y1, int x2, int y2, unsigned char r, unsigned char g, unsigned char b, GRF_Imagen img) { GRF_Imagen ptr = ((img==0) ? ventana : img); boxRGBA(ptr, x1, y1, x2, y2, r, g, b, 255); if (img==0 && dibujo_activo) SDL_UpdateRect(ptr, min(x1,x2), min(y1,y2), abs(x1-x2)+1, abs(y1-y2)+1); }
void render(SDL_Surface* screen){ if (y + h >= screen->h){ landed = true; } if (placed){ boxRGBA(screen, x, y, x+w, y+h, 128, 64, 0, 255); } }
void DrawMessages(void){ char Str[55],I; boxRGBA(screen,0,0,399,100,100,100,100,255); for (I=0;I<10;I++){ sprintf(Str,"%d:%s",I,Lvl[Level].Text[I]); stringRGBA(screen,0,I*10,Str,200,200,200,255); } SDL_UpdateRect(screen,0,0,400,100); }
void DrawMsg(char Msg[]){ boxRGBA(screen,350,400,439,409,16,16,16,0xFF); rectangleRGBA(screen,350,400,439,409,32,32,32,0xFF); if (Msg[strlen(Msg)-1]!='!') stringRGBA(screen,351,401,Msg,200,200,200,0xFF); else stringRGBA(screen,351,401,Msg,250,50,50,0xFF); SDL_UpdateRect(screen,350,400,90,10); }
// ********************************************************************************* // ***** Erase_Data ******** // ***** Erase the old data ******** // ***** (r) void ******** // ***** (1) Struct_Coordinates *: coordinate of left corner of box ******** // ***** (2) Struct_Coordinates *: coordinate of left corner of box ******** // ***** (3) SDL_Color; background color ******** // ********************************************************************************* void Erase_Data(SDL_Surface* p_DS, Struct_Coordinates s, SDL_Color v_bg, int v_border) { // ***** Erase old data by covering up with box ***** boxRGBA(p_DS, s.x1, s.y1, s.x2, s.y2, v_bg.r, v_bg.g, v_bg.b,255); // ***** Box Border ***** if(v_border) rectangleRGBA(p_DS, s.x1, s.y1, s.x2, s.y2, 0,0,255,255); return; }
void DrawTxtMenu(char Mnu[10][20]){ int I,L=0; boxRGBA(screen,0,400,419,409,64,64,64,0xFF); rectangleRGBA(screen,0,400,419,409,32,32,32,0xFF); for (I=0;(I<10)&&(Mnu[I][0]!='\0');I++){ stringRGBA(screen,2+L*8,402,Mnu[I],250,250,250,0xFF); L+=strlen(Mnu[I]); } SDL_UpdateRect(screen,0,400,400,10); }
int BEE::draw_rectangle(int x, int y, int w, int h, bool is_filled, bool is_hud) { if (!is_hud) { convert_view_coords(x, y); } SDL_Rect rect = {x, y, w, h}; if (is_filled) { return boxRGBA(renderer, x+w, y, x, y+h, color->r, color->g, color->b, color->a); } else { return rectangleRGBA(renderer, x+w, y, x, y+h, color->r, color->g, color->b, color->a); } }
int read_history() { // message processing loop bool done = false; while (!done) { SDL_Event event; while (SDL_PollEvent(&event)) { // check for messages switch (event.type) { // exit if the window is closed case SDL_QUIT: return -1; break; // check for keypresses case SDL_KEYDOWN: { // exit if ANY PRESSED return 0; break; } } // end switch } // end of message processing print_full_picture(BITMAPS[IMG_HISTORY]); boxRGBA(MAIN_SCREEN,100,50,560,320,0xFF,0xFF,0xFF,0xFF); put_text_at(-1,48,"VIKING HISTORICAL TEXT"); put_text_at(120,80,"Vikings were North Europeans who went raiding and trading"); put_text_at(120,100,"across most of Europe around 800-1050. The name comes"); put_text_at(120,120,"from the phrase \"to go viking\", originally meaning to set"); put_text_at(120,140,"out on a journey. Vikings sailed to Greenland and built"); put_text_at(120,160,"colonies, sailed to England and looted monasteries, sailed"); put_text_at(120,180,"to Constantinople and became mercenaries, sailed to Russia"); put_text_at(120,200,"and captured slaves, sailed to France and settled down,"); put_text_at(120,220,"and the most important Vikings were buried in boats. In"); put_text_at(120,240,"this game, you play Vikings trying to sail to Vinland (North"); put_text_at(120,260,"America) to establish a settlement there and live off"); put_text_at(120,280,"the fat of the land, far away from the bitter snows of"); put_text_at(120,300,"Norway."); if (Mix_Playing(-1) == 0) Mix_PlayChannel(-1, SOUNDS[SND_MAIN_MENU], 0); SDL_Flip(MAIN_SCREEN); SDL_Delay(100); } return 0; }
void Image::draw_rectangle(Color c, float x, float y, float width, float height, bool filled) { SDL_Surface* aux = SDL_CreateRGBSurface(SDL_SRCALPHA, width, height, 32, 0, 0, 0, 0); if(filled) boxRGBA(aux, 0, 0, width, height, c.r, c.g, c.b, SDL_ALPHA_OPAQUE); else rectangleRGBA(aux, 0, 0, width, height, c.r, c.g, c.b, SDL_ALPHA_OPAQUE); dstrect.x = x; dstrect.y = y; SDL_BlitSurface(aux, null, GameEngine::display->implementation->sdlDisplaySurface, &dstrect); SDL_FreeSurface(aux); }
void draw_move_to (SDL_Surface *screen, Sint16 wx, Sint16 wy, Sint16 zoom) { /* center of selected field */ Sint16 x_rel = wx - world_up_x; Sint16 y_rel = wy - world_up_y; Sint16 x1 = (x_rel * zoom) + (zoom / 4); Sint16 y1 = (y_rel * zoom) + (zoom / 4); Sint16 x2 = (x_rel * zoom) + (zoom - (zoom / 4)); Sint16 y2 = (y_rel * zoom) + (zoom - (zoom / 4)); boxRGBA (screen, x1, y1, x2, y2, 204, 24, 24, 255); }