01147c0d35
* Implement a simple state machine to simulate different game stats * Create a generic menu to display different menus * Update the Makefile for TTF support * Draw a simple diagram to show the stats
45 lines
1,021 B
C
45 lines
1,021 B
C
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include "SDL.h"
|
|
#include "SDL_ttf.h"
|
|
#include "config.h"
|
|
#include "states.h"
|
|
#include "draw.h"
|
|
#include "menu.h"
|
|
|
|
void displayMainmenu() {
|
|
drawMenu(mainMenu, 3);
|
|
}
|
|
|
|
void displayNumplayers() {
|
|
drawMenu(numplayersMenu, 4);
|
|
}
|
|
|
|
void displayCredits() {
|
|
drawMenu(creditsMenu, 1);
|
|
}
|
|
|
|
void displayRunninggame() {
|
|
if (terrain == NULL) terrain = generateTerrain(150.0, 180.0);
|
|
|
|
Uint32 sky = SDL_MapRGB(screen->format, 186, 215, 217);
|
|
Uint32 green = SDL_MapRGB(screen->format, 101, 200, 21);
|
|
Uint32 darkGreen = SDL_MapRGB(screen->format, 52, 99, 14);
|
|
Uint32 ground = SDL_MapRGB(screen->format, 124, 88, 10);
|
|
|
|
for (int x=0; x<SCREEN_WIDTH; x++) {
|
|
int y = terrain[x];
|
|
|
|
drawLine(x, 0, x, y, sky);
|
|
if (y <= SCREEN_HEIGHT-15) drawLine(x, y, x, y+15, green);
|
|
if (y <= SCREEN_HEIGHT-20) drawLine(x, y+15, x, y+20, darkGreen);
|
|
if (y <= SCREEN_HEIGHT-21) drawLine(x, y+20, x, SCREEN_HEIGHT, ground);
|
|
}
|
|
}
|
|
|
|
void displayRlyquit() {
|
|
drawMenu(rlyquitMenu, 2);
|
|
}
|
|
|