Author Topic: Movement on the graph screen  (Read 6302 times)

0 Members and 1 Guest are viewing this topic.

Offline DincoC

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +1/-0
    • View Profile
Movement on the graph screen
« 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.
Code: [Select]
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.

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Movement on the graph screen
« Reply #1 on: November 03, 2012, 04:39:34 pm »
When using ClrDraw, the Y variable gets messed up. You should use another variable.
It works fine replacing X,Y with B,A

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Movement on the graph screen
« Reply #2 on: November 03, 2012, 04:49:10 pm »
Exactly what dinosteven said. Generally in TI-BASIC you should avoid using X and Y because they get updated by drawing commands.
« Last Edit: November 03, 2012, 04:49:25 pm by Deep Thought »




Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Movement on the graph screen
« Reply #3 on: November 03, 2012, 04:56:10 pm »
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.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Movement on the graph screen
« Reply #4 on: November 03, 2012, 05:01:59 pm »
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.

Offline DincoC

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +1/-0
    • View Profile
Re: Movement on the graph screen
« Reply #5 on: November 03, 2012, 07:21:23 pm »
I changed the symbols and now pressing up/down arrow doesn't seem to do anything.

Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Movement on the graph screen
« Reply #6 on: November 03, 2012, 07:22:28 pm »
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.
« Last Edit: November 03, 2012, 07:26:20 pm by dinosteven »

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Movement on the graph screen
« Reply #7 on: November 03, 2012, 07:38:56 pm »
Yeah, make sure you update all of them. I count six instances of X and six instances of Y you should replace.




Offline DincoC

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +1/-0
    • View Profile
Re: Movement on the graph screen
« Reply #8 on: November 04, 2012, 08:25:21 am »
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.

Offline Deep Toaster

  • So much to do, so much time, so little motivation
  • Administrator
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 8217
  • Rating: +758/-15
    • View Profile
    • ClrHome
Re: Movement on the graph screen
« Reply #9 on: November 04, 2012, 10:15:42 am »
Don't see why that would happen from the source... Are you sure you didn't mistype? Especially the Y+(K=34... line.
« Last Edit: November 04, 2012, 10:17:43 am by Deep Thought »




Offline dinosteven

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 194
  • Rating: +10/-1
    • View Profile
Re: Movement on the graph screen
« Reply #10 on: November 04, 2012, 10:28:23 am »
It works. Here's a screenie of me scrolling through the code and running it:

Offline DincoC

  • LV0 Newcomer (Next: 5)
  • Posts: 4
  • Rating: +1/-0
    • View Profile
Re: Movement on the graph screen
« Reply #11 on: November 04, 2012, 11:19:56 am »
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 :)