Share My Creation Cloney Bird - Flappy Bird clone - source code included

I've put together a simple Flappy Bird clone using the accelerated surface library. It's nothing complicated but was a good exercise for me to play around with making a simple game. I've included the source code for you all to play with if you like. I believe Flappy Bird is the pong of this generation for programmers, it serves as a good example of something you should try to learnt o program to teahc you the basics of setting up a game scene, tracking score, reading and writing a highscore to a file, accepting user input and updating the scene quickly to give smooth graphics.
2014-03-04 08.32.17.png
2014-03-04 08.32.02.png

I want to say a big thanks to Informatix for his help with handling the scaling issues I ran into with this to support different screen sizes.
 

Attachments

  • CloneyBird.zip
    19.9 KB · Views: 4,145
  • result.apk
    153.1 KB · Views: 1,529

Douglas Farias

Expert
Licensed User
Longtime User
Can you
Yes, the game restarts when you tap after you die. I have found a problem with speed and scaling when I've testing it on different devices, this is now the next thing for me to fix.
try make to when you die show a button to restart . When restart button click back to menu and show you tap to play like fla0py bird. No direct . Tap to restart is incorrect. In the flaapy bird original you click in restart bitton and you come to new screen with a title tap to play sory for my english
 

walterf25

Expert
Licensed User
Longtime User
Okay, I've figured out more of libGDX now. I've attached my first test version using it. It's not finished but should show how much smoother libGDX will run on different devices. Also, the graphics may scale better but I've not tested this yet.
that's very nice andy, but it would be a lot easier if you use lgScn2d, you can control the angle of the bird way easier with less code, and draw the gackground with less code also, also you can detect the collision easier, take a look at this file this was done in libgdx. you can open with a program called JdGUI or any other programs that opens jar files.
the file is too large to attach it so you can download it from my dropbox
https://dl.dropboxusercontent.com/u/82367588/flappybird_dex2jar.jar

Good luck.
 

imbault

Well-Known Member
Licensed User
Longtime User
I've just done an update while on the train. Find it attached: now has title screen and game restart.
Hi, bug on start :

com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bmfont_0.png

any idea
 

andymc

Well-Known Member
Licensed User
Longtime User
Hi, okay, not sure why it's not running, I'll need to check the file. I've got a problem with timing anyway, so will need to look at that. It runs fine on devices that lock the refresh rate to 60 fps but other devices, such as emulators are having problems as these can go well over 100 fps and the game runs far too fast. I need to figure out delta timing.

Thanks walterf25 but I don't know what to do with the .jar file you attached to your post. Are you able to export the project as a zip?

I've updated the file,it shouldn't give the file not found error now for the font file. I just forgot to sync the files tab before exporting the project.
 

Attachments

  • CloneyBird_LibGDX.zip
    112.7 KB · Views: 475
Last edited:

Xardoz

Member
Licensed User
Longtime User
The code bombs on me, not sure why...

B4X:
Error occurred on line: 146 (main)
com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bird.png

The file exist!
 

Beja

Expert
Licensed User
Longtime User
sorry, duplicate by mistake
 
Last edited:

Beja

Expert
Licensed User
Longtime User
This version is impossible to win, I mean impossible, because the bars will become too close to pass through.. Is there anyway to increase the distance? I have reduced the speed to .06 but also didn't help.
 

andymc

Well-Known Member
Licensed User
Longtime User
This version is impossible to win, I mean impossible, because the bars will become too close to pass through.. Is there anyway to increase the distance? I have reduced the speed to .06 but also didn't help.

Try increasing the pipe countdown variable amount.
 

andymc

Well-Known Member
Licensed User
Longtime User
In the latest libGDX based version I have, the line is:
pipeCD = vpW*0.40
it's line number 213
basisally what this does is sets the next pipe to appear 40% across the screen from the last pipe, mekanign you can have just over three pipes on screen at once. One at 10%, one at 50% then one at 90%. Increasing this value to something bigger will spread the pipes out a little. If you want another way of making the game easier then you could set the new pipe height to be withiooon a set range of the last pipe generated to stop any large height differences. You could adapt this code to doe a tunnel game like the chopper game where the pipes are right next to each other with no gaps and only a small diffrerence in heights. But I'll leave you to figure that one out for yourself!
 

Beja

Expert
Licensed User
Longtime User
Thanks and instead of widening the gap between pipes, I will try to make different levels of difficulty.. the easy one will have the gaps (no change) and wide enough for a beginner to build confidence, level two a littler harder.

BTW:
What's the meaning of "CD" in pipeCD?
 

boten

Active Member
Licensed User
Longtime User
I understand that
B4X:
lGdx_GL.glClearColor(0, 0, 1, 1) 'Blue background
lGdx_GL.glClear(lGdx_GL.GL10_COLOR_BUFFER_BIT)
will clear the the screen with Blue.

I want to create a transparent "surface" so that the Activity's background will show (perhaps showing the REAL world thru the camera)
I tried adjusting the 4th parameter (alpha?) to get a transparent background, but even setting to 0 did not work.

In essence, is there a way that the "background" of libgdx will show the REAL world thru the device camera?
 

andymc

Well-Known Member
Licensed User
Longtime User
I found this atfer googling your problem:
AndroidApplicationConfiguration cfg =newAndroidApplicationConfiguration();
cfg.r = cfg.g = cfg.b = cfg.a =8;

cfg.useGL20 =false;

View view = initializeForView(newLineDrawing(), cfg);

if(graphics.getView()instanceofSurfaceView){SurfaceView glView =(SurfaceView) graphics.getView();
glView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
glView.setZOrderOnTop(true);}

I don't know if it will help.
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Where I can find the "AcceleratedSurface" lib?
 

mlc

Active Member
Licensed User
Longtime User
Hello andymc,
I have found that in some devices, the bar spacing is smaller. (see image)
if pipeCD = 40%x then here shows approximately 120%x

upload_2015-6-22_10-45-46.png


With these changes, I managed to display the same on all my devices.

B4X:
Sub Globals
      Dim pipeCD As Float 'Int = 50
End sub

B4X:
Sub Activity_Create(FirstTime As Boolean)
'    scaleX = (screenX / 400)
    scaleY = (screenY / 600)
    Dim xx As Float = (screenX * 600) / screenY
    scaleX = (screenX / xx)

    speed = speed * scaleX

End sub

upload_2015-6-22_12-53-18.png


Can you check it on your devices?
 
Last edited:
Top