Page 1 of 2

Flappy löve (Works on android! (theoretically))

Posted: Mon Feb 17, 2014 7:47 pm
by veethree
This was going to happen eventually and you all know it. A flappy bird clone.

It's pretty minimal at the moment, But i think it plays nicely. You just have an infinite game loop, Press any key to start, And the player starts falling, press up, W or space to "flap". If/when you crash into one of the pipe things, You die and the game starts over.

Note that it uses a shader and a canvas. If your machine doesn't support those, Too bad. (If you really want to play this and don't support shaders/canvases, You can edit the code yourself, all the shader stuff happens in game:draw in game.lua)

Enough text, Here's screenshots: (Outdated)
Image
You'll be seeing this alot
Image

In case you couldn't tell the design is based off the old forum banner.

I do not recommend looking through the code. Might give you a headache. I wasn't exactly thinking straight while coding this. (if you know what i mean)

Latest version available on github.
flappy.love
Up to date (Also theoretically works on android)
(228.64 KiB) Downloaded 210 times

Re: Flappy löve

Posted: Mon Feb 17, 2014 7:49 pm
by Doctory
I was just about to do this :ultrahappy:
Nice game.

Re: Flappy löve

Posted: Mon Feb 17, 2014 9:48 pm
by Zarty55
Nice game.

Saw 2 bugs. When you lose and hit space bar the gravity won't work, obstacles don't spawn and score is being counted ;)
The background has a small gap that keeps blinking when the screen moves.

Re: Flappy löve

Posted: Mon Feb 17, 2014 9:49 pm
by josefnpat
Can you FOSS this, so I can offer pull requests to make this an android game? ;)

Re: Flappy löve

Posted: Mon Feb 17, 2014 10:10 pm
by veethree
josefnpat wrote:Can you FOSS this, so I can offer pull requests to make this an android game? ;)
Sure! What's FOSS?

Re: Flappy löve

Posted: Tue Feb 18, 2014 12:02 am
by josefnpat
Talked to veethree, he's pushed code to github!

https://github.com/v3p/flappy_love

Re: Flappy löve

Posted: Tue Feb 18, 2014 1:02 am
by veethree
Zarty55 wrote:Nice game.

Saw 2 bugs. When you lose and hit space bar the gravity won't work, obstacles don't spawn and score is being counted ;)
The background has a small gap that keeps blinking when the screen moves.
You have to press a key (any) to start the game. And i fixed the score being counted, Latest version on github. (link in the OP)

Re: Flappy löve (Works on android! (theoretically))

Posted: Sun Feb 23, 2014 10:45 pm
by Reef
This is great! I've been playing around with your code a bit, and in the process of adapting it I've run into a little problem. I don't know if I'm better off asking in the help forum but my code is mostly based on yours so, I figured I'd just ask here.

For collision testing and debugging purposes I was trying to make the player change color while overlapping one of the walls but it doesn't seem to be working. I can make change the color upon collision, but then it doesn't revert to the original color when it is not colliding. Would you (or anyone else) mind taking a look? This is from main.lua

Code: Select all

-- collision, loop through walls
  for i,v in ipairs(wall.array) do
    for _,s in ipairs(v) do
      if checkCollision(player.x, player.y, player.size, player.size, s.x, s.y, s.width, s.height) then
        player.collision = true
      else
        player.collision = false
      end
    end    
  end
If I remove the else condition , the player will change color but not change back. With this else condition nothing happens.

Re: Flappy löve (Works on android! (theoretically))

Posted: Sun Feb 23, 2014 11:30 pm
by veethree
Reef wrote:---
Couldn't tell you why, But that logic doesn't usually work. Try something like this:

Code: Select all

  player.collision = false
  for i,v in ipairs(wall.array) do
    for _,s in ipairs(v) do
      if checkCollision(player.x, player.y, player.size, player.size, s.x, s.y, s.width, s.height) then
        player.collision = true
      end
    end    
  end

Re: Flappy löve (Works on android! (theoretically))

Posted: Sun Feb 23, 2014 11:39 pm
by Germanunkol
@Reef, after finding a collision, you set the collision boolean, but then continue looping through the other values. So if there's any other value in the table where it doesn't collide, then the boolean is set back to false.

You could use a break command in the for loops, to jump out of the loops after the player.collision is set to true. Unless you need to call checkCollision on all tiles (even when you already know that it collided with one), then veethree's way is the best way to go.