Author Topic: Axe code of jumping help!?  (Read 4604 times)

0 Members and 1 Guest are viewing this topic.

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Axe code of jumping help!?
« 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?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Axe code of jumping help!?
« Reply #1 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
« Last Edit: November 07, 2011, 04:24:48 pm by parser padwan »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #2 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?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Axe code of jumping help!?
« Reply #3 on: November 07, 2011, 04:11:52 pm »
helped ;D
(well, I hope :P)

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #4 on: November 07, 2011, 04:25:08 pm »
Thanks so much! You truly saved me a lot of time trying to figure that out :)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Axe code of jumping help!?
« Reply #5 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

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #6 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
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Axe code of jumping help!?
« Reply #7 on: November 07, 2011, 09:24:38 pm »
The gravity is in the code explanation...
(well, very simple gravity :))
« Last Edit: November 07, 2011, 09:25:01 pm by parser padwan »

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #8 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
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline parserp

  • Hero Extraordinaire
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1455
  • Rating: +88/-7
  • The King Has Returned
    • View Profile
Re: Axe code of jumping help!?
« Reply #9 on: November 07, 2011, 09:27:45 pm »
oh yeah, for complex gravity you definitely wouldn't want to use that... :)

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #10 on: November 07, 2011, 09:32:57 pm »
yeah, for now it works
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe code of jumping help!?
« Reply #11 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..
I'm not a nerd but I pretend:

Offline saintrunner

  • Custom Spriter: You ask it! I'll Make it!
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1787
  • Rating: +115/-11
  • Flogging Molly
    • View Profile
    • Jonny K Music
Re: Axe code of jumping help!?
« Reply #12 on: November 08, 2011, 08:21:37 am »
Yeah that makes sense.

but easy and gravity don't always go together. lol
« Last Edit: November 08, 2011, 08:22:18 am by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Axe code of jumping help!?
« Reply #13 on: November 08, 2011, 10:35:15 am »
heck, I meant "makes it easier"
I'm not a nerd but I pretend: