Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
too fast :)
#1
i have a cursor that i move around the screen with the keys but its too fast

when i press "p" it shoots half way across the screen, how do i make it move 1 square every half a second
Reply
#2
Just enhance the "resolution" of calculation, lets say, by 8 (then divide the coordinate by 8 to get he correct position). Also using PAUSE 1 in loops to slow it down, is a passibility.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#3
thanks that slowed it down,

I want the cursor to move continuously if the key is held down for 1.5 seconds, how do I measure that time?
Reply
#4
slenkar Wrote:I want the cursor to move continuously if the key is held down for 1.5 seconds, how do I measure that time?
You can use the FRAMES systemvariable (3 bytes at 23672). For 1.5 seconds just wait until the first byte (or was it last?) is greater than 73, now you can do your action. Then poke it again with zero. If you not want to reset it for some other reaseons, can also use all three bytes together, and calculate a modulo of 75 from it, but I prefer to reset it, and use one single byte, or two bytes (Uinteger) for speed reasons (65536 Frames=1310 seconds=21 minutes).
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#5
could I have an example please?

so is there a system timer, that can be read from and written to?
Reply
#6
You should have a look at Chapter 18 of the Sinclair ZX Spectrum manual.
http://www.worldofspectrum.org/ZXBasicMa...hap18.html
Reply
#7
ah very good thanks
Reply
#8
This example has been already implmented in the Wiki (look in your /examples directory).
See here https://zxbasic.readthedocs.io/en/docs/e.../#clockbas
and here https://zxbasic.readthedocs.io/en/docs/e...#clock2bas
Reply
#9
thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)