Skip to content

Commit

Permalink
Added tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
Zegis committed Apr 27, 2014
1 parent c0880cb commit 0319306
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 8 deletions.
68 changes: 63 additions & 5 deletions Game.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "Game.h"


Game::Game(void): MAXLVL(2)
Game::Game(void): MAXLVL(3)
{
if(InitializeAllegro())
{
Expand All @@ -20,7 +20,7 @@ Game::Game(void): MAXLVL(2)
followerBMP = al_load_bitmap("follower.png");

font = al_load_ttf_font("pirulen.ttf",40,0);
msgFont = al_load_ttf_font("pirulen.ttf", 18,0);
msgFont = al_load_ttf_font("pirulen.ttf", 16,0);

player = new Sprite(playerBMP, false);
follower = new Sprite(followerBMP, true);
Expand Down Expand Up @@ -70,6 +70,7 @@ void Game::Run()

if(GameMenu())
{
GameTutorial();
currentLvl = 1;
GameLoop();
}
Expand All @@ -93,11 +94,11 @@ bool Game::GameMenu()

lineY = 440;

al_draw_text(msgFont, al_map_rgb(255,255,255), 15, lineY, 0, "Press ENTER to start");
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineY, ALLEGRO_ALIGN_CENTRE, "Press ENTER to start");
lineOffset = al_get_font_line_height(msgFont);
lineY += lineOffset;

al_draw_text(msgFont, al_map_rgb(255,255,255), 65, lineY, 0, "ESCAPE to quit");
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineY, ALLEGRO_ALIGN_CENTRE, "ESCAPE to quit");

al_flip_display();

Expand All @@ -115,6 +116,63 @@ bool Game::GameMenu()
}
}

void Game::GameTutorial()
{
al_clear_to_color(al_map_rgb(0,0,0));

int lineStartY = 50;
int lineOffsetY = al_get_font_line_height(msgFont);

al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "You're unlucky");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "little spirit!");
lineStartY += lineOffsetY *2;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Evil, hulking ogre");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "captured you to help in...");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Treasure hunting!");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Bring him to chalice!");
lineStartY += lineOffsetY * 3;

al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Use arrow keys to:");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "move spirit and");

lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "dig into earth");

lineStartY += lineOffsetY * 2;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Use numpad arrows");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "to order ogre left, right");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "and numpad 5");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "to stop ogre!");
lineStartY += lineOffsetY*2;

al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Press R");
lineStartY += lineOffsetY;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "to restart current level");

lineStartY += lineOffsetY * 3;
al_draw_text(msgFont, al_map_rgb(255,255,255), 175, lineStartY, ALLEGRO_ALIGN_CENTRE, "Press ENTER to continue");

al_flip_display();

ALLEGRO_EVENT ev;

while(true)
{
al_wait_for_event(evQueue, &ev);

if(ev.type == ALLEGRO_EVENT_KEY_DOWN && ev.keyboard.keycode == ALLEGRO_KEY_ENTER)
break;
}
}

void Game::GameLoop()
{
ALLEGRO_EVENT ev;
Expand Down Expand Up @@ -309,7 +367,7 @@ void Game::DrawEnd()

al_draw_text(font,al_map_rgb(255,255,255), 45, 180, 0, "Victory!");

al_draw_text(msgFont,al_map_rgb(255,255,255), 30, 280, 0, "Thanks for playing!");
al_draw_text(msgFont,al_map_rgb(255,255,255), 175, 280, ALLEGRO_ALIGN_CENTRE, "Thanks for playing!");
}

al_flip_display();
Expand Down
4 changes: 3 additions & 1 deletion Game.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ class Game
bool CheckForTileCollision(int nexX, int newY, bool isFollower);

void CheckObjectCollisions(Sprite* object);
Sprite* Game::GetSpriteCollision(Sprite* object);
Sprite* GetSpriteCollision(Sprite* object);

void GameLoop();

void GameTutorial();

bool GameMenu();

string assembleMapName();
Expand Down
4 changes: 2 additions & 2 deletions map02.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.......
.......
.@...F.
.....F.
.@.....
GGGGR..
R0RRRGR
0000000
Expand Down
10 changes: 10 additions & 0 deletions map03.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.......
.......
.@...F.
GGGGRGG
R0RRR0R
0000001
RRRR.RR
0000000
.......
GGGGGGG

0 comments on commit 0319306

Please sign in to comment.