Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
flappy bird add waiting state
Browse files Browse the repository at this point in the history
  • Loading branch information
andyroiiid committed Jun 14, 2021
1 parent 5ed5b74 commit c44ec6a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions assets/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function haru.init()
haru.renderer.setCameraHalfHeight(5.0)

background = haru.renderer.Sprite.new("background-day.png", 32)
message = haru.renderer.Sprite.new("message.png", 32)

soundEvents = {
die = haru.audio.getEventDescription("event:/die"),
Expand All @@ -25,6 +26,7 @@ function haru.shutdown()
end

function reset()
waiting = true
prevPressed = false
prevOpening = false
scores = 0
Expand All @@ -36,11 +38,20 @@ end
function haru.update(deltaTime)
local pressed = haru.window.isKeyPressed(32)
if pressed and not prevPressed then
haru.audio.fireOneShotEvent(soundEvents.wing)
player:jump()
if waiting then
haru.audio.fireOneShotEvent(soundEvents.swoosh)
waiting = false
else
haru.audio.fireOneShotEvent(soundEvents.wing)
player:jump()
end
end
prevPressed = pressed

if waiting then
return
end

pipes:update(deltaTime)
player:update(deltaTime)

Expand Down Expand Up @@ -72,6 +83,11 @@ function haru.draw()
background:draw(9.0, 0.0, 0.0)
background:draw(0.0, 0.0, 0.0)
background:draw(-9.0, 0.0, 0.0)
pipes:draw()
player:draw();

if waiting then
message:draw(0.0, 0.0, 0.0)
else
pipes:draw()
player:draw()
end
end
Binary file added assets/message.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c44ec6a

Please sign in to comment.