Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature2 game play #2

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Array-Jumper/Array-Jumper.vcxproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
Expand Down Expand Up @@ -133,14 +133,25 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="source\Gameplay\GameplayController.cpp" />
<ClCompile Include="source\Gameplay\GameplayService.cpp" />
<ClCompile Include="source\Global\Config.cpp" />
<ClCompile Include="source\Event\EventService.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="source\Global\ServiceLocator.cpp" />
<ClCompile Include="source\Level\LevelController.cpp" />
<ClCompile Include="source\Level\LevelModel.cpp" />
<ClCompile Include="source\Level\LevelService.cpp" />
<ClCompile Include="source\Level\LevelView.cpp" />
<ClCompile Include="source\Player\PlayerController.cpp" />
<ClCompile Include="source\Player\PlayerModel.cpp" />
<ClCompile Include="source\Player\PlayerService.cpp" />
<ClCompile Include="source\Player\PlayerView.cpp" />
<ClCompile Include="source\Sound\SoundService.cpp" />
<ClCompile Include="source\Main\GameService.cpp" />
<ClCompile Include="source\Graphics\GraphicService.cpp" />
<ClCompile Include="source\UI\Credits\CreditsScreenUIController.cpp" />
<ClCompile Include="source\UI\Gameplay\GameplayUIController.cpp" />
<ClCompile Include="source\UI\Instructions\InstructionsUIController.cpp" />
<ClCompile Include="source\UI\MainMenu\MainMenuUIController.cpp" />
<ClCompile Include="source\UI\SplashScreen\SplashScreenUIController.cpp" />
Expand All @@ -152,12 +163,26 @@
<ClCompile Include="source\UI\UIService.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="header\Gameplay\GameplayController.h" />
<ClInclude Include="header\Gameplay\GameplayService.h" />
<ClInclude Include="header\Global\Config.h" />
<ClInclude Include="header\Event\EventService.h" />
<ClInclude Include="header\Level\BlockType.h" />
<ClInclude Include="header\Level\LevelController.h" />
<ClInclude Include="header\Level\LevelData.h" />
<ClInclude Include="header\Level\LevelModel.h" />
<ClInclude Include="header\Level\LevelService.h" />
<ClInclude Include="header\Level\LevelView.h" />
<ClInclude Include="header\Player\MovementDirection.h" />
<ClInclude Include="header\Player\PlayerController.h" />
<ClInclude Include="header\Player\PlayerModel.h" />
<ClInclude Include="header\Player\PlayerService.h" />
<ClInclude Include="header\Player\PlayerView.h" />
<ClInclude Include="header\Sound\SoundService.h" />
<ClInclude Include="header\Main\GameService.h" />
<ClInclude Include="header\Graphics\GraphicService.h" />
<ClInclude Include="header\UI\Credits\CreditsScreenUIController.h" />
<ClInclude Include="header\UI\Gameplay\GameplayUIController.h" />
<ClInclude Include="header\UI\Instructions\InstructionsUIController.h" />
<ClInclude Include="header\UI\MainMenu\MainMenuUIController.h" />
<ClInclude Include="header\UI\SplashScreen\SplashScreenUIController.h" />
Expand Down Expand Up @@ -195,6 +220,7 @@
<Image Include="assets\textures\outscal_logo.png" />
<Image Include="assets\textures\play_button.png" />
<Image Include="assets\textures\quit_button.png" />
<Image Include="assets\textures\target.png" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
21 changes: 21 additions & 0 deletions Array-Jumper/Array-Jumper.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@
<ClCompile Include="source\UI\UIElement\ImageView.cpp" />
<ClCompile Include="source\UI\UIElement\TextView.cpp" />
<ClCompile Include="source\UI\UIElement\UIView.cpp" />
<ClCompile Include="source\Player\PlayerModel.cpp" />
<ClCompile Include="source\Player\PlayerView.cpp" />
<ClCompile Include="source\Player\PlayerController.cpp" />
<ClCompile Include="source\Player\PlayerService.cpp" />
<ClCompile Include="source\Level\LevelModel.cpp" />
<ClCompile Include="source\Level\LevelView.cpp" />
<ClCompile Include="source\Level\LevelController.cpp" />
<ClCompile Include="source\Level\LevelService.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="header\Main\GameService.h">
Expand Down Expand Up @@ -74,6 +82,16 @@
<ClInclude Include="header\UI\UIElement\ImageView.h" />
<ClInclude Include="header\UI\UIElement\TextView.h" />
<ClInclude Include="header\UI\UIElement\UIView.h" />
<ClInclude Include="header\Player\PlayerModel.h" />
<ClInclude Include="header\Player\PlayerView.h" />
<ClInclude Include="header\Player\PlayerController.h" />
<ClInclude Include="header\Player\PlayerService.h" />
<ClInclude Include="header\Level\LevelModel.h" />
<ClInclude Include="header\Level\LevelView.h" />
<ClInclude Include="header\Level\LevelController.h" />
<ClInclude Include="header\Level\LevelService.h" />
<ClInclude Include="header\Level\BlockType.h" />
<ClInclude Include="header\Level\LevelData.h" />
</ItemGroup>
<ItemGroup>
<Media Include="assets\sounds\background_music.mp3" />
Expand Down Expand Up @@ -133,6 +151,9 @@
<Image Include="assets\textures\quit_button.png">
<Filter>Resource Files</Filter>
</Image>
<Image Include="assets\textures\target.png">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<Font Include="assets\fonts\bubbleBobble.ttf" />
Expand Down
Binary file added Array-Jumper/assets/textures/target.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions Array-Jumper/header/Event/EventService.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Event
ButtonState right_arrow_button_state;
ButtonState A_button_state;
ButtonState D_button_state;
ButtonState Space_buttonPressed;

bool isGameWindowOpen();
bool gameWindowWasClosed();
Expand All @@ -46,5 +47,6 @@ namespace Event
bool pressedDKey();
bool pressedLeftMouseButton();
bool pressedRightMouseButton();
bool heldSpaceKey();
};
}
27 changes: 27 additions & 0 deletions Array-Jumper/header/Gameplay/GameplayController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include "../../header/Level/BlockType.h"

namespace Gameplay
{
class GameplayController
{
private:

bool isObstacle(Level:: BlockType value);
bool isEndBlock(Level::BlockType value);
void processObstacle();
void processEndBlock();

void gameOver();

public:

void intialize();
void update();
void render();

void onPositionChanged(int position);
void onDeath();
};
}

25 changes: 25 additions & 0 deletions Array-Jumper/header/Gameplay/GameplayService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
#include "GameplayController.h"

namespace Gameplay
{
class GameplayService
{
private:
GameplayController* gameplay_controller;

void destroy();

public:
GameplayService();
~GameplayService();

void intialize();
void update();
void render();

void onPositionChanged(int position);
void onDeath();
};
}

1 change: 1 addition & 0 deletions Array-Jumper/header/Global/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Global
// Textures
static const sf::String array_jumper_bg_texture_path;
static const sf::String box_texture_path;
static const sf::String target_texture_path;
static const sf::String character_texture_path;
static const sf::String instructions_button_texture_path;
static const sf::String letter_one_texture_path;
Expand Down
9 changes: 9 additions & 0 deletions Array-Jumper/header/Global/ServiceLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#include "../../header/Event/EventService.h"
#include "../../header/UI/UIService.h"
#include "../../header/Sound/SoundService.h"
#include "../../header/Player/PlayerService.h"
#include "../../header/Level/LevelService.h"
#include "../../header/Gameplay/GameplayService.h"

namespace Global
{
Expand All @@ -13,6 +16,9 @@ namespace Global
Event::EventService* event_service;
Sound::SoundService* sound_service;
UI::UIService* ui_service;
Player::PlayerService* player_service;
Level::LevelService* level_service;
Gameplay::GameplayService* gameplay_service;

~ServiceLocator();

Expand All @@ -31,5 +37,8 @@ namespace Global
Event::EventService* getEventService();
Sound::SoundService* getSoundService();
UI::UIService* getUIService();
Player::PlayerService* getPlayerService();
Level::LevelService* getLevelService();
Gameplay::GameplayService* getGameplayService();
};
}
20 changes: 20 additions & 0 deletions Array-Jumper/header/Level/BlockType.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

// Each level should be represented as a array of integers
// -1 : Obstacle 1
// -2 : Obstacle 2
// 0 : End block
// 1,2,3 : Numbers

namespace Level
{
enum BlockType
{
OBSTACLE_ONE = -1,
OBSTACLE_TWO = -2,
TARGET = 0,
ONE = 1,
TWO = 2,
THREE = 3,
};
}
27 changes: 27 additions & 0 deletions Array-Jumper/header/Level/LevelController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include "LevelModel.h"

namespace Level
{
class LevelView;
class LevelModel;

class LevelController
{
private:
LevelView* level_view;
LevelModel* level_model;

public:
LevelController();
~LevelController();

void initialize();
void update();
void render();

BoxDimensions getBoxDimensions();
BlockType getCurrentBoxValue(int currentPosition);
};
}

23 changes: 23 additions & 0 deletions Array-Jumper/header/Level/LevelData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include "BlockType.h"

namespace Level
{

struct LevelData
{
static const int NUMBER_OF_BOXES = 10;

BlockType level_boxes[NUMBER_OF_BOXES] = {
BlockType::ONE,
BlockType::TWO,
BlockType::OBSTACLE_ONE,
BlockType::TWO,
BlockType::THREE,
BlockType::ONE,
BlockType::OBSTACLE_TWO,
BlockType::TWO,
BlockType::ONE,
BlockType::TARGET};
};
}
30 changes: 30 additions & 0 deletions Array-Jumper/header/Level/LevelModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#pragma once
#include "LevelData.h"

namespace Level
{

struct BoxDimensions
{
float box_width;
float box_height;
float box_spacing;

float box_spacing_percentage = 0.3f;
float bottom_offset = 200.f;
};


class LevelModel
{
private:
LevelData current_level_data;

public:
LevelModel();
~LevelModel();

BlockType getCurrentBoxValue(int currentPosition);
};
}

28 changes: 28 additions & 0 deletions Array-Jumper/header/Level/LevelService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once
#include "BlockType.h"


namespace Level
{
class LevelController;
struct BoxDimensions;

class LevelService
{
private:
LevelController* level_controller;

void destroy();
public:
LevelService();
~LevelService();

void intialize();
void update();
void render();

BoxDimensions getBoxDimensions();
BlockType getCurrentBoxValue(int currentPosition);
};
}

Loading