Example #1
0
void
gameover(struct game *g)
{
	SDL_Rect r;
	struct position *p = g->frontend;
	int pph;			/* points per hour */

#if 0
	if (g->running == false)
		return;
#endif
	pph = g->points * 3600.f / (time(NULL) - g->game_time);

    r.x = p->x + 10;
    r.y = p->y + p->size * PREVIEW_H + 60;
    char endMsg[1024];
    sprintf(endMsg,"GAME OVER\nYour Score: %i\nPress any key/button",g->points,g->lines_cleared,g->level);
    sf_puts(screen, &r, endMsg);
    SDL_UpdateRects(screen, 1, &r);

    r.y += r.h;

    SDL_Event e;
    while (SDL_WaitEvent(&e) && (e.type != SDL_KEYDOWN && e.type != SDL_MOUSEBUTTONDOWN)) {
        SDL_Delay(10);
    }


#if 0	
	g->running = false;
#endif
    restart_game(g);
}
Example #2
0
void drawInstructions(struct game *g)
{
    SDL_Rect r;
    struct position *p = g->frontend;

    r.x = p->x2;
    r.y = p->y2 + p->size * PREVIEW_H + 60;
    char instMsg[1024];
    sprintf(instMsg,"\nCopypastris\nby Christiaan Janssen\nRemixed from sdltetris (sourceforge)\nBerlin 5h microJam 2012\n\nInstructions:\nMouse:    select on click\nCTRL+X:   cut\nCTRL+C:   copy\nCTRL+V:   paste");
    sf_puts(screen, &r, instMsg);
    SDL_UpdateRects(screen, 1, &r);
}
Example #3
0
void
level_up(struct game *g)
{
	SDL_Rect r;
	const struct position *p = g->frontend;

	++g->level;

	r.x = p->x + 3 * p->size;
	r.y = p->y + 7 * p->size;
	sf_puts(screen, &r, "Level Up!");
	SDL_UpdateRect(screen, r.x, r.y, r.w, r.h);
	SDL_Delay(MSG_DELAY);
	SDL_BlitSurface(bground, &r, screen, &r);
	SDL_UpdateRect(screen, r.x, r.y, r.w, r.h);
	
	/* zwiekszam szybkosc spadania tetramino */
	if (g->fall_time > FALL_BY_LEVEL)
		g->fall_time -= FALL_BY_LEVEL;
	else 
		g->fall_time /= 2;
}
Example #4
0
/* debug printf - could use varargs and vsprintf if so desired
 */
void
dprintf(const char *str)
{
	sf_puts(str);
}