summary refs log tree commit diff stats
path: root/titlestate.cpp
blob: 425e4ca6627d7a3403b75bfdd74a6f296ca763f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "includes.h"

TitleState::TitleState()
{
	background = SDL_LoadBMP("title.bmp");
	pointer = SDL_LoadBMP("pointer.bmp");
	selection = 0;

	SDL_WM_SetCaption("Maze Of Life", NULL);
}

void TitleState::input(SDLKey key)
{
	if ((key == SDLK_UP) && (selection != 0))
	{
		selection--;
	} else if ((key == SDLK_DOWN) && (selection != 3))
	{
		selection++;
	} else if (key == SDLK_RETURN)
	{
		switch (selection)
		{
			case 0:
				changeState(new GameState());

				break;
			case 1:
				changeState(new HowToPlayState());

				break;
			case 2: // Add choose highscore list
				break;
			case 3:
				exit(0);
		}
	}
}

void TitleState::render(SDL_Surface* screen)
{
	SDL_BlitSurface(background, NULL, screen, NULL);

	SDL_Rect pSpace;
	pSpace.x = 136;
	pSpace.y = (selection==0?316:(selection==1?350:(selection==2?381:417)));
	pSpace.w = screen->w;
	pSpace.h = screen->h;

	SDL_BlitSurface(pointer, NULL, screen, &pSpace);
}