idk stuff's on the screen but still have to make it work

windows
BraydonKains 6 years ago
parent 4ae3a615c2
commit 2bb2c77c8f

@ -78,6 +78,15 @@
<Allegro_AddonFont>true</Allegro_AddonFont>
<Allegro_AddonColor>true</Allegro_AddonColor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Allegro_AddonImage>true</Allegro_AddonImage>
<Allegro_AddonTTF>true</Allegro_AddonTTF>
<Allegro_AddonPrimitives>true</Allegro_AddonPrimitives>
<Allegro_AddonAudio>true</Allegro_AddonAudio>
<Allegro_AddonAcodec>true</Allegro_AddonAcodec>
<Allegro_AddonFont>true</Allegro_AddonFont>
<Allegro_AddonColor>true</Allegro_AddonColor>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
@ -132,6 +141,7 @@
<ClCompile Include="cursor.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="game_screen.cpp" />
<ClCompile Include="line.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="start_screen.cpp" />
</ItemGroup>
@ -140,6 +150,7 @@
<ClInclude Include="enums.h" />
<ClInclude Include="game.h" />
<ClInclude Include="game_screen.h" />
<ClInclude Include="line.h" />
<ClInclude Include="screen.h" />
<ClInclude Include="start_screen.h" />
</ItemGroup>

@ -28,6 +28,9 @@
<Filter Include="Source Files\ScreensImplement">
<UniqueIdentifier>{bc95f981-5965-4a34-8f2e-afba2627bb4b}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\TrustFallImplement">
<UniqueIdentifier>{b26b82a2-f4cd-444a-923f-82aad7c96345}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@ -48,6 +51,9 @@
<ClCompile Include="game_screen.cpp">
<Filter>Source Files\ScreensImplement</Filter>
</ClCompile>
<ClCompile Include="line.cpp">
<Filter>Source Files\TrustFallImplement</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cursor.h">
@ -68,5 +74,8 @@
<ClInclude Include="game_screen.h">
<Filter>Header Files\Screens</Filter>
</ClInclude>
<ClInclude Include="line.h">
<Filter>Header Files\TrustFall</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -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);

@ -2,6 +2,9 @@
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <vector>
#include <string>

@ -1,8 +1,12 @@
#include "game_screen.h"
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include <vector>
#include <string>
#include "game_screen.h"
#define FPS 60
using std::vector;
using std::string;
@ -10,33 +14,84 @@ GameScreen::GameScreen(std::map<std::string, ALLEGRO_BITMAP*> _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() {

@ -1,7 +1,6 @@
#pragma once
#include "line.h"
#include "screen.h"
#include "cursor.h"
class GameScreen : public Screen {
public:

@ -21,16 +21,13 @@ Line::Line(int _start_x, int _start_y, map<string, ALLEGRO_BITMAP*> _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);
}
}
}

@ -1,11 +1,4 @@
#include <stdio.h>
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_image.h>
#include <allegro5/allegro_primitives.h>
#include <allegro5/allegro_audio.h>
#include <allegro5/allegro_acodec.h>
#include <string>
#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;
}

@ -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;

Loading…
Cancel
Save