void Credits::Tick()
{
	/*debug("scroll_y: %d", scroll_y>>CSF);
	debug("spawn_y: %d", spawn_y);
	debug("scr_spawn_y: %d", SCREEN_Y(spawn_y));
	debug("trigger: %d", SCREEN_HEIGHT+MARGIN);
	debug("");*/
	/*debug("imgno: %d", bigimage.imgno);
	debug("state: %d", bigimage.state);
	debug("imagex: %d", bigimage.imagex);*/
	
	if (roll_running || SCREEN_Y(spawn_y) >= (SCREEN_HEIGHT + 8))
	{
		scroll_y += 0x100;
	}
	
	while(roll_running && SCREEN_Y(spawn_y) < (SCREEN_HEIGHT + MARGIN))
	{
		RunNextCommand();
	}
	
	if (player)
	{
		player->hide = true;
		player->dead = true;	// should pretty much completely disable HandlePlayer()
	}
	
	game_tick_normal();
	bigimage.Draw();
	Draw();
}
Exemple #2
0
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);
}
Exemple #3
0
void GameOutputFrame(void)
{
	const float screenYOff =
		(float)MAX(-SCREEN_HEIGHT, SCREEN_Y(camera.Y) - SCREEN_HEIGHT / 2);
	// Draw the background.
	DrawBackground(&BG, screenYOff);

	SpaceDraw(&space, screenYOff);
	PickupsDraw(Screen, screenYOff);
	ParticlesDraw(Screen, screenYOff);

	int c = 0;
	for (int i = 0; i < MAX_PLAYERS; i++)
	{
		PlayerDraw(&players[i], screenYOff);

		if (!players[i].Enabled) continue;

		// Draw each player's current score.
		char buf[17];
		sprintf(buf, "%d", players[i].Score);
		const SDL_Color white = { 255, 255, 255, 255 };
#ifdef TTF
		SDL_Surface *t = TTF_RenderText_Blended(font, buf, white);
#endif
		const int x = (c + 1) * SCREEN_WIDTH / (PlayerEnabledCount() + 1);
#ifdef TTF
		const int wHalf = (t->w + PLAYER_SPRITESHEET_WIDTH) / 2;
#else
		const int wHalf = (16 + PLAYER_SPRITESHEET_WIDTH) / 2;
#endif
		// Draw the player icon, followed by the score number
		SDL_Rect src = {
			0, 0, PLAYER_SPRITESHEET_WIDTH, PLAYER_SPRITESHEET_HEIGHT
		};
		SDL_Rect dest = { (Sint16)(x - wHalf), 0, 0, 0 };
		SDL_BlitSurface(PlayerSpritesheets[i], &src, Screen, &dest);
		// Draw score number
		dest.x = (Sint16)(x - wHalf + PLAYER_SPRITESHEET_WIDTH);
#ifdef TTF
		dest.y = (Sint16)(PLAYER_SPRITESHEET_HEIGHT - t->h) / 2;
#else
		dest.y = (Sint16)(PLAYER_SPRITESHEET_HEIGHT - 16) / 2;
#endif
		
#ifdef TTF
		SDL_BlitSurface(t, NULL, Screen, &dest);
		SDL_FreeSurface(t);
#endif

		c++;
	}

	SDL_Flip(Screen);
}
Exemple #4
0
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);
}
Exemple #5
0
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);
}
bool Credits::DrawLine(CredLine *line)
{
	int x = line->x;
	int y = SCREEN_Y(line->y);
	if (y < -MARGIN) return true;	// line can be deleted now
	
	if (line->image)
	{
		draw_sprite(x - 24, y - 8, SPR_CASTS, line->image);
		//DrawBox(x, y, x+GetFontWidth(line->text, TEXT_SPACING), y+8,  56, 0, 0);
	}
	
	//int font_draw(int x, int y, const char *string, int font_spacing)
	//DrawRect(x, y, x+63, y+8, 128, 0, 0);
	font_draw(x, y, line->text, TEXT_SPACING);
	
	return false;
}
Exemple #7
0
static void ParticleDraw(const Particle *p, const float y)
{
	AnimationDraw(
		&p->anim, (int)SCREEN_X(p->x), (int)(SCREEN_Y(p->y) - y));
}