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 3 level progression #6

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Draw a Box with Overlay
akashkapoordev committed Nov 1, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 85d1b9358733bdbbc7365cb9f5a2f465c333515f
4 changes: 2 additions & 2 deletions Array-Jumper/header/Level/LevelModel.h
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ namespace Level
{
struct BoxDimension
{
float box_width;
float box_height;
float box_width = 300.f;
float box_height = 300.f;

float box_spacing;

18 changes: 16 additions & 2 deletions Array-Jumper/header/Level/LevelView.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include "../../header/UI/UIElement/ImageView.h"
#include "LevelModel.h"
namespace Level
{
class LevelController;
@@ -13,18 +14,31 @@ namespace Level
void update();
void render();



void calcuateBoxDimension();
UI::UIElement::ImageView* getBoxImage(BlockType type);

void drawBox(sf::Vector2f position);
void drawBoxValue(sf::Vector2f position, BlockType type);



private:
LevelController* level_controller;
UI::UIElement::ImageView* background_image;
UI::UIElement::ImageView* box_image;
sf::RenderWindow* game_window;

const float background_alpha = 110.f;

BoxDimension box_dimension;

UI::UIElement::ImageView* target_overlay_image;
UI::UIElement::ImageView* letter_one_overlay_image;
UI::UIElement::ImageView* letter_two_overlay_image;
UI::UIElement::ImageView* letter_three_overlay_image;
UI::UIElement::ImageView* obstacle_one_overlay_image;
UI::UIElement::ImageView* obstacle_two_overlay_image;

void createImage();
void initilizeImage();
void updateImage();
6 changes: 3 additions & 3 deletions Array-Jumper/source/Global/ServiceLocator.cpp
Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ namespace Global
sound_service->initialize();
ui_service->initialize();
level_service->initialize();
player_service->initialize();
//player_service->initialize();
}

void ServiceLocator::update()
@@ -54,7 +54,7 @@ namespace Global
if (GameService::getGameState() == GameState::GAMEPLAY)
{
level_service->update();
player_service->update();
//player_service->update();

}
}
@@ -66,7 +66,7 @@ namespace Global
if (GameService::getGameState() == GameState::GAMEPLAY)
{
level_service->render();
player_service->render();
//player_service->render();

}
}
80 changes: 79 additions & 1 deletion Array-Jumper/source/Level/LevelView.cpp
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
namespace Level
{
using namespace Global;
using namespace UI::UIElement;

Level::LevelView::LevelView(LevelController* controller)
{
@@ -29,25 +30,102 @@ namespace Level
{
drawImage();
}
void LevelView::calcuateBoxDimension()
{
if (!game_window) return;

box_dimension.box_width = 300.f;
box_dimension.box_height = 300.f;
}
ImageView* LevelView::getBoxImage(BlockType type)
{
switch (type)
{
case BlockType::OBSTACLE_ONE:
return obstacle_one_overlay_image;
break;
case BlockType::OBSTACLE_TWO:
return obstacle_two_overlay_image;
break;
case BlockType::TARGET:
return target_overlay_image;
break;
case BlockType::ONE:
return letter_one_overlay_image;
break;
case BlockType::TWO:
return letter_two_overlay_image;
break;
case BlockType::THREE:
return letter_three_overlay_image;
break;
}
}
void LevelView::drawBox(sf::Vector2f position)
{
box_image->setPosition(position);
box_image->render();
}
void LevelView::drawBoxValue(sf::Vector2f position, BlockType type)
{
ImageView* image = getBoxImage(type);
image->setPosition(position);
image->render();
}
void LevelView::createImage()
{
background_image = new UI::UIElement::ImageView();
background_image = new ImageView();
box_image = new ImageView();
target_overlay_image = new ImageView();
letter_one_overlay_image = new ImageView();
letter_two_overlay_image = new ImageView();
letter_three_overlay_image = new ImageView();
obstacle_one_overlay_image = new ImageView();
obstacle_two_overlay_image = new ImageView();


}
void LevelView::initilizeImage()
{
background_image->initialize(Config::array_jumper_bg_texture_path, game_window->getSize().x, game_window->getSize().y, sf::Vector2f(0, 0));
background_image->setImageAlpha(background_alpha);

box_image->initialize(Config::box_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
//target_overlay_image->initialize(Config::target_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
letter_one_overlay_image->initialize(Config::letter_one_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
letter_two_overlay_image->initialize(Config::letter_two_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
letter_three_overlay_image->initialize(Config::letter_three_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
obstacle_one_overlay_image->initialize(Config::obstacle_01_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
obstacle_two_overlay_image->initialize(Config::obstacle_02_texture_path, box_dimension.box_width, box_dimension.box_height, sf::Vector2f(0, 0));
}
void LevelView::updateImage()
{
background_image->update();
box_image->update();
target_overlay_image->update();
letter_one_overlay_image->update();
letter_two_overlay_image->update();
letter_three_overlay_image->update();
obstacle_one_overlay_image->update();
obstacle_two_overlay_image->update();
}
void LevelView::drawImage()
{
background_image->render();
drawBox(sf::Vector2f(0, 0));
BlockType blockTypeToDraw = level_controller->getCurrentBoxValue(0);
drawBoxValue(sf::Vector2f(0, 0), blockTypeToDraw);

}
void LevelView::deleteImage()
{
delete(background_image);
delete(box_image);
delete(target_overlay_image);
delete(letter_one_overlay_image);
delete(letter_two_overlay_image);
delete(letter_three_overlay_image);
delete(obstacle_one_overlay_image);
delete(obstacle_two_overlay_image);
}
}