Author Topic: quick platform pxl-testing tut  (Read 10826 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
quick platform pxl-testing tut
« on: November 20, 2011, 04:08:22 pm »
This is mainly for hellninjas :)

Lets say you want to have a program that displays a sprite (stickman) and has various platforms for you to run and jump on! But how would you code this? PXL-TEST!

lets say you have a sprite like the one below, how would you code this so your sprite stays on a line?

heres how!

:line(0,63,95,63)
:if (pxl-test(X,Y+8) or pxl-test(X+5,Y+8)=0)
:Y-1->Y


just put this before your display graph, and where ever you display him on the screen, he will always fall until he hits a line!

If you have any questions on jumping or I missed typed something, feel free to tell me!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #1 on: November 20, 2011, 04:10:38 pm »
What about the top of the character?
And the left and right sides of the character?
I definently don't want him walking through lines xD!

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: quick platform pxl-testing tut
« Reply #2 on: November 20, 2011, 04:15:32 pm »
just add pxl-tests to the sides and top of him at each of your getkeys
like
:if getkey(?) and pxl-test(?,?)=0

so basically saying, if your press left, and there is not a line there then move left, and if there is a line there do nothing. that should work
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #3 on: November 20, 2011, 04:16:44 pm »
Source code upload example?

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: quick platform pxl-testing tut
« Reply #4 on: November 20, 2011, 04:17:36 pm »
one sec I have a game I made forever ago that uses this, but I let it go through lines, so let me fix it.
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #5 on: November 20, 2011, 04:18:19 pm »
one sec I have a game I made forever ago that uses this, but I let it go through lines, so let me fix it.
Forever ago!! thats a long time :P
Thanks!

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: quick platform pxl-testing tut
« Reply #6 on: November 20, 2011, 04:26:28 pm »
ok here you go, and I only pxl-tested the bottom left side of the sprite, but an example would be looking like this

:if getkey(2) and (pxl-test(X,Y+7)=0)
:X-1->X


and then for the right one you would do it for X+8,Y+7
and this is only at his feet, so if the line was higher you would still go through it, but then your just pxl-test his whole side for all the getkeys, which will take a while but it will work!

you know how to jump right?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #7 on: November 20, 2011, 04:30:30 pm »
So the X+8 and Y+8 would be going over 8 pixels and then down 8 Pixels?
How would it be completed for the sprite I gave you? Since its over to the right of the screen...
And do I have to pxl-Test( every sprite on his body?
I don't want to right multiple If Getkey(#) of the same number...

And thanks for getting this tutorial up!
« Last Edit: November 20, 2011, 04:31:22 pm by hellninjas »

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: quick platform pxl-testing tut
« Reply #8 on: November 20, 2011, 04:34:54 pm »
my tip, just look at the hex pic, and write down all the sprites that are turned on, the proceed to pxl test the ones that will hit something. and I would pxl test it all. but yes this will take a while, but its the only way I know to do it. and yes the more you add to X it goes right, and the the more you add to Y the more down. Keep in mind it always starts at the upper left hand corner of the sprite box. To make things easy, only pxl test his side, if you don't want him going through a wall, I think its ok to jump through lines

edit: plus if it is a wall, you only have to pxl test his farthest right or left sprite that is on!
« Last Edit: November 20, 2011, 04:35:27 pm by saintrunner »
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: quick platform pxl-testing tut
« Reply #9 on: November 20, 2011, 04:34:58 pm »
To check the top, pxl-test(X,Y) or pxl-test(X+WIDTH,Y).
To check the right side, pxl-test(X+WIDTH,Y) or pxl-test(X+WIDTH,Y+HEIGHT)
To check left side, pxl-test(X,Y) or pxl-test(X,Y+HEIGHT)
To check bottom, pxl-test(X,Y+HEIGHT) or pxl-test(X+WIDTH,Y+HEIGHT)
« Last Edit: November 20, 2011, 04:35:53 pm by epic7 »

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #10 on: November 20, 2011, 04:37:01 pm »
Thanks both of yah!
Alot of help!!!

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: quick platform pxl-testing tut
« Reply #11 on: November 20, 2011, 04:37:25 pm »
If you send me your source, I can do it for you and you can then look at it?
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #12 on: November 20, 2011, 04:45:32 pm »
Deleted my source out of frustration but instead will give you peanuts...
!peanuts

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: quick platform pxl-testing tut
« Reply #13 on: November 20, 2011, 04:48:38 pm »
Ew I don't like peanuts! lol, and If you compiled it you still have it in your axe backup, and for future reference, if you are about to give up on a project , just send it my way! I love working on new stuff!
My Sprites Thread   :Updated often :) for your viewing pleasure

GAMES:

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: quick platform pxl-testing tut
« Reply #14 on: November 20, 2011, 04:49:48 pm »
Could you make a source now? So I can see an coded example?