Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: saintrunner on November 20, 2011, 04:08:22 pm

Title: quick platform pxl-testing tut
Post by: saintrunner 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!
Title: Re: quick platform pxl-testing tut
Post by: hellninjas 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!
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 04:16:44 pm
Source code upload example?
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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.
Title: Re: quick platform pxl-testing tut
Post by: hellninjas 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!
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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?
Title: Re: quick platform pxl-testing tut
Post by: hellninjas 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!
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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!
Title: Re: quick platform pxl-testing tut
Post by: epic7 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)
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 04:37:01 pm
Thanks both of yah!
Alot of help!!!
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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?
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 04:45:32 pm
Deleted my source out of frustration but instead will give you peanuts...
!peanuts
Title: Re: quick platform pxl-testing tut
Post by: saintrunner 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!
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 04:49:48 pm
Could you make a source now? So I can see an coded example?
Title: Re: quick platform pxl-testing tut
Post by: saintrunner on November 20, 2011, 04:50:03 pm
sure! ill post the one I had above.

this is a game I made a while back, and it has a lot of extra stuff, but I put a .look at this, where you need to pay attention. and It is only pxltested at the left foot! any questions just pm me!
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 04:59:04 pm
Thanks!
Title: Re: quick platform pxl-testing tut
Post by: ztrumpet on November 20, 2011, 05:04:33 pm
Quick note about optimizing in Axe:
Instead of writing this line like this,
:if (pxl-test(X,Y+8) or pxl-test(X+5,Y+8)=0)
it is more optimized to write it like this:
Code: [Select]
:!If pxl-test(X,Y+8) or pxl-test(X+5,Y+8)Basically the !If just checks if it's equal to zero.

Nice job on the rudimentary tutorial. :)
Title: Re: quick platform pxl-testing tut
Post by: saintrunner on November 20, 2011, 05:29:59 pm
thanks, I forgot about that!
Title: Re: quick platform pxl-testing tut
Post by: epic7 on November 20, 2011, 05:32:25 pm
I didn't use that in mine because I didn't know how !If works in compound if statements
Title: Re: quick platform pxl-testing tut
Post by: saintrunner on November 20, 2011, 05:51:29 pm
I don't think you can use it in compounds :P
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 06:42:52 pm
Thats a good idea...
!If and If tut!
Title: Re: quick platform pxl-testing tut
Post by: epic7 on November 20, 2011, 07:06:46 pm
That would be more of an explaination rather than a tutorial :P
Title: Re: quick platform pxl-testing tut
Post by: Yeong on November 20, 2011, 07:09:33 pm
Quick note about optimizing in Axe:
Instead of writing this line like this,
:if (pxl-test(X,Y+8) or pxl-test(X+5,Y+8)=0)
it is more optimized to write it like this:
Code: [Select]
:!If pxl-test(X,Y+8) or pxl-test(X+5,Y+8)Basically the !If just checks if it's equal to zero.

Nice job on the rudimentary tutorial. :)
Isn't it
Code: [Select]
!If pxl-test(X,Y+8) and (pxl-test(X+5,Y+8) ? or
Code: [Select]
!If pxl-test(X,Y+8)?pxl-test(X+5,Y+8)EDIT:Nvm. I didn't see the code carefully.
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 07:13:25 pm
Quick note about optimizing in Axe:
Instead of writing this line like this,
:if (pxl-test(X,Y+8) or pxl-test(X+5,Y+8)=0)
it is more optimized to write it like this:
Code: [Select]
:!If pxl-test(X,Y+8) or pxl-test(X+5,Y+8)Basically the !If just checks if it's equal to zero.

Nice job on the rudimentary tutorial. :)
Isn't it
Code: [Select]
!If pxl-test(X,Y+8) and (pxl-test(X+5,Y+8) ? or
Code: [Select]
!If pxl-test(X,Y+8)?pxl-test(X+5,Y+8)
Im sort of hoping its "or" becuase I just got done taking ALOT of notes...
Title: Re: quick platform pxl-testing tut
Post by: Yeong on November 20, 2011, 07:15:20 pm
actually, I take my word back.
I didn't see the code carefully. :P
Title: Re: quick platform pxl-testing tut
Post by: hellninjas on November 20, 2011, 07:22:02 pm
OK, FEW!!!
xD