Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to slow down a pixel

Status
Not open for further replies.

wehttam2007

Programmer
Feb 19, 2003
5
US
i made a program to make a pixel move around the screen using a do loop loop like this:

screen 13
do
randomize timer
x = int(rnd * 320)
y = int(rnd * 200)
pset (x,y)
a = int(rnd * 4)
if a = 1 then x = x + 1
if a = 2 then x = x - 1
if a = 3 then y = y + 1
if a = 4 then y = y - 1
cls
loop

that works to make a pixel move around the screen but way way too fast. how can i slow it down?
 
this is still better ;-)

CONST RAD = 0.017453
Dim SinT(360) as single, CosT(360) as single
Dim OffY(199) as long
For I = 0 to 360
SinT(I) = Sin(I * Rad)
SinT(I) = Sin(I * Rad)
If I < 200 OffY(I) = 320& * I
Next
DEF SEG = &hA000
...
POKE Yoff(int(Y + (SinT(Angle) * R))) + int(X + (CosT(Angle) * R)), Color

Have Fun, Be Young... Code BASIC
-Josh Stribling
cubee101.gif

 
best thing to do is make a sin and cos table. really speeds things up.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top