Online preview: http://osgames.duapp.com/apprun.html?appid=osgames1-551421721381542
Online Editor: http://osgames.duapp.com/gamebuilder.php?appid=osgames1-551421721381542
Scanning:
Run:
Set of ring is a fire dance on a very popular game, it is the Flappybird variant, is also the gravity induction game, the difference is the collision detection from the Flappybird pipe, into a rope in the middle.
This rope in Gamebuilder with Uicanvas to achieve, Uicanvas in the previous blog Gamebuilder Development Game Application series of 100 lines of code implementation do not step on the white block is introduced.
The ropes here are drawn, and therefore cannot be used to detect collisions between CANTK rigid bodies onbegincontact, but instead use the onmoved interface of the ring (rigid body) to detect collisions with the rope.
The calculation of the rope
win.onlinemoved = function() { if(win.gamestarted = = =0) {SetTimeout (win.onlinemoved, -);return; } win.points.shift (); ++win.count; ++win.score;if(Win.score%Ten===0) Win.find ("Score"). SetText (Win.score *0.1);varOy = win.points[win.points.length-1];if(Win.count% -===0) {win.factor = Win.genfactor (); Win.count =0; }vary = oy + win.factor; while(Y >=290|| Y <= the) {win.factor = Win.genfactor (); y = oy + win.factor; Win.count =0; } win.points.push (y); SetTimeout (win.onlinemoved, -);};
The drawing of the rope
function(ctx){ var pa = win.points; 20; ‘yellow‘; ctx.moveTo(0, pa[0]); for(var1; i < pa.length; i++) { ctx.lineTo(i, pa[i]); } ctx.stroke();};
The composition of the ring
The ring is a combination of two rigid bodies, one in the Uicanvas (yellow one) below.
Collision detection
Implements the Onmoved event interface for the ring.
win.oncirclemoved = function(point, Element) { vary = point.y;varx =Math. Floor (point.x + ELEMENT.W);if(Y + -> Win.points[x] + $|| Y + element.h- -< Win.points[x] + $) {win.gamestarted =0; Win.find ("Ui-box"). Setenable (false); Win.find ("Ui-box-1"). Setenable (false); Win.openwindow ("Win-result", function() {Win.replay (); Win.initgame ();},false,Math. Floor (Win.score *0.1)); }};
Gamebuilder Development Game Application series of 70 lines of code to implement a set of rings