flappy bird remake

I am trying to remake flappy bird, and right now, I am not even close to done. For now, I need to know how to make the bird fall back down. Any help?

local physics = require "physics" physics.start() local bird = display.newImage("Flappy-Bird.png", display.contentWidth/2, display.contentHeight/2) bird:scale(.15,.15) physics.addBody( bird, "rigid", {density=0, friction=0, bounce=0 } ) function activatebird(self, event) self:applyForce( 0, -35, self.x, self.y ) end local timeLimit = 4 function touchScreen (event) if event.phase == "began" then bird.enterFrame = activatebird Runtime:addEventListener( "enterFrame", bird ) end end timer.performWithDelay( 1000, timerDown, timerLimit) Runtime:addEventListener( "touch", touchScreen )

why did you make a runtime listener for the touch event? try modifying the function like this:

  1. function touchScreen (event)
  2.     if event.phase == “began” then
  3.         bird:applyForce( 0, -35, bird.x, bird.y ) --just increase the yForce value until the bird goes up high enough
  4.     end
  5. end

to make things fall add some gravity:

physics.setGravity(0,10)

I see someone has created a tutorial for this so maybe worth checking out for you:

http://forums.coronalabs.com/topic/44434-flappy-bird-code-walk-through/

gravity is by default physics.setGravity(0,9.8), so thats not the problem

maybe try a bodytype of “dynamic” instead of “rigid” and 1 as density? Dont think rigid is a valid option here. and 0 density gives 0 mass.

  • physics.addBody( bird, “dynamic”, {density=1, friction=0, bounce=0 } )

 

Hi @chandra2000,

As @borgb says, “rigid” is not a valid body type. Please read through the physics body guide for details:

http://docs.coronalabs.com/guide/physics/physicsBodies/index.html

Brent

why did you make a runtime listener for the touch event? try modifying the function like this:

  1. function touchScreen (event)
  2.     if event.phase == “began” then
  3.         bird:applyForce( 0, -35, bird.x, bird.y ) --just increase the yForce value until the bird goes up high enough
  4.     end
  5. end

to make things fall add some gravity:

physics.setGravity(0,10)

I see someone has created a tutorial for this so maybe worth checking out for you:

http://forums.coronalabs.com/topic/44434-flappy-bird-code-walk-through/

gravity is by default physics.setGravity(0,9.8), so thats not the problem

maybe try a bodytype of “dynamic” instead of “rigid” and 1 as density? Dont think rigid is a valid option here. and 0 density gives 0 mass.

  • physics.addBody( bird, “dynamic”, {density=1, friction=0, bounce=0 } )

 

Hi @chandra2000,

As @borgb says, “rigid” is not a valid body type. Please read through the physics body guide for details:

http://docs.coronalabs.com/guide/physics/physicsBodies/index.html

Brent