Omnimaga
Calculator Community => TI Calculators => TI-BASIC => Topic started by: DincoC on November 03, 2012, 04:12:47 pm
-
Hello,
I have read this nice tutorial about movement and I tried to do the same thing, but on the graph screen. I tried to add movement in the second dimension. For some reason it doesn't work - once any of the arrow keys is pressed, the pixel goes to the top of the screen and can only be moved horizontally.
AxesOff:
FnOff:
ClrDraw:
ClrHome:
32->Y:
48->X:
Repeat K=45:
Pxl-On(Y,X:
Repeat Ans:
Getkey->K:
End:
ClrDraw:
X+(K=26 and X<94)-(K=24 and X>0)->X:
Y+(K=34 and Y<62)-(K=25 and Y>0)->Y:
End:
Also I know that this is a very simple subject, but I'm just a beginner and I can't figure this by myself.
-
When using ClrDraw, the Y variable gets messed up. You should use another variable.
It works fine replacing X,Y with B,A
-
Exactly what dinosteven said. Generally in TI-BASIC you should avoid using X and Y because they get updated by drawing commands.
-
If you only need to move one pixel around, you should use pxl-off instaed of cleardraw. It's a lot faster, especially when you have got a level as well since then you don't need to redraw the level every frame.
-
By the way, what's better for stopping the pixel from going out of bounds?
DincoC's method or using a max and min command? I've always used max and min, cause that's what's on the TIBD.
-
I changed the symbols and now pressing up/down arrow doesn't seem to do anything.
-
What symbols?
EDIT:
Oh the symbols for the variables. Hmmm.... It works on my calc. Make sure every variable is updated, you probably updated the pxl-on() but not the part where it moves up/down.
-
Yeah, make sure you update all of them. I count six instances of X and six instances of Y you should replace.
-
Yeah, I updated all of them. Besides the lack of vertical movement, there is also another bug. When I move the pixel to the left, it goes ok for 13 steps. On the 14th step it jumps one step left and one step down, then it goes to the left for another 8 steps and on the 9th jumps one left and one up. When going back right it does a similar thing, except it jumps up.
-
Don't see why that would happen from the source... Are you sure you didn't mistype? Especially the Y+(K=34... line.
-
It works. Here's a screenie of me scrolling through the code and running it:
(http://img27.imageshack.us/img27/3213/screenshot000.gif)
-
Ok it works now. I had replaced "K" with "Ans" and this was a mistake. I understand why it wouldn't work with Ans now :)