Author Topic: Never got around to asking :P  (Read 2732 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Never got around to asking :P
« on: May 31, 2012, 11:15:00 am »
How would I use the pxl-test( command to prevent my character from falling through pixels, with acceleration of course, x256.
Or is there another, possibly easy, way to do this?

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Never got around to asking :P
« Reply #1 on: May 31, 2012, 11:37:39 am »
uhh, divide by 256 to snap to a pixel.
From there, before you draw anything but the ground or solid platforms, use pxl-test(x,y+#)  the plus number will be different depending on the height of your sprite.  0 means no pixel there, 1 means pixel there
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: Never got around to asking :P
« Reply #2 on: May 31, 2012, 11:44:34 am »
So..

Code: [Select]
:If getKey(1) and (pxl-test(X/256,Y/256+4)=0)
???

Offline Happybobjr

  • James Oldiges
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2325
  • Rating: +128/-20
  • Howdy :)
    • View Profile
Re: Never got around to asking :P
« Reply #3 on: May 31, 2012, 11:53:14 am »
probably not.  You said there is acceleration, which adds another dimension into it.


try...
:If getKey(1)
:*calculations in movement and stored to another variable, such as Z, as would be resulting location*
:If pxl-test(X/256,Z/256+4)=0
:Z->Y
:else
:Z + 256 -> Y
:end
:end

Try that.


you my need to change it to be relevant to your code.


Edit: added an example program.
« Last Edit: May 31, 2012, 12:50:24 pm by Happybobjr »
School: East Central High School
 
Axe: 1.0.0
TI-84 +SE  ||| OS: 2.53 MP (patched) ||| Version: "M"
TI-Nspire    |||  Lent out, and never returned
____________________________________________________________