summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2009-06-19 21:22:34 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2009-06-19 21:22:34 -0400
commit1941186fa99ce9a9e333d9ab0deb928937e1ea61 (patch)
tree683188717e4acbb4623460cc28f61d08edb9a3a6
parentdf28032e41530c0230b1c72c3684e1bd49c7019e (diff)
downloadmazeoflife-1941186fa99ce9a9e333d9ab0deb928937e1ea61.tar.gz
mazeoflife-1941186fa99ce9a9e333d9ab0deb928937e1ea61.tar.bz2
mazeoflife-1941186fa99ce9a9e333d9ab0deb928937e1ea61.zip
Added How To Play
Closes #103
-rw-r--r--Makefile2
-rw-r--r--htp1.bmpbin0 -> 921738 bytes
-rw-r--r--htp2.bmpbin0 -> 921738 bytes
-rw-r--r--htpstate.cpp56
-rw-r--r--htpstate.h18
-rw-r--r--includes.h1
-rw-r--r--titlestate.cpp4
7 files changed, 79 insertions, 2 deletions
diff --git a/Makefile b/Makefile index b79fe63..7f503ba 100644 --- a/Makefile +++ b/Makefile
@@ -1,4 +1,4 @@
1OBJS = mazeoflife.o titlestate.o gamestate.o 1OBJS = mazeoflife.o titlestate.o htpstate.o gamestate.o
2CC = g++ 2CC = g++
3CFLAGS = `pkg-config sdl --cflags` 3CFLAGS = `pkg-config sdl --cflags`
4LIBS = `pkg-config sdl --libs` 4LIBS = `pkg-config sdl --libs`
diff --git a/htp1.bmp b/htp1.bmp new file mode 100644 index 0000000..df06101 --- /dev/null +++ b/htp1.bmp
Binary files differ
diff --git a/htp2.bmp b/htp2.bmp new file mode 100644 index 0000000..5dcb4c4 --- /dev/null +++ b/htp2.bmp
Binary files differ
diff --git a/htpstate.cpp b/htpstate.cpp new file mode 100644 index 0000000..273392e --- /dev/null +++ b/htpstate.cpp
@@ -0,0 +1,56 @@
1#include "includes.h"
2
3HowToPlayState::HowToPlayState()
4{
5 background1 = SDL_LoadBMP("htp1.bmp");
6 background2 = SDL_LoadBMP("htp2.bmp");
7 pointer = SDL_LoadBMP("pointer.bmp");
8 secondPage = false;
9 selection = 0;
10}
11
12void HowToPlayState::input(SDLKey key)
13{
14 if ((key == SDLK_LEFT) && (selection != 0))
15 {
16 selection--;
17 } else if ((key == SDLK_RIGHT) && (selection != 1))
18 {
19 selection++;
20 } else if (key == SDLK_RETURN)
21 {
22 switch (selection)
23 {
24 case 0:
25 secondPage = !secondPage;
26
27 break;
28 case 1:
29 changeState(new TitleState());
30
31 break;
32 }
33 }
34}
35
36void HowToPlayState::render(SDL_Surface* screen)
37{
38 SDL_Rect pSpace;
39
40 if (!secondPage)
41 {
42 SDL_BlitSurface(background1, NULL, screen, NULL);
43
44 pSpace.x = (selection==0?74:216);
45 } else {
46 SDL_BlitSurface(background2, NULL, screen, NULL);
47
48 pSpace.x = (selection==0?45:238);
49 }
50
51 pSpace.y = 430;
52 pSpace.w = screen->w;
53 pSpace.h = screen->h;
54
55 SDL_BlitSurface(pointer, NULL, screen, &pSpace);
56}
diff --git a/htpstate.h b/htpstate.h new file mode 100644 index 0000000..2639d1a --- /dev/null +++ b/htpstate.h
@@ -0,0 +1,18 @@
1#ifndef HTPSTATE_H
2#define HTPSTATE_H
3
4class HowToPlayState : public State {
5 public:
6 HowToPlayState();
7 void input(SDLKey key);
8 void render(SDL_Surface* screen);
9
10 private:
11 SDL_Surface* background1;
12 SDL_Surface* background2;
13 SDL_Surface* pointer;
14 bool secondPage;
15 int selection;
16};
17
18#endif
diff --git a/includes.h b/includes.h index d066b8e..fa6abeb 100644 --- a/includes.h +++ b/includes.h
@@ -5,4 +5,5 @@
5#include "state.h" 5#include "state.h"
6#include "mazeoflife.h" 6#include "mazeoflife.h"
7#include "titlestate.h" 7#include "titlestate.h"
8#include "htpstate.h"
8#include "gamestate.h" 9#include "gamestate.h"
diff --git a/titlestate.cpp b/titlestate.cpp index ee6a2b5..144148a 100644 --- a/titlestate.cpp +++ b/titlestate.cpp
@@ -23,7 +23,9 @@ void TitleState::input(SDLKey key)
23 changeState(new GameState()); 23 changeState(new GameState());
24 24
25 break; 25 break;
26 case 1: // Add How To Play 26 case 1:
27 changeState(new HowToPlayState());
28
27 break; 29 break;
28 case 2: // Add choose highscore list 30 case 2: // Add choose highscore list
29 break; 31 break;