[Added] Crates, Hud for bullets and health
This commit is contained in:
@@ -16,7 +16,6 @@ public:
|
||||
{
|
||||
this->position = pos;
|
||||
this->direction = direction;
|
||||
std::cout << direction << std::endl;
|
||||
}
|
||||
|
||||
// ~Bullet() {}
|
||||
@@ -25,8 +24,8 @@ public:
|
||||
{
|
||||
move();
|
||||
hasCollided = false;
|
||||
envCollision();
|
||||
objCollision();
|
||||
envCollision();
|
||||
// // detectCollision();
|
||||
}
|
||||
|
||||
@@ -42,14 +41,14 @@ public:
|
||||
|
||||
protected:
|
||||
Color color = RED;
|
||||
Vector2 position;
|
||||
int size = 7;
|
||||
bool hasCollided = false;
|
||||
|
||||
private:
|
||||
// TextureWrapper object;
|
||||
Vector2 position;
|
||||
float direction;
|
||||
float velocity = 15.0f;
|
||||
int size = 7;
|
||||
bool hasCollided = false;
|
||||
|
||||
void move()
|
||||
{
|
||||
@@ -59,7 +58,7 @@ private:
|
||||
}
|
||||
void envCollision()
|
||||
{
|
||||
if (position.y < 0 || position.y > GetScreenHeight())
|
||||
if (position.x < 0 || position.y < 0 || position.y > GetScreenHeight())
|
||||
{
|
||||
hasCollided = true;
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
#ifndef CRATE_H
|
||||
#define CRATE_H
|
||||
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
#include "entities/PBullet.h"
|
||||
|
||||
class Crate {
|
||||
public:
|
||||
Crate() {
|
||||
this->texture = TextureWrapper(AssetService::getInstance().getSprite(ESprite::CRATE),{32,32});
|
||||
}
|
||||
|
||||
Crate(Vector2 pos) {
|
||||
this->texture = TextureWrapper(AssetService::getInstance().getSprite(ESprite::CRATE),{32,32}, pos);
|
||||
}
|
||||
|
||||
void logic() {
|
||||
|
||||
}
|
||||
|
||||
bool hasBeenHit() {
|
||||
return this->hit;
|
||||
}
|
||||
|
||||
void setHit(bool hit) {
|
||||
this->hit = hit;
|
||||
}
|
||||
|
||||
void draw() {
|
||||
DrawTexture(this->texture.getTexture(), this->texture.getPosition().x, this->texture.getPosition().y, WHITE);
|
||||
}
|
||||
|
||||
TextureWrapper& getObject() {
|
||||
return this->texture;
|
||||
}
|
||||
|
||||
private:
|
||||
TextureWrapper texture;
|
||||
bool hit; // Whether a PBullet has hit the create
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
+66
-5
@@ -8,6 +8,7 @@
|
||||
#include "services/MapService.h"
|
||||
#include "services/InputService.h"
|
||||
#include "services/GameService.h"
|
||||
#include "services/CollectableService.h"
|
||||
#include "entities/Player.h"
|
||||
#include "entities/Text.h"
|
||||
#include "entities/Bullet.h"
|
||||
@@ -47,6 +48,8 @@ public:
|
||||
this->player.setPosition({200, 350});
|
||||
this->crosshair = TextureWrapper(AssetService::getInstance().getSprite(ESprite::CROSSHAIR), {15, 15}, {0, 0}, {0, 0, 15, 15});
|
||||
|
||||
CollectableService::getInstance().initCollectables();
|
||||
|
||||
initPauseScreen();
|
||||
initGameOverScreen();
|
||||
|
||||
@@ -80,8 +83,9 @@ public:
|
||||
AudioService::getInstance().pauseMusic();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
GameService::getInstance().bulletLogic();
|
||||
CollectableService::getInstance().collectableLogic();
|
||||
|
||||
this->player.logic();
|
||||
if (this->player.getTexture().getPosition().x > (StateService::getInstance().getScreenSize().x / 2.0f))
|
||||
@@ -104,6 +108,7 @@ public:
|
||||
// }
|
||||
GameService::getInstance().drawBullets();
|
||||
this->map.draw();
|
||||
CollectableService::getInstance().drawCollectables();
|
||||
this->player.draw();
|
||||
|
||||
EndMode2D();
|
||||
@@ -116,6 +121,7 @@ public:
|
||||
{
|
||||
drawGameOver();
|
||||
}
|
||||
drawHud();
|
||||
drawCrosshair();
|
||||
EndDrawing();
|
||||
}
|
||||
@@ -250,10 +256,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void shootLogic()
|
||||
{
|
||||
}
|
||||
|
||||
void drawPaused()
|
||||
{
|
||||
// 100, 100, 255, 60
|
||||
@@ -290,6 +292,65 @@ private:
|
||||
// 0,
|
||||
// WHITE);
|
||||
}
|
||||
|
||||
void drawHud()
|
||||
{
|
||||
drawHudHealth();
|
||||
drawHudBullets();
|
||||
}
|
||||
|
||||
void drawHudBullets()
|
||||
{
|
||||
Vector2i pixel_pos = Vector2i(5, 40);
|
||||
Texture2D ammoSprite = AssetService::getInstance().getSprite(ESprite::HUD_AMMO);
|
||||
Vector2i display_pos;
|
||||
for (int i = 0; i < this->player.getAmmo(); i++)
|
||||
{
|
||||
if (i <= 49)
|
||||
{
|
||||
display_pos = Vector2i(pixel_pos.x + ammoSprite.width * i, pixel_pos.y);
|
||||
}
|
||||
if (i > 49 && i <= 99)
|
||||
{
|
||||
display_pos = Vector2i(pixel_pos.x + ammoSprite.width * (i - (50)), pixel_pos.y + ammoSprite.height);
|
||||
}
|
||||
else if (i > 99 && i <= 149)
|
||||
{
|
||||
display_pos = Vector2i(pixel_pos.x + ammoSprite.width * (i - (100)), pixel_pos.y + ammoSprite.height * 2);
|
||||
}
|
||||
else if (i > 149 && i <= 199)
|
||||
{
|
||||
display_pos = Vector2i(pixel_pos.x + ammoSprite.width * (i - (150)), pixel_pos.y + ammoSprite.height * 3);
|
||||
}
|
||||
else if (i > 199 && i <= 249)
|
||||
{
|
||||
display_pos = Vector2i(pixel_pos.x + ammoSprite.width * (i - (200)), pixel_pos.y + ammoSprite.height * 4);
|
||||
}
|
||||
DrawTexture(ammoSprite, display_pos.x, display_pos.y, WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
void drawHudHealth()
|
||||
{
|
||||
Vector2i pixel_pos = Vector2i(5, 5);
|
||||
Texture2D noHealthSprite = AssetService::getInstance().getSprite(ESprite::HUD_HEART_EMPTY);
|
||||
Texture2D healthSprite = AssetService::getInstance().getSprite(ESprite::HUD_HEART);
|
||||
// sVector2f coord_pos = GetWindow().mapPixelToCoords(pixel_pos);
|
||||
for (int i = 0; i < this->player.getMaxHealth(); i++)
|
||||
{
|
||||
Vector2i pos = Vector2i(pixel_pos.x + noHealthSprite.width * i, pixel_pos.y);
|
||||
// noHealthSprite[i].setPosition(coord_pos.x + noHealthTexture.getSize().x * i, coord_pos.y);
|
||||
DrawTexture(noHealthSprite, pos.x, pos.y, WHITE);
|
||||
}
|
||||
for (int i = 0; i < this->player.getHealth(); i++)
|
||||
{
|
||||
// healthSprite[i].setPosition(coord_pos.x + healthTexture.getSize().x * i, coord_pos.y);
|
||||
// DrawTexture(ammoSprite, display_pos.x, display_pos.y, WHITE);
|
||||
Vector2i pos = Vector2i(pixel_pos.x + healthSprite.width * i, pixel_pos.y);
|
||||
// noHealthSprite[i].setPosition(coord_pos.x + noHealthTexture.getSize().x * i, coord_pos.y);
|
||||
DrawTexture(healthSprite, pos.x, pos.y, WHITE);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,9 +1,10 @@
|
||||
#ifndef MAP_H
|
||||
#define MAP_H
|
||||
|
||||
#include <vector>
|
||||
#include "raylib.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
#include "entities/Vector2i.h"
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
/**
|
||||
@@ -28,6 +29,10 @@ public:
|
||||
return this->colMap;
|
||||
}
|
||||
|
||||
void updateColmapTile(Vector2i tile, bool collision) {
|
||||
this->colMap[tile.y][tile.x] = collision ? 1 : 0;
|
||||
}
|
||||
|
||||
private:
|
||||
/** Holds the number for every single tile, which refers to a certain sprite in the tileset */
|
||||
std::vector<std::vector<Vector2>> map;
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
#ifndef PBULLET_H
|
||||
#define PBULLET_H
|
||||
|
||||
#include "services/CollectableService.h"
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/Bullet.h"
|
||||
#include <iostream>
|
||||
|
||||
class PBullet : public Bullet {
|
||||
class PBullet : public Bullet
|
||||
{
|
||||
public:
|
||||
|
||||
PBullet() {}
|
||||
PBullet(Vector2 pos, float angle) : Bullet(pos, angle) {
|
||||
PBullet(Vector2 pos, float angle) : Bullet(pos, angle)
|
||||
{
|
||||
this->color = YELLOW;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
void objCollision() override {
|
||||
|
||||
void objCollision() override
|
||||
{
|
||||
/** Check for collisions with creates */
|
||||
for (auto &crate : CollectableService::getInstance().getCrates())
|
||||
{
|
||||
if(this->position.x + this->size > crate.getObject().getPosition().x && this->position.x - this->size < crate.getObject().getPosition().x &&
|
||||
this->position.y + this->size > crate.getObject().getPosition().y && this->position.y - this->size < crate.getObject().getPosition().y ) {
|
||||
crate.setHit(true);
|
||||
AssetService::getInstance().playSound(ESound::CRATE_BREAK);
|
||||
// AssetService::getInstance().playSound(ESound::JELLY_FREED);
|
||||
this->hasCollided = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "services/GameService.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
#include "enums/ECorner.h"
|
||||
#include "enums/ESound.h"
|
||||
#include "entities/Vector2i.h"
|
||||
#include "entities/PBullet.h"
|
||||
|
||||
@@ -20,11 +21,12 @@ public:
|
||||
this->texture = TextureWrapper(AssetService::getInstance().getSprite(ESprite::PLAYER), {32, 32}, {200, 200});
|
||||
|
||||
prevFrame = GetTime();
|
||||
spriteAnimation = {0, 0};
|
||||
spriteAnimation = {0, Right};
|
||||
this->gunRight = TextureWrapper(AssetService::getInstance().getSprite(ESprite::PLAYER_GUN_RIGHT), {58, 29}, {0, 0});
|
||||
this->gunLeft = TextureWrapper(AssetService::getInstance().getSprite(ESprite::PLAYER_GUN_LEFT), {58, 29}, {0, 0});
|
||||
this->ammo = max_ammo;
|
||||
this->prevShot = GetTime();
|
||||
this->health = max_health;
|
||||
}
|
||||
~Player()
|
||||
{
|
||||
@@ -54,6 +56,18 @@ public:
|
||||
this->texture.setPosition(pos);
|
||||
}
|
||||
|
||||
int getAmmo() {
|
||||
return this->ammo;
|
||||
}
|
||||
|
||||
uint8_t getHealth() {
|
||||
return this->health;
|
||||
}
|
||||
|
||||
uint8_t getMaxHealth() {
|
||||
return this->max_health;
|
||||
}
|
||||
|
||||
protected:
|
||||
private:
|
||||
TextureWrapper texture;
|
||||
@@ -63,9 +77,9 @@ private:
|
||||
float jumpPower = 7.2f;
|
||||
float moveSpeed = 5.0f;
|
||||
float gravity = 0.6f;
|
||||
float animationDelay = 0.2f; // In seconds
|
||||
float animationDelay = 0.2f; // In seconds
|
||||
double prevFrame;
|
||||
Vector2 spriteAnimation; // Keeps track of (1) Sprite cycling and (2) Player direction
|
||||
Vector2i spriteAnimation; // Keeps track of (1) Sprite cycling and (2) Player direction
|
||||
enum Direction
|
||||
{
|
||||
Down,
|
||||
@@ -79,10 +93,12 @@ private:
|
||||
bool groundCollision; // Keeps track of whether or not the player has collided with the ground
|
||||
bool crateTopCollision; // Whether the player is standing on top of a crate
|
||||
|
||||
int ammo;
|
||||
int max_ammo = 100;
|
||||
float firingRate= 0.2f; // Delay in seconds
|
||||
uint8_t ammo; // Current ammo of the player
|
||||
uint8_t max_ammo = 100; // Max ammo of the player
|
||||
float firingRate= 0.2f; // Delay in seconds
|
||||
double prevShot; // The last time the player fired a bullet
|
||||
uint8_t health; // Current health of the player
|
||||
uint8_t max_health = 10; // Max health of the player
|
||||
|
||||
void applyGravity()
|
||||
{
|
||||
@@ -278,6 +294,7 @@ private:
|
||||
{
|
||||
if (this->texture.getPosition().y > StateService::getInstance().getScreenSize().y)
|
||||
{
|
||||
this->health = 0;
|
||||
GameService::getInstance().setGameOver(true);
|
||||
AudioService::getInstance().setMusic(EMusic::GAME_OVER);
|
||||
AudioService::getInstance().playMusic();
|
||||
@@ -335,14 +352,18 @@ private:
|
||||
if (InputService::getInstance().isMouseButtonDown(MOUSE_BUTTON_LEFT) && GetTime() - prevShot > firingRate && groundCollision)
|
||||
{
|
||||
prevShot = GetTime();
|
||||
if (ammo == 0) {
|
||||
if (ammo == 0 || (GameService::getInstance().getMouseWorldPos().x > (this->texture.getPosition().x - this->gunLeft.getSize().x/2.0f) && spriteAnimation.y == Left) ||
|
||||
(GameService::getInstance().getMouseWorldPos().x < (this->texture.getPosition().x + this->texture.getSize().x + gunLeft.getSize().x/2.0f) && spriteAnimation.y == Right))
|
||||
{
|
||||
// Play empty gun sound
|
||||
AssetService::getInstance().playSound(ESound::NO_AMMO);
|
||||
return;
|
||||
}
|
||||
// Play shooting sound
|
||||
AssetService::getInstance().playSound(ESound::SHOOT);
|
||||
ammo--;
|
||||
Vector2 bulletStartLocation = {this->texture.getPosition().x + 10, this->texture.getPosition().y + 10};
|
||||
|
||||
Vector2 bulletStartLocation = {this->texture.getPosition().x + 10, this->texture.getPosition().y + 10};
|
||||
Vector2 mouseWorldPos = GameService::getInstance().getMouseWorldPos();
|
||||
|
||||
if (spriteAnimation.y == Left)
|
||||
@@ -353,7 +374,7 @@ private:
|
||||
if (spriteAnimation.y == Right)
|
||||
{
|
||||
bulletStartLocation.y = this->texture.getPosition().y + 10;
|
||||
bulletStartLocation.x = this->texture.getPosition().x + 37;
|
||||
bulletStartLocation.x = this->texture.getPosition().x + 22;
|
||||
}
|
||||
|
||||
if (mouseWorldPos.x > this->texture.getPosition().x + (this->gunLeft.getSize().x) && spriteAnimation.y == Right ||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef ESOUND_H
|
||||
#define ESOUND_H
|
||||
|
||||
enum class ESound {
|
||||
SHOOT,
|
||||
NO_AMMO,
|
||||
CRATE_BREAK,
|
||||
JELLY_FREED,
|
||||
HEAL_PICKUP,
|
||||
AMMO_PICKUP,
|
||||
POWERUP,
|
||||
PLAYER_DAMAGE,
|
||||
ENEMY_DEFEATED,
|
||||
VICTORY
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "enums/EBackground.h"
|
||||
#include "enums/EMap.h"
|
||||
#include "enums/ESprite.h"
|
||||
#include "enums/ESound.h"
|
||||
#include "services/Service.h"
|
||||
|
||||
class AssetService: public Service<AssetService>
|
||||
@@ -32,6 +33,10 @@ public:
|
||||
return this->sprites[sprite];
|
||||
}
|
||||
|
||||
void playSound(ESound sound) {
|
||||
PlaySound(sounds[sound]);
|
||||
}
|
||||
|
||||
protected:
|
||||
AssetService();
|
||||
|
||||
@@ -41,7 +46,7 @@ private:
|
||||
|
||||
std::string assetDir;
|
||||
std::unordered_map<EFont, std::string> fonts;
|
||||
std::vector<Sound> sounds;
|
||||
std::unordered_map<ESound, Sound> sounds;
|
||||
std::unordered_map<EMusic, Music> music;
|
||||
std::unordered_map<EBackground, Texture2D> backgrounds;
|
||||
std::unordered_map<EMap, std::string> maps;
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
#ifndef COLLECTABLE_SERVICE_H
|
||||
#define COLLECTABLE_SERVICE_H
|
||||
|
||||
#include "raylib.h"
|
||||
#include "services/Service.h"
|
||||
#include "services/MapService.h"
|
||||
#include "entities/Vector2i.h"
|
||||
#include "entities/Crate.h"
|
||||
#include "entities/PBullet.h"
|
||||
#include <vector>
|
||||
|
||||
class CollectableService : public Service<CollectableService>
|
||||
{
|
||||
public:
|
||||
void initCollectables()
|
||||
{
|
||||
initCrates();
|
||||
}
|
||||
|
||||
void collectableLogic()
|
||||
{
|
||||
crateLogic();
|
||||
}
|
||||
|
||||
void drawCollectables()
|
||||
{
|
||||
drawCrates();
|
||||
}
|
||||
|
||||
// void checkCratesForCollision(PBullet bullet)
|
||||
// {
|
||||
// for (auto it = crates.begin(); it != crates.end();)
|
||||
// {
|
||||
// auto &crate = *it;
|
||||
// // if (*it % 2 == 0) {
|
||||
// if (crate.bulletCollision(bullet))
|
||||
// {
|
||||
// Vector2 pos = crate.getObject().getPosition();
|
||||
// Vector2i tilePos = Vector2i(pos.x / MapService::getInstance().getMap().getTileSize(), pos.y / MapService::getInstance().getMap().getTileSize());
|
||||
// MapService::getInstance().getMap().updateColmapTile(tilePos, false);
|
||||
// it = crates.erase(it); // erase returns the next iterator
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ++it;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
std::vector<Crate>& getCrates() {
|
||||
return this->crates;
|
||||
}
|
||||
|
||||
private:
|
||||
void initCrates()
|
||||
{
|
||||
crates.clear();
|
||||
Vector2 location;
|
||||
int tileSize = MapService::getInstance().getMap().getTileSize();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
crates.push_back(Crate());
|
||||
// crateLocation.push_back(location);
|
||||
}
|
||||
crates[0].getObject().setPosition({38.0f * tileSize, 9.0f * tileSize});
|
||||
crates[1].getObject().setPosition({41.0f * tileSize, 5.0f * tileSize});
|
||||
crates[2].getObject().setPosition({68.0f * tileSize, 4.0f * tileSize});
|
||||
|
||||
for (int i = 0; i < crates.size(); i++)
|
||||
{
|
||||
Vector2i crateTilePos = Vector2i(crates[i].getObject().getPosition().x / tileSize, crates[i].getObject().getPosition().y / tileSize);
|
||||
MapService::getInstance().getMap().updateColmapTile(crateTilePos, true);
|
||||
}
|
||||
// crates[0].y = 9 * tileSize;
|
||||
|
||||
// crateLocation[1].x = 41 * tileSize;
|
||||
// crateLocation[1].y = 5 * tileSize;
|
||||
|
||||
// crateLocation[2].x = 68 * tileSize;
|
||||
// crateLocation[2].y = 4 * tileSize;
|
||||
}
|
||||
|
||||
void initJellies()
|
||||
{
|
||||
}
|
||||
|
||||
void crateLogic()
|
||||
{
|
||||
for (auto it = crates.begin(); it != crates.end();)
|
||||
{
|
||||
auto &crate = *it;
|
||||
/**
|
||||
* If the crate has been hit:
|
||||
* 1. Remove the collision tile from the collision map
|
||||
*
|
||||
*/
|
||||
if (crate.hasBeenHit())
|
||||
{
|
||||
Vector2 pos = crate.getObject().getPosition();
|
||||
Vector2i tilePos = Vector2i(pos.x / MapService::getInstance().getMap().getTileSize(), pos.y / MapService::getInstance().getMap().getTileSize());
|
||||
MapService::getInstance().getMap().updateColmapTile(tilePos, false);
|
||||
it = crates.erase(it);
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// void destroyCrate(int index) {
|
||||
// Vector2 pos = crates[index].getObject().getPosition();
|
||||
// Vector2i tilePos = Vector2i(pos.x/MapService::getInstance().getMap().getTileSize(), pos.y/MapService::getInstance().getMap().getTileSize());
|
||||
// MapService::getInstance().getMap().updateColmapTile(tilePos, false);
|
||||
// crates.erase(crates.begin() + index);
|
||||
// }
|
||||
|
||||
// void checkCratesForCollision(PBullet bullet)
|
||||
// {
|
||||
// for (auto it = crates.begin(); it != crates.end();)
|
||||
// {
|
||||
// auto &crate = *it;
|
||||
// // if (*it % 2 == 0) {
|
||||
// if (crate.bulletCollision(bullet))
|
||||
// {
|
||||
// Vector2 pos = crate.getObject().getPosition();
|
||||
// Vector2i tilePos = Vector2i(pos.x / MapService::getInstance().getMap().getTileSize(), pos.y / MapService::getInstance().getMap().getTileSize());
|
||||
// MapService::getInstance().getMap().updateColmapTile(tilePos, false);
|
||||
// it = crates.erase(it); // erase returns the next iterator
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ++it;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void jellyLogic()
|
||||
{
|
||||
}
|
||||
|
||||
void drawCrates()
|
||||
{
|
||||
for (int i = 0; i < crates.size(); i++)
|
||||
{
|
||||
crates[i].draw();
|
||||
}
|
||||
}
|
||||
|
||||
void drawJellies()
|
||||
{
|
||||
}
|
||||
|
||||
void drawHudJellies()
|
||||
{
|
||||
}
|
||||
|
||||
void drawAmmoPacks()
|
||||
{
|
||||
}
|
||||
|
||||
void drawHealthpacks()
|
||||
{
|
||||
}
|
||||
|
||||
// sf::Text jelliesFreed; // Holds the text that shows how many jellies are freed
|
||||
// sf::Font jelliesFreedFont; // Holds the font used for the text of the display
|
||||
|
||||
// sf::Sprite jelliesFreedSprite; // Holds the sprite of the jelly in the top right corner
|
||||
|
||||
// Vector2i jellyDisplayLocation; // Holds the location where the amount of jellies freed are displayed
|
||||
std::vector<Crate> crates;
|
||||
// std::vector<sf::Sprite> crateSprite; // Holds the sprites of the crates
|
||||
// std::vector<sf::Sprite> jellySprite; // Holds the sprites of the jellies inside the crates
|
||||
// std::vector<Vector2> crateLocation; // Holds the locations of the crates/jellies
|
||||
// std::vector<Vector2> velocity; // Makes sure the jellies jump when the crate is destroyed
|
||||
// std::vector<bool> collision; // Keeps track of whether or not the player has collided with a crate
|
||||
// std::vector<bool> crateDestroyed; // Keeps track of whether or not a crate has been destroyed
|
||||
|
||||
// unsigned int totalAmntCrates; // Holds the total amount of crates
|
||||
// unsigned int amntCratesDestroyed; // Holds the amount of crates that have been destroyed
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -47,6 +47,11 @@ public:
|
||||
Vector2 mouseWorldPos = {GetMousePosition().x + camera.target.x - camera.offset.x, GetMousePosition().y};
|
||||
return mouseWorldPos;
|
||||
}
|
||||
|
||||
Vector2 toWorldPos(Vector2i pixelPos) {
|
||||
Vector2 worldPos = {(float)pixelPos.x + camera.target.x - camera.offset.x, (float)pixelPos.y};
|
||||
return worldPos;
|
||||
}
|
||||
// void setGame(Game game) {
|
||||
// this->game = game;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user