Just by the way: this time I also will join the contest...
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts MenuQuoteonly question is how fast console window can be refreshed, and some functions to print at selected X,Y position would be also usefully.
QuoteI like these contests because it gives access to some cool functions.
TYPE tRect
x
y
direction
speed
ENDTYPE
GLOBAL rect[] AS tRect, space
main()
FUNCTION main:
generateRects()
WHILE TRUE
drawLines()
drawBoxes()
IF INKEY$() = " "
INC space, 1
IF space > 1 THEN space = 0
ENDIF
SHOWSCREEN
WEND
ENDFUNCTION
FUNCTION generateRects:
LOCAL r AS tRect
LOCAL offset
FOR tmpY = 0 TO 15
offset = RND(25)
r.direction = MOD(tmpY, 2)
r.speed = 100 + RND(200)
FOR tmpX = 0 TO 10
r.x = 0 + (tmpX * 60) + offset
r.y = 5 + (tmpY * 30)
DIMPUSH rect[], r
NEXT
NEXT
ENDFUNCTION
FUNCTION addRect: x, y, direction
ENDFUNCTION
FUNCTION drawLines:
LOCAL tmpY
FOR tmpY = 0 TO 15
DRAWRECT 0, 0 + (tmpY * 30), 640, 5, RGB(128, 128, 128)
NEXT
ENDFUNCTION
FUNCTION drawBoxes:
FOREACH r IN rect[]
IF space = TRUE
IF r.direction = 0
INC r.x, r.speed / 500
ENDIF
IF r.direction = 1
DEC r.x, r.speed / 500
ENDIF
ENDIF
DRAWRECT r.x, r.y, 5, 25, RGB(128, 128, 128)
DRAWRECT r.x + 5, r.y, 25, 25, RGB(255, 255, 255)
DRAWRECT r.x + 30, r.y, 5, 25, RGB(128, 128, 128)
IF r.x < -30
r.x = 640
ENDIF
IF r.x > 640
r.x = -30
ENDIF
NEXT
ENDFUNCTION