void TitleScreenOutputFrame(void) { DrawBackground(&BG, 0); HighScoreDisplayDraw(&HSD); for (int i = 0; i < MAX_PLAYERS; i++) { Tex t = GetControlTex(i); SDL_Rect dest = { SCREEN_X((i + 1) * FIELD_WIDTH / (MAX_PLAYERS + 1)) - t.W / 2, (SCREEN_HEIGHT - t.H) / 2 - SCREEN_X(PLAYER_RADIUS), t.W, t.H }; RenderTex(t.T, NULL, &dest); } for (int i = 0; i < MAX_PLAYERS; i++) { PlayerDraw(&players[i], 0); } for (int i = 0; i < MAX_PLAYERS; i++) { BlockDraw(&blocks[i], 0); } DrawTitleImg(); // Draw player icons if winners if (!Start) { const int left = (SCREEN_WIDTH - PLAYER_SPRITESHEET_WIDTH * winners) / 2; for (int i = 0; i < winners; i++) { const int playerIndex = winnerIndices[i]; SDL_Rect src = { 0, 0, PLAYER_SPRITESHEET_WIDTH, PLAYER_SPRITESHEET_HEIGHT }; SDL_Rect dest = { left + i * PLAYER_SPRITESHEET_WIDTH, SCREEN_HEIGHT * 0.66f, src.w, src.h }; RenderTex(PlayerSpritesheets[playerIndex].T, &src, &dest); } } SDL_Color c = { 177, 177, 177, 255 }; TextRenderCentered( font, WelcomeMessage, (int)(SCREEN_HEIGHT * 0.75f), c); SDL_RenderPresent(Renderer); }
void BlockDraw(const Block *block, const float y) { const cpVect pos = cpBodyGetPosition(block->Body); SDL_Rect src = { 0, 0, SCREEN_X(block->W), block->T.H }; SDL_Rect dest = { (int)SCREEN_X((float)pos.x - block->W / 2), (int)(SCREEN_Y((float)pos.y + block->H / 2) - y), src.w, src.h }; RenderTex(block->T.T, &src, &dest); }
void BlockDraw(const Block *block, const float y) { const cpVect pos = cpBodyGetPosition(block->Body); SDL_Rect src = { 0, 0, (Sint16)SCREEN_X(block->W), (Sint16)block->Surface->h }; SDL_Rect dest = { (Sint16)SCREEN_X((float)pos.x - block->W / 2), (Sint16)(SCREEN_Y((float)pos.y + block->H / 2) - y), 0, 0 }; SDL_BlitSurface(block->Surface, &src, Screen, &dest); }
void place_sprite(sprite_t *s, camera_t *c) { bool exist = s->obj != NULL; int screen_x = SCREEN_X(*s, *c); int screen_y = SCREEN_Y(*s, *c); ENGINE_DEBUGFMT("sprite in world at %d, %d on screen at %d, %d, exist: %d, height: %d", s->x, s->height, screen_x, screen_y, exist, SPRITE_HEIGHT(*s)); if ((screen_y + SPRITE_HEIGHT(*s) < 0) || (screen_y > SCREEN_HEIGHT) || (screen_x + SPRITE_WIDTH(*s) < 0) || (screen_x > SCREEN_WIDTH)) { if (exist) { ENGINE_DEBUG("sprite left! deleting it"); delete_sprite(s); } return; } else { if (!exist) { ENGINE_DEBUG("sprite on screen and needs to be created"); s->obj = new_obj(); } } obj_set_attr(s->obj, s->shape | ATTR0_REG, s->size, ATTR2_PALBANK(s->palbank) | s->tile); obj_set_pos(s->obj, screen_x, screen_y); }
static void ParticleDraw(const Particle *p, const float y) { AnimationDraw( &p->anim, (int)SCREEN_X(p->x), (int)(SCREEN_Y(p->y) - y)); }