Forum Archive

Flappy Bird on Pythonista

bashedcrab

https://gist.github.com/BashedCrab/8949577

This started out as a Flappy Bird clone (can be done in under 100 lines of Pythonista), but I let my son do a bit of a redesign. He decided an underwater setting involving an Octopus was much more enjoyable.

The game play and physics are tuned to replicate the original Flappy Bird as closely as possible, so it is hard! If you want to make it a bit more fun for young kids, make the gap larger (Default is 360. 450 is much easier but still a challenge for young kids).

Enjoy.

omz

Love it! Really nice use of the emojis.

pruppert222

Cool! Thanks for sharing.

bee18

The default tower gap is too narrow. It makes the game alot harder.

bashedcrab

It is supposed to be hard. Most players take many tries just to get past the first tower in Flappy Bird. This experiment had the author play 150 times, and still only had a best of 7.

http://www.wired.com/wiredscience/2014/02/difficult-flappy-bird/

This gist is modelled as closely as possible on the original Flappy bird to the point the the tower gap/width, scroll speed, jump height, gravity etc make playing this game just as frustrating as the original. If you want to make it accessible for kids, increase the gap. But doing for yourself will destroy the Flappy Bird's addictive quality.

bee18

Flappy bird is too hard to be an enjoyable game. That's why people love and hate it at the same time. I don't want to get stressed because of this stupid little game. LOL.

I was about to try to make another Flappy Bird clone using Codea/Pythonista. Fortunately, I found your code before I did it. So, instead of making my own, I simply took yours and modify it to my taste. Now, I have my own version of Flappy Bird which I could enjoy playing. It's not as hard as the original Flappy Bird, but it's not too easy as well. With my modification, it's not hard to get score of 10, but it's still pretty hard to get over 20. Now, that's an enjoyable yet challenging simple game. At least to my taste. :)

And, thank you for sharing the code. I really appreciate it.

bashedcrab

You're welcome. Glad someone is enjoying it!

My next game is a lot less frustrating and a lot more fun.

ccc

My particular modification was to make all the graphic elements subclasses of scene.Layer. For the most part it was fairly simple to do and completely eliminated most of the draw() methods. However, I struggled to understand Tower enough to change it. I am glad to hear that the game is nearly impossible to play because I was really unable to build up a high score.

brumm

Great!!! Thank you.

Sebastian

Nicely done! Looks a lot better than my version XD

bashedcrab

Hey TripleC,
I couldn't decide whether each part of a tower should be it's own object, or if I should aggregate them into one for ease of scoring and collision detection. I went with the aggregate class, but it is probably bad OO design, and it is harder to understand. The Tower class holds 4 Rect()'s. (1 to represent each of the elements of the towers you need to fly through), and then has a draw() function, and an intersects() function for collision detection with the player.

self.upper_tower is a Rect to represent the shaft that starts at the roof
self.upper_cap is a Rect to represent the wider 'cap' that sits on the end of the upper tower
self.lower_tower is a Rect to represent the shaft that starts at the ground
self.lower_cap is a Rect to represent the wider cap that sits on the end of the lower tower

It draws each of the rects to screen manually - not sure how you would convert it to a layer (or layers).

due3die

Thanks for the game awesome but strange to cross best:2.

Cubbarooney104

I was actually working on a flappy bird clone myself (also underwater)! It isn't as nice as yours though (besides, mine is much easier)!

Thanks for the great learning material

Cubbarooney

Gerzer

Nice! You inspired me to create a game similar to, yet different from, Flappy Bird. Can't wait to see your next game.

fleech

Sorry for this dumb question, but how do i copy this code on to my pythonista editor on my iphone to try and execute it? I am a beginner in python and don't know.

dgelessus

First of all copy the entire script from the site linked above, unfortunately this can sometimes be a little tricky with the iOS text selection. Then open Pythonista, create a new blank script, name it something (like JumpyOctopus), paste the copied code, and finally press play in the upper right.

dozzzl

Thanks for sharing mate! Like your flappy! Could you guys check mine flappy games, I've made two already:
Flappy Minaj and Floppy Ufo

thanks mates!

fleech

@dgelessus thanks :D

Butler

This game might be similar to flappy bird but it is just as much fun and you have the option to fiddle around with it and modify it to your own needs.

Mark

Bamboo bird is best in my opinion
It has a whole new set of graphics and Game Center which makes it even more addicting
Check out Bamboo Bird on the apple App Store!!!

GaryGadget

I have just purchased Pythonista and followed the link to this forum and your game was the first I downloaded and executed (intuitively) to demonstrate to my two sons how good this programming app can be. It was so easy to do and such good fun to be able to code in changes to your game and watch the changes when executed. Great thanks. It impressed my kids and I hope it will stimulate them into coding a bit more.

Just one question if you have time. The octopus image you use, is it part of a Pythonistal library of images? I assume it is in a root directory or something because you don't use a path for it. I'm new to Python and IOS coding so don't know if I'm missing something here. Tried looking and found it in the Textures folder!

Thanks again for your code share.

Regards
Gary

dgelessus

There is a fairly large collection of images, icons and sounds included with Pythonista, which are in folders that cannot normally be accessed. You can get a list of all of them (and conveniently insert the names) using the + button in the toolbar while the keyboard is visible in the editor.

GaryGadget

Found it thanks although I could only find it on my iPad and not on my iPhone!

Great find this app and forum, hopefully now I can help my school kids a bit more at my convenience if you know what I mean.

Regards
Gary

Sebastian

@GaryGadget To access the images, sounds, etc on iPhone you have to open the little copy-paste popup menu. In that menu you'll find another option which says 'Insert...'

GaryGadget

Aha! Found it eventually. Thanks for that.

Johnnnyfever

Cool, thanks for this. I'm just getting back into coding and this was fun to play with and make some changes and customize it.