Author Topic: GLBasic Contest 02: 2D Art  (Read 54 times)

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1657
    • View Profile
    • http://lostrevenant.blogspot.com
GLBasic Contest 02: 2D Art
« on: 2019-Apr-08 »
Hi,

here we go, it's time for an other contest:


Definition

Write a 2D art program in GLBasic. It should be a little piece of art, not an art creation program.

Rules

  • Write the whole program only in GLBasic
  • no third party libraries
  • Keep the code short and simple
  • Make the result look impressive

Goal

Show us your best little art project, with or without movement and impress us.

Submission

Just post your code here in a codeblock, so everybody can study your awesome work.

Closing Date

19.05.2019

Example

Here is my little example. It's an optical illusion.

If you press the space bar, you can start and stop the movement.

Code: GLBasic [Select]

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
 

Winner

This is a fun contest and there is nothing to win... Nevertheless, together we can choose a winner...



Good luck and have fun.
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est

Offline WPShadow

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1657
    • View Profile
    • http://lostrevenant.blogspot.com
Re: GLBasic Contest 02: 2D Art
« Reply #1 on: 2019-Apr-09 »
I know, this contest looks pointless at first, but it's pretty handy for backgrounds or scenes in games
AMD X2 4600, 2 GB Ram, ATI X1950 XTX, XP PRO SP2: GLB Premium 10.beta_dingsi, <(´.´<) Kirby Dance (>`.`)>
http://lostrevenant.blogspot.com
alea iacta est