2011-02-18, 08:47 PM
heres my code
When I draw random dots the rnd function works fine,
but when I draw factories at random positions it doesnt turn out right
I am trying to draw the red ones on the right side of the screen but they end up on the left
the blue ones are all over the screen
Code:
POKE Uinteger 23675, @MyUdgBlock
randomize
BORDER 7 : PAPER 7 : INK 0 : CLS
PRINT AT 3,13 ; PAPER 1 ; INK 7 ; "BattleField"
PRINT AT 5,9 ; PAPER 7 ; INK 0 ; "Q - Up"
PRINT AT 6,9 ; PAPER 7 ; INK 0 ; "A - Down"
PRINT AT 7,9 ; PAPER 7 ; INK 0 ; "O - Left"
PRINT AT 8,9 ; PAPER 7 ; INK 0 ; "P - Right"
PRINT AT 9,9 ; PAPER 7 ; INK 0 ; "M - Select"
PRINT AT 10,3 ; PAPER 7 ; INK 0 ; "You have to select units"
PRINT AT 11,3 ; PAPER 7 ; INK 0 ; "to fight the enemy units"
PRINT AT 15,3 ; PAPER 7 ; INK 0 ; "Press any key to start"
60 LET j$ = INKEY$
IF j$ = "" THEN GOTO 60: END IF
Function byterndrange (first As uByte, last As uByte) As uByte
return Rnd * (last - first) + first
End Function
paper 4
cls
BORDER 4: INK 0
for x=0 to 200
plot byterndrange(0,255),byterndrange(0,192)
next
Dim BlueFactoryX (6) as uByte
Dim BlueFactoryY (6) as uByte
For x =0 to 5
BlueFactoryX(x) = byterndrange(1,9)
BlueFactoryY(x) = byterndrange(1,24)
Next
dim RedFactoryX (6) as uByte
dim RedFactoryY (6) as uByte
For x =0 to 5
RedFactoryX(x) = byterndrange(28,32)
RedFactoryY(x) = byterndrange(1,24)
Next
drawFactories()
sub drawFactories()
for x =0 to 5
ink 1
print at BlueFactoryX(x), BlueFactoryY(x); CHR$(144)
ink 2
print at RedFactoryX(x), RedFactoryY(x); CHR$(144)
next
End sub
STOP : REM Avoid execution to enter this zone
MyUdgBlock: REM a simple Label; @Label returns it's memory address
ASM
incbin "factory.BIN"
END ASMWhen I draw random dots the rnd function works fine,
but when I draw factories at random positions it doesnt turn out right
I am trying to draw the red ones on the right side of the screen but they end up on the left
the blue ones are all over the screen



as it's slightly faster (specially during in-game prints)