[Added] Jellies, healthpacks, ammopacks, powerups, [Updated] Gun rotation
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#ifndef JELLY_H
|
||||
#define JELLY_H
|
||||
|
||||
#include "raylib.h"
|
||||
#include "services/MapService.h"
|
||||
#include "services/AssetService.h"
|
||||
#include "entities/TextureWrapper.h"
|
||||
|
||||
class Jelly
|
||||
{
|
||||
public:
|
||||
Jelly(){
|
||||
this->texture = TextureWrapper(AssetService::getInstance().getSprite(ESprite::JELLY),{32,32});
|
||||
AssetService::getInstance().playSound(ESound::JELLY_FREED);
|
||||
}
|
||||
Jelly(Vector2 startPos)
|
||||
{
|
||||
this->startPosition = startPos;
|
||||
this->texture = TextureWrapper(AssetService::getInstance().getSprite(ESprite::JELLY),{32,32},startPos);
|
||||
AssetService::getInstance().playSound(ESound::JELLY_FREED);
|
||||
}
|
||||
|
||||
void logic()
|
||||
{
|
||||
if (texture.getPosition().y >= startPosition.y)
|
||||
{
|
||||
velocity.y = -jumpSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
velocity.y += gravity;
|
||||
}
|
||||
|
||||
texture.move(velocity);
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
DrawTexture(texture.getTexture(), texture.getPosition().x, texture.getPosition().y, WHITE);
|
||||
}
|
||||
|
||||
private:
|
||||
TextureWrapper texture;
|
||||
float jumpSpeed = 7.0f;
|
||||
float gravity = 0.6f;
|
||||
Vector2 velocity = {0, 0};
|
||||
Vector2 startPosition = {0,0};
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user