fix: merge conflict
This commit is contained in:
+1
-4
@@ -108,11 +108,8 @@ typedef struct {
|
|||||||
Animation animation;
|
Animation animation;
|
||||||
Physics physics;
|
Physics physics;
|
||||||
float rotation;
|
float rotation;
|
||||||
<<<<<<< HEAD
|
|
||||||
Sound soundFlapping;
|
Sound soundFlapping;
|
||||||
=======
|
|
||||||
int health;
|
int health;
|
||||||
>>>>>>> origin/pirate
|
|
||||||
int gold;
|
int gold;
|
||||||
} Player;
|
} Player;
|
||||||
|
|
||||||
@@ -249,7 +246,7 @@ void UpdatePlayer(void);
|
|||||||
void RenderPlayer(void);
|
void RenderPlayer(void);
|
||||||
|
|
||||||
Enemies CreateEnemies(void);
|
Enemies CreateEnemies(void);
|
||||||
void UpdateEnemies(Enemies *enemies, Projectiles *projectiles);
|
void UpdateEnemies(Enemies *enemies);
|
||||||
void RenderEnemies(Enemies *enemies);
|
void RenderEnemies(Enemies *enemies);
|
||||||
|
|
||||||
Birds CreateBirds(void);
|
Birds CreateBirds(void);
|
||||||
|
|||||||
+2
-7
@@ -243,12 +243,7 @@ float Cross2D(Vector2 a, Vector2 b);
|
|||||||
Vector2 GetPositionInsideRectangle(Rectangle rec);
|
Vector2 GetPositionInsideRectangle(Rectangle rec);
|
||||||
Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max);
|
Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
bool SaveStorageValue(const char *fileName, unsigned int position, int value);
|
||||||
bool SaveStorageValue(const char* fileName, unsigned int position, int value);
|
int LoadStorageValue(const char *fileName, unsigned int position);
|
||||||
int LoadStorageValue(const char* fileName, unsigned int position);
|
|
||||||
|
|
||||||
#endif //ENGINE_H
|
|
||||||
|
|
||||||
=======
|
|
||||||
#endif // ENGINE_H
|
#endif // ENGINE_H
|
||||||
>>>>>>> origin/pirate
|
|
||||||
|
|||||||
+5
-22
@@ -2,9 +2,7 @@
|
|||||||
|
|
||||||
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
||||||
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
|
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
|
||||||
{"assets/gameplay_theme.mp3"},
|
{"assets/gameplay_theme.mp3"}, {"assets/sea.wav"}};
|
||||||
{"assets/sea.wav"}
|
|
||||||
};
|
|
||||||
|
|
||||||
void InitGame(App *app) {
|
void InitGame(App *app) {
|
||||||
|
|
||||||
@@ -61,23 +59,19 @@ void UpdateGame(App *app) {
|
|||||||
|
|
||||||
UpdateMouse(&g->mouse);
|
UpdateMouse(&g->mouse);
|
||||||
|
|
||||||
|
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
UpdateCamera2D(&player->physics.position, &g->mouse);
|
UpdateCamera2D(&player->physics.position, &g->mouse);
|
||||||
UpdateFloor(&g->floor);
|
UpdateFloor(&g->floor);
|
||||||
UpdatePlayer();
|
UpdatePlayer();
|
||||||
UpdateBirds(&g->birds);
|
UpdateBirds(&g->birds);
|
||||||
UpdateEnemies(&g->enemies, &g->projectiles);
|
UpdateEnemies(&g->enemies);
|
||||||
UpdateIslands(&g->islands);
|
UpdateIslands(&g->islands);
|
||||||
<<<<<<< HEAD
|
|
||||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
|
||||||
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
||||||
=======
|
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||||
UpdateProjectiles(&g->projectiles);
|
|
||||||
CheckPlayerCollisions(GetPlayer(), &app->game.enemies);
|
CheckPlayerCollisions(GetPlayer(), &app->game.enemies);
|
||||||
CheckEnemyCollisions(&app->game.enemies);
|
CheckEnemyCollisions(&app->game.enemies);
|
||||||
CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies, GetPlayer());
|
CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies,
|
||||||
>>>>>>> origin/pirate
|
GetPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderComponents(App *app) {
|
void RenderComponents(App *app) {
|
||||||
@@ -99,18 +93,7 @@ void RenderGame(App *app) {
|
|||||||
BeginMode2D(*camera);
|
BeginMode2D(*camera);
|
||||||
RenderComponents(app);
|
RenderComponents(app);
|
||||||
EndMode2D();
|
EndMode2D();
|
||||||
<<<<<<< HEAD
|
|
||||||
DrawTextureRec(
|
|
||||||
g->mouse.cursorTexture,
|
|
||||||
(Rectangle){0, 0, g->mouse.cursorTexture.width,
|
|
||||||
g->mouse.cursorTexture.height},
|
|
||||||
(Vector2){g->mouse.screenPosition.x, g->mouse.screenPosition.y}, WHITE);
|
|
||||||
|
|
||||||
Player *player = GetPlayer();
|
|
||||||
DrawText(TextFormat("Gold: %u", player->gold), 0.0f, 0.0f, 12.0f, YELLOW);
|
|
||||||
=======
|
|
||||||
RenderOverlay(&g->mouse);
|
RenderOverlay(&g->mouse);
|
||||||
>>>>>>> origin/pirate
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
|
|||||||
+20
-75
@@ -1,148 +1,93 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
|
||||||
const TextureAsset enemiesTextureAssets[ENEMIES_TEX_COUNT] = {
|
const TextureAsset enemiesTextureAssets[ENEMIES_TEX_COUNT] = {
|
||||||
{"assets/ship_start.png", 16.0f, 16.0f, 90.0f}
|
{"assets/ship_start.png", 16.0f, 16.0f, 90.0f}};
|
||||||
};
|
|
||||||
|
|
||||||
Enemies CreateEnemies(void){
|
Enemies CreateEnemies(void) {
|
||||||
Enemies enemies = {.count = MAX_ENEMIES};
|
Enemies enemies = {.count = MAX_ENEMIES};
|
||||||
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
||||||
Texture2D texture = LoadTexture(textureAsset.path);
|
Texture2D texture = LoadTexture(textureAsset.path);
|
||||||
float frameWidth = textureAsset.frameWidth;
|
float frameWidth = textureAsset.frameWidth;
|
||||||
float rotation = textureAsset.rotation;
|
float rotation = textureAsset.rotation;
|
||||||
|
|
||||||
for (int i = 0; i < enemies.count; i++)
|
for (int i = 0; i < enemies.count; i++) {
|
||||||
{
|
|
||||||
enemies.sprite[i] = (Sprite){
|
enemies.sprite[i] = (Sprite){
|
||||||
.texture = texture,
|
.texture = texture,
|
||||||
.frameSize = {frameWidth, frameWidth},
|
.frameSize = {frameWidth, frameWidth},
|
||||||
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
||||||
.destRec = {GetScreenWidth()/2, 0.0f, frameWidth, frameWidth},
|
.destRec = {GetScreenWidth() / 2, 0.0f, frameWidth, frameWidth},
|
||||||
.origin = {frameWidth / 2, frameWidth / 2},
|
.origin = {frameWidth / 2, frameWidth / 2},
|
||||||
.rotation = rotation,
|
.rotation = rotation,
|
||||||
.color = WHITE
|
.color = WHITE};
|
||||||
};
|
|
||||||
|
|
||||||
enemies.animation[i] = (Animation){
|
enemies.animation[i] = (Animation){.state = 1,
|
||||||
.state = 1,
|
|
||||||
.currentFrame = 0,
|
.currentFrame = 0,
|
||||||
.maxFrame = 2,
|
.maxFrame = 2,
|
||||||
.framesCounter = 0,
|
.framesCounter = 0,
|
||||||
.framesSpeed = 2.0f,
|
.framesSpeed = 2.0f,
|
||||||
.animTimer = 0.0f
|
.animTimer = 0.0f};
|
||||||
};
|
|
||||||
|
|
||||||
Rectangle cameraRec = GetCameraRectangle();
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
|
|
||||||
enemies.physics[i] = (Physics){
|
enemies.physics[i] =
|
||||||
.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
(Physics){.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
||||||
.direction = (Vector2){0.0f, 0.0f},
|
.direction = (Vector2){0.0f, 0.0f},
|
||||||
.speed = 5.0f,
|
.speed = 5.0f,
|
||||||
.weight = 5.0f
|
.weight = 5.0f};
|
||||||
};
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
enemies.arrived[i] = true;
|
enemies.arrived[i] = true;
|
||||||
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
||||||
enemies.alive[i] = true;
|
enemies.alive[i] = true;
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
enemies.arrived[i] = true;
|
|
||||||
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
|
||||||
>>>>>>> origin/pirate
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return enemies;
|
return enemies;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
void UpdateEnemies(Enemies *enemies) {
|
||||||
void UpdateEnemies(Enemies *enemies, Projectiles *projectiles) {
|
|
||||||
Camera2D *camera = GetCamera();
|
Camera2D *camera = GetCamera();
|
||||||
Rectangle cameraRec = GetCameraRectangle();
|
Rectangle cameraRec = GetCameraRectangle();
|
||||||
|
|
||||||
for (int i = 0; i < enemies->count; i++) {
|
for (int i = 0; i < enemies->count; i++) {
|
||||||
if (enemies->alive[i]) {
|
if (!enemies->alive[i])
|
||||||
|
continue;
|
||||||
for (int j = 0; j < projectiles->count; j++){
|
|
||||||
if (!projectiles->active[j]) continue;
|
|
||||||
if (CheckCollisionCircleRec(projectiles->physics[j].position, projectiles->radius[j], enemies->sprite[i].destRec)){
|
|
||||||
enemies->alive[i] = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (enemies->arrived[i]) {
|
if (enemies->arrived[i]) {
|
||||||
enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
||||||
enemies->arrived[i] = false;
|
enemies->arrived[i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CheckCollisionPointCircle(enemies->physics[i].position,
|
if (CheckCollisionPointCircle(enemies->physics[i].position,
|
||||||
enemies->destPos[i], 10.0F)) {
|
enemies->destPos[i], 10.0F)) {
|
||||||
enemies->arrived[i] = true;
|
enemies->arrived[i] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetDistanceBetweenTwoVectors(enemies->physics[i].position,
|
if (GetDistanceBetweenTwoVectors(enemies->physics[i].position,
|
||||||
camera->target) > 1000) {
|
camera->target) > 1000) {
|
||||||
enemies->physics[i].position =
|
enemies->physics[i].position =
|
||||||
GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position,
|
Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position,
|
||||||
enemies->destPos[i]);
|
enemies->destPos[i]);
|
||||||
|
|
||||||
UpdatePhysics(&enemies->physics[i], dir);
|
UpdatePhysics(&enemies->physics[i], dir);
|
||||||
UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position);
|
UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position);
|
||||||
|
|
||||||
float rotation = Vector2ToRotation(dir);
|
float rotation = Vector2ToRotation(dir);
|
||||||
UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f);
|
UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f);
|
||||||
|
|
||||||
UpdateAnimation(&enemies->animation[i], GetFrameTime());
|
UpdateAnimation(&enemies->animation[i], GetFrameTime());
|
||||||
UpdateSpriteSourceRec(&enemies->sprite[i],
|
UpdateSpriteSourceRec(&enemies->sprite[i],
|
||||||
&(Vector2){enemies->sprite[i].frameSize.x *
|
&(Vector2){enemies->sprite[i].frameSize.x *
|
||||||
enemies->animation[i].currentFrame,
|
enemies->animation[i].currentFrame,
|
||||||
enemies->sprite[i].frameSize.y});
|
enemies->sprite[i].frameSize.y});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEnemies(Enemies *enemies) {
|
void RenderEnemies(Enemies *enemies) {
|
||||||
for (int i = 0; i < enemies->count; i++) {
|
for (int i = 0; i < enemies->count; i++) {
|
||||||
if (enemies->alive[i]){
|
if (enemies->alive[i]) {
|
||||||
RenderSprite(&enemies->sprite[i]);
|
RenderSprite(&enemies->sprite[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
void UpdateEnemies(Enemies *enemies){
|
|
||||||
Camera2D *camera = GetCamera();
|
|
||||||
Rectangle cameraRec = GetCameraRectangle();
|
|
||||||
|
|
||||||
for (int i = 0; i < enemies->count; i++)
|
|
||||||
{
|
|
||||||
if(enemies->arrived[i])
|
|
||||||
{
|
|
||||||
enemies->destPos[i] = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
|
||||||
enemies->arrived[i] = false;
|
|
||||||
}
|
|
||||||
if(CheckCollisionPointCircle(enemies->physics[i].position, enemies->destPos[i], 10.0F))
|
|
||||||
{
|
|
||||||
enemies->arrived[i] = true;
|
|
||||||
}
|
|
||||||
if(GetDistanceBetweenTwoVectors(enemies->physics[i].position, camera->target) > 1000){
|
|
||||||
enemies->physics[i].position = GetPositionOutsideRectangle(cameraRec, 100, 1000);
|
|
||||||
}
|
|
||||||
Vector2 dir = GetDirectionBetweenTwoVectors(enemies->physics[i].position, enemies->destPos[i]);
|
|
||||||
UpdatePhysics(&enemies->physics[i], dir);
|
|
||||||
UpdateSpriteDestRec(&enemies->sprite[i], &enemies->physics[i].position);
|
|
||||||
float rotation = Vector2ToRotation(dir);
|
|
||||||
UpdateSpriteRotation(&enemies->sprite[i], rotation + 90.0f);
|
|
||||||
UpdateAnimation(&enemies->animation[i], GetFrameTime());
|
|
||||||
UpdateSpriteSourceRec(&enemies->sprite[i], &(Vector2){enemies->sprite[i].frameSize.x * enemies->animation[i].currentFrame, enemies->sprite[i].frameSize.y});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderEnemies(Enemies *enemies){
|
|
||||||
|
|
||||||
for (int i = 0; i < enemies->count; i++)
|
|
||||||
{
|
|
||||||
RenderSprite(&enemies->sprite[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> origin/pirate
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+26
-82
@@ -1,14 +1,9 @@
|
|||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum { FLAPPING, SOUND_COUNT } SoundID;
|
||||||
FLAPPING,
|
|
||||||
SOUND_COUNT
|
|
||||||
}SoundID;
|
|
||||||
|
|
||||||
const SoundAsset playerSoundAssets[SOUND_COUNT] = {
|
const SoundAsset playerSoundAssets[SOUND_COUNT] = {{"assets/flapping.wav"}};
|
||||||
{"assets/flapping.wav"}
|
|
||||||
};
|
|
||||||
|
|
||||||
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
|
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
|
||||||
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f}};
|
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f}};
|
||||||
@@ -31,73 +26,18 @@ Player *GetPlayer(void) {
|
|||||||
return &player;
|
return &player;
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
void CreatePlayer(void)
|
|
||||||
{
|
|
||||||
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
|
||||||
|
|
||||||
Texture2D texture = LoadTexture(startShipAsset.path);
|
|
||||||
float frameWidth = startShipAsset.frameWidth;
|
|
||||||
float rotation = (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION);
|
|
||||||
|
|
||||||
Sprite playerSprite = {
|
|
||||||
.texture = texture,
|
|
||||||
.frameSize = {frameWidth, frameWidth},
|
|
||||||
.sourceRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
|
||||||
.destRec = {0.0f, 0.0f, frameWidth, frameWidth},
|
|
||||||
.origin = {frameWidth / 2, frameWidth / 2},
|
|
||||||
.rotation = rotation,
|
|
||||||
.color = WHITE
|
|
||||||
};
|
|
||||||
=======
|
|
||||||
void CreatePlayer(void) {
|
void CreatePlayer(void) {
|
||||||
|
|
||||||
InitConfig(&config, "config/player.ini");
|
InitConfig(&config, "config/player.ini");
|
||||||
|
|
||||||
int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX");
|
int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX");
|
||||||
int START_GOLD = GetConfigInt(&config, "START_GOLD");
|
int START_GOLD = GetConfigInt(&config, "START_GOLD");
|
||||||
>>>>>>> origin/pirate
|
|
||||||
|
|
||||||
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
TextureAsset startShipAsset = playerTextureAssets[START_SHIP];
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
Physics playerPhysics = {
|
|
||||||
.position = (Vector2){(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX), (float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY)},
|
|
||||||
.direction = (Vector2){0.0f, 0.0f},
|
|
||||||
.speed = playerSpeeds[ANCHOR]
|
|
||||||
};
|
|
||||||
|
|
||||||
Player* player = GetPlayer();
|
|
||||||
*player = (Player){
|
|
||||||
.sprite = playerSprite,
|
|
||||||
.animation = playerAnimation,
|
|
||||||
.physics = playerPhysics,
|
|
||||||
.rotation = rotation,
|
|
||||||
.soundFlapping = LoadSound(playerSoundAssets[FLAPPING].path),
|
|
||||||
.gold = LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_GOLD)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdatePlayer(void)
|
|
||||||
{
|
|
||||||
Player* player = GetPlayer();
|
|
||||||
if(IsKeyPressed(KEY_W) || IsKeyPressed(KEY_UP)){
|
|
||||||
|
|
||||||
|
|
||||||
if(player->physics.speed < playerSpeeds[FAST_AHEAD]){
|
|
||||||
if(player->physics.speed < playerSpeeds[SLOW_AHEAD]){
|
|
||||||
PlaySound(player->soundFlapping);
|
|
||||||
player->physics.speed = playerSpeeds[SLOW_AHEAD];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PlaySound(player->soundFlapping);
|
|
||||||
player->physics.speed = playerSpeeds[FAST_AHEAD];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
Texture2D texture = LoadTexture(startShipAsset.path);
|
Texture2D texture = LoadTexture(startShipAsset.path);
|
||||||
float frameWidth = startShipAsset.frameWidth;
|
float frameWidth = startShipAsset.frameWidth;
|
||||||
float rotation = startShipAsset.rotation;
|
float rotation =
|
||||||
|
(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION);
|
||||||
|
|
||||||
Sprite playerSprite = {.texture = texture,
|
Sprite playerSprite = {.texture = texture,
|
||||||
.frameSize = {frameWidth, frameWidth},
|
.frameSize = {frameWidth, frameWidth},
|
||||||
@@ -114,18 +54,29 @@ void UpdatePlayer(void)
|
|||||||
.framesSpeed = 0.0f,
|
.framesSpeed = 0.0f,
|
||||||
.animTimer = 0.0f};
|
.animTimer = 0.0f};
|
||||||
|
|
||||||
Physics playerPhysics = {.position = (Vector2){0.0f, 0.0f},
|
Physics playerPhysics = {
|
||||||
.direction = (Vector2){0.0f, 0.0f},
|
.position = {(float)LoadStorageValue(STORAGE_DATA_FILE,
|
||||||
|
STORAGE_POSITION_POSX),
|
||||||
|
(float)LoadStorageValue(STORAGE_DATA_FILE,
|
||||||
|
STORAGE_POSITION_POSY)},
|
||||||
|
.direction = {0.0f, 0.0f},
|
||||||
.speed = playerSpeeds[ANCHOR],
|
.speed = playerSpeeds[ANCHOR],
|
||||||
.weight = 10.0f};
|
.weight = 10.0f};
|
||||||
|
|
||||||
Player *player = GetPlayer();
|
Player *player = GetPlayer();
|
||||||
*player = (Player){.sprite = playerSprite,
|
|
||||||
|
*player = (Player){
|
||||||
|
.sprite = playerSprite,
|
||||||
.animation = playerAnimation,
|
.animation = playerAnimation,
|
||||||
.physics = playerPhysics,
|
.physics = playerPhysics,
|
||||||
.rotation = rotation,
|
.rotation = rotation,
|
||||||
|
.soundFlapping = LoadSound(playerSoundAssets[FLAPPING].path),
|
||||||
.health = PLAYER_HEALTH_MAX,
|
.health = PLAYER_HEALTH_MAX,
|
||||||
.gold = START_GOLD};
|
.gold = LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_GOLD)};
|
||||||
|
|
||||||
|
if (player->gold == 0) {
|
||||||
|
player->gold = START_GOLD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatePlayer(void) {
|
void UpdatePlayer(void) {
|
||||||
@@ -139,7 +90,6 @@ void UpdatePlayer(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
>>>>>>> origin/pirate
|
|
||||||
|
|
||||||
if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) {
|
if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) {
|
||||||
if (player->physics.speed > playerSpeeds[ANCHOR]) {
|
if (player->physics.speed > playerSpeeds[ANCHOR]) {
|
||||||
@@ -166,22 +116,16 @@ void UpdatePlayer(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player->sprite.rotation = player->rotation;
|
|
||||||
|
|
||||||
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
player->sprite.rotation = player->rotation;
|
player->sprite.rotation = player->rotation;
|
||||||
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
||||||
UpdatePhysics(&player->physics, dir);
|
UpdatePhysics(&player->physics, dir);
|
||||||
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX, (int)player->physics.position.x);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX,
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY, (int)player->physics.position.y);
|
(int)player->physics.position.x);
|
||||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION, (int)player->rotation);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY,
|
||||||
=======
|
(int)player->physics.position.y);
|
||||||
UpdatePhysics(&player->physics, dir);
|
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION,
|
||||||
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
(int)player->rotation);
|
||||||
>>>>>>> origin/pirate
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPlayer(void) {
|
void RenderPlayer(void) {
|
||||||
|
|||||||
Reference in New Issue
Block a user