ARCHIVE > Cobra

Just got one Error in Plamsa !!!

(1/2) > >>

Hotshot:

I have fixed the error but my plamsa isnt working  :-[

--- Code: ---PROGRAM
uses pure2d,keyset

var
cosinus       : Array[641] of integer
R             : Array[64]  of integer
G             : Array[64]  of integer
B             : Array[64]  of integer
MRGB          : Array[256] of integer
i             :integer
position      :integer
c             :integer
a                    :string
wave1,wave2,wave4,x,y:integer
plasma               :element

Procedure Grahamplasma()
var
wave1,wave2,wave3,wave4:integer
x,y,f,d          :integer
cosinus       : Array[641] of integer
mrgb   : Array[256] of integer

begin

wave1 = wave1 + 2
If wave1 >= 320 Then wave1 = 0
wave2 = wave2 + 2
If wave2 >= 320 Then wave2 = 0
wave3 = wave3 + 3
If wave3 >= 320 Then wave3 = 0

LockBuffer
For y = 0 To 319
d = cosinus[y + wave2] + cosinus[y + wave3]
For x = 0 To 319
f = cosinus[x + wave1] + cosinus[x + y] + d And \$FF
PixelFast(x, y, ToRGBA(f,f,f))

Next
Next
UnlockBuffer
DrawImage (plasma,0,0)

END

Begin
OPENSCREEN

plasma=CreateImage(320,320)

position = 0
For c = 0 To 640
cosinus[c] = Cos((115*3.14159265358 * c) / 320) * 32 + 32
Next

For i=0 To 63
r[i]=i*4
g[i]=0
b[i]=255-(i*4)
Next

For i=0 To 63
r[i+64]=255-(i*4)
g[i+64]=i*2
b [i+64]=0
Next

For i=0 To 63
r[i+128]=i*2
g[i+128]=128-(i*2)
b[i+128]=i*4
Next

For i=0 To 63
r[i+192]=128+(i*2)
g[i+192]=i
b[i+192]=255-(i*4)
Next

For i=0 To 255
mrgb[i]=((r[i]*\$10000)+(g[i]*\$100)+b[i])And \$FFFFFF
Next

// mainloop
While a<>27
a=GetKey()
Grahamplasma()
Flip
Wend
End

--- End code ---

Jim:
What is 'f'?  Where do you define or set it to anything?
Also, is your screen really 320x320 or is it 320x240?  320x200?  I think the 'y' For loop is wrong.

Jim

Hotshot:
I have fixed the error and now it is working  :)
What people think of it?
I will post EXE Files on here soon

--- Code: ---PROGRAM
uses pure2d,keyset

var
cosinus       : Array[641] of integer
R             : Array[64]  of integer
G             : Array[64]  of integer
B             : Array[64]  of integer
MRGB          : Array[256] of integer
position      :integer
a             :string
wave1,wave2,wave3,wave4:integer
x,y,i,c,f,d            :integer
plasma                 :element

Procedure Grahamplasma()

begin

wave1 = wave1 + 2
If wave1 >= 320 Then wave1 = 0
wave2 = wave2 + 2
If wave2 >= 320 Then wave2 = 0
wave3 = wave3 + 3
If wave3 >= 320 Then wave3 = 0

LockBuffer
For y = 0 To 319
d = cosinus[y + wave2] + cosinus[y + wave3]
For x = 0 To 319
f = cosinus[x + wave1] + cosinus[x + y] + d And \$FF
PixelFast(x, y, ToRGBA(f,f,f))

Next
Next
UnlockBuffer
DrawImage (plasma,0,0)

END

Begin
OPENSCREEN

plasma=CreateImage(320,320)

position = 0
For c = 0 To 640
cosinus[c] = Cos((115*3.14159265358 * c) / 320) * 32 + 32
Next

For i=0 To 63
r[i]=i*4
g[i]=0
b[i]=255-(i*4)
Next

For i=0 To 63
r[i+64]=255-(i*4)
g[i+64]=i*2
b [i+64]=0
Next

For i=0 To 63
r[i+128]=i*2
g[i+128]=128-(i*2)
b[i+128]=i*4
Next

For i=0 To 63
r[i+192]=128+(i*2)
g[i+192]=i
b[i+192]=255-(i*4)
Next

For i=0 To 255
mrgb[i]=((r[i]*\$10000)+(g[i]*\$100)+b[i])And \$FFFFFF
Next

// mainloop
While a<>27
a=GetKey()
Grahamplasma()
Flip
Wend
End

--- End code ---

Screenshot

EXE FILES

hellfire:
I get diagonal lines with palette-overflow and it crashes on 'esc'.

Hotshot:
Sorry Hellfire. what do you think of it?

[#] Next page

Go to full version