0 Members and 1 Guest are viewing this topic.
.Initialize0->X->Y.Main Game LoopRepeat getkey(15)ClrDrawPt-On(X/256,Y/256,Pic1)Dispgraph.Just so it's not too fast...Pause 75End
0->X->Y->ERepeat getkey(15).Add Y_Velocity to Y_PositionY+E->Y.Add a constant acceleration to Y_VelocityE+100->EClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
0->X->Y->ERepeat getkey(15)Y+E->YE+100->E.Make sure he doesn't fall off the bottom of the screenIf Y>>14336.^^make sure it's >>, not >. >> works on negative numers, > doesn't..14336 = 56 (the lowest we want our character to be able to go) * 256 (256x inflation)14336->Y0->E.there are other ways of stopping the character, like in Builderboy's Zedd physics library, objects bounce when they hit the ground and stuff like that.EndClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
0->X->Y->ERepeat getkey(15)Y+E->YE+100->EIf Y>>1433614336->Y0->EEnd.Press [2nd] to flyIf getkey(54)E-150->E.This number needs to be bigger than 100, to overcome gravityEnd.Make it so the character doesn't fly off the top of the screenIf Y<<00->Y->EEndClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
0->X->Y->ERepeat getkey(15).Every frame, add X_Velocity to X_positionX+D->XY+E->YE+100->EIf Y>>1433614336->Y0->EEndIf getkey(54)E-150->EEndIf Y<<00->Y->EEnd.When the user presses right, add to X_VelocityIf getkey(3)D+50->DEnd.When the user presses left, subtract from itIf getkey(2)D-50->DEndClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
0->X->Y->ERepeat getkey(15)X+D->XY+E->YE+100->EIf Y>>1433614336->Y0->EEndIf getkey(54)E-150->EEndIf Y<<00->Y->EEndIf getkey(3)D+50->DEndIf getkey(2)D-50->DEnd.If the character is off the right edge...If X>>22528.bring him back22528->X0->DEnd.If the character is off the left edge...If X<<0.we can take care of this0->X->DEndClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
0->X->Y->ERepeat getkey(15)X+D->XY+E->YE+100->EIf Y>>1433614336->Y0->EEndIf getkey(54)E-150->EEndIf Y<<00->Y->EEndIf getkey(3)D+50->DEndIf getkey(2)D-50->DEndIf X>>2252822528->X0->DEndIf X<<00->X->DEnd.if the user isn't pressing right and the user isn't pressing leftIf getkey(2)=0 and (getkey(3)=0).divide the acceleration value by 2D//2->DEndClrDrawPt-On(X/256,Y/256,Pic1)DispgraphPause 75End
BUTTSFREDKIN I LOVE YOU NOW...(in a manly way... )
When you hit the jump key, set the y-velocity to a negative value (this can vary depending on how high you want the jump to be, and make sure the y-velocity is stored in a signed variable). Then, every frame add your gravity constant, add the y-velocity to the y-position, and you should be set.
Meeeee! Yeah, I thought it might be a bit tricky for gravity, bt I started and I noticed how really simple it was