diff --git a/TrustFall/TrustFall/TrustFall.vcxproj b/TrustFall/TrustFall/TrustFall.vcxproj
index 8209fe7..67da29d 100644
--- a/TrustFall/TrustFall/TrustFall.vcxproj
+++ b/TrustFall/TrustFall/TrustFall.vcxproj
@@ -78,6 +78,15 @@
true
true
+
+ true
+ true
+ true
+ true
+ true
+ true
+ true
+
Level3
@@ -132,6 +141,7 @@
+
@@ -140,6 +150,7 @@
+
diff --git a/TrustFall/TrustFall/TrustFall.vcxproj.filters b/TrustFall/TrustFall/TrustFall.vcxproj.filters
index ad87e00..631ad32 100644
--- a/TrustFall/TrustFall/TrustFall.vcxproj.filters
+++ b/TrustFall/TrustFall/TrustFall.vcxproj.filters
@@ -28,6 +28,9 @@
{bc95f981-5965-4a34-8f2e-afba2627bb4b}
+
+ {b26b82a2-f4cd-444a-923f-82aad7c96345}
+
@@ -48,6 +51,9 @@
Source Files\ScreensImplement
+
+ Source Files\TrustFallImplement
+
@@ -68,5 +74,8 @@
Header Files\Screens
+
+ Header Files\TrustFall
+
\ No newline at end of file
diff --git a/TrustFall/TrustFall/game.cpp b/TrustFall/TrustFall/game.cpp
index 368ccc8..719563d 100644
--- a/TrustFall/TrustFall/game.cpp
+++ b/TrustFall/TrustFall/game.cpp
@@ -32,8 +32,9 @@ void Game::reset() {
void Game::run() {
StartScreen start_screen(sprites);
- GameScreen game_screen(sprites);
+ GameScreen game_screen(sprites, 3);
while (state != Exit) {
+ al_clear_to_color(al_map_rgb(0, 0, 0));
switch (state) {
case Start:
start_screen.run(font);
diff --git a/TrustFall/TrustFall/game.h b/TrustFall/TrustFall/game.h
index b9acaac..5b15833 100644
--- a/TrustFall/TrustFall/game.h
+++ b/TrustFall/TrustFall/game.h
@@ -1,7 +1,10 @@
#pragma once
-#include
-#include
-#include
+#include
+#include
+#include
+#include
+#include
+#include
#include
#include
diff --git a/TrustFall/TrustFall/game_screen.cpp b/TrustFall/TrustFall/game_screen.cpp
index 7ea626b..8ecbf51 100644
--- a/TrustFall/TrustFall/game_screen.cpp
+++ b/TrustFall/TrustFall/game_screen.cpp
@@ -1,8 +1,12 @@
-#include "game_screen.h"
-
+#include
+#include
#include
#include
+#include "game_screen.h"
+
+#define FPS 60
+
using std::vector;
using std::string;
@@ -10,33 +14,84 @@ GameScreen::GameScreen(std::map _sprites, int _lin
sprites = _sprites;
for (int i = 0; i < _lines; i++) {
- Line new_line(SCREEN_W-220, SCREEN_H/_lines * i, sprites);
+ Line new_line(SCREEN_W/2, SCREEN_H/_lines * i, sprites);
+ lines.push_back(new_line);
}
selected = 0;
}
void GameScreen::run(ALLEGRO_FONT * font) {
+ bool music = true;
+
ALLEGRO_EVENT_QUEUE* event_queue = NULL;
event_queue = al_create_event_queue();
al_register_event_source(event_queue, al_get_keyboard_event_source());
+
+ ALLEGRO_TIMER* timer = NULL;
+ timer = al_create_timer(1.5);
+ al_register_event_source(event_queue, al_get_timer_event_source(timer));
redraw(font);
al_flip_display();
bool exit_screen = false;
+ al_start_timer(timer);
while (!exit_screen) {
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
+ if (ev.type == ALLEGRO_EVENT_TIMER) {
+ int add_to = rand() % (lines.size()+1);
+ for (int i = 0; i < lines.size(); i++) {
+ if (i == add_to) {
+ lines.at(i).add_employee();
+ }
+ lines.at(i).move();
+ }
+ al_clear_to_color(al_map_rgb(0, 0, 0));
+ redraw(font);
+ al_flip_display();
+ }
+ if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
+ switch (ev.keyboard.keycode) {
+ case ALLEGRO_KEY_DOWN:
+ if (selected < 2) selected++;
+ break;
+ case ALLEGRO_KEY_UP:
+ if (selected > 0) selected--;
+ break;
+ case ALLEGRO_KEY_SPACE:
+ lines.at(selected).add_catcher();
+ break;
+ case ALLEGRO_KEY_M:
+ if (ev.keyboard.modifiers == ALLEGRO_KEYMOD_CTRL) {
+ music = false;
+ }
+ break;
+ case ALLEGRO_KEY_H:
+ if (ev.keyboard.modifiers == ALLEGRO_KEYMOD_CTRL) {
+ music = music; //INCOMPLETE
+ }
+ break;
+ case ALLEGRO_KEY_ESCAPE:
+ next_state = Exit;
+ exit_screen = true;
+ break;
+ }
- if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
-
+ al_clear_to_color(al_map_rgb(0, 0, 0));
+ redraw(font);
+ al_flip_display();
}
}
}
void GameScreen::redraw(ALLEGRO_FONT* font) {
+ al_draw_bitmap(sprites["Mr. Manager"], 10, 0 + (SCREEN_H / lines.size() * selected), NULL);
+ for (int i = 0; i < lines.size(); i++) {
+ lines.at(i).draw();
+ }
}
void GameScreen::back() {
diff --git a/TrustFall/TrustFall/game_screen.h b/TrustFall/TrustFall/game_screen.h
index 984fd21..92c6272 100644
--- a/TrustFall/TrustFall/game_screen.h
+++ b/TrustFall/TrustFall/game_screen.h
@@ -1,7 +1,6 @@
#pragma once
#include "line.h"
#include "screen.h"
-#include "cursor.h"
class GameScreen : public Screen {
public:
diff --git a/TrustFall/TrustFall/line.cpp b/TrustFall/TrustFall/line.cpp
index ac88528..db8ab6b 100644
--- a/TrustFall/TrustFall/line.cpp
+++ b/TrustFall/TrustFall/line.cpp
@@ -21,16 +21,13 @@ Line::Line(int _start_x, int _start_y, map _sprites) {
}
void Line::move() {
- if (caught) {
- caught = false;
- catchers[0] = catchers[1];
- catchers[1] = catchers[0];
- catchers[2] = 0;
- }
-
if (employees[0]) {
if (catchers[0]) {
+
caught = true;
+ catchers[0] = catchers[1];
+ catchers[1] = catchers[0];
+ catchers[2] = 0;
}
else {
fall = true;
@@ -65,24 +62,24 @@ void Line::draw() {
}
}
- for (int i = 2; i > -1; i++) {
+ for (int i = 2; i > -1; i--) {
if (i = 0) {
if (caught) {
al_draw_bitmap(sprites["EmployeeHappy"], start_x - 40, start_y, NULL);
- al_draw_bitmap(sprites["MrMan"], start_x - 40, start_y - 40, NULL);
+ caught = false;
}
else if (fall) {
al_draw_bitmap(sprites["EmployeeSad"], start_x - 40, start_y - 55, ALLEGRO_FLIP_VERTICAL);
}
else {
if (catchers[i]) {
- al_draw_bitmap(sprites["MrMan"], start_x - 40, start_y - 40, NULL);
+ al_draw_bitmap(sprites["Mr. Man"], start_x - 40, start_y - 40, NULL);
}
}
}
else {
if (catchers[i]) {
- al_draw_bitmap(sprites["MrMan"], start_x - 40 - (50*(i+1)), start_y - 40, NULL);
+ al_draw_bitmap(sprites["Mr. Man"], start_x - 40 - (50*(i)), start_y + 40, NULL);
}
}
}
diff --git a/TrustFall/TrustFall/main.cpp b/TrustFall/TrustFall/main.cpp
index 2d0c430..5943959 100644
--- a/TrustFall/TrustFall/main.cpp
+++ b/TrustFall/TrustFall/main.cpp
@@ -1,11 +1,4 @@
#include
-#include
-#include
-#include
-#include
-#include
-#include
-
#include
#include "game.h"
@@ -40,11 +33,7 @@ int main()
return -1;
}
if (!al_install_keyboard()) {
- fprintf(stderr, "failed to initialize allegro!\n");
- return -1;
- }
- if (!al_reserve_samples(1)) {
- fprintf(stderr, "failed to reserve samples!\n");
+ fprintf(stderr, "failed to initialize keyboard!\n");
return -1;
}
@@ -56,6 +45,6 @@ int main()
main_game.run();
al_destroy_display(display);
-
+
return 0;
}
\ No newline at end of file
diff --git a/TrustFall/TrustFall/start_screen.cpp b/TrustFall/TrustFall/start_screen.cpp
index 25709d3..69d24b8 100644
--- a/TrustFall/TrustFall/start_screen.cpp
+++ b/TrustFall/TrustFall/start_screen.cpp
@@ -41,7 +41,7 @@ void StartScreen::run(ALLEGRO_FONT * font) {
cont();
exit_screen = true;
break;
- case ALLEGRO_KEY_BACKSPACE:
+ case ALLEGRO_KEY_ESCAPE:
back();
exit_screen = true;
break;