Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: saintrunner on November 07, 2011, 03:23:58 pm
-
So I have read some of the tutorials on how to code an object jumping in basic, and I know that it should similarly apply in Axe, but for some reason I cant get it to work right! What im trying to do is get a sprite (of mario) to jump when I press 'up'. I also know I need to incorporate gravity, but I can't get it right. can someone help me? maybe show me an example program?
-
hmm... this doesn't look like it's in the right section, but I'll see what i can do...
Got it!
:.Jump
:[guysprite]->Pic1
:0->J //our jump variable
:1->X //players x coord
:55->Y //players y coord
:Repeat getKey(15) //main loop
:ClrDraw
:Line(0,63,95,63) //line on bottom
:Pt-On(X,Y,Pic1) // draw the guy
:DispGraph
:If getKey(4) and (pxl-Test(X,Y+8)) //see if pressed up and standing on ground
:10->J //change the 10 to set how high he jumps
:End
:If (J>0) //if player is currently jumping
:Y-1->Y //move him up- aka: jump
:J-1->J //decrament J
:End
:If (pxl-Test(X,Y+8)=0) and (J=0) //see if not jumping and not anything beneath it
:Y+1->Y //this is our gravity- move him down
:End
:Pause 100 //slows down our loop so we can see what's happening
:End
Of course, you'll need to add player movement and stuff, but this should work :)
EDIT #3: it works, just tried it ;D
-
oh yeah sorry, I'm in a rush too get this game done, and I didnt even check the category. :P but can you help?
-
helped ;D
(well, I hope :P)
-
Thanks so much! You truly saved me a lot of time trying to figure that out :)
-
lol I've never done jumping with one variable and so simple code before...
I taught myself something! ;D
-
Looking back it actually was very simple, I think I was over complicating it. I really want to involve gravity, but I'll get that later! lol
-
The gravity is in the code explanation...
(well, very simple gravity :))
-
yes, but I want to implement complex gravity. with like velocity and acceleration given different conditions. lol
-
oh yeah, for complex gravity you definitely wouldn't want to use that... :)
-
yeah, for now it works
-
I always use a very easy method: I define some value (example: 4) as a zero. below it it is jumping, above it falling. It is useful for jumping since you can for example just set the value to zero and thus to -4. I hope its clear this way..
-
Yeah that makes sense.
but easy and gravity don't always go together. lol
-
heck, I meant "makes it easier"