Flappy Ball (aka Floaty Ball) game


(Scott) #1

Continuing the discussion from Flappy Ball Thread:

Floaty Ball, or Flappy Ball as the intro screen calls it, was a game included as an example in early versions of the Arduboy library. It was removed because it was virtually unplayable, due to the speed that the ball moved.

I’ve taken some time to clean it up a bit and fiddled with the rise and fall speed of the ball, to make it easier to play (maybe too easy?). I renamed it from FloatyBall to FlappyBall, to match the intro screen.

My version is on GitHub at:

The code that I used as a base is here.

A video of the current version running on the Arduboy 1.0 production unit.

A video of the original version being played on the original prototype Arduboy can be seen on YouTube:


Flappy Birdie - A Flappy Bird Clone
"Semi-Official" Game List for the Arduboy
Arduboy's Cousin?
Adding sound - error 48 [Solved]
"Semi-Official" Game List for the Arduboy
Playing a score with an int array?
(Scott) #2

I’ve adjusted the parameters and code that generates the pipes. The gap will now be located over a larger range. The gap has been decreased slightly. The space between the pipes has increased slightly.

If you downloaded the game before this message was posted, you may wish to grab it again and try this new version. It’s a bit more difficult. :smiley:


(Scott) #3

More fixes and changes:

  • The location of the pipe gaps wasn’t random. It just kept repeating.
  • The vertical movement of the ball was flawed.
  • The falling of the ball when the game ends wasn’t visible.
  • Other minor things.

(Scott) #4

I’ve now added an increasing difficulty factor, to prevent the game from going on forever for skilled players.

The gap between the pipes starts out larger than before but it gets progressively smaller as the score increases.


#5

i try your version.
first game score is 8. next 20. good speed.
incidentally, old version score got only 1 or 2 :slight_smile:

I’d like to make a suggestion.
It might be interesting to use the fixed-point numbers.
if it use your project, probably ball move very smooth.

i use my all project.

#define NUM2FIX(N)                ((N) << 8)
#define FIX2NUM(F)                ((F) >> 8)

(Scott) #6

:thumbsup: My best score with my currently released code is 49 but I’ve really only played to test it.

I’m not sure how this would help. The game only uses addition and subtraction and I don’t believe there are any overflows. There aren’t any multiplication or division operations. Can you give an example of where it would help?


#7

Fixed Point is old programming technique.
old game computer use it.

CPU of Calculation was late.
float or double variable is very very slow.
programmer used only 8bit or 16bit int variable.
http://www.drunkencoders.com/tutorials/GBA/appendixA.html#fixed
http://www.coranac.com/tonc/text/fixed.htm

the most good thing is decimal point.
8.8 = 8 bits integer 8 bits fraction

example.
my tiny depth projtct. pls see source code.
https://github.com/akkera102/02_tiny_depth/blob/master/src/ship.cpp

30 line: ShipInit

Ship.fx = FT(OLED_SCREEN_CX/2 - SHIP_CX/2);

Ship.fx is signed short(16bit). it set Arduboy screen center.
FT is My C Macro.

#define FT(T) ((T) << 8)
#define FF(F) ((F) >> 8)

70-78 line: ShipMove

Ship.fx += 200;
Ship.fx -= 200;

53 line: ShipDraw

OledDrawBmp(FF(Ship.fx), FF(Ship.fy) + n, bitmapShip);

videos.


(Scott) #8

Yes, I understand what Fixed Point is. I just don’t see how using it would benefit Flappy Ball. The code is all integer based, without any multiplication or division that has to deal with fractional results.

Again, what part of the Flappy Ball code would work better using Fixed Point math?


#9

my talikng is about the ball moving function.
if i edit your source, i edit it.

char ballY = 32;                // Floaty's height
char ballVY = 0;                // Floaty's vertical velocity

char -> signed short(16bit)

arduboy.setFrameRate(30);

30 -> 60(fps)

and, more code and parameters must need modification.
but… It may not be tremendous big change. :sweat_smile:


(Scott) #10

Using Fixed Point, you could possibly do a more accurate simulation of acceleration due to gravity but I doubt the result would be very noticeable compared to the technique currently used.

Currently, the ball position is only being updated every other frame, so it’s at 15 fps. So yes, you could use Fixed Point math to interpolate and update at 30 fps or 60 fps. It would be smoother but I wonder how much your eyes would notice it. You’re welcome to try it if you wish.


(Scott) #11

OK, I decided to try this. I used 4 bits for the fractional part of the int.

I kept the game at 30 fps but the ball position is now updated every frame instead of every other frame. I don’t know if you’ll notice it being any smoother but it will improve collision detection. It also makes it easier to experiment with different values for the gravitational acceleration and jump velocity.

I’ve also added the display of button usage information, and the ability to toggle sound off and on.

Some of the parameters that control game play have been changed, so the difficulty may have been affected, but I don’t think by much.


#12

That’s great. i want to try game.

umm… just I’m on a business trip.
my home and devkit is too far.
pls wait 1 day.


(Scott) #13

More changes:

  • The number of points that cause the pipe gap to narrow is reduced from 6 to 5. I felt the game was going on a bit too long, for me at least.

  • The point sound is no longer interrupted by a flap sound.

  • The number of bits used for the fraction part of an integer has been increased from 4 to 6. This doesn’t affect anything with the current game settings but allows finer control of the acceleration and jump velocity values in case anyone wishes to experiment with them (especially if the frame rate were to be increased).


#14

new version is cool than old version.

not jerky. very smooooth!!
too comfortable, i think it seems connected with a feather. speed is no problem.
playing 15 min. my new record is 27. im not good gamer. :slight_smile:


(Ross) #15

This is a pretty fun game, it does run really well.

I got this put on codebender, I’ll have to get instructions to load it to the devkit, I don’t see our hardware in the variants yet, but it will work with the 1.0 unit.

https://codebender.cc/sketch:290556


(Scott) #16

My goal was to make it easy enough at the beginning so that beginners, children and less skilled players wouldn’t find it too frustrating, but it would increase in difficulty fast enough that it would end in a reasonable amount of time for experts.

With the current settings, I’ve managed to get above 50 a few times but that’s with my home made system. I can’t say how I’d do with a real Arduboy or DevKit.

The only way I can see doing this on codebender, until they directly support the DevKit as a board type, would be to copy the library into the sketch or set up a personal library, and then comment out the #define ARDUBOY_10 and uncomment #define AB_DEVKIT in core.h, as instructed.


(Ross) #17

It’s already been added, they are just waiting on a few games to add the hardware definitions. All of the games will be under the ArduboyGames account on their site. There should be an Arduboy and Arduboy Devkit in the drop down menu in the upper right soon.


(Scott) #18

My ArduboyLife sketch can be added there, if desired. I’ve verified that it works correctly with the current Arduboy library on codebender.


(Ross) #19

From http://gigazine.net/news/20160531-arduboy-review/


(Jun-Liang Tan) #20

This is fun! My highscore is 74. Lets see who can beat it :grin:.