Forum
too fast :) - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16)
+---- Thread: too fast :) (/showthread.php?tid=312)



too fast :) - slenkar - 02-22-2011

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


Re: too fast :) - LCD - 02-22-2011

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.


Re: too fast :) - slenkar - 02-22-2011

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?


Re: too fast :) - LCD - 02-23-2011

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).


Re: too fast :) - slenkar - 10-30-2011

could I have an example please?

so is there a system timer, that can be read from and written to?


Re: too fast :) - britlion - 10-30-2011

You should have a look at Chapter 18 of the Sinclair ZX Spectrum manual.
http://www.worldofspectrum.org/ZXBasicManual/zxmanchap18.html


Re: too fast :) - slenkar - 10-30-2011

ah very good thanks


Re: too fast :) - boriel - 10-31-2011

This example has been already implmented in the Wiki (look in your /examples directory).
See here https://zxbasic.readthedocs.io/en/docs/examples/clock.bas/#clockbas
and here https://zxbasic.readthedocs.io/en/docs/examples/clock2.bas/#clock2bas


Re: too fast :) - slenkar - 10-31-2011

thanks