Author Topic: problem with PxlTest  (Read 9135 times)

0 Members and 1 Guest are viewing this topic.

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
problem with PxlTest
« on: September 23, 2011, 06:27:50 am »
EDIT: Somehow the entire problem vanishes once I replace PlotOn with PxlChg. I don't know how, but it works.

I have a problem with the PxlTest command in an IF statement. I basically want a dot to move around the screen without running into any pixels that are on. But for some reason the dot will move regardless of whether or not there is a dot in the way. I used a different program to check it by breaking the program when the dot is next to a pixel in the on state, and it says it is on, no matter how i formulate it (PxlTest(B,A), PxlTest(B,A)=0, PxlTest(B,A)=/=1, etc) it will definitely say the pixel is on. But the IF-statement will simply ignore whatever state the pixel is in. I'll post the code for the IF-statement when the down button is pressed.

Code: [Select]
If Getkey=28 And PxlTest(64-B+1)=0
(the 64 is because I use PlotOn to place the pixel, making the Y-coordinate (the B variable in this case) inverted. Because the graph screen is 64 high this makes sure the coordinates are correct)
Then A->D:B->E:B+1->B
(D and E just remove the old dot image when it has moved)
IfEnd

If you think it's the inversion making it go wrong it isn't; as I said before I tested it by continuously using PxlChg on the pixel that should be tested to make sure the right pixel is tested. Can anybody help me?
« Last Edit: September 23, 2011, 06:45:47 am by sjasogun1 »
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: problem with PxlTest
« Reply #1 on: September 23, 2011, 06:56:30 am »
You need an X coordinate in PxlTest, it takes two arguments
Also, it PlotOn a command that doesn't really turn on the pixels (does pxl-Test recognize them?)
« Last Edit: September 23, 2011, 07:00:09 am by chattahippie »

Offline Horrowind

  • LV2 Member (Next: 40)
  • **
  • Posts: 25
  • Rating: +6/-0
    • View Profile
Re: problem with PxlTest
« Reply #2 on: September 23, 2011, 07:15:40 am »
Im not sure, if I understand you correctly (okay, well I'm pretty sure I don't), but I think the problem rises from the difference between the pxl-commands and the plot-commands. The plot-command use the settings of the ViewWindow, so normaly something like x-axis from -6.3 to 6.3 an y-axis from -3.1 to 3.1, while pxl uses another coordinate system, top-left corner is (1,1) with y-axis turned down and x-axis turning right. The bottom right corner is on the legacy calcs (63,127) (note that first y and then x) and the prizm something different.

So a good approach to this problem is using a viewWindow, which makes converting to the pxl-coordinates relatively easy (ViewWindow 1,127,1,1,63,1), so PlotOn x,y is equivalent to Pxl-On 64-y,x or something similar. Also note that the plot commands override the X and Y variables.
(This is, because the "Plot "-Command without parameters can be used as an screeninput, it gives a cursor and retrieves the coordinates of the given point in X and Y. But PlotOn 13, 37 overrides these too).

I hope clearing the difference between these two help you sort out your problem.