Create Retro Style RasterBars ala C=64

Previous topic - Next topic

Amon

Here's a small code snippet for creating rasterbars. Just use the image I've included and run it to see the effect.

Code (glbasic) Select
// --------------------------------- //
// Project: RasterBars By Amon
// Start: Saturday, December 26, 2009
// IDE Version: 7.203


SETCURRENTDIR("Media") // seperate media and binaries?
LOADSPRITE "rasterbar.png",0

SETSCREEN 800,600,0

LIMITFPS 60



LET  yincrease = 50

TYPE RB
x
y
a
s
d
ENDTYPE

GLOBAL RBArr[] AS RB

FOR xiter = 0 TO 10
GLOBAL r AS RB
r.x = 0
r.y = 70
r.a = yincrease
r.s = 10
r.d = 5
yincrease = yincrease + 20
DIMPUSH RBArr[], r
NEXT

WHILE KEY(01) = 0
BLACKSCREEN

DrawRB()
UpdateRB()

SHOWSCREEN
WEND

FUNCTION UpdateRB:
FOREACH r IN RBArr[]
r.y = r.y + SIN(r.a)
r.a = r.a + 2
IF r.a >= 360 THEN r.a = r.a - 359
NEXT
ENDFUNCTION

FUNCTION DrawRB:
FOREACH r IN RBArr[]
DRAWSPRITE 0,r.x,r.y
NEXT
ENDFUNCTION


[attachment deleted by admin]
- http://www.amon.co | Dev Tools - BlitzMax - Shiva Unlimited - Unity Pro - Carrara 8 Pro - Hexagon 2.2.5 - Blacksmith 3D Paint - FuturePaint Pro - Bryce 7 Pro.
I'm never wrong at all; I just discover 1000 ways that don't work!