Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: saintrunner on November 07, 2011, 03:23:58 pm

Title: Axe code of jumping help!?
Post 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?
Title: Re: Axe code of jumping help!?
Post by: parserp on November 07, 2011, 03:54:23 pm
hmm... this doesn't look like it's in the right section, but I'll see what i can do...
Got it!
Code: [Select]
:.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
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 07, 2011, 04:06:23 pm
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?
Title: Re: Axe code of jumping help!?
Post by: parserp on November 07, 2011, 04:11:52 pm
helped ;D
(well, I hope :P)
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 07, 2011, 04:25:08 pm
Thanks so much! You truly saved me a lot of time trying to figure that out :)
Title: Re: Axe code of jumping help!?
Post by: parserp on November 07, 2011, 04:33:02 pm
lol I've never done jumping with one variable and so simple code before...
I taught myself something! ;D
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 07, 2011, 09:23:05 pm
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
Title: Re: Axe code of jumping help!?
Post by: parserp on November 07, 2011, 09:24:38 pm
The gravity is in the code explanation...
(well, very simple gravity :))
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 07, 2011, 09:26:45 pm
yes, but I want to implement complex gravity. with like velocity and acceleration given different conditions. lol
Title: Re: Axe code of jumping help!?
Post by: parserp on November 07, 2011, 09:27:45 pm
oh yeah, for complex gravity you definitely wouldn't want to use that... :)
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 07, 2011, 09:32:57 pm
yeah, for now it works
Title: Re: Axe code of jumping help!?
Post by: aeTIos on November 08, 2011, 06:40:32 am
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..
Title: Re: Axe code of jumping help!?
Post by: saintrunner on November 08, 2011, 08:21:37 am
Yeah that makes sense.

but easy and gravity don't always go together. lol
Title: Re: Axe code of jumping help!?
Post by: aeTIos on November 08, 2011, 10:35:15 am
heck, I meant "makes it easier"