Online Demo: http://osgames.duapp.com/apprun.html?appid=osgames1-911422256817006
Online Editor: http://osgames.duapp.com/gamebuilder.php?appid=osgames1-911422256817006
Scanning:
Run:
Flappybird is a 2014 explosion of a game, belongs to the classic gravity induction game, play very simple at the same time and very abusive heart, it is this feature let Flappybird in the social network virus-like spread.
Gamebuilder integrates the box2d physics engine and develops this type of gravity-sensing game that belongs to his housekeeping skills.
A total of only 60 lines of flppybird are required for the Gamebuilder implementation, which basically realizes the random distribution of the pipe in the vertical direction (the horizontal position is fixed), and of course you can set the pipe yourself, so that if 10 lines of code will be done.
The game consists of two main aspects:
Horizontal Cloth Tube
The virtual width of the screen is set to 100000 pixels, placing only the top and bottom four pipes, such as:
The bird crosses the tube (to the left of the screen) back into the front of the bird (right side of the screen).
- Location Generation function
function() { var x, y; for(var04; i++) { var position = {x:0, y:0}; 480 + i*320; y = win.randomY(); position.x = x; position.y = y; win.pList.push(position); }};
Win.updateplist = function() { varWin = This. GetWindow ();varBird = Win.find ("Bird");//Bird over tube, play sound, add points if(Bird.x > Win.nextscorex) {Win.nextscorex + = the; Win.find ("Effects"). Play ("Disappear.mp3"); Win.score + =1; Win.find ("Score"). SetText (Win.score); }//The leftmost tube moves out of the screen, move it to the right if(win.plist[0].x- This. Xoffset <- the) {varp = Win.pList.shift (); p.x = win.plist[2].x + the; P.Y = Win.randomy (); Win.pList.push (P); }};
- Periodically update the pipe position based on the location list
function() { win.updatePList(); for(var04; i++) { win.find("boxup" + i).setPosition(win.pList[i].x, win.pList[i].y); win.find("boxdown"850); } 50);};
Collision detection
In the game, the bird as a rigid body, in the game has been required to remain vacant, once the collision is considered to end the game, so long as the implementation of the bird Onbegincontact event interface can be.
Event code:
varthis.getWindow();if(!win.gameOver) { true; win.find("bird").setV(015); win.openWindow("win-result"function(ret) {false, win.score);}
Gamebuilder Development Game Application series of 60 lines of code implementation Flappybird