Page 1 of 1

Posted: Thu Aug 08, 2002 5:22 pm
by BackupUser
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

Posted: Thu Aug 08, 2002 5:40 pm
by BackupUser
Restored from previous forum. Originally posted by traumatic.

Code: Select all

If snd(i) < -#gheight
snd(i) = snd(i) = 2*#gheight
EndIf
guess because of the two 'equals'-operators,
maybe you meant the 'plus'-operator instead?

(does anyone know why i can't use the plus-sign in here??)

regards,
traumatic

Posted: Thu Aug 08, 2002 5:53 pm
by BackupUser
Restored from previous forum. Originally posted by Pupil.
(does anyone know why i can't use the plus-sign in here??)
You can, only problem is that you can't see '+' when previewing...

Posted: Thu Aug 08, 2002 5:56 pm
by BackupUser
Restored from previous forum. Originally posted by Chevron.

Doh!! Silly me, for the life of me I couldn't see that. Thanks, that does seem to be the problem. Ive updated the code to show what I was trying to acheive.
Many thanks.

Posted: Thu Aug 08, 2002 6:07 pm
by BackupUser
Restored from previous forum. Originally posted by traumatic.
You can, only problem is that you can't see '+' when previewing...
ah, ok. thought i was blind first...