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
41 changes: 41 additions & 0 deletions include/Components/Bullets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,38 @@ namespace rtype::components {
public:
Bullets();
~Bullets();
/**
* @brief Create a Bullet object
*
* @param pos
* @return sf::CircleShape
*/
sf::CircleShape CreateBullet(sf::Vector2f pos);
/**
* @brief Call it to make your entity able to shoot bullet
*
* @param id
* @param sprite
* @return true
* @return false
*/
bool ShootBullet(int id, sf::Sprite sprite);
/**
* @brief Function to call CreateBullet for the server
*
* @param id
* @param sprite
* @return true
* @return false
*/
bool ServerShootBullet(int id, sf::Sprite sprite);
/**
* @brief Make collision between Bullet and an Entity
*
* @param bounds
* @return true
* @return false
*/
bool collided(sf::FloatRect bounds)
{
for (auto& ammo : this->bullets_list)
Expand All @@ -40,7 +69,19 @@ namespace rtype::components {
return false;
};

/**
* @brief Draw all the bullets
*
* @param win
*/
void drawBullets(sf::Window &win);
/**
* @brief Update the frame for the bullet
*
* @param bounds
* @return true
* @return false
*/
bool update(sf::FloatRect bounds);

// void SetBullets(float radius, sf::Vector2f velocity, float maxSpeed);
Expand Down
5 changes: 5 additions & 0 deletions include/Engine/Audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace rtype::engine {
public:
Audio();
~Audio();
/**
* @brief Create a Sound object
*
* @param audio
*/
void CreateSound(sf::Sound audio);

protected:
Expand Down
34 changes: 34 additions & 0 deletions include/Engine/Draw.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,44 @@ namespace rtype::engine {
public:
Draw();
~Draw();
/**
* @brief Create a rectangle
*
* @param height
* @param width
* @param pos
* @return sf::RectangleShape
*/
sf::RectangleShape DrawRectangle(int height, int width, sf::Vector2f pos);
/**
* @brief Create a sphere
*
* @param radius
* @return sf::CircleShape
*/
sf::CircleShape DrawSphere(int radius);
/**
* @brief Set the Texture To Object object
*
* @param texture
* @param posRect
*/
void SetTextureToObject(sf::Texture texture, sf::IntRect posRect);
/**
* @brief Set the Texture To Circle object
*
* @param circle
* @param texture
* @param posRect
*/
void SetTextureToCircle(sf::CircleShape circle, sf::Texture texture, sf::IntRect posRect);
/**
* @brief Set the Texture To Rectangle object
*
* @param rectangle
* @param texture
* @param posRect
*/
void SetTextureToRectangle(sf::RectangleShape rectangle, sf::Texture texture, sf::IntRect posRect);

protected:
Expand Down
54 changes: 52 additions & 2 deletions include/Engine/Event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,74 @@ namespace rtype::engine {

class Event {
public:
/**
* @brief Init a client to server
*
* @param clt
*/
Event(sk::Skaldi<sk::client::UDP, sk::server::UDP> *clt);
~Event();
void handleEvent();
void handleInput();
void update();
/**
* @brief Check the input of the player and return the appropriate action
*
* @param obj_pos
* @param action
* @return EventType
*/
EventType ServerPlayerAction(sf::Transformable &obj_pos, EventType action);
/**
* @brief Make an object movable with the keyboard
*
* @param obj_pos
*/
void MakeObjectMovable(sf::Transformable &obj_pos);
/**
* @brief Make an object clickable
*
* @param button
*/
void MakeObjectClickable(sf::RectangleShape button);
/**
* @brief Make a Sprite movable with the keyboard
*
* @param asset
*/
void MakeSpriteMovable(sf::Sprite &asset); //player move on input
/**
* @brief Make a Sprite from an another clien movable with the keyboard
*
* @param asset
*/
void MakeSpriteMovable_Bis(sf::Sprite &asset); //player move on input test only
/**
* @brief Get the Mouse Pos object
*
* @param event
*/
void GetMousePos(sf::Event event);
/**
* @brief Get the Mouse Pressed object
*
* @param event
*/
void GetMousePressed(sf::Event event);

/**
* @brief Get the Client Buffer object
*
* @return std::string
*/
std::string getClientBuffer()
{
return this->clt->client->getBuffer();
}

/**
* @brief Send a message to the serveur
*
* @param msg
*/
void sendMessage(std::string msg)
{
this->clt->client->send(msg);
Expand Down
12 changes: 12 additions & 0 deletions include/Engine/StateManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ namespace rtype::engine {
public:
StateManager();
~StateManager();
/**
* @brief Create a menu
*
*/
void Menu(void);
/**
* @brief Launch the game
*
*/
void GameRun(void);
/**
* @brief Init a end game
*
*/
void End(void);

protected:
Expand Down
59 changes: 57 additions & 2 deletions include/Engine/Window.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,80 @@ namespace rtype::engine {
public:
Window();
~Window();
/**
* @brief Display the window with his event
*
* @return int
*/
int DisplayWindow(void);
/**
* @brief Draw the window
*
* @return int
*/
int DrawWindow(void) {this->window.display(); return 0;};
/**
* @brief Use it to update the event
*
* @return true
* @return false
*/
bool UpdateEvent(void);
/**
* @brief Check if the window is open
*
* @return true
* @return false
*/
bool IsOpen(void);
/**
* @brief Check if the window is close
*
* @return true
* @return false
*/
bool IsClosed(void);
/**
* @brief Check the event type
*
* @return true
* @return false
*/
bool HandleEvent(const sf::Event::EventType &type);
/**
* @brief Create a Window object
*
* @param mode
* @param name
*/
void CreateWindow(sf::VideoMode mode, std::string name);

/**
* @brief Clear the window
*
*/
void clear() { this->window.clear(sf::Color::Black); };
/**
* @brief Close the window
*
*/
void close() {this->window.close();};

/**
* @brief Init the clock for the game
*
*/
void t_clock()
{
this->winTimer = this->winClock.getElapsedTime();
std::cerr<<winTimer.asSeconds()<<std::endl;
if (this->winTimer.asSeconds() > 1.f)
winClock.restart();
};

/**
* @brief Draw the entity
*
* @param en
*/
void Draw(sf::Drawable &en)
{
this->window.draw(en);
Expand Down
1 change: 0 additions & 1 deletion include/Entities/Actors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class Actors : public Entity
public:
Actors();
~Actors();

std::string getTag() {return this->tag}
std::string getName()
int getID();
Expand Down
17 changes: 16 additions & 1 deletion include/Entities/EntitiesManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,32 @@ namespace rtype::entities {
*/
void NewEntity(std::string fpath, sf::Vector2f pos, sf::Vector2f scale);

/**
* @brief return a ID
*
* @return std::list<int8_t>
*/
std::list<int8_t> getIDs() {
return IDs;
};

void setPId(int id) { this->pId = id;}
int8_t getPId() {return this->pId;}

/**
* @brief Get the Entities List object
*
* @return std::array<sf::Sprite, 100>
*/
std::array<sf::Sprite, 100> getEntitiesList() {
return entities;
};

/**
* @brief Get the Sprite object and his ID
*
* @param id
* @return sf::Sprite&
*/
sf::Sprite &getSprite(int8_t id) {
//check if valid
return this->entities[id];
Expand Down