Copper Star

Do you have something to share with us? A tip for newbies, perhaps? Post it here.
Post Reply
peter
Active Member
Posts: 123
Joined: Mon Oct 22, 2007 2:31 pm

Copper Star

Post by peter » Sat Aug 02, 2014 8:40 pm

Hi,
have a nice day.

Code: Select all

SCREEN 640,480

d=40
c=10000
ys#=0.15
a#=0.0

While KeyDown(27)=0
Color 0,0,0
Cls

For x=-90 To 90
For y=-90 To 90
    Color 255,200,200
    Dot 300+Sin(a)*(x+y), 250+ys*(y-x)*c/(x*x+y*y+d)
Next y
Next x

a =a+10.0
If a >=360 Then a= -a

Text 265,16,"COPPER STAR"
DrawScreen
wend

User avatar
CCE
Artist
Artist
Posts: 650
Joined: Mon Aug 27, 2007 9:53 pm

Re: Copper Star

Post by CCE » Wed Aug 06, 2014 7:26 pm

Hello, that's a pretty cool retro effect. It's possible to make it faster by using locked framebuffer operations instead of simple Dot. I replaced the Dot command with a PutPixel2 and it's already much faster. Please see the source code below.

Code: Select all

SCREEN 640,480

d=40
c=10000
ys#=0.15
a#=0.0

While KeyDown(27)=0
Color 0,0,0
' An ARGB pixel where A = 255, R = 255, G = 200, B = 200
pixel = 255 shl 24 + 255 shl 16 + 200 shl 8 + 200

lock SCREEN()
For x=-90 To 90
For y=-90 to 90
	putPixel2 300+sin(a)*(x+y), 250+ys*(y-x)*c/(x*x+y*y+d), pixel
Next y
Next x
unlock SCREEN()

a =a+10.0
If a >=360 Then a= -a

Text 265,16,"COPPER STAR"
DrawScreen
wend

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest