Posted: Thu Aug 08, 2002 5:22 pm
Restored from previous forum. Originally posted by Chevron.
When trying to compile the code below I get the error 'unable to compile'.
[edit] The code has been corrected, thanks to you guys, and now shows what I was trying to acheive
;------------------------------------------------------------------------------
;Set screen size
#gwidth=400
#gheight=200
OpenWindow(0, 100, 100, 400, 200, #PB_Window_SystemMenu, "2D Drawing Test")
StartDrawing(WindowOutput())
Dim snd(#gwidth)
Dim col(256)
Dim colmap(#gwidth,#gheight)
; Make a "palette"
For i = 0 To 63
col(i)=i*4*256*256 ; Reds
col(i+64)=i*4*256 ; Greens
col(i+128)=i*4 ; Blues
col(i+192)=i*4*256*256+i*4*256+i*4 ; Greys
Next
While quit=0
; Fake a 'sound wave'
snd(0) = Random(2*(#gheight/3))
snd(0)=snd(0)-#gheight/3
For i = 1 To #gwidth-1
snd(i) = snd(i-1) + Random(20)-10
If snd(i) #gheight
snd(i) = snd(i) - 2*#gheight
EndIf
Next
;'Flame' effect
For x = 0 To #gwidth-1
For y = 0 To #gheight-2
p1 = colmap(x+1,y)
p2 = colmap(x,y+1)
p3 = colmap(x+1,y+1)
p4 = colmap(x,y)
If p1 0
s = s - 1
EndIf
colmap(x,y)=s
Plot( x,y,col(s))
Next
colmap(x,(#gheight/2)+(snd(x)/3))=255
Plot( x,(#gheight/2)+snd(x)/3,$ffffff) ; White
Next
wend
;-------------------------------------------------------------------------------
Many thanks.
Edited by - Chevron on 08 August 2002 18:23:25
Edited by - Chevron on 08 August 2002 18:58:31
Edited by - Chevron on 08 August 2002 18:58:51
When trying to compile the code below I get the error 'unable to compile'.
[edit] The code has been corrected, thanks to you guys, and now shows what I was trying to acheive
;------------------------------------------------------------------------------
;Set screen size
#gwidth=400
#gheight=200
OpenWindow(0, 100, 100, 400, 200, #PB_Window_SystemMenu, "2D Drawing Test")
StartDrawing(WindowOutput())
Dim snd(#gwidth)
Dim col(256)
Dim colmap(#gwidth,#gheight)
; Make a "palette"
For i = 0 To 63
col(i)=i*4*256*256 ; Reds
col(i+64)=i*4*256 ; Greens
col(i+128)=i*4 ; Blues
col(i+192)=i*4*256*256+i*4*256+i*4 ; Greys
Next
While quit=0
; Fake a 'sound wave'
snd(0) = Random(2*(#gheight/3))
snd(0)=snd(0)-#gheight/3
For i = 1 To #gwidth-1
snd(i) = snd(i-1) + Random(20)-10
If snd(i) #gheight
snd(i) = snd(i) - 2*#gheight
EndIf
Next
;'Flame' effect
For x = 0 To #gwidth-1
For y = 0 To #gheight-2
p1 = colmap(x+1,y)
p2 = colmap(x,y+1)
p3 = colmap(x+1,y+1)
p4 = colmap(x,y)
If p1 0
s = s - 1
EndIf
colmap(x,y)=s
Plot( x,y,col(s))
Next
colmap(x,(#gheight/2)+(snd(x)/3))=255
Plot( x,(#gheight/2)+snd(x)/3,$ffffff) ; White
Next
wend
;-------------------------------------------------------------------------------
Many thanks.
Edited by - Chevron on 08 August 2002 18:23:25
Edited by - Chevron on 08 August 2002 18:58:31
Edited by - Chevron on 08 August 2002 18:58:51