Yume Project 3.0
Touhou-inspired Danmaku game made in C only
Chargement...
Recherche...
Aucune correspondance
sprite.h
Aller à la documentation de ce fichier.
1
18
19#pragma once
20
21#include "components/common.h"
22
23#include "ecs/component.h"
24#include <raylib.h>
25#include <stdbool.h>
26
27typedef struct Pool Pool;
28
35typedef struct {
37 Rectangle srcRect;
38 Vector2 center;
39 Vector2 scale;
40 Color color;
41 int renderPriority; // Pour afficher devant/derriere d'autres..
42 bool display;
43
44 // Pour l'animation
51 float rotation;
52 Vector2 animStart;
53
54} Sprite;
55
57DECLARE_SETTER_GETTER(Sprite, int, textureID)
58DECLARE_SETTER_GETTER(Sprite, Rectangle, srcRect)
59DECLARE_SETTER_GETTER(Sprite, Vector2, center)
60DECLARE_SETTER_GETTER(Sprite, float, rotation)
61DECLARE_SETTER_GETTER(Sprite, Vector2, scale)
62DECLARE_SETTER_GETTER(Sprite, Color, color)
63DECLARE_SETTER_GETTER(Sprite, int, renderPriority)
64DECLARE_SETTER_GETTER(Sprite, int, display)
65DECLARE_SETTER_GETTER(Sprite, bool, isAnimated)
66DECLARE_SETTER_GETTER(Sprite, int, animFrameCount)
67DECLARE_SETTER_GETTER(Sprite, int, animSpeed)
68DECLARE_SETTER_GETTER(Sprite, int, animTimer)
69DECLARE_SETTER_GETTER(Sprite, int, currentFrame)
70DECLARE_SETTER_GETTER(Sprite, int, frameWidth)
71DECLARE_SETTER_GETTER(Sprite, Vector2, animStart)
72
73
86extern void Sprite_set_texture(Sprite *sprite, int renderPriority, int textureID);
87
95extern void Sprite_set_animation(Sprite *sprite, int frameCount, int delay);
96
108extern void Sprite_set_SourceRect(Sprite *sprite, float x, float y, float width, float height);
109
118
126extern void Sprite_draw_sprite(Sprite *sprite, Position *pos, Tag *tag);
127
136extern void Sprite_draw_all(Pool *pool);
137
145extern void Sprite_draw_range(Pool *p, int min_layer, int max_layer);
Composants communs à toutes les entités (Position, Tag).
EntityType Tag
Definition common.h:40
Macros nécessaire à la création de nouvelles composantes de l'ECS.
#define DEFINE_COMPONENT_MANAGER(Type, Number)
Créé un composant dans l'ECS.
Definition component.h:62
#define DECLARE_SETTER_GETTER(Component, type, champ)
Definition component.h:121
#define MAX_ENTITIES
Definition ecs.h:14
void Sprite_draw_sprite(Sprite *sprite, Position *pos, Tag *tag)
Dessine un sprite à la position donnée.
void UpdateAnimation(Sprite *sprite)
Met à jour l'état d'animation interne d'un sprite.
void Sprite_set_SourceRect(Sprite *sprite, float x, float y, float width, float height)
Définit le rectangle source pour le sprite.
void Sprite_set_texture(Sprite *sprite, int renderPriority, int textureID)
Ajoute une texture avec les valeurs pas défauts.
void Sprite_draw_range(Pool *p, int min_layer, int max_layer)
Dessine les sprites dont la renderPriority est dans l'intervalle.
void Sprite_set_animation(Sprite *sprite, int frameCount, int delay)
Configure l'animation d'un sprite.
void Sprite_draw_all(Pool *pool)
Dessine tous les sprites présents dans la pool.
La pool est la structure qui contient l'Entity Component System Elle gêre les différentes composantes...
Definition pool.h:42
Definition common.h:44
Composante Sprite dans l'ECS Cette composante sert à associer une texture à une Entité....
Definition sprite.h:35
int frameWidth
Definition sprite.h:50
bool display
Definition sprite.h:42
Color color
Definition sprite.h:40
Rectangle srcRect
Definition sprite.h:37
int currentFrame
Definition sprite.h:49
int animSpeed
Definition sprite.h:47
Vector2 center
Definition sprite.h:38
bool isAnimated
Definition sprite.h:45
int animFrameCount
Definition sprite.h:46
int animTimer
Definition sprite.h:48
int renderPriority
Definition sprite.h:41
Vector2 scale
Definition sprite.h:39
float rotation
Definition sprite.h:51
int textureID
Definition sprite.h:36
Vector2 animStart
Definition sprite.h:52