{
- "player": {
- "start_pos": [
- 200,
- 200
- ],
- "scale": [
- 0.5,
- 0.5
- ],
+ "player" :
+ {
+ "start_pos": [200, 200],
+ "scale": [0.5, 0.5],
"max_speed": 5,
"degrees_per_second": 360,
- "sack": {
- "offset": [
- 25,
- -5
- ],
- "scale": [
- 0.3,
- 0.3
- ],
- "angle": -25
+ "sack" :
+ {
+ "offset" : [25, -5],
+ "scale" : [0.3, 0.3],
+ "angle" : -25
}
+
},
"helper": {
- "start_pos": [
- 1000,
- 50
- ],
- "scale": [
- 0.3,
- 0.3
- ],
+ "start_pos": [1000, 50],
+ "scale": [0.3, 0.3],
"max_speed": 2,
- "direction": [
- 0.35,
- 1
- ],
+
+ "direction": [0.35, 1],
"stop_top": 50,
"stop_bot": 500
},
- "bottle": {
- "scale": [
- 0.5,
- 0.5
- ]
+ "bottle":
+ {
+ "scale": [0.5, 0.5]
},
- "game_constants": {
- "scoreboard": 5,
- "bottles_per_second": 1.5,
- "game_time": 30,
+ "game_constants":
+ {
+ "scoreboard" : 5,
+ "bottles_per_second" : 1.5,
+ "game_time" : 10,
"yf_per_second": 0.125,
"bikes_per_second": 0.17,
"point_scale_div": 3.0,
"highscore_file": "assets/highscore.csv"
},
- "map": {
- "points_pos": [
- 5,
- 38
- ],
- "collected_pos": [
- 5,
- 76
- ],
- "time_pos": [
- 5,
- 0
- ],
+ "map":
+ {
+ "points_pos": [5, 38],
+ "collected_pos": [5, 76],
+ "time_pos": [5, 0],
"font_size": 36
},
- "main_enemy": {
- "scale": [
- 0.35,
- 0.35
- ],
- "start_pos": [
- 50,
- 600
- ],
+
+ "main_enemy":
+ {
+ "scale" : [0.35, 0.35],
+ "start_pos" : [50, 600],
"max_speed": 2.0,
"degrees_per_second": 360
},
- "yf": {
- "scale": [
- 1,
- 1
- ],
- "max_speed": 2.0,
- "direction": [
- 0,
- -1
- ]
+ "yf":
+ {
+ "scale" : [1, 1],
+ "max_speed" : 2.0,
+ "direction": [0, -1]
+
},
- "bike_enemy": {
- "scale": [
- 0.25,
- 0.25
- ],
- "max_speed": 5.0,
- "direction": [
- 0,
- 1
- ],
+
+ "bike_enemy":
+ {
+ "scale" : [0.25, 0.25],
+ "max_speed" : 5.0,
+ "direction": [0, 1],
"sin_amplitude": 50,
"sin_omega": 5
},
- "game_state_assets": {
+
+ "game_state_assets":
+ {
"kir_file": "assets/kir.png",
"YF_file": "assets/YF.png",
"cyklist_file": "assets/cyklist.png",
"helper_file": "assets/ysex.png",
"map_file": "assets/bakgrund.png"
},
- "gameover_menu": {
+ "gameover_menu":
+ {
"texture": "assets/game_over.png",
- "texture_mouse": "assets/muspekareRed.png",
- "font": "assets/fonts/Philosopher-Regular.ttf"
+ "texture_mouse" : "assets/muspekareRed.png",
+ "font" : "assets/fonts/Philosopher-Regular.ttf"
},
- "pause_menu": {
+
+ "pause_menu":
+ {
"texture": "assets/Pause_bild.png",
- "texture_mouse": "assets/muspekareGul.png",
+ "texture_mouse" : "assets/muspekareGul.png",
"font": "assets/fonts/Philosopher-Regular.ttf"
},
- "scoreboard_menu": {
+ "scoreboard_menu":
+ {
"texture": "assets/scoreboard.png",
- "texture_mouse": "assets/muspekare2.png",
+ "texture_mouse" : "assets/muspekare2.png",
"font": "assets/fonts/Philosopher-Regular.ttf"
},
- "start_menu": {
- "texture": "assets/meny_bild.png",
- "texture_mouse": "assets/muspekareGul.png",
- "font": "assets/fonts/Philosopher-Regular.ttf"
+ "start_menu":
+ {
+ "texture": "assets/meny_bild.png",
+ "texture_mouse" : "assets/muspekareGul.png",
+ "font": "assets/fonts/Philosopher-Regular.ttf"
}
+
}
\ No newline at end of file
Nisseboi, 5
Lukas is KUNG, 5
-NissePisse, 4
Nils, 1
sprite.setPosition(position);
}
-void Bike_enemy::collision_player()
-{}
-void Bike_enemy::collision_enemy()
-{}
+void Bike_enemy::collision(Object &other)
+{
+}
void Bike_enemy::update(Context& context)
{
//Game_state* game = static_cast<Game_state*>(context.current_state.get());
public:
Bike_enemy(sf::Texture& txtr, json& params);
~Bike_enemy() = default;
- void collision_player();
- void collision_enemy();
+ void collision(Object &other) override;
void update(Context& context) override;
void render(sf::RenderWindow &window) const override;
#include "Bottle.h"
#include "constants.h"
#include "Context.h"
-#include "States.h"
Bottle::Bottle(sf::Texture& txtr, json& params)
{
texture = txtr;
sprite.setTexture(texture);
- position ={rand()%static_cast<int>(S_WIDTH*5/7.0f - S_WIDTH/5.0f +1) + S_WIDTH/5.0f,
- static_cast<float>(rand()%static_cast<int>(S_HEIGHT+1))};
+ position ={rand()%(S_WIDTH*5/7 - S_WIDTH/5 +1) + S_WIDTH/5, rand()%S_HEIGHT+1}; //x-pixel WIDTH/5 - WIDTH*5/7
sprite.setScale(params["scale"][0], params["scale"][1]);
sf::FloatRect gb {sprite.getGlobalBounds()};
sprite.setOrigin(gb.width / 2, gb.height / 2);
sprite.setPosition(position);
}
+void Bottle::collision(Object& other)
+{
+
+}
void Bottle::update(Context& context)
{
- static_cast<Game_state*>(context.current_state.get());
+
}
void Bottle::render(sf::RenderWindow& window) const
public:
Bottle(sf::Texture& txtr, json& params);
+ void collision(Object& other) override;
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
void set_texture(sf::Texture& txtr);
using json = nlohmann::json;
-GameOver_menu::GameOver_menu(int const points, json& params) :
- menu_index{1},
- points{points},
-
- exit_game{false},
- menu{false},
-
+GameOver_menu::GameOver_menu(int const points, json& params) :
texture{},
texture2{},
-
sprite{},
+ rectangle{},
mouse_l{},
mouse_r{},
-
- rectangle{},
-
- playerInput{},
-
- playerText{},
linetext{},
funfacttext{},
entertext{},
pointstext{},
+ playerInput{},
+ playerText{},
+ data{},
savetext{},
quittext{},
-
font{},
-
- data{}
+ exit_game{false},
+ menu{false},
+ menu_index{1},
+ points{points}
{
data = std::move(params);
texture.loadFromFile(data["gameover_menu"]["texture"]);
case 0: // A
if(menu_index == 1)
{
- load_to_csv();
+ load_to_csv(playerText);
menu = true;
menu_index = 1;
}
break;
}
break;
-
- default:
- break;
}
break;
case sf::Event::KeyPressed:
if(menu_index == 1)
{
- load_to_csv();
+ load_to_csv(playerText);
menu = true;
menu_index = 1;
}
}
}
+
// if not backspace, print letters
else if(playerInput.getSize() < 20)
{
playerInput += event.text.unicode;
}
+
playerText.setString(playerInput);
+
}
+
+
}
//spara namn till fil
-void GameOver_menu::load_to_csv()
+void GameOver_menu::load_to_csv(sf::Text playertext)
{
std::string current_line{playerText.getString() + ", " + std::to_string(points)};
#include "constants.h"
#include "Context.h"
-Helper::Helper(sf::Texture& txtr, json& params) :
- stop_bot{params["stop_bot"]},
- stop_top{params["stop_top"]},
- max_speed{params["max_speed"]},
- movement{}
+Helper::Helper(sf::Texture& txtr, json& params) : stop_bot{params["stop_bot"]}, stop_top{params["stop_top"]}, max_speed{params["max_speed"]}, movement{}
{
texture = txtr;
position = {params["start_pos"][0], params["start_pos"][1]};
}
-void Helper::collision_player()
+void Helper::collision(Object& other)
{
move(false);
}
void Helper::update(Context& context)
-{
- static_cast<Game_state*>(context.current_state.get());
+{
move();
+
+ //Game_state* game = static_cast<Game_state*>(context.current_state.get());
+
}
void Helper::move(bool forward)
Helper(sf::Texture& txtr, json& params);
~Helper() = default;
- void collision_player();
+ void collision(Object& other) override;
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
//void move(Time);
private:
void move(bool forward=true);
-
float stop_bot;
float stop_top;
float max_speed;
-
sf::Vector2f movement;
};
#include "Context.h"
#include "constants.h"
-Main_enemy::Main_enemy(sf::Texture& txtr, json& params):
- max_speed{params["max_speed"]},
- tumble_degrees{0},
- rotation{params["degrees_per_second"]},
-
- tumbling{false},
- moving_to_bottle{false}
+Main_enemy::Main_enemy(sf::Texture& txtr, json& params): max_speed{params["max_speed"]}, moving_to_bottle{false}, tumbling{false}, tumble_degrees{0}, rotation{params["degrees_per_second"]}
{
//texture.loadFromFile("assets/6Ling_figur2.png");
texture = txtr;
}
-void Main_enemy::collision_yf()
-{
- move(false);
-}
-
-void Main_enemy::collision_bike()
-{
- move(false);
-}
-
-void Main_enemy::collision_player()
+void Main_enemy::collision(Object& other)
{
move(false);
- tumbling = true;
}
-
void Main_enemy::update(Context& context)
{
if(tumbling)
window.draw(sprite);
}
+void Main_enemy::collision(Player& player)
+{
+ move(false);
+ tumbling = true;
+}
+
void Main_enemy::move(bool forward)
{
if (moving_to_bottle)
public:
Main_enemy(sf::Texture& txtr, json& params);
~Main_enemy() = default;
- void collision_yf();
- void collision_bike();
- void collision_player();
+ void collision(Object& other) override;
+ void collision(Player& player);
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
protected:
private:
- float bottle_dist(std::unique_ptr<Bottle> const& bottle);
- sf::Vector2f find_closest_bottle(std::vector<std::unique_ptr<Bottle>> & bottles);
- void move(bool forward = true);
-
float max_speed;
float tumble_degrees;
- int rotation;
-
+ int rotation;
bool tumbling;
bool moving_to_bottle;
+ void move(bool forward = true);
+ float bottle_dist(std::unique_ptr<Bottle> const& bottle);
+ sf::Vector2f find_closest_bottle(std::vector<std::unique_ptr<Bottle>> & bottles);
};
#endif
\ No newline at end of file
#include <string>
-Map::Map(sf::Texture& txtr, sf::Texture& bottle_txtr, json& params) :
- texture{txtr},
- bottle_texture{bottle_txtr},
-
- sprite{},
- bottle_sprite{},
-
- point_text{},
- collected_text{},
- time_text{},
-
- font{}
+Map::Map(sf::Texture& txtr, sf::Texture& bottle_txtr, json& params) : texture{txtr}, sprite{}, point_text{}, collected_text{}, time_text{}, bottle_texture{bottle_txtr}, bottle_sprite{}, font{}
{
sprite.setTexture(texture);
time_text.setString("Time left: " + std::to_string(time_left) + " s");
}
-void Map::collision_player()
-{}
-
void Map::render(sf::RenderWindow& window) const
{
window.draw(sprite);
public:
Map(sf::Texture& txtr, sf::Texture& bottle_txtr, json& params);
~Map() = default;
- void collision_player();
+
void update(int const collected, int const points, int const time_left);
void render(sf::RenderWindow& window) const;
bool collides(Object& other);
protected:
private:
sf::Texture texture;
- sf::Texture bottle_texture;
-
sf::Sprite sprite;
+ sf::Texture bottle_texture;
sf::Sprite bottle_sprite;
-
sf::Text point_text;
sf::Text collected_text;
sf::Text time_text;
-
sf::Font font;
};
{
return get_hitbox().intersects(other.get_hitbox());
}
+ virtual void collision(Object& other) = 0;
virtual void update(Context& context) = 0;
virtual void render(sf::RenderWindow& window) const = 0;
using json = nlohmann::json;
-Pause_menu::Pause_menu(json& params) :
- menu_index{1},
-
- resume_game{false},
- exit_game{false},
- menu{false},
-
- texture{},
- texture2{},
-
- sprite{},
- mouse_l{},
- mouse_r{},
-
- resumetext{},
- startmenutext{},
- quittext{},
-
- font{},
-
- data{}
+Pause_menu::Pause_menu(json& params) : texture{}, texture2{}, sprite{}, mouse_l{}, mouse_r{}, resumetext{}, startmenutext{},
+ quittext{}, font{}, resume_game{false}, exit_game{false}, menu{false}, menu_index{1}, data{}
{
data = params;
texture.loadFromFile(data["pause_menu"]["texture"]);
break;
}
break;
- default:
- break;
}
break;
case sf::Event::KeyPressed:
#include "Context.h"
#include "constants.h"
-Player::Player(sf::Texture& player_txtr, sf::Texture& sack_txtr, json& params) :
- collected{0},
- rotation{params["degrees_per_second"]},
- tumble_degrees{0},
- max_speed{params["max_speed"]},
-
- tumbling{false},
-
- sack{},
- sack_texture{sack_txtr},
- sack_offset{params["sack"]["offset"][0], params["sack"]["offset"][1]}
+Player::Player(sf::Texture& player_txtr, sf::Texture& sack_txtr, json& params) : sack_texture{sack_txtr}, collected{0}, max_speed{params["max_speed"]}, tumbling{false}, tumble_degrees{0}, rotation{params["degrees_per_second"]}
{
-
texture = player_txtr;
position = {params["start_pos"][0], params["start_pos"][1]};
sf::FloatRect gb_s {sack.getLocalBounds()};
sack.setOrigin(gb_s.width / 3, gb_s.height / 5);
+ sack_offset = {params["sack"]["offset"][0], params["sack"]["offset"][1]};
sack.rotate(params["sack"]["angle"]);
sack.setPosition(position + sack_offset);
}
-void Player::collision_helper()
+void Player::collision(Object& other)
{
move(false);
+
}
-void Player::collision_map()
+void Player::collision(Map& map)
{
if (tumbling)
{
}
}
-void Player::collision_yf()
+void Player::collision(YF& yf)
{
move(false);
tumbling = true;
}
-
-void Player::collision_bike()
+void Player::collision(Bike_enemy& bike)
{
move(false);
tumbling = true;
}
-void Player::collision_enemy()
-{}
-
void Player::update(Context& context)
{
- static_cast<Game_state*>(context.current_state.get());
-
+
+ // Get game_state from context, static_cast since we know that game is currently running
+ // game_state is still managed by context
+ //Game_state* game = static_cast<Game_state*>(context.current_state.get());
+
if(tumbling)
{
sprite.rotate(-1*std::copysign(1, direction.x)*rotation/FPS);
}
void Player::handle_input(sf::Event& event)
-{
- switch(event.type)
- {
- default:
- break;
- }
+{
if (!tumbling)
{
if (!sf::Joystick::isConnected(0))
sf::Joystick::getAxisPosition(0, sf::Joystick::Y) / 100
};
- double len{pow(direction.x, 2) + pow(direction.y, 2)};
+ float len{pow(direction.x, 2) + pow(direction.y, 2)};
if (len > 1)
{
direction.x /= sqrt(len);
Player(sf::Texture& player_txtr, sf::Texture& sack_txtr, json& params);
~Player() = default;
- void collision_yf();
- void collision_helper();
- void collision_enemy();
- void collision_bike();
- void collision_map();
+ void collision(Object& other) override;
+ void collision(Map& map);
+ void collision(YF& yf);
+ void collision(Bike_enemy& bike);
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
void handle_input(sf::Event& event);
protected:
private:
void move(bool forward=true);
-
int collected;
- int rotation;
float tumble_degrees;
+ int rotation;
float max_speed;
-
bool tumbling;
-
sf::Sprite sack;
sf::Texture sack_texture;
sf::Vector2f sack_offset;
using json = nlohmann::json;
-Scoreboard_menu::Scoreboard_menu(json& params) :
- menu_index{1},
-
- exit_game{false},
- menu{false},
-
- texture{},
- texture2{},
-
- sprite{},
- mouse_l{},
- mouse_r{},
-
- scoreboardtext{},
- firstplacetext{},
- startmenutext{},
- quittext{},
-
- font{},
-
- data{}
+Scoreboard_menu::Scoreboard_menu(json& params) : texture{}, texture2{}, sprite{}, menu{false}, exit_game{false},
+ startmenutext{}, quittext{}, mouse_r{}, mouse_l{}, font{}, menu_index{1}, data{}
+
{
data = std::move(params);
texture.loadFromFile(data["scoreboard_menu"]["texture"]);
break;
}
break;
- default:
- break;
}
break;
case sf::Event::KeyPressed:
using json = nlohmann::json;
-Start_menu::Start_menu(json& params) :
- start_game{false},
- exit_game{false},
- scoreboard{false},
-
- menu_index{1},
-
- texture{},
- texture2{},
-
- sprite{},
- mouse_l{},
- mouse_r{},
-
- starttext{},
- scoreboardtext{},
- quittext{},
-
- font{},
-
- data{}
+Start_menu::Start_menu(json& params) : texture{}, texture2{}, sprite{}, mouse_l{}, mouse_r{}, starttext{}, scoreboardtext{},
+ quittext{}, font{}, start_game{false}, exit_game{false}, scoreboard{false}, menu_index{1}, data{}
{
data = std::move(params);
break;
}
break;
- default:
- break;
}
break;
case sf::Event::KeyPressed:
using json = nlohmann::json;
-Game_state::Game_state(json& params) :
+Game_state::Game_state(json& params) :
+ game_map{},
+ pause_game{false},
+ player{},
bottles{},
-
+ helper{},
+ bike{},
time_since_last_bottle{0.0f},
game_time{0},
time_since_last_yf{0.0f},
time_since_last_bike{0.0f},
- points{0},
-
- pause_game{false},
-
- game_map{},
- player{},
- helper{},
- enemy{},
- yf{},
- bike{},
-
bottle_texture {},
YF_texture {},
bike_texture{},
-
- data{}
+ yf{},
+ data{},
+ enemy{},
+ points{0}
{
data = std::move(params);
sf::Texture main_enemy_texture;
return;
}
- // Update player and helper
+ for (unsigned int i {0}; i < bottles.size(); ++i)
+ {
+ if (enemy->collides(*(bottles[i])))
+ {
+
+ bottles.erase(bottles.begin() + i);
+
+ }
+ else if (player->collides(*(bottles[i])))
+ {
+ bottles.erase(bottles.begin() + i);
+ player->add_collected();
+ }
+ }
+
player->update(context);
helper->update(context);
- // Handle collision
-
if (player->collides(*helper))
{
points += player->get_collected() + floor(player->get_collected() / static_cast<float>(data["game_constants"]["point_scale_div"]));
player->zero_collected();
- player->collision_helper();
- helper->collision_player();
+ player->collision(*helper);
+ helper->collision(*player);
}
if (player->collides(*enemy))
{
- enemy->collision_player();
- player->collision_enemy();
+ enemy->collision(*player);
}
-
if(yf != nullptr)
{
if (player->collides(*yf))
{
player->zero_collected();
-
- player->collision_yf();
- yf->collision_player();
+ player->collision(*yf);
}
if(enemy->collides(*yf))
{
- enemy->collision_yf();
- yf->collision_enemy();
+ enemy->collision(*yf);
}
}
-
if(bike != nullptr)
{
if (player->collides(*bike))
{
player->zero_collected();
-
- player->collision_bike();
- bike->collision_player();
+ player->collision(*bike);
}
if(enemy->collides(*bike))
{
- enemy->collision_bike();
- bike->collision_enemy();
- }
- }
-
- if(game_map->collides(*player))
- {
- player->collision_map();
- game_map->collision_player();
- }
-
- // Collect bottles
-
- for (unsigned int i {0}; i < bottles.size(); ++i)
- {
- if (enemy->collides(*(bottles[i])))
- {
-
- bottles.erase(bottles.begin() + i);
-
- }
- else if (player->collides(*(bottles[i])))
- {
- bottles.erase(bottles.begin() + i);
- player->add_collected();
+ enemy->collision(*bike);
}
}
{
bike->update(context);
}
+ if(game_map->collides(*player))
+ {
+ player->collision(*game_map);
+ }
}
void Game_state::render(sf::RenderWindow &window) const
float game_time;
float time_since_last_yf;
float time_since_last_bike;
- int points;
-
- bool pause_game;
std::unique_ptr<Map> game_map;
std::unique_ptr<Player> player;
std::unique_ptr<YF> yf;
std::unique_ptr<Bike_enemy> bike;
+ bool pause_game;
sf::Texture bottle_texture;
sf::Texture YF_texture;
sf::Texture bike_texture;
-
json data;
+ int points;
};
class Start_menu : public State
void handle_input(sf::Event& event) override;
private:
- bool start_game;
- bool exit_game;
- bool scoreboard;
-
- int menu_index;
-
sf::Texture texture;
sf::Texture texture2;
-
sf::Sprite sprite;
sf::Sprite mouse_l;
sf::Sprite mouse_r;
-
sf::Text starttext;
sf::Text scoreboardtext;
sf::Text quittext;
-
sf::Font font;
+ bool start_game;
+ bool exit_game;
+ bool scoreboard;
json data;
+
+ int menu_index;
};
class Pause_menu : public State
void render(sf::RenderWindow& window) const override;
void handle_input(sf::Event& event) override;
private:
- int menu_index;
-
- bool resume_game;
- bool exit_game;
- bool menu;
-
sf::Texture texture;
sf::Texture texture2;
-
sf::Sprite sprite;
sf::Sprite mouse_l;
sf::Sprite mouse_r;
-
sf::Text resumetext;
sf::Text startmenutext;
sf::Text quittext;
-
sf::Font font;
+ bool resume_game;
+ bool exit_game;
+ bool menu;
json data;
+
+ int menu_index;
};
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
void handle_input(sf::Event& event) override;
-private:
- int menu_index;
-
- bool exit_game;
- bool menu;
-
+private:
sf::Texture texture;
sf::Texture texture2;
-
sf::Sprite sprite;
sf::Sprite mouse_l;
sf::Sprite mouse_r;
-
sf::Text scoreboardtext;
sf::Text firstplacetext;
sf::Text startmenutext;
sf::Text quittext;
-
sf::Font font;
+ bool exit_game;
+ bool menu;
json data;
+ int menu_index;
};
void update(Context& context) override;
void render(sf::RenderWindow& window) const override;
void handle_input(sf::Event& event) override;
- void load_to_csv();
+ void load_to_csv(sf::Text playerText);
private:
- int menu_index;
- int points;
-
- bool exit_game;
- bool menu;
-
sf::Texture texture;
sf::Texture texture2;
-
sf::Sprite sprite;
+ sf::CircleShape rectangle;
sf::Sprite mouse_l;
sf::Sprite mouse_r;
-
- sf::CircleShape rectangle;
-
sf::String playerInput;
-
sf::Text playerText;
sf::Text linetext;
sf::Text funfacttext;
sf::Text pointstext;
sf::Text savetext;
sf::Text quittext;
-
sf::Font font;
+ bool exit_game;
+ bool menu;
json data;
+ int menu_index;
+ int points;
};
#include "YF.h"
#include "constants.h"
#include "Context.h"
-#include "States.h"
YF::YF(sf::Texture& txtr, json& params) : max_speed{params["max_speed"]}
{
texture = txtr;
sprite.setTexture(texture);
//position = {500, 500};
- position ={rand()%static_cast<int>(S_WIDTH*5/7.0f - S_WIDTH/5.0f +1) + S_WIDTH/5.0f, S_HEIGHT}; //x-pixel WIDTH/5 - WIDTH*5/7
+ position ={rand()%(S_WIDTH*5/7 - S_WIDTH/5 +1) + S_WIDTH/5, S_HEIGHT}; //x-pixel WIDTH/5 - WIDTH*5/7
//sprite.setScale(params["scale"][0], params["scale"][1]);
sprite.setScale(params["scale"][0],params["scale"][1]);
sf::FloatRect gb {sprite.getGlobalBounds()};
}
-void YF::collision_player()
-{}
-void YF::collision_enemy()
-{}
+void YF::collision(Object &other)
+{
+}
void YF::update(Context& context)
{
- static_cast<Game_state*>(context.current_state.get());
-
+ //Game_state* game = static_cast<Game_state*>(context.current_state.get());
position += direction*max_speed;
sprite.setPosition(position);
}
public:
YF(sf::Texture& txtr, json& params);
~YF() = default;
- void collision_enemy();
- void collision_player();
+ void collision(Object &other) override;
void update(Context& context) override;
void render(sf::RenderWindow &window) const override;