Skip to content

Commit

Permalink
explicitly specifying float
Browse files Browse the repository at this point in the history
  • Loading branch information
VadimBoev committed Oct 6, 2024
1 parent 87ce85f commit fdb0db0
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions FlappyBird/app/src/main/jni/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,32 +188,32 @@ bool InitGame()
t_yellowbird_midflap = LoadTexture("sprites/yellowbird-midflap.png");
t_yellowbird_upflap = LoadTexture("sprites/yellowbird-upflap.png");

bird.x = ScaleX(18.52);
bird.y = ScaleY(20);
bird.x = ScaleX(18.52f);
bird.y = ScaleY(20.f);
bird.velocity = 0.0f;
bird.angle = 0.0f;
bird.width = ScaleX(11.11);
bird.height = ScaleY(4.17);
bird.width = ScaleX(11.11f);
bird.height = ScaleY(4.17f);
bird.currentTexture = t_yellowbird_midflap;
bird.frame = 0;
bird.lastFrameTime = 0;


pipes[0].x = ScaleX(100);
pipes[0].y = ScaleY(37.5);
pipes[0].w = ScaleX(15);
pipes[0].h = ScaleY(37.5);
pipes[0].x = ScaleX(100.f);
pipes[0].y = ScaleY(37.5f);
pipes[0].w = ScaleX(15.f);
pipes[0].h = ScaleY(37.5f);
pipes[0].offset = Random(ScaleY(-SPACE_BETWEEN_PIPES), ScaleY(SPACE_BETWEEN_PIPES));

pipes[1].x = ScaleX(100) + ScaleX(60);
pipes[1].y = ScaleY(37.5);
pipes[1].w = ScaleX(15);
pipes[1].h = ScaleY(37.5);
pipes[1].x = ScaleX(100.f) + ScaleX(60.f);
pipes[1].y = ScaleY(37.5f);
pipes[1].w = ScaleX(15.f);
pipes[1].h = ScaleY(37.5f);
pipes[1].offset = Random(ScaleY(-SPACE_BETWEEN_PIPES), ScaleY(SPACE_BETWEEN_PIPES));


logoY = ScaleY(20.83);
birdY = ScaleY(20.83);
logoY = ScaleY(20.83f);
birdY = ScaleY(20.83f);
logoVelocity = 1.1f;
birdVelocity = 1.1f;

Expand All @@ -224,7 +224,7 @@ bool InitGame()
birdTexturesForLogo[1] = t_yellowbird_midflap;
birdTexturesForLogo[2] = t_yellowbird_upflap;

panelY = ScaleY(100);
panelY = ScaleY(100.f);

newBestScore = false;

Expand Down Expand Up @@ -340,7 +340,7 @@ bool CheckCollision()
}

// ground collision
float baseHeight = ScaleY(75);
float baseHeight = ScaleY(75.f);
if (bird.y + bird.width > baseHeight)
{
return true;
Expand Down Expand Up @@ -443,52 +443,52 @@ void RenderSmallScore(int score, float x, float y, float digitWidth, float digit
void Render()
{
//background
RenderTexture(t_background_day, 0, 0, ScaleX(100), ScaleY(95.83));
RenderTexture(t_background_day, 0, 0, ScaleX(100.f), ScaleY(95.83f));

//cycle base texture
if (currentState != STOP_GAME && currentState != FADE_OUT_GAMEOVER && currentState != FALL_BIRD && currentState != FADE_IN_PANEL)
{
offsetBase -= gameSpeed;
}

RenderTexture(t_base, offsetBase, ScaleY(75), ScaleX(100), ScaleY(25));
RenderTexture(t_base, offsetBase, ScaleY(75.f), ScaleX(100.f), ScaleY(25.f));

if (offsetBase < 0)
{
RenderTexture(t_base, ScaleX(100) + offsetBase, ScaleY(75), ScaleX(100), ScaleY(25));
RenderTexture(t_base, ScaleX(100.f) + offsetBase, ScaleY(75.f), ScaleX(100.f), ScaleY(25.f));
}

if (offsetBase <= -ScaleX(100))
if (offsetBase <= -ScaleX(100.f))
{
offsetBase = 0;
}

logoY += logoVelocity;
birdY += birdVelocity;

if (logoY > ScaleY(20.83) + 25 || logoY < ScaleY(20.83) - 25) {
if (logoY > ScaleY(20.83f) + 25 || logoY < ScaleY(20.83f) - 25) {
logoVelocity = -logoVelocity;
}

if (birdY > ScaleY(20.83) + 25 || birdY < ScaleY(20.83) - 25) {
if (birdY > ScaleY(20.83f) + 25 || birdY < ScaleY(20.83f) - 25) {
birdVelocity = -birdVelocity;
}

if (currentState == IDLE || currentState == FADE_IN)
{
RenderTexture(t_logo, ScaleX(15), logoY, ScaleX(55.56), ScaleY(5.21));
RenderTexture(t_logo, ScaleX(15.f), logoY, ScaleX(55.56f), ScaleY(5.21f));

UpdateBirdTextureForLogo();

RenderTexture(curTextureAnimBirdForLogo, ScaleX(75), birdY, bird.width, bird.height);

if (ButtonBump(t_start, ScaleX(10), ScaleY(65), ScaleX(35), ScaleY(6)))
if (ButtonBump(t_start, ScaleX(10.f), ScaleY(65.f), ScaleX(35.f), ScaleY(6.f)))
{
currentState = FADE_IN;
}

// button SCORE
if (ButtonBump(t_score, ScaleX(55), ScaleY(65), ScaleX(35), ScaleY(6)))
if (ButtonBump(t_score, ScaleX(55.f), ScaleY(65.f), ScaleX(35.f), ScaleY(6.f)))
{

}
Expand All @@ -497,8 +497,8 @@ void Render()
{
RenderBird();

RenderTexture(t_message, ScaleX(10), ScaleY(9), ScaleX(80), ScaleY(50));
if (Button(0, 0, ScaleX(100), ScaleY(100)))
RenderTexture(t_message, ScaleX(10.f), ScaleY(9.f), ScaleX(80.f), ScaleY(50.f));
if (Button(0, 0, ScaleX(100.f), ScaleY(100.f)))
{
currentState = GO_GAME;
}
Expand All @@ -511,9 +511,9 @@ void Render()
for (int i = 0; i < 2; i++)
{
pipes[i].x -= gameSpeed;
if (pipes[i].x < -ScaleX(15))
if (pipes[i].x < -ScaleX(15.f))
{
pipes[i].x = ScaleX(115);
pipes[i].x = ScaleX(115.f);
pipes[i].offset = Random(ScaleY(-SPACE_BETWEEN_PIPES), ScaleY(SPACE_BETWEEN_PIPES));
}

Expand All @@ -531,7 +531,7 @@ void Render()
PlayAudio("audio/hit.mp3");
}

if (IsClick(0, 0, ScaleX(100), ScaleY(100)))
if (IsClick(0, 0, ScaleX(100.f), ScaleY(100.f)))
{
Jump();
PlayAudio("audio/wing.mp3");
Expand All @@ -541,7 +541,7 @@ void Render()
RenderBird();

if (score > 0)
RenderScore(score, ScaleX(45), ScaleY(7), ScaleX(8), ScaleY(5));
RenderScore(score, ScaleX(45.f), ScaleY(7.f), ScaleX(8.f), ScaleY(5.f));
}
else if (currentState == STOP_GAME)
{
Expand Down Expand Up @@ -576,17 +576,17 @@ void Render()
RenderBird();

uint32_t color = 0x00FFFFFF | (fadeOutAlpha << 24);
CreateBox(color, 0, 0, ScaleX(100), ScaleY(100));
CreateBox(color, 0, 0, ScaleX(100.f), ScaleY(100.f));
}
else if (currentState == FALL_BIRD)
{
ApplyGravity();
RenderPipes();
RenderBird();

if (bird.y + bird.height >= ScaleY(75) - bird.height)
if (bird.y + bird.height >= ScaleY(75.f) - bird.height)
{
bird.y = ScaleY(75) - bird.height;
bird.y = ScaleY(75.f) - bird.height;
currentState = FADE_IN_PANEL;
}
}
Expand All @@ -596,21 +596,21 @@ void Render()
RenderBird();

panelY = MoveTowards(panelY, ScaleY(30), 20.0f);
RenderTexture(t_panel, ScaleX(15), panelY, ScaleX(70), ScaleY(17.5));
RenderTexture(t_panel, ScaleX(15.f), panelY, ScaleX(70.f), ScaleY(17.5f));

// Render default score
RenderSmallScore(score, ScaleX(70), panelY + ScaleY(5), ScaleX(4), ScaleY(3));
RenderSmallScore(score, ScaleX(70.f), panelY + ScaleY(5.f), ScaleX(4.f), ScaleY(3.f));

// Render best score
RenderSmallScore(bestScore, ScaleX(70), panelY + ScaleY(11.5), ScaleX(4), ScaleY(3));
RenderSmallScore(bestScore, ScaleX(70.f), panelY + ScaleY(11.5f), ScaleX(4.f), ScaleY(3.f));

if (newBestScore)
{
RenderTexture(t_new, ScaleX(56), panelY + ScaleY(9), ScaleX(10), ScaleY(1.8));
RenderTexture(t_new, ScaleX(56.f), panelY + ScaleY(9.f), ScaleX(10.f), ScaleY(1.8f));
}


RenderTexture(t_gameover, ScaleX(17.5), ScaleY(18), ScaleX(65), ScaleY(6));
RenderTexture(t_gameover, ScaleX(17.5f), ScaleY(18.f), ScaleX(65.f), ScaleY(6.f));

// Render medal
if (score >= 40) medalTexture = t_platinum_medal;
Expand All @@ -621,37 +621,37 @@ void Render()

if (medalTexture)
{
RenderTexture(medalTexture, ScaleX(22), panelY + ScaleY(6), ScaleX(15), ScaleY(7));
RenderTexture(medalTexture, ScaleX(22.f), panelY + ScaleY(6.f), ScaleX(15.f), ScaleY(7.f));
}

// button OK
if (ButtonBump(t_ok, ScaleX(10), ScaleY(65), ScaleX(35), ScaleY(6)))
if (ButtonBump(t_ok, ScaleX(10.f), ScaleY(65.f), ScaleX(35.f), ScaleY(6.f)))
{
//Reset
currentState = IDLE;
score = 0;

bird.x = ScaleX(18.52);
bird.y = ScaleY(20);
bird.x = ScaleX(18.52f);
bird.y = ScaleY(20.f);
bird.velocity = 0.0f;
bird.angle = 0.0f;
bird.width = ScaleX(11.11);
bird.height = ScaleY(4.17);
bird.width = ScaleX(11.11f);
bird.height = ScaleY(4.17f);
bird.currentTexture = t_yellowbird_midflap;
bird.frame = 0;
bird.lastFrameTime = 0;


pipes[0].x = ScaleX(100);
pipes[0].y = ScaleY(37.5);
pipes[0].w = ScaleX(15);
pipes[0].h = ScaleY(37.5);
pipes[0].x = ScaleX(100.f);
pipes[0].y = ScaleY(37.5f);
pipes[0].w = ScaleX(15.f);
pipes[0].h = ScaleY(37.5f);
pipes[0].offset = Random(ScaleY(-SPACE_BETWEEN_PIPES), ScaleY(SPACE_BETWEEN_PIPES));

pipes[1].x = ScaleX(100) + ScaleX(60);
pipes[1].y = ScaleY(37.5);
pipes[1].w = ScaleX(15);
pipes[1].h = ScaleY(37.5);
pipes[1].x = ScaleX(100.f) + ScaleX(60.f);
pipes[1].y = ScaleY(37.5f);
pipes[1].w = ScaleX(15.f);
pipes[1].h = ScaleY(37.5f);
pipes[1].offset = Random(ScaleY(-SPACE_BETWEEN_PIPES), ScaleY(SPACE_BETWEEN_PIPES));

panelY = ScaleY(100);
Expand Down

0 comments on commit fdb0db0

Please sign in to comment.