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

Feature 1 level #21

Open
wants to merge 4 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
22 changes: 22 additions & 0 deletions Linked-List-Snake/Linked-List-Snake.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,24 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="source\Level\LevelController.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="source\Level\LevelService.cpp" />
<ClCompile Include="source\Level\LevelView.cpp" />
<ClCompile Include="source\Time\TimeService.cpp" />
<ClCompile Include="source\UI\Credits\CreditsScreenUIController.cpp" />
<ClCompile Include="source\UI\Instructions\InstructionsScreenUIController.cpp" />
<ClCompile Include="source\UI\MainMenu\MainMenuUIController.cpp" />
<ClCompile Include="source\UI\UIElement\RectangleShapeView.cpp" />
<ClCompile Include="source\UI\SplashScreen\SplashScreenUIController.cpp" />
<ClCompile Include="source\UI\UIElement\AnimatedImageView.cpp" />
<ClCompile Include="source\UI\UIElement\ButtonView.cpp" />
<ClCompile Include="source\UI\UIElement\ImageView.cpp" />
<ClCompile Include="source\UI\UIElement\TextView.cpp" />
<ClCompile Include="source\UI\UIElement\UIView.cpp" />
<ClCompile Include="source\UI\UIService.cpp" />
<ClCompile Include="source\UI\Credits\CreditsScreenUIController.cpp" />
<ClCompile Include="source\UI\Instructions\InstructionsScreenUIController.cpp" />
<ClCompile Include="source\UI\UIElement\AnimatedImageView.cpp" />
<ClCompile Include="source\UI\UIElement\ButtonView.cpp" />
<ClCompile Include="source\Global\Config.cpp" />
Expand All @@ -148,11 +162,18 @@
<ClCompile Include="source\Global\ServiceLocator.cpp" />
<ClCompile Include="source\Sound\SoundService.cpp" />
<ClCompile Include="source\UI\SplashScreen\SplashScreenUIController.cpp" />
<ClCompile Include="source\UI\UIElement\RectangleShapeView.cpp" />
<ClCompile Include="source\UI\UIElement\TextView.cpp" />
<ClCompile Include="source\UI\UIService.cpp" />
<ClCompile Include="source\UI\UIElement\UIView.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\Level\LevelNumber.h" />
<ClInclude Include="include\Level\LevelController.h" />
<ClInclude Include="include\Level\LevelData.h" />
<ClInclude Include="include\Level\LevelModel.h" />
<ClInclude Include="include\Level\LevelService.h" />
<ClInclude Include="include\Level\LevelView.h" />
<ClInclude Include="include\Time\TimeService.h" />
<ClInclude Include="include\UI\Credits\CreditsScreenUIController.h" />
<ClInclude Include="include\UI\Instructions\InstructionsScreenUIController.h" />
Expand All @@ -168,6 +189,7 @@
<ClInclude Include="include\Global\ServiceLocator.h" />
<ClInclude Include="include\Sound\SoundService.h" />
<ClInclude Include="include\UI\SplashScreen\SplashScreenUIController.h" />
<ClInclude Include="include\UI\UIElement\RectangleShapeView.h" />
<ClInclude Include="include\UI\UIElement\TextView.h" />
<ClInclude Include="include\UI\UIService.h" />
<ClInclude Include="include\UI\UIElement\UIView.h" />
Expand Down
72 changes: 72 additions & 0 deletions Linked-List-Snake/Linked-List-Snake.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,54 @@
<ClCompile Include="source\UI\Instructions\InstructionsScreenUIController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Level\LevelController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Level\LevelService.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Level\LevelView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Time\TimeService.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\RectangleShapeView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\Credits\CreditsScreenUIController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\Instructions\InstructionsScreenUIController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\MainMenu\MainMenuUIController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\SplashScreen\SplashScreenUIController.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\AnimatedImageView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\ButtonView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\ImageView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\TextView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\UIView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIService.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\UI\UIElement\RectangleShapeView.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="include\Main\GameService.h">
Expand Down Expand Up @@ -119,5 +167,29 @@
<ClInclude Include="include\UI\Instructions\InstructionsScreenUIController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelNumber.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelController.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelData.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelModel.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelService.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Level\LevelView.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\Time\TimeService.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="include\UI\UIElement\RectangleShapeView.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>
3 changes: 3 additions & 0 deletions Linked-List-Snake/include/Global/ServiceLocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "UI/UIService.h"
#include "Sound/SoundService.h"
#include "Time/TimeService.h"
#include "Level/LevelService.h"

namespace Global
{
Expand All @@ -15,6 +16,7 @@ namespace Global
Sound::SoundService* sound_service;
UI::UIService* ui_service;
Time::TimeService* time_service;
Level::LevelService* level_service;

ServiceLocator();
~ServiceLocator();
Expand All @@ -34,6 +36,7 @@ namespace Global
Sound::SoundService* getSoundService();
UI::UIService* getUIService();
Time::TimeService* getTimeService();
Level::LevelService* getLevelService();
void deleteServiceLocator();
};
}
23 changes: 23 additions & 0 deletions Linked-List-Snake/include/Level/LevelController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include "../../include/Level/LevelModel.h"
#include "../../include/Level/LevelView.h"
namespace Level
{
class LevelController
{

LevelModel* level_model;
LevelView* level_view;



public:
LevelController();
void initialize();
void update();
void render();
~LevelController();
float getCellWidth();
float getCellHeight();
};
}
21 changes: 21 additions & 0 deletions Linked-List-Snake/include/Level/LevelData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "../../include/Level/LevelService.h"
namespace Level
{
enum class LevelNumber;



struct LevelData
{
LevelNumber level_index;

LevelData(LevelNumber ind)
{
level_index = ind;
}


};

}
26 changes: 26 additions & 0 deletions Linked-List-Snake/include/Level/LevelModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#pragma once
#include <SFML/System/Vector2.hpp>
#include "Level/LevelData.h"
#include <vector>
namespace Level
{
class LevelModel
{
std::vector<LevelData> level_configuration;

float cell_width;
float cell_height;

public:
static const int number_of_rows = 28;
static const int number_of_columns = 50;

LevelModel();
~LevelModel();

void initialize(int width, int height);

float getCellWidth();
float getCellHeight();
};
}
9 changes: 9 additions & 0 deletions Linked-List-Snake/include/Level/LevelNumber.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
namespace Level
{
enum class LevelNumber
{
ONE,
TWO,
};
}
23 changes: 23 additions & 0 deletions Linked-List-Snake/include/Level/LevelService.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#pragma once
#include "../../include/Level/LevelController.h"
#include "../../include/Level/LevelNumber.h"
namespace Level
{


class LevelService
{
LevelNumber current_level;
LevelController* level_controller;
void createLevelController();
public:
LevelService();
void initialize();
void update();
void render();
~LevelService();


void createLevel(LevelNumber level_to_load);
};
}
41 changes: 41 additions & 0 deletions Linked-List-Snake/include/Level/LevelView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once
#include <SFML/Graphics.hpp>
#include "UI/UIElement/RectangleShapeView.h"
namespace Level
{
using namespace UI;
using namespace UI::UIElement;
class LevelView
{

const sf::Color background_color = sf::Color(180, 200, 160);
RectangleShapeView* background_rectangle;
sf::Color border_color = sf::Color::Black;
float grid_width;
float grid_height;

RectangleShapeView* border_rectangle;

public:



static const int border_thickness = 10;
static const int border_offset_left = 40;
static const int border_offset_top = 40;



LevelView();
void initialize();
void update();
void render();
~LevelView();
float getGridWidth();
float getGridHeight();
void initializeBorder();
void calculateGridExtents();
void initializeBackground();

};
}
56 changes: 56 additions & 0 deletions Linked-List-Snake/include/UI/GameplayUI/GameplayUIController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once
#include "UI/Interface/IUIController.h"
#include "UI/UIElement/TextView.h"

namespace UI
{
namespace GameplayUI
{
class GameplayUIController : public Interface::IUIController
{
private:
// Constants:
const float font_size = 60.f;

const float text_y_position = 7.f;
const float level_number_text_x_position = 65.f;
const float score_text_x_position = 800.f;

// Constants: Operations and Time Complexities
const float operations_font_size = 36.f;
const float operations_text_x_position = 1330.f;
const float operations_text_y_position = 10.f;
const float time_complexity_text_x_position = 1330.f;
const float time_complexity_text_y_position = 45.f;

UI::UIElement::TextView* level_number_text;
UI::UIElement::TextView* score_text;
UI::UIElement::TextView* time_complexity_text;
UI::UIElement::TextView* operation_text;

void createTexts();
void initializeTexts();
void initializeLevelNumberText();
void initializeScoreText();
void initializeTimeComplexityText();
void initializeOperationText();

void updateLevelNumberText();
void updateScoreText();
void updateTimeComplexityText();
void updateOperationText();

void destroy();

public:
GameplayUIController();
~GameplayUIController();

void initialize() override;
void update() override;
void render() override;
void show() override;
};
}
}

Loading