Start Screen and art completed

windows
Braydon Kains 6 years ago
parent 58ed73faf6
commit 2a355a51ba

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2042
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TrustFall", "TrustFall\TrustFall.vcxproj", "{C6900ECF-254F-4751-A968-DDA699CCD5A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Debug|x64.ActiveCfg = Debug|x64
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Debug|x64.Build.0 = Debug|x64
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Debug|x86.ActiveCfg = Debug|Win32
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Debug|x86.Build.0 = Debug|Win32
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Release|x64.ActiveCfg = Release|x64
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Release|x64.Build.0 = Release|x64
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Release|x86.ActiveCfg = Release|Win32
{C6900ECF-254F-4751-A968-DDA699CCD5A6}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {33B495B4-3A19-4588-AA7F-6E664C8E0C19}
EndGlobalSection
EndGlobal

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{C6900ECF-254F-4751-A968-DDA699CCD5A6}</ProjectGuid>
<RootNamespace>TrustFall</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<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>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cursor.cpp" />
<ClCompile Include="game.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="start_screen.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cursor.h" />
<ClInclude Include="enums.h" />
<ClInclude Include="game.h" />
<ClInclude Include="screen.h" />
<ClInclude Include="start_screen.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\AllegroDeps.1.7.0.0\build\native\AllegroDeps.targets" Condition="Exists('..\packages\AllegroDeps.1.7.0.0\build\native\AllegroDeps.targets')" />
<Import Project="..\packages\Allegro.5.2.4.0\build\native\Allegro.targets" Condition="Exists('..\packages\Allegro.5.2.4.0\build\native\Allegro.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\AllegroDeps.1.7.0.0\build\native\AllegroDeps.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\AllegroDeps.1.7.0.0\build\native\AllegroDeps.targets'))" />
<Error Condition="!Exists('..\packages\Allegro.5.2.4.0\build\native\Allegro.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Allegro.5.2.4.0\build\native\Allegro.targets'))" />
</Target>
</Project>

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Source Files\EngineImplement">
<UniqueIdentifier>{208c3bdc-70a1-468f-abb5-27de77aca6f5}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Engine">
<UniqueIdentifier>{39102eef-101d-459c-91bd-eb99f53a680c}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\TrustFall">
<UniqueIdentifier>{9584aa99-4970-43df-9c74-abb55fe47b48}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files\Screens">
<UniqueIdentifier>{c35524f9-e2af-4389-8842-332f6f7a1048}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\ScreensImplement">
<UniqueIdentifier>{bc95f981-5965-4a34-8f2e-afba2627bb4b}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="cursor.cpp">
<Filter>Source Files\EngineImplement</Filter>
</ClCompile>
<ClCompile Include="game.cpp">
<Filter>Source Files\EngineImplement</Filter>
</ClCompile>
<ClCompile Include="start_screen.cpp">
<Filter>Source Files\ScreensImplement</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cursor.h">
<Filter>Header Files\Engine</Filter>
</ClInclude>
<ClInclude Include="enums.h">
<Filter>Header Files\TrustFall</Filter>
</ClInclude>
<ClInclude Include="screen.h">
<Filter>Header Files\Engine</Filter>
</ClInclude>
<ClInclude Include="game.h">
<Filter>Header Files\Engine</Filter>
</ClInclude>
<ClInclude Include="start_screen.h">
<Filter>Header Files\Screens</Filter>
</ClInclude>
</ItemGroup>
</Project>

@ -0,0 +1,102 @@
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_primitives.h>
#include <string>
#include "cursor.h"
using std::string;
using std::vector;
template<class T>
Cursor<T>::Cursor()
{
active = false;
}
template<class T>
void Cursor<T>::activate(std::vector<T> _items)
{
items = _items;
selected = 0;
active = true;
}
template<class T>
void Cursor<T>::deactivate()
{
active = false;
}
template<class T>
void Cursor<T>::draw(float _x_start, float _y_start, float _y_offset, ALLEGRO_FONT* _font) {
vector<string> items_text = get_item_strings();
x_start = _x_start;
y_start = _y_start;
y_offset = _y_offset;
font = _font;
for (int i = 0; i < items_text.size(); i++) {
al_draw_text(font, al_map_rgb(255, 255, 255), x_start, y_start + (y_offset*i), ALLEGRO_ALIGN_LEFT, items_text.at(i).c_str());
}
update_selector();
}
template<class T>
void Cursor<T>::down()
{
if (selected < items.size() - 1) {
selected++;
redraw();
}
}
template<class T>
void Cursor<T>::up()
{
if (selected > 0) {
selected--;
redraw();
}
}
template<class T>
T Cursor<T>::get_selected() {
return items.at(selected);
}
template<class T>
void Cursor<T>::redraw()
{
al_clear_to_color(al_map_rgb(0, 0, 0));
draw(x_start, y_start, y_offset, font);
}
template<class T>
void Cursor<T>::update_selector() {
ALLEGRO_COLOR white = al_map_rgb(255, 255, 255);
float offset = y_offset * selected;
float x1 = x_start - 5;
float y1 = y_start + offset;
float x2 = x_start - 5;
float y2 = y_start + 5 + offset;
float x3 = x_start - 1;
float y3 = y_start + 2.5 + offset;
al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, white);
}
template Cursor<string>::Cursor();
template void Cursor<string>::activate(std::vector<string> _options);
template void Cursor<string>::deactivate();
template void Cursor<string>::draw(float x_start, float y_start, float _y_offset, ALLEGRO_FONT* font);
template void Cursor<string>::redraw();
template void Cursor<string>::up();
template void Cursor<string>::down();
template string Cursor<string>::get_selected();
template void Cursor<string>::update_selector();
vector<string> Cursor<string>::get_item_strings() {
return items;
}

@ -0,0 +1,29 @@
#pragma once
#include <vector>
template <class T>
class Cursor {
public:
std::vector<T> items;
int selected;
bool active;
Cursor();
void activate(std::vector<T> _items);
void deactivate();
void draw(float _x_start, float _y_start, float _y_offset, ALLEGRO_FONT* _font);
void up();
void down();
T get_selected();
private:
float x_start;
float y_start;
float y_offset;
ALLEGRO_FONT* font;
std::vector<std::string> get_item_strings();
void update_selector();
void redraw();
};

@ -0,0 +1,12 @@
#pragma once
#define SCREEN_W 640
#define SCREEN_H 480
enum State {
Start,
Gameplay,
Help,
End,
Exit
};

@ -0,0 +1,38 @@
#include "game.h"
#include "start_screen.h"
using std::string;
using std::map;
using std::pair;
Game::Game() {
}
void Game::init() {
score = 0;
state = Start;
sprites.insert(pair<string, ALLEGRO_BITMAP*>("Title", al_load_bitmap("logo.bmp")));
sprites.insert(pair<string, ALLEGRO_BITMAP*>("Mr. Man", al_load_bitmap("MrMan.bmp")));
sprites.insert(pair<string, ALLEGRO_BITMAP*>("Mr. Manager", al_load_bitmap("MrManager.bmp")));
sprites.insert(pair<string, ALLEGRO_BITMAP*>("KeyUp", al_load_bitmap("small_key_up.bmp")));
sprites.insert(pair<string, ALLEGRO_BITMAP*>("Spacebar", al_load_bitmap("spacebar.bmp")));
font = al_create_builtin_font();
}
void Game::reset() {
score = 0;
state = Start;
}
void Game::run() {
while (state != Exit) {
switch (state) {
case Start:
StartScreen start_screen(sprites);
start_screen.run(font);
state = start_screen.next_state;
break;
}
}
}

@ -0,0 +1,31 @@
#pragma once
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <allegro5/allegro_image.h>
#include <vector>
#include <string>
#include <map>
#include "enums.h"
class Game {
public:
//Allegro elements
ALLEGRO_FONT* font;
//Game elements
State state;
int score;
std::map<std::string, ALLEGRO_BITMAP*> sprites;
Game();
void init();
void run();
private:
void reset();
};

@ -0,0 +1,42 @@
#include "game_screen.h"
#include <vector>
#include <string>
using std::vector;
using std::string;
GameScreen::GameScreen(std::map<std::string, ALLEGRO_BITMAP*> _sprites) {
sprites = _sprites;
}
void GameScreen::run(ALLEGRO_FONT * font) {
ALLEGRO_EVENT_QUEUE* event_queue = NULL;
event_queue = al_create_event_queue();
al_register_event_source(event_queue, al_get_keyboard_event_source());
redraw(font);
al_flip_display();
bool exit_screen = false;
while (!exit_screen) {
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
}
}
}
void GameScreen::redraw(ALLEGRO_FONT* font) {
}
void GameScreen::back() {
next_state = Exit;
}
void GameScreen::cont() {
next_state = End;
}

@ -0,0 +1,15 @@
#pragma once
#include "screen.h"
#include "cursor.h"
class GameScreen : public Screen {
public:
std::map<std::string, ALLEGRO_BITMAP*> sprites;
GameScreen(std::map<std::string, ALLEGRO_BITMAP*> _sprites);
void run(ALLEGRO_FONT* font);
void redraw(ALLEGRO_FONT* font);
void back();
void cont();
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 211 KiB

@ -0,0 +1,61 @@
#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"
using std::string;
int main()
{
//Allegro setup
if (!al_init()) {
fprintf(stderr, "failed to initialize allegro!\n");
return -1;
}
if (!al_init_font_addon()) {
fprintf(stderr, "failed to initialize font!\n");
return -1;
}
if (!al_init_primitives_addon()) {
fprintf(stderr, "failed to initialize primitives!\n");
return -1;
}
if (!al_init_image_addon()) {
fprintf(stderr, "failed to initialize image addon!\n");
return -1;
}
if (!al_install_audio()) {
fprintf(stderr, "failed to initialize audio!\n");
return -1;
}
if (!al_init_acodec_addon()) {
fprintf(stderr, "failed to initialize audio codecs!\n");
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");
return -1;
}
ALLEGRO_DISPLAY* display = al_create_display(SCREEN_W, SCREEN_H);
al_clear_to_color(al_map_rgb(0, 0, 0));
Game main_game;
main_game.init();
main_game.run();
al_destroy_display(display);
return 0;
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Allegro" version="5.2.4.0" targetFramework="native" />
<package id="AllegroDeps" version="1.7.0.0" targetFramework="native" />
</packages>

@ -0,0 +1,19 @@
#pragma once
#include <allegro5/allegro.h>
#include <allegro5/allegro_font.h>
#include <vector>
#include <string>
#include <map>
#include "enums.h"
class Screen {
public:
State next_state;
std::map<std::string, ALLEGRO_BITMAP*> sprites;
virtual void run(ALLEGRO_FONT* font) = 0;
virtual void redraw(ALLEGRO_FONT* font) = 0;
virtual void back() = 0;
virtual void cont() = 0;
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

@ -0,0 +1,85 @@
#include "start_screen.h"
#include <vector>
#include <string>
using std::vector;
using std::string;
StartScreen::StartScreen(std::map<std::string, ALLEGRO_BITMAP*> _sprites) {
vector<string> menu_options;
menu_options.push_back("Start");
menu_options.push_back("Quit");
menu.activate(menu_options);
sprites = _sprites;
}
void StartScreen::run(ALLEGRO_FONT * font) {
ALLEGRO_EVENT_QUEUE* event_queue = NULL;
event_queue = al_create_event_queue();
al_register_event_source(event_queue, al_get_keyboard_event_source());
redraw(font);
menu.draw(300.0, 400.0, 20.0, font);
al_flip_display();
bool exit_screen = false;
while (!exit_screen) {
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
switch (ev.keyboard.keycode) {
case ALLEGRO_KEY_UP:
menu.up();
break;
case ALLEGRO_KEY_DOWN:
menu.down();
break;
case ALLEGRO_KEY_ENTER:
cont();
exit_screen = true;
break;
case ALLEGRO_KEY_BACKSPACE:
back();
exit_screen = true;
break;
}
redraw(font);
al_flip_display();
}
}
}
void StartScreen::redraw(ALLEGRO_FONT* font) {
al_draw_bitmap(sprites["Title"], 0, 20, NULL);
al_draw_bitmap(sprites["Mr. Manager"], SCREEN_W / 2 - 24, 150, NULL);
for (int i = 1; i < 7; i++) {
al_draw_bitmap(sprites["Mr. Man"], SCREEN_W / 8 * i + 14, SCREEN_H / 2 - 40, NULL);
}
al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 20, ALLEGRO_ALIGN_CENTER, "Mr. Manager wants to run a teambuilding exercise for his employees.");
al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 30, ALLEGRO_ALIGN_CENTER, "Help Mr.Manager place his employees at the end of his");
al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 2 + 40, ALLEGRO_ALIGN_CENTER, "conveyor belts to make sure no other employees fall off.");
al_draw_bitmap(sprites["KeyUp"], SCREEN_W / 3, SCREEN_H / 2 + 60, NULL);
al_draw_bitmap(sprites["KeyUp"], SCREEN_W / 3 + 34, SCREEN_H / 2 + 60, ALLEGRO_FLIP_VERTICAL);
al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 1.5 - 10, ALLEGRO_ALIGN_LEFT, "Up and down - Move cursor");
al_draw_bitmap(sprites["Spacebar"], SCREEN_W / 3 + 20, SCREEN_H / 2 + 100, NULL);
al_draw_text(font, al_map_rgb(255, 255, 255), SCREEN_W / 2, SCREEN_H / 1.3 - 20, ALLEGRO_ALIGN_LEFT, "Spacebar - Place employee");
}
void StartScreen::back() {
next_state = Exit;
}
void StartScreen::cont() {
if (menu.get_selected() == "Start") {
next_state = Gameplay;
}
else {
next_state = Exit;
}
}

@ -0,0 +1,16 @@
#pragma once
#include "screen.h"
#include "cursor.h"
class StartScreen : public Screen {
public:
Cursor<std::string> menu;
std::map<std::string, ALLEGRO_BITMAP*> sprites;
StartScreen(std::map<std::string, ALLEGRO_BITMAP*> _sprites);
void run(ALLEGRO_FONT* font);
void redraw(ALLEGRO_FONT* font);
void back();
void cont();
};
Loading…
Cancel
Save