48 lines
1.3 KiB
C
48 lines
1.3 KiB
C
#include "appTypes.h"
|
|
|
|
const TextureAsset islandsTextureAssets[ISLANDS_TEX_COUNT] = {
|
|
{"assets/island.png", 16.0f, 16.0f, 0.0f}
|
|
};
|
|
|
|
Islands CreateIslands(void){
|
|
TextureAsset islandAsset = islandsTextureAssets[ISLAND];
|
|
Texture2D texture = LoadTexture(islandAsset.path);
|
|
float frameWidth = islandAsset.frameWidth;
|
|
float rotation = islandAsset.rotation;
|
|
|
|
Sprite islandSprite = {
|
|
.texture = texture,
|
|
.frameSize = {frameWidth, frameWidth},
|
|
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
|
.destRec = {GetScreenWidth()/2, 0.0f, frameWidth, frameWidth},
|
|
.origin = {frameWidth / 2, frameWidth / 2},
|
|
.rotation = rotation,
|
|
.color = WHITE
|
|
};
|
|
|
|
Physics islandPhysics = {
|
|
.position = (Vector2){-100.0f, 0.0f},
|
|
.direction = (Vector2){0.0f, 0.0f},
|
|
.speed = 10.0f
|
|
};
|
|
|
|
return (Islands){
|
|
.sprite = islandSprite,
|
|
.physics = islandPhysics
|
|
};
|
|
|
|
}
|
|
|
|
void UpdateIslands(Islands *islands){
|
|
|
|
UpdatePhysics(&islands->physics, (Vector2){0.0f,0.0f});
|
|
UpdateSpriteDestRec(&islands->sprite, &islands->physics.position);
|
|
UpdateAnimation(&islands->animation, GetFrameTime());
|
|
UpdateSpriteSourceRec(&islands->sprite, &(Vector2){islands->sprite.frameSize.x * islands->animation.currentFrame, islands->sprite.frameSize.y});
|
|
}
|
|
|
|
void RenderIslands(Islands *islands){
|
|
RenderSprite(&islands->sprite);
|
|
}
|
|
|