Author Topic: Stages and Collision  (Read 17646 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #45 on: November 19, 2011, 03:45:36 pm »
So implementing this into my code... How would this look in code form? (Axe)

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #46 on: November 19, 2011, 03:46:14 pm »
What? The pxl-test?


Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #47 on: November 19, 2011, 03:50:03 pm »
Yes, collision with the stage

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #48 on: November 19, 2011, 03:55:32 pm »
If pxl-test(x,y+8) or (pxl-test(x+WIDTH OF SPRITE,y+8)
.put something so that the player won't go down
End

Or, just use the inverse of this to make him fall instead if you'd like

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: Stages and Collision
« Reply #49 on: November 19, 2011, 04:01:26 pm »
I make it like this

set motion variables.and set any variable as 0...lets make it J

then in your main loop before the display graph put this part in

This should work,
here it is at the loop

:repeat getkey(15)
:if getkey(2) and (X/=0)   //   /= means doesn't equal
:X-1->X
:end
:if getkey(3) and (X/=89)
:X+1->X
:end
:if getkey(4) and ((pxl-test(X,Y+8) and (pxl-test(X+8,Y+8))  //checks to see if you are on the ground
:15->J    //what ever number you use will change the jump height
:if (J>0)
:Y-1->Y
:J-1->J
:end
if ((pxl-test(X,Y+8) and (pxl-test(X+8,Y+8)=0) and (J=0)
:Y+1->Y
:end
:now do all of your ptchange's and display graphs!


get rid of the j stuff if you don't want jumping
« Last Edit: November 19, 2011, 04:02:02 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #50 on: November 20, 2011, 03:02:00 am »
Ok I input the code for a simple test and my character flies up passed the top of the screen and soon I can no longer see him...
Please help I can't fix this!
I uploaded the SRC below...
Im new to the Pxl-Test( command so if you can get a tutorial somewhere to help me out a bit I would be very greatful!!
Thanks...
EDIT: I think i might want to include the stage1 appvar as well huh xD
« Last Edit: November 20, 2011, 03:07:29 am by hellninjas »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #51 on: November 20, 2011, 03:51:06 am »
Here's the code, please help!
Code: [Select]
:.JUMPDUDE
:[1C141C080C081C22]→Pic0MR
:[1C141C0818081C22]→Pic0ML
:ClrHome
:ClrDraw
:44→X
:50→Y
:1→D
:DiagnosticOff
:Repeat getKey(15)
:DispGraph
:ClrDraw
:GetCalc("vSTAGE1",Y0
:conj(Y0,L6,768)
:If D=1
:Pt-On(X,Y,Pic0MR)
:Else
:Pt-On(X,Y,Pic0ML)
:End
:If getKey(2) and (X≠0)
:X-1→X
:2→D
:End
:If getKey(3) and (X≠89)
:X+1→X
:1→D
:End
:If getKey(4) and pxl-Test(X,Y+8) and (pxl-Test(X+8,Y+8)
:15→J
:End
:If J>0
:Y-1→Y
:J-1→J
:End
:If pxl-Test(X,Y+8) and (pxl-Test(X+8,Y+8)=0) and (J=0)
:Y+1→Y
:End
:End


Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #52 on: November 20, 2011, 04:35:05 am »
ok I gave J a value in the beggining, of 0
But now my character is not coming down from the air!
AAAGH!

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: Stages and Collision
« Reply #53 on: November 22, 2011, 03:37:35 pm »
Maybe try

:If (pxl-Test(X,Y+8)=0) and (pxl-Test(X+8,Y+8)=0) and (J=0)

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: Stages and Collision
« Reply #54 on: November 22, 2011, 03:45:07 pm »
I can fix this, give me a sec!

change the and to an or in the second pixl test

It should look like this!


:.JUMPDUDE
:[1C141C080C081C22]→Pic0MR
:[1C141C0818081C22]→Pic0ML
:ClrHome
:ClrDraw
:44→X
:50→Y
:1→D
:0->J
:DiagnosticOff
:Repeat getKey(15)
:DispGraph
:ClrDraw
:GetCalc("vSTAGE1",Y0
:conj(Y0,L6,768)
:If D=1
:Pt-On(X,Y,Pic0MR)
:Else
:Pt-On(X,Y,Pic0ML)
:End
:If getKey(2) and (X≠0)
:X-1→X
:2→D
:End
:If getKey(3) and (X≠89)
:X+1→X
:1→D
:End
:If getKey(4) and (pxl-Test(X,Y+8) or (pxl-Test(X+8,Y+8)
:15→J
:End
:If J>0
:Y-1→Y
:J-1→J
:End
:If pxl-Test(X,Y+8) or (pxl-Test(X+8,Y+8)=0) and (J=0)
:Y+1→Y
:End
:End



and you will keep falling though, cause you need to draw all of those lines in the level itself, or it will make you go right through them!
« Last Edit: November 22, 2011, 04:02:01 pm by saintrunner »
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

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: Stages and Collision
« Reply #55 on: November 22, 2011, 04:46:01 pm »
sorry to double post, but I'm assuming this will be a critical fix to your game, hellninjas!

I just remade, what I think your going for in your game, and you can feel free to use it!
Below is the source and screenie! But you are going to have to draw the rest of the lines for the level! just put them in under all the other lines in the source!

Good luck and I hope this helps!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #56 on: November 22, 2011, 05:38:23 pm »
Thanks! I made a few more tests to add to this, thanks for all the help everyone! :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: Stages and Collision
« Reply #57 on: November 22, 2011, 05:46:05 pm »
what tests do you need to add? and did my source help?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Stages and Collision
« Reply #58 on: November 22, 2011, 10:26:56 pm »
Yes it helped alot! And i didn't add anything to THIS source, I made other games and was practicing :D

Offline C0deH4cker

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 258
  • Rating: +11/-1
    • View Profile
    • iNinjas Forum/Repo
Re: Stages and Collision
« Reply #59 on: November 23, 2011, 12:22:09 am »
This is the best way:

Code: [Select]
0->C
For(A,0,7)
C + pxl-test(X+A,Y+8)->C
End
If C
.Player is standing
Else
.Player is in the air
End

This will work in cases like this:

     @
    _||_
     / \
      #
      #

Where the pixels under the feet arent on but one under the player is.