Guest_imported
New member
- Jan 1, 1970
- 0
I was trying to create a simple randomized screensaver with the following
source code:
10 SCREEN 12
w = 0
LOCATE 20, 20
c = INT(RND * 16)
x = INT(RND * 640)
y = INT(RND * 480)
PSET (x, y)
DO
COLOR c
w = w + 1
IF w = 30000 THEN
GOTO 10
END IF
poep = INT(RND * 5)
IF poep = 1 THEN
x = x + 1
ELSEIF poep = 2 THEN
x = x - 1
ELSEIF poep = 4 THEN
y = y - 1
ELSEIF poep = 3 THEN
y = y + 1
END IF
PSET (x, y)
LOCATE 1, 2
LOOP UNTIL keyed$ <> ""
But the problem is that every time I start the program, it creates the same
patern every time. How can i change this? I also made a little prog to
test if the RND-was really the problem:
CLS
0
x1 = 0
x2 = 0
x3 = 0
x4 = 0
10
x = INT(RND * 5)
IF x = 1 THEN
x1 = x1 + 1
END IF
IF x = 2 THEN
x2 = x2 + 1
END IF
IF x = 3 THEN
x3 = x3 + 1
END IF
IF x = 4 THEN
x4 = x4 + 1
END IF
LOCATE 2, 1
PRINT x1
PRINT x2
PRINT x3
PRINT x4
IF x1 = 3000 THEN
SLEEP 5
END IF
GOTO 10
The loop stops when x1 has reached 3000, and every time it stops, the x2, x3
and x4 have the same value. Is it possible at all to make a real randomized
program?
source code:
10 SCREEN 12
w = 0
LOCATE 20, 20
c = INT(RND * 16)
x = INT(RND * 640)
y = INT(RND * 480)
PSET (x, y)
DO
COLOR c
w = w + 1
IF w = 30000 THEN
GOTO 10
END IF
poep = INT(RND * 5)
IF poep = 1 THEN
x = x + 1
ELSEIF poep = 2 THEN
x = x - 1
ELSEIF poep = 4 THEN
y = y - 1
ELSEIF poep = 3 THEN
y = y + 1
END IF
PSET (x, y)
LOCATE 1, 2
LOOP UNTIL keyed$ <> ""
But the problem is that every time I start the program, it creates the same
patern every time. How can i change this? I also made a little prog to
test if the RND-was really the problem:
CLS
0
x1 = 0
x2 = 0
x3 = 0
x4 = 0
10
x = INT(RND * 5)
IF x = 1 THEN
x1 = x1 + 1
END IF
IF x = 2 THEN
x2 = x2 + 1
END IF
IF x = 3 THEN
x3 = x3 + 1
END IF
IF x = 4 THEN
x4 = x4 + 1
END IF
LOCATE 2, 1
PRINT x1
PRINT x2
PRINT x3
PRINT x4
IF x1 = 3000 THEN
SLEEP 5
END IF
GOTO 10
The loop stops when x1 has reached 3000, and every time it stops, the x2, x3
and x4 have the same value. Is it possible at all to make a real randomized
program?