fix: merge conflict
This commit is contained in:
+1
-4
@@ -108,11 +108,8 @@ typedef struct {
|
||||
Animation animation;
|
||||
Physics physics;
|
||||
float rotation;
|
||||
<<<<<<< HEAD
|
||||
Sound soundFlapping;
|
||||
=======
|
||||
int health;
|
||||
>>>>>>> origin/pirate
|
||||
int gold;
|
||||
} Player;
|
||||
|
||||
@@ -249,7 +246,7 @@ void UpdatePlayer(void);
|
||||
void RenderPlayer(void);
|
||||
|
||||
Enemies CreateEnemies(void);
|
||||
void UpdateEnemies(Enemies *enemies, Projectiles *projectiles);
|
||||
void UpdateEnemies(Enemies *enemies);
|
||||
void RenderEnemies(Enemies *enemies);
|
||||
|
||||
Birds CreateBirds(void);
|
||||
|
||||
+2
-7
@@ -243,12 +243,7 @@ float Cross2D(Vector2 a, Vector2 b);
|
||||
Vector2 GetPositionInsideRectangle(Rectangle rec);
|
||||
Vector2 GetPositionOutsideRectangle(Rectangle rec, int min, int max);
|
||||
|
||||
<<<<<<< HEAD
|
||||
bool SaveStorageValue(const char* fileName, unsigned int position, int value);
|
||||
int LoadStorageValue(const char* fileName, unsigned int position);
|
||||
bool SaveStorageValue(const char *fileName, unsigned int position, int value);
|
||||
int LoadStorageValue(const char *fileName, unsigned int position);
|
||||
|
||||
#endif //ENGINE_H
|
||||
|
||||
=======
|
||||
#endif // ENGINE_H
|
||||
>>>>>>> origin/pirate
|
||||
|
||||
+6
-23
@@ -2,9 +2,7 @@
|
||||
|
||||
const ShaderAsset shaderAssets[SHADER_COUNT] = {{"shaders/postfx.fs"}};
|
||||
const SoundtrackAsset soundtrackAssets[SOUNDTRACK_COUNT] = {
|
||||
{"assets/gameplay_theme.mp3"},
|
||||
{"assets/sea.wav"}
|
||||
};
|
||||
{"assets/gameplay_theme.mp3"}, {"assets/sea.wav"}};
|
||||
|
||||
void InitGame(App *app) {
|
||||
|
||||
@@ -61,23 +59,19 @@ void UpdateGame(App *app) {
|
||||
|
||||
UpdateMouse(&g->mouse);
|
||||
|
||||
|
||||
Player *player = GetPlayer();
|
||||
UpdateCamera2D(&player->physics.position, &g->mouse);
|
||||
UpdateFloor(&g->floor);
|
||||
UpdatePlayer();
|
||||
UpdateBirds(&g->birds);
|
||||
UpdateEnemies(&g->enemies, &g->projectiles);
|
||||
UpdateEnemies(&g->enemies);
|
||||
UpdateIslands(&g->islands);
|
||||
<<<<<<< HEAD
|
||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||
UpdateSoundtrack(&g->soundtracks[AMBIENT], app->flags.soundtrackOn);
|
||||
=======
|
||||
UpdateProjectiles(&g->projectiles);
|
||||
UpdateProjectiles(&g->projectiles, &g->enemies);
|
||||
CheckPlayerCollisions(GetPlayer(), &app->game.enemies);
|
||||
CheckEnemyCollisions(&app->game.enemies);
|
||||
CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies, GetPlayer());
|
||||
>>>>>>> origin/pirate
|
||||
CheckProjectileCollisions(&app->game.projectiles, &app->game.enemies,
|
||||
GetPlayer());
|
||||
}
|
||||
|
||||
void RenderComponents(App *app) {
|
||||
@@ -99,20 +93,9 @@ void RenderGame(App *app) {
|
||||
BeginMode2D(*camera);
|
||||
RenderComponents(app);
|
||||
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);
|
||||
>>>>>>> origin/pirate
|
||||
EndTextureMode();
|
||||
|
||||
|
||||
BeginDrawing();
|
||||
ClearBackground(BLACK);
|
||||
for (int i = 0; i < SHADER_COUNT; i++) {
|
||||
|
||||
+62
-117
@@ -1,148 +1,93 @@
|
||||
#include "app.h"
|
||||
|
||||
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 enemies = {.count = MAX_ENEMIES};
|
||||
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
||||
Texture2D texture = LoadTexture(textureAsset.path);
|
||||
float frameWidth = textureAsset.frameWidth;
|
||||
float rotation = textureAsset.rotation;
|
||||
Enemies CreateEnemies(void) {
|
||||
Enemies enemies = {.count = MAX_ENEMIES};
|
||||
TextureAsset textureAsset = enemiesTextureAssets[BOAT];
|
||||
Texture2D texture = LoadTexture(textureAsset.path);
|
||||
float frameWidth = textureAsset.frameWidth;
|
||||
float rotation = textureAsset.rotation;
|
||||
|
||||
for (int i = 0; i < enemies.count; i++)
|
||||
{
|
||||
enemies.sprite[i] = (Sprite){
|
||||
.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
|
||||
};
|
||||
for (int i = 0; i < enemies.count; i++) {
|
||||
enemies.sprite[i] = (Sprite){
|
||||
.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};
|
||||
|
||||
enemies.animation[i] = (Animation){
|
||||
.state = 1,
|
||||
.currentFrame = 0,
|
||||
.maxFrame = 2,
|
||||
.framesCounter = 0,
|
||||
.framesSpeed = 2.0f,
|
||||
.animTimer = 0.0f
|
||||
};
|
||||
enemies.animation[i] = (Animation){.state = 1,
|
||||
.currentFrame = 0,
|
||||
.maxFrame = 2,
|
||||
.framesCounter = 0,
|
||||
.framesSpeed = 2.0f,
|
||||
.animTimer = 0.0f};
|
||||
|
||||
Rectangle cameraRec = GetCameraRectangle();
|
||||
Rectangle cameraRec = GetCameraRectangle();
|
||||
|
||||
enemies.physics[i] = (Physics){
|
||||
.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
||||
.direction = (Vector2){0.0f, 0.0f},
|
||||
.speed = 5.0f,
|
||||
.weight = 5.0f
|
||||
};
|
||||
enemies.physics[i] =
|
||||
(Physics){.position = GetPositionOutsideRectangle(cameraRec, 100, 1000),
|
||||
.direction = (Vector2){0.0f, 0.0f},
|
||||
.speed = 5.0f,
|
||||
.weight = 5.0f};
|
||||
|
||||
<<<<<<< HEAD
|
||||
enemies.arrived[i] = true;
|
||||
enemies.destPos[i] = (Vector2){0.0f, 0.0f};
|
||||
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, Projectiles *projectiles) {
|
||||
void UpdateEnemies(Enemies *enemies) {
|
||||
Camera2D *camera = GetCamera();
|
||||
Rectangle cameraRec = GetCameraRectangle();
|
||||
|
||||
for (int i = 0; i < enemies->count; i++) {
|
||||
if (enemies->alive[i]) {
|
||||
|
||||
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->alive[i])
|
||||
continue;
|
||||
|
||||
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});
|
||||
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++) {
|
||||
if (enemies->alive[i]){
|
||||
if (enemies->alive[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
|
||||
}
|
||||
|
||||
|
||||
|
||||
+32
-88
@@ -1,14 +1,9 @@
|
||||
#include "app.h"
|
||||
#include "engine.h"
|
||||
|
||||
typedef enum {
|
||||
FLAPPING,
|
||||
SOUND_COUNT
|
||||
}SoundID;
|
||||
typedef enum { FLAPPING, SOUND_COUNT } SoundID;
|
||||
|
||||
const SoundAsset playerSoundAssets[SOUND_COUNT] = {
|
||||
{"assets/flapping.wav"}
|
||||
};
|
||||
const SoundAsset playerSoundAssets[SOUND_COUNT] = {{"assets/flapping.wav"}};
|
||||
|
||||
const TextureAsset playerTextureAssets[PLAYER_TEX_COUNT] = {
|
||||
{"assets/ship_start.png", 16.0f, 16.0f, 0.0f}};
|
||||
@@ -31,73 +26,18 @@ Player *GetPlayer(void) {
|
||||
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) {
|
||||
|
||||
InitConfig(&config, "config/player.ini");
|
||||
|
||||
int PLAYER_HEALTH_MAX = GetConfigInt(&config, "HEALTH_MAX");
|
||||
int START_GOLD = GetConfigInt(&config, "START_GOLD");
|
||||
>>>>>>> origin/pirate
|
||||
|
||||
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);
|
||||
float frameWidth = startShipAsset.frameWidth;
|
||||
float rotation = startShipAsset.rotation;
|
||||
float rotation =
|
||||
(float)LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION);
|
||||
|
||||
Sprite playerSprite = {.texture = texture,
|
||||
.frameSize = {frameWidth, frameWidth},
|
||||
@@ -114,18 +54,29 @@ void UpdatePlayer(void)
|
||||
.framesSpeed = 0.0f,
|
||||
.animTimer = 0.0f};
|
||||
|
||||
Physics playerPhysics = {.position = (Vector2){0.0f, 0.0f},
|
||||
.direction = (Vector2){0.0f, 0.0f},
|
||||
.speed = playerSpeeds[ANCHOR],
|
||||
.weight = 10.0f};
|
||||
Physics playerPhysics = {
|
||||
.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],
|
||||
.weight = 10.0f};
|
||||
|
||||
Player *player = GetPlayer();
|
||||
*player = (Player){.sprite = playerSprite,
|
||||
.animation = playerAnimation,
|
||||
.physics = playerPhysics,
|
||||
.rotation = rotation,
|
||||
.health = PLAYER_HEALTH_MAX,
|
||||
.gold = START_GOLD};
|
||||
|
||||
*player = (Player){
|
||||
.sprite = playerSprite,
|
||||
.animation = playerAnimation,
|
||||
.physics = playerPhysics,
|
||||
.rotation = rotation,
|
||||
.soundFlapping = LoadSound(playerSoundAssets[FLAPPING].path),
|
||||
.health = PLAYER_HEALTH_MAX,
|
||||
.gold = LoadStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_GOLD)};
|
||||
|
||||
if (player->gold == 0) {
|
||||
player->gold = START_GOLD;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdatePlayer(void) {
|
||||
@@ -139,7 +90,6 @@ void UpdatePlayer(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
>>>>>>> origin/pirate
|
||||
|
||||
if (IsKeyPressed(KEY_S) || IsKeyPressed(KEY_DOWN)) {
|
||||
if (player->physics.speed > playerSpeeds[ANCHOR]) {
|
||||
@@ -167,21 +117,15 @@ void UpdatePlayer(void) {
|
||||
}
|
||||
|
||||
player->sprite.rotation = player->rotation;
|
||||
|
||||
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
||||
|
||||
<<<<<<< HEAD
|
||||
player->sprite.rotation = player->rotation;
|
||||
Vector2 dir = RotationToVector2(player->rotation - 90.0f);
|
||||
UpdatePhysics(&player->physics, dir);
|
||||
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX, (int)player->physics.position.x);
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY, (int)player->physics.position.y);
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION, (int)player->rotation);
|
||||
=======
|
||||
UpdatePhysics(&player->physics, dir);
|
||||
UpdateSpriteDestRec(&player->sprite, &player->physics.position);
|
||||
>>>>>>> origin/pirate
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSX,
|
||||
(int)player->physics.position.x);
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_POSY,
|
||||
(int)player->physics.position.y);
|
||||
SaveStorageValue(STORAGE_DATA_FILE, STORAGE_POSITION_ROTATION,
|
||||
(int)player->rotation);
|
||||
}
|
||||
|
||||
void RenderPlayer(void) {
|
||||
|
||||
Reference in New Issue
Block a user