Dark Bit Factory & Gravity

GENERAL => Challenges & Competitions => Topic started by: TinDragon on June 11, 2006

Title: Short Intro Challenge - Parallax Starfield
Post by: TinDragon on June 11, 2006
Here's another one, a real basic starfield as I couldn't think of anything else :)
Code: [Select]
Graphics 640,480,0,2
SetBuffer BackBuffer()
Dim starx(600)
Dim stary(600)
For lop=0 To 600
starx(lop)=Rnd(640)
stary(lop)=Rnd(480)
Next
Repeat
Cls
For lop=0 To 600
speed=1+(lop Mod 3)
starx(lop)=starx(lop)+speed
If starx(lop)>640 Then starx(lop)=0
Color 85*speed,85*speed,85*speed
Plot starx(lop),stary(lop)
Next
Flip
Until KeyDown(1) Or MouseDown(1)
Title: Re: Short Intro Challenge - Parallax Starfield
Post by: Shockwave on June 11, 2006
A little unimaginative but Ok.
Btw, you've wasted several lines, I shrunk it for you;
Code: [Select]
Graphics 640,480,0,2
SetBuffer BackBuffer()
Dim starx(600),stary(600)
For lop=0 To 600
starx(lop)=Rnd(640)
stary(lop)=Rnd(480)
Next
Repeat
Cls
For lop=0 To 600
starx(lop)=starx(lop)+(1+(lop Mod 3))
If starx(lop)>640 Then starx(lop)=0
Color 85*(1+(lop Mod 3)),85*(1+(lop Mod 3)),85*(1+(lop Mod 3))
Plot starx(lop),stary(lop)
Next
Flip
Until KeyDown(1) Or MouseDown(1)
Title: Re: Short Intro Challenge - Parallax Starfield
Post by: Hotshot on May 23, 2011
Here the BlitzMax Version :)

Code: [Select]
Graphics 640,480,0

Local starx[601]
Local stary[601]

For lop=0 To 600
    starx[lop]=Rnd(640)
    stary[lop]=Rnd(480)
Next

Repeat
      Cls
      For lop=0 To 600
          starx[lop]=starx[lop]+(1+(lop Mod 3))
          If starx[lop]>640 Then starx[lop]=0
          SetColor 85*(1+(lop Mod 3)),85*(1+(lop Mod 3)),85*(1+(lop Mod 3))
          Plot starx[lop],stary[lop]
      Next
      Flip
Until KeyDown(KEY_ESCAPE) Or MouseDown(1)