Skip to content
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
4 changes: 4 additions & 0 deletions Array-Jumper/Array-Jumper.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
<ClCompile Include="source\Event\EventService.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="source\Global\ServiceLocator.cpp" />
<ClCompile Include="source\Player\PlayerModel.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" />
Expand All @@ -154,6 +156,8 @@
<ItemGroup>
<ClInclude Include="header\Global\Config.h" />
<ClInclude Include="header\Event\EventService.h" />
<ClInclude Include="header\Player\PlayerModel.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" />
Expand Down
4 changes: 4 additions & 0 deletions Array-Jumper/Array-Jumper.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
<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" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="header\Main\GameService.h">
Expand Down Expand Up @@ -74,6 +76,8 @@
<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" />
</ItemGroup>
<ItemGroup>
<Media Include="assets\sounds\background_music.mp3" />
Expand Down
34 changes: 34 additions & 0 deletions Array-Jumper/header/Player/PlayerModel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma once
namespace Player
{
enum class PlayerState
{
ALIVE,
DEAD
};

class PlayerModel
{
private:

const int max_lives = 3;

PlayerState player_state;
int current_position;
int current_lives;

public:

void initialize();

PlayerState getPlayerState();
void setPlayerState(PlayerState new_player_state);

void resetPlayer();
void resetPosition();
int getCurrentPosition();
void setCurrentPosition(int new_position);
void decreamentLife();
int getCurrentLives();
};
}
31 changes: 31 additions & 0 deletions Array-Jumper/header/Player/PlayerView.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#pragma once
#include "../../header/UI/UIElement/ImageView.h"

namespace Player
{
class PlayerController;
class PlayerView
{
private:
sf::RenderWindow* game_window;
UI::UIElement::ImageView* player_image;

float player_height;
float player_width;

void initializePlayerImage();
void drawPlayer();
void loadPlayer();
void calculatePlayerDimensions();
void updatePlayerPosition();
sf::Vector2f calulcatePlayerPosition();

public:
PlayerView();
~PlayerView();

void initialize();
void update();
void render();
};
}
37 changes: 37 additions & 0 deletions Array-Jumper/source/Player/PlayerModel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "../../header/Player/PlayerModel.h"


namespace Player
{
void Player::PlayerModel::initialize()
{
//Yet to implement
}

PlayerState PlayerModel::getPlayerState()
{
return player_state;
}

void PlayerModel::setPlayerState(PlayerState new_player_state)
{
player_state = new_player_state;
}

void PlayerModel::resetPlayer()
{
current_position = 0;
player_state = PlayerState::ALIVE;
current_lives = max_lives;
}

void PlayerModel::resetPosition()
{
current_position = 0;
}

int PlayerModel::getCurrentPosition() { return current_position; }
void PlayerModel::setCurrentPosition(int new_position) { current_position = new_position; }
void PlayerModel::decreamentLife() { current_lives--; }
int PlayerModel::getCurrentLives() { return current_lives; }
}
71 changes: 71 additions & 0 deletions Array-Jumper/source/Player/PlayerView.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include "../../header/Player/PlayerView.h"
#include <iostream>
#include "../../header/Global/Config.h"
#include "../../source/Global/ServiceLocator.cpp"
#include "../../header/UI/UIElement/ImageView.h"


using namespace Global;
using namespace UI::UIElement;
//using namespace Level;
namespace Player
{
PlayerView::PlayerView()
{
game_window = nullptr;
player_image = new ImageView();
}

PlayerView::~PlayerView() {}

void PlayerView::initialize()
{
game_window = ServiceLocator::getInstance()->getGraphicService()->getGameWindow();
loadPlayer();
}

sf::Vector2f PlayerView::calulcatePlayerPosition()
{
return sf::Vector2f(0, 0);
}

void PlayerView::updatePlayerPosition()
{
player_image->setPosition(calulcatePlayerPosition());
}

void PlayerView::drawPlayer()
{
player_image->render();
}

void PlayerView::update()
{
updatePlayerPosition();
}

void PlayerView::render()
{
//Yet to implement
}

void PlayerView::loadPlayer()
{
calculatePlayerDimensions();
initializePlayerImage();
}

void PlayerView::calculatePlayerDimensions()
{
player_height = 1000.f;
player_width = 1000.f;
}

void PlayerView::initializePlayerImage()
{
player_image->initialize(Config::character_texture_path,
player_width,
player_height,
sf::Vector2f(0, 0));
}
}