Flappy Bird [ng] for android (w/ sound effects)
BlitzMax Forums/Brucey's Modules/Flappy Bird [ng] for android (w/ sound effects)
| ||
Today I threw together a Flappy-Bird clone in NG with purpose of being cross platform (win/android). the android version works identical to windows and not much needed to be handled differently between the 2 platforms code wise. For audio, I had to use the c api of soloud. However there is a noticeable delay in the phone version of playing sound effects. I had read that the newer versions of android had fixed that issue and I tested on a galaxy 6. might be an sdl issue. (PortAudio is bettter??). You can get the source files and compiled apk and exe here. The code is minimal, it's not a framework and there was no effort to optimize anything. just enough code to make the game and I was rushed for time. In fact, the way I wrote it, it creates a lot of junk for the GC to deal with each frame. However the framerate is a greasy 60fps (200 without vsync) on android. It's pretty cool being able to code in Bmax and deploy on mobile. Thanks Brucey!! |
| ||
404 The requested URL /download/flappybird_ng.zip was not found on this server. If you have "highscores" you might need to handle virtualKeyboard. Dunno if there is now a way to see the "area" of the keyboard (you want to know where to draw the "input field" and if you have to draw the background etc.). @delayed effects Maybe it uses Android's mediamanager (like Monkey does - I believe). Dunno if you use "streaming" for the SFX too, which might result in an delay. Once the DL works I might give it a try (incl. looking at the sources). bye Ron |
| ||
fixed the link. |
| ||
'cant exactly print the thing... ?Not android If res Then Print soloud.getErrorString(res) Else Print("ok!") ? SDL.SDL exposes the Logging-functionality now (after I begged Brucey to expose it ;-) So you could do a ?android 'debug not shown in normal logcat 'LogDebug(SDL_LOG_CATEGORY_APPLICATION, text) LogInfo(SDL_LOG_CATEGORY_APPLICATION, text) LogWarn(SDL_LOG_CATEGORY_APPLICATION, text) ?not android print "bla ? Edit: just saw, you use that already in "error" - so what is the problem you are facing? If you want a "console output": I use a "logfile"-approach (adding everything to a list of strings) - if you debug, you just print the latest lines to the screen (using DrawText). bye Ron |
| ||
cool! I have not tried it on the android but desktop version looks good so far! :) |
| ||
Today I threw together a Flappy-Bird clone in NG Excellent ! Thanks for persevering ;-) The plan is to improve the workflow over time. Yours and everyone else's input helps with this process. For audio, I had to use the c api of soloud Oh. Did you have problems with TSLWav ? The loadMem() method exposes the same functionality as you used in AudioInit(). |
| ||
Adjusted to load oggs: oggenc -q 3 -o smack.ogg smack.wav oggenc -q 3 -o flap.ogg flap.wav oggenc -q 3 -o bading.ogg bading.wav Flappy.bmx Incbin "assets/bading.ogg" Incbin "assets/flap.ogg" Incbin "assets/smack.ogg" audio.bmx Why does an "bading = new TSLWav.LoadMem(...)" not work? Upon destroy of a "TSLWav"-instance, it also cleans up on "destroy()" (the "asPtr" ...). So you either use my approach, or just keep using your direct access to the soLoud-interna. An even more simple approach is: Set SoLoud as AudioDriver, and use Blitzmax' "LoadSound()" ;-) bye Ron |
| ||
This variant relies on SetAudioDriver("SoLoud") as it then allows to relay loading functionality to SoLoud. If you give it a "LoadSound(oggfile)" it handles that as well as wavs, mon(otone sounds) ... If you pass the "LoadSound" the according flags, it also does "streaming" for you. So if you want to have a looped "background music", then it should be doable with global music:TSound = LoadSound("path", SOLOUD_SOUND_WAVSTREAM | SOUND_LOOP) |
| ||
An even more simple approach is: Set SoLoud as AudioDriver, and use Blitzmax' "LoadSound()" Which is the way I expected most people to use it. I still need to finish the TStream load implementation... |
| ||
I am also quite unsure if that loading functionality in SoLoudAudio skips other protos - at least if you extend from this driverif "::"-not-found sound.load(bla) else only check for "incbin" and if that fails...return error Maybe it would be better to fail back then to "sound.load()" again (in the case of "sound.load()" knowing how to handle the incoming URI). But for now I assume stream-handling would be nice (because it then allows for "sdl::assets/bla.ogg" For now you would need to load the ogg to memory (via TStream and sdl::-proto) and then do a "TSoloudSound(sound).loadMem(...)". @ Brucey Please also check if the "stream-code" is then compatible to the streaming-flag of soloud. bye Ron |
| ||
So is the SoLoud Driver now allows streaming? I was loading 2mb bgm ogg files before with android and it takes around 6-8 secs to load.. |
| ||
Just give that code line in #8 a try, did not test it, but according to the sources, it should work. For now you better use a sound provided by "incbin::" as the "sdl::" one is not supported yet. bye Ron |
| ||
Thank you I will try that. |