Mar 4, 2014 Replies: 68 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. 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 CloneyBird.zip 19.9 KB · Views: 4,773 result.apk result.apk 153.1 KB · Views: 2,067 Click to expand...
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. 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.
Douglas Farias Expert Licensed User Longtime User Mar 13, 2014 #41 Can you andymc said: 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. Click to expand... 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
Can you andymc said: 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. Click to expand... 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 Mar 14, 2014 #42 andymc said: 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. Click to expand... 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.
andymc said: 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. Click to expand... 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.
Douglas Farias Expert Licensed User Longtime User Mar 14, 2014 #43 i tested and dont run on my device *-* xD
imbault Well-Known Member Licensed User Longtime User Mar 14, 2014 #44 andymc said: I've just done an update while on the train. Find it attached: now has title screen and game restart. Click to expand... Hi, bug on start : com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bmfont_0.png any idea
andymc said: I've just done an update while on the train. Find it attached: now has title screen and game restart. Click to expand... 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 Mar 14, 2014 #45 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 CloneyBird_LibGDX.zip 112.7 KB · Views: 901 Last edited: Mar 14, 2014
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.
Xardoz Member Licensed User Longtime User Apr 11, 2014 #46 The code bombs on me, not sure why... Code: Error occurred on line: 146 (main) com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bird.png The file exist!
The code bombs on me, not sure why... Code: 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 Apr 12, 2014 #47 sorry, duplicate by mistake Last edited: Apr 12, 2014
Beja Expert Licensed User Longtime User Apr 12, 2014 #48 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.
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 Apr 14, 2014 #49 Beja said: 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. Click to expand... Try increasing the pipe countdown variable amount.
Beja said: 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. Click to expand... Try increasing the pipe countdown variable amount.
Informatix Expert Licensed User Longtime User Apr 14, 2014 #50 Xardoz said: The code bombs on me, not sure why... Code: Error occurred on line: 146 (main) com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bird.png The file exist! Click to expand... Run in Release mode not in Debug mode.
Xardoz said: The code bombs on me, not sure why... Code: Error occurred on line: 146 (main) com.badlogic.gdx.utils.GdxRuntimeException: Couldn't load file: bird.png The file exist! Click to expand... Run in Release mode not in Debug mode.
Beja Expert Licensed User Longtime User Apr 15, 2014 #51 @andymc, Try increasing the pipe countdown variable amount. Click to expand... Hi andy, Sorry but I couldn't find that var in the code.. please point me to it.
@andymc, Try increasing the pipe countdown variable amount. Click to expand... Hi andy, Sorry but I couldn't find that var in the code.. please point me to it.
andymc Well-Known Member Licensed User Longtime User Apr 15, 2014 #52 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!
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 Apr 15, 2014 #53 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?
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 Apr 29, 2014 #54 I understand that Code: 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?
I understand that Code: 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 Apr 29, 2014 #55 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.
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 Jun 3, 2015 #56 Where I can find the "AcceleratedSurface" lib?
Erel B4X founder Staff member Licensed User Longtime User Jun 4, 2015 #57 https://www.b4x.com/android/forum/pages/results/?query=AcceleratedSurface+library&page=1&prefix=0
mlc Active Member Licensed User Longtime User Jun 22, 2015 #58 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 With these changes, I managed to display the same on all my devices. Code: Sub Globals Dim pipeCD As Float 'Int = 50 End sub Code: 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 Can you check it on your devices? Last edited: Jun 22, 2015
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 With these changes, I managed to display the same on all my devices. Code: Sub Globals Dim pipeCD As Float 'Int = 50 End sub Code: 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 Can you check it on your devices?
andymc Well-Known Member Licensed User Longtime User Jun 22, 2015 #59 Hi mlc, I had this problem too, I decided to switch to using libGDX because that doesn't give me these problems as you can use a set screen resolution for all devices.
Hi mlc, I had this problem too, I decided to switch to using libGDX because that doesn't give me these problems as you can use a set screen resolution for all devices.