Files
sinbad/src/appGameRose.c
T

60 lines
1.4 KiB
C

#include <raylib.h>
#include "appCore.h"
#include "engineAssets.h"
#include "rose.h"
#include "engineSprite.h"
const TextureAsset roseTextureAssets[ROSE_TEX_COUNT] = {{
"assets/rose.png",
2560.0f,
2560.0f,
0.0f
}};
Rose CreateRose(void){
TextureAsset roseAsset = roseTextureAssets[ROSE];
Texture2D texture = LoadTextureCached(roseAsset.path);
float frameWidth = roseAsset.frameWidth;
Vector2 frameSize = {frameWidth, frameWidth};
float rotation = roseAsset.rotation;
Rectangle sourceRec = {0.0f, 0.0f, frameWidth, frameWidth};
float destSize = GetScreenWidth() * ROSE_SCREEN_WIDTH_FRACTION;
Rectangle destRec = {GetScreenWidth() / 2, GetScreenHeight(), destSize, destSize};
Vector2 origin = {destSize / 2, destSize / 2};
Color color = WHITE;
Sprite sprite = {
.texture = texture,
.frameSize = frameSize,
.sourceRec = sourceRec,
.destRec = destRec,
.origin = origin,
.rotation = rotation,
.color = color
};
Rose rose = {
.sprite = sprite
};
return rose;
}
void UpdateRose(Rose *rose, Player *player){
float rotationSpeed = player->rotation;
if (IsGameActionDown(ACTION_TURN_LEFT)) {
rose->sprite.rotation -= rotationSpeed * GetFrameTime();
}
if (IsGameActionDown(ACTION_TURN_RIGHT)) {
rose->sprite.rotation += rotationSpeed * GetFrameTime();
}
}
void RenderRose(Rose *rose){
RenderSprite(&rose->sprite);
}