Author Topic: how to jump?  (Read 24429 times)

0 Members and 4 Guests are viewing this topic.

Offline Cram

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +0/-0
    • View Profile
Re: how to jump?
« Reply #15 on: December 21, 2011, 12:25:12 am »
wow thx a lot i understand how to jump now! :D and i found a little glitch lol one of your line is (0,0,0,64) so if getkey(2) and (X/=0) should be if getkey(2) and (X/=1) :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: how to jump?
« Reply #16 on: December 21, 2011, 12:28:24 am »
oh yeah (its called a bug) and I just wrote that wrong....I usually write that part as a collision (more difficult)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline Cram

  • LV3 Member (Next: 100)
  • ***
  • Posts: 49
  • Rating: +0/-0
    • View Profile
Re: how to jump?
« Reply #17 on: December 21, 2011, 12:56:30 pm »
ah ok and that is my next question, how can i put more collision? :O

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #18 on: December 21, 2011, 03:25:20 pm »
Collision with what type of gravity, and collisions on all sides?

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: how to jump?
« Reply #19 on: December 21, 2011, 03:27:57 pm »
easiest way is to do it is with pxl-test. just throw in arguments like
if getkey(2) and pxl-test(X,Y+8)=0  //if left is pushed and the pxl at the bottom left hand corner is off (remember X and Y set at zero is the top left hand corner)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #20 on: December 21, 2011, 03:29:21 pm »
I could give grappler's current subroutines. They use pxl-test (which I need to change) but a more complicated way, which I could simplify for simple gravity and post here.

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: how to jump?
« Reply #21 on: December 21, 2011, 03:32:23 pm »
I think he gets the gravity, it's just replacing the left and right hitting of objects.....but go ahead :) (I'm actually interested in seeing how your doing it, cause you generally optimize better then me)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #22 on: December 21, 2011, 03:33:31 pm »
For pxl-testing?

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: how to jump?
« Reply #23 on: December 21, 2011, 03:34:49 pm »
sorry I misread you post, go ahead, I think that might help :)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #24 on: December 21, 2011, 03:37:22 pm »
I was going to show my collisions for more realistic gravity, but mine aren't perfectly functioning so.... :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: how to jump?
« Reply #25 on: December 21, 2011, 03:39:37 pm »
Mine are slightly skewed as well, But I'm working on it...as for simple collision and gravity, pxl-test will work for now :)
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #26 on: December 21, 2011, 03:40:42 pm »
I need to use virtual pxltesting.

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: how to jump?
« Reply #27 on: December 21, 2011, 05:25:12 pm »
heres a source code for a simple movement/platformer engine I made a while back :) I hope it helps a little

Code: [Select]
:.JUMP
:[1C141C080C081C22]→Pic0MR
:[3828381030103844]→Pic0ML
:1→D
:0→J
:40→X
:55→Y
:Lbl 1
:Line(0,63,95,63)
:Line(0,0,0,63)
:Line(95,0,95,63)
:Line(0,0,95,0)
:Line(0,50,25,50)
:Line(25,50,25,63)
:Line(70,50,95,50)
:Line(70,50,70,63)
:
:Repeat getKey(15)
:If getKey(2) and (pxl-Test(X,Y+7)≠1)
:X-1→X
:2→D
:End
:If getKey(3) and (pxl-Test(X+7,Y+7)≠1)
:X+1→X
:1→D
:End
:If getKey(4) and (pxl-Test(X+1,Y+8) or pxl-Test(X+8,Y+8) and (S≠1))
:15→J
:End
:If (J>0)
:Y-1→Y
:J-1→J
:End
:If (pxl-Test(X+8,Y+8) or pxl-Test(X+1,Y+8)=0) and (J=0)
:Y+1→Y
:End
:If (D=1)
:Pt-Change(X,Y,Pic0MR)
:Pause 20
:End
:If (D=2)
:Pt-Change(X,Y,Pic0ML)
:Pause 20
:End
:DispGraph
:If (D=1)
:Pt-Change(X,Y,Pic0MR)
:End
:If (D=2)
:Pt-Change(X,Y,Pic0ML)
:End
:End

btw, the D variable is for the direction of the sprite (look at my screenie a couple posts above) you don't need this unless you want your sprite to look like he is looking different directions
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: how to jump?
« Reply #28 on: December 21, 2011, 05:36:18 pm »
Allow me to optimize/shorten a bit :P

Code: [Select]
:.JUMP
:[1C141C080C081C22]→Pic0MR
:[3828381030103844]
:1→D-1->J
:40→X
:55→Y
:Lbl 1
:Line(0,63,95,63)
:Line(0,,,63)
:Line(95,0,95,63)
:Line(0,,95,0)
:Line(0,50,25,50)
:Line(25,50,25,63)
:Line(70,50,95,50)
:Line(70,50,70,63)
:Repeat getKey(15)
:If getKey(2) and (pxl-Test(X,Y+7)≠1)
:X--
:2→D
:End
:If getKey(3) and (pxl-Test(X+7,Y+7)≠1)
:X++
:1→D
:End
:If getKey(4) and (pxl-Test(X+1,Y+8) or pxl-Test(X+8,Y+8) and (S≠1))
:15→J
:End
:If J>0
:Y--
:J--
:End
:If (pxl-Test(X+8,Y+8) or pxl-Test(X+1,Y+8)=0) and (J=0)
:Y++
:End
:For(Z,0,1)
:Pt-Change(X,Y,D*8+Pic0MR
:!If Z
:DispGraph
:Pause 20
:End
:End
:End
« Last Edit: December 21, 2011, 05:40:56 pm by epic7 »

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: how to jump?
« Reply #29 on: December 21, 2011, 05:41:04 pm »
The reason I didn't optimize it was because this is so he can learn how to do it, I know how to do all that.....but thanks...?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES: