GLBasic forum

Main forum => Competitions => Topic started by: WPShadow on 2019-Apr-08

Title: GLBasic Contest 02: 2D Art
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 speedENDTYPEGLOBAL rect[] AS tRect, spacemain()FUNCTION main: generateRects() WHILE TRUE drawLines() drawBoxes() IF INKEY\$() = " " INC space, 1 IF space > 1 THEN space = 0 ENDIF SHOWSCREEN WENDENDFUNCTIONFUNCTION generateRects:LOCAL r AS tRectLOCAL 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 NEXTENDFUNCTIONFUNCTION addRect: x, y, directionENDFUNCTIONFUNCTION drawLines:LOCAL tmpY FOR tmpY = 0 TO 15 DRAWRECT 0, 0 + (tmpY * 30), 640, 5, RGB(128, 128, 128) NEXTENDFUNCTIONFUNCTION 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 NEXTENDFUNCTION`
Winner

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

Good luck and have fun.

=====

Winner of the contest:

:enc:Qedo (50%) & Snoopy (50%) :enc:

Title: Re: GLBasic Contest 02: 2D Art
I know, this contest looks pointless at first, but it's pretty handy for backgrounds or scenes in games
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-Apr-20
This is an experimental piece i tinkered with a few years ago, hardly worth being called art.
It uses a rocking motion of sins and cos. eg. -1 to 1 to -1 to 1 etc

1. compile fullscreen 1920x1080
2. dont forget to grab this background image, or the special effect at the end will not look right.

Code: (glbasic) [Select]
`// --------------------------------- //// Project: ColorPalette// Start: Saturday, August 08, 2015// IDE Version: 12.312// compile 1920 x 1080 resolution fullscreenLOADSPRITE "sky2.png", 9999WHILE TRUE STATIC a# = 0 a# = a# + 0.1 IF a# > 359.0 a# = 0.0 ENDIF b# = SIN(a#) * 127.0 // the meters - still experimenting with colors..these are read to go...they have inputs [0.0..1.0] or [-1.0..1.0] METER_Volume(30,40,20,300,SIN(a/2)) METER_SINE(60,40,20,300,SIN(a) )//, 0x604020, 0x707070) METER_SINE(90,40,20,300,COS(b) )//, 0x604020, 0x707070)// stars DrawStar(200,500, 0xffffff, 5 , -50 , a , 0.5) DrawStar(300,600, 0xff00ff, 5 , -100 , a , 0.75) DrawStar(200,640, 0x808080 + RGB(COS(a)*127,128,0), 24 , -128 , 0 , SIN(a) * 1.0) DrawStar(200,640, 0x808080 + RGB(0,COS(a)*127,128), 24 , -128 , a , 0.2) // fractal sun // this one needs HEAVY experimenting! MakeSun(960,540, 2048, 2048+COS(b)*2048, 1, RGB( (127+COS(b*10)*127), (127+SIN(b*10)*127),COS(b*5)*127+127), 0x000000, b#, 0.1)  //this is the fractal...its a lil messy IF (GETTIMERALL() >20000) c=c+0.01 IF c>1.0 THEN c=1.0 DrawStar( 940, 540, 0xffffff, 5, 9999, a, c) ENDIF IF (GETTIMERALL() >24000) THEN END SHOWSCREENWEND//FUNCTION MakeSun: x1%, y1%, Points2%, Size2%, Wander%, Color#, Color2#, Angle#, Depth# DrawStar(x1% , y1%+2 , Color#, Points2%, -Size2%  ,  COS(Angle#)*2.0, Depth#) DrawStar(x1% , y1% , Color2#, Points2% , -Size2% ,  0 , Depth#) RETURN 0ENDFUNCTIONFUNCTION METER_SINE: x%, y%, w%, h%, Level#, Color1% = 0x00f0f0, Color2% = 0xf0f000 // Level# = -1.0 to 1.0 eg. [-1.0..1.0] IF Level# < -1.0 THEN Level# = -1.0 IF Level# > 1.0 THEN Level# = 1.0 PRINT Level,10,10 LOCAL MeterLevel# = (h% - 1 ) * Level# POLYVECTOR x%,y%,w%,h%,0x0000f0 DRAWRECT x%+2,y%+2,w%-4,h%-4,Color2% DRAWRECT x%+4,y%+4,w%-8,h%-8,Color2% * 0.4 DRAWRECT x%+4,y%+(h%/2),w%-8,-MeterLevel#/2,Color1% RETURN 0ENDFUNCTIONFUNCTION METER_Volume: x%, y%, w%, h%, Level#, Color1% = 0x806040, Color2% = 0xf0f000 //Level# = 0 to 1.0 [0..1] IF Level# < 0 THEN Level# = 0 IF Level# > 1.0 THEN Level# = 1.0 PRINT Level,10,10 LOCAL MeterLevel# = ( h% - 4 ) * Level# DRAWRECT x%,y%,w%,h,Color1% DRAWRECT x%+4,y%+4,w%-8,h%-9,Color1% * 0 DRAWRECT x%+4,y%+h%-4,w%-8,-MeterLevel#, Color2% RETURN 0ENDFUNCTIONFUNCTION DrawStar: x%, y%, Color#, NumberOfPoints%, TextureID%, Rotate#, Depth# // make some stars! -TextureID# = SIZE If No Sprites ID is supplied. (-) Negative ID // Star Creator Code Designed Neil M. Silver,  Aug. 9, 2015 // // The Algorithm: // -- //   NumberOfPoints = Number of visually obvious points, eg. An American Star is 5 pointed. // -- //   Vector Count = The number of actual vectors a polyvector needs, in fan mode, can be calculated: // //     ( V = P * 2 + 2 ) //     VectorCount% = ( NumberOfPoints% * 2 ) + 2 ) //     Note: Add Two, one for the center point, one for the last point. // -- //   VectorAngleSize% = is the turn size for each vector to draw. //     ( A = 180 / P ) //     VectorAngleSize# = ( 180.0 / NumberOfPoints% ) // -- //   Depth% //     The inner and outer radius represent the length of the points, and the depth of thier inner corners. //     The Depth% value is a scalar, a ratio of the outer radius, 0.5 is good for stars...play with this [0.1~~1.0] // //                           . ________________ //                                            ^ //                    .   .    .     .        |   Outer Radius //                                            V //                       .     ________________ //                                            V  Inner Radius (Depth#) //                           .   ______________ //                      .          . // // // --    //   Rotate%, 360 degrees    // -- //  A negative value for TextureID% will make the star that size, without an image. //  eg ( TextureID%  = -5 ) will make the star 10 wide, radius 5...no skin. // --    // // Other notes: // Its midhandled. // Use a square image, root 2 // STATIC Phase% LOCAL iW%, iH%, ViR#, VoR# LOCAL VectorCount% = ( ( NumberOfPoints% * 2 ) + 2 ) LOCAL VectorAngleSize# = ( 180.0 / NumberOfPoints% ) * 1.0 LOCAL tX#, tY#, vX#, vY# // Get the outer radius: IF TextureID% >= 0 GETSPRITESIZE TextureID%, iW%, iH% ViR# = ( iW% * 0.5 ) * Depth# VoR# = ( iW% * 0.5 ) * 1.0 ELSE VoR# = ABS(TextureID%) //use -textureid for a size param ViR# = ( VoR# * Depth# ) ENDIF //STAR: STARTPOLY TextureID%, 0 // FAN Mode only! POLYVECTOR x%, y%, VoR#, VoR#, Color# // center vector LOCAL AngleNow# FOR i% = 0 TO VectorCount% - 1 AngleNow# = ( ( VectorAngleSize# * i% * 1.0 ) + Rotate# ) * 1.0 Phase% = Phase% + 1 IF Phase% > 1 Phase% = 0 ENDIF IF Phase% vX# = COS( AngleNow# ) * VoR# vY# = SIN( AngleNow# ) * VoR# ELSE vX# = COS( AngleNow# ) * ViR# vY# = SIN( AngleNow# ) * ViR# ENDIF tX# = vX# + VoR# tY# = vY# + VoR# POLYVECTOR x% + vX#, y% + vY#, tX#, tY#, Color# NEXT ENDPOLY RETURN 0ENDFUNCTION`
Title: Re: GLBasic Contest 02: 2D Art
This is awesome
Title: Re: GLBasic Contest 02: 2D Art
Post by: bigsofty on 2019-Apr-23
This is an experimental piece i tinkered with a few years ago, hardly worth being called art.

I disagree, very much art!  ;)
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-Apr-23
Hemlos is a very very good programmer.

A professional level.
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-Apr-23
I'm not a pro, but i have read a few books.
And to give credit where it's due, Gernot was a huge influence on my thirst for math.
I'm looking forward to more entries!

About the program, it was simply really.
It was a benchtest program to show what the function DrawStar() could do.
DrawStar was a brainstorm, as you can see in the remarks of the function showing a progression of the idea.
All the effects, are a result of using several combinations and configurations of this function:
Code: (glbasic) [Select]
`DrawStar(x%, y%, Color#, NumberOfPoints%, TextureID%, Rotate#, Depth#)`
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-Apr-24
You can have a professional level without being a professional.
In fact, I was talking about your work in general, not just this program. For example, your particle engine was really good.
But if you prefer me to say that you are an average programmer, ok no problem  =D  ;)

I will try to do something (I like the concurence friendly). The code of WPShadow is simpler but the optical effect is nice (and according to the rules of the contest, the complexity doesn't matter this time).

Ps : Since I really rediscover the interactions between GLB and C, Gernot is not only for me a very good programmer, but my living god :nw:  :)
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-Apr-25
I will try to do something (I like the concurence friendly). The code of WPShadow is simpler but the optical effect is nice (and according to the rules of the contest, the complexity doesn't matter this time).

Sounds good, looking forward to more entries.
I like these contests because it gives access to some cool functions.
The more the merrier!
Title: Re: GLBasic Contest 02: 2D Art
Quote
I like these contests because it gives access to some cool functions.

That's my idea. Short little codes and everybody can learn something from the different programming styles
Title: Re: GLBasic Contest 02: 2D Art
Post by: dreamerman on 2019-Apr-26
I had no idea for something small & simple and didn't want to copy another plasma/fire example so I made this, nothing special, just to have more entries in competition.  Code isn't piece of art, so.. ;)

Main source:
Code: (glbasic) [Select]
`// --------------------------------- //// Project: 2dpixart// by dreamerman_pl// only GLBasic code// coded to run in 640x480//TYPE point2d    x%    y%ENDTYPETYPE point_struct    pos AS point2d    vec AS point2d    target AS point2d    dir_num%    color%ENDTYPE            GLOBAL my_point[] AS point_structGLOBAL my_point_count% = 1000       // how many moving rectanglesGLOBAL endit% = 0GLOBAL i1%, anim_pos%, txt_pos AS point2dDIM my_point[my_point_count%]SMOOTHSHADING FALSE         // prefer stronk pixelsLIMITFPS 60CREATESCREEN 0, 1, 640, 480prepare_text()// set some pointsFOR i1% = 0 TO my_point_count%  -1    my_point[i1%].pos = ret_p2d(RND(639), RND(479))    find_newtarget(i1%)    my_point[i1%].color% = RGB(RND(4)*64-1, RND(4)*64-1, RND(4)*64-1)   // yeap some may be totally black :DNEXTREPEAT    CLEARSCREEN    USESCREEN 0    ALPHAMODE -0.025    DRAWRECT 0, 0, 640, 480, RGB(0,0,0)    ALPHAMODE -0.25        // move rectangles    FOR i1% = 0 TO my_point_count% - 1        IF (my_point[i1%].pos.x% = my_point[i1%].target.x%)            IF (my_point[i1%].pos.y% = my_point[i1%].target.y%)                find_newtarget(i1%)            ELSE                INC my_point[i1%].pos.y%, my_point[i1%].vec.y%            ENDIF        ELSE            INC my_point[i1%].pos.x%, my_point[i1%].vec.x%        ENDIF        DRAWRECT my_point[i1%].pos.x%-3, my_point[i1%].pos.y%-3, 7, 7, my_point[i1%].color%    NEXT        USESCREEN 1    ALPHATESTING 1.0    ALPHAMODE -1.0    // text background animation, what a crap code :D    INC anim_pos%, 2    IF anim_pos% > 500 THEN anim_pos% = anim_pos% - 180    FOR i1% = 0 TO 800 STEP 5        DRAWRECT i1%, 0, 5, 200, RGB(128*ABS(SIN(i1%+anim_pos%)), 0, 255*ABS(SIN(i1%)))    NEXT        ALPHAMODE 0.0    glEnable(GL_BLEND)                      // change opengl blend func    glBlendFunc(GL_ONE, GL_SRC_ALPHA)       // so we can draw magenta-pink and transparent pixel at same time    DRAWSPRITE 3, 0, 0        ALPHATESTING 1.0    USESCREEN -1    ALPHAMODE 0.0    DRAWSPRITE 1, 0, 0                  // draw offscreen buffer with moving rectangles    glBlendFunc(GL_SRC_ALPHA, GL_ONE)    glDisable(GL_BLEND)                 // back to normal?    //CLEARSCREEN RGB(0, 255, 0)        // for tests    ALPHATESTING 1.0                    // draw magenta-pink as transparent    ALPHAMODE -1.0    DRAWSPRITE 2, txt_pos.x%, txt_pos.y%    // draw text inside    DRAWSPRITE 4, txt_pos.x%, txt_pos.y%    // text border    SHOWSCREENUNTIL endit% = 1END// return point2d typeFUNCTION ret_p2d AS point2d: x%, y%    LOCAL temp AS point2d    temp.x% = x%    temp.y% = y%    RETURN tempENDFUNCTION// find new target-direction for rectangleFUNCTION find_newtarget%: id%    my_point[id%].target = ret_p2d(RND(639), RND(479))    IF (my_point[id%].target.x% < my_point[id%].pos.x%); my_point[id%].vec.x% = -1    ELSEIF (my_point[id%].target.x% > my_point[id%].pos.x%); my_point[id%].vec.x% = 1    ELSE; my_point[id%].vec.x% = 0    ENDIF    IF (my_point[id%].target.y% < my_point[id%].pos.y%); my_point[id%].vec.y% = -1    ELSEIF (my_point[id%].target.y% > my_point[id%].pos.y%); my_point[id%].vec.y% = 1    ELSE; my_point[id%].vec.y% = 0    ENDIFENDFUNCTION// load image from Data section and draw with desired colorsFUNCTION prepare_txt_sprite%: screenid%, acode1%, color1%, acode2%, color2%    LOCAL i1%, i2%, i3%, i4%, i5%, czs1\$        RESTORE napis_glb    READ i1%, i2%    USESCREEN screenid%    ALPHATESTING 1.0            // force drawing all colors even transparent magenta-pink    ALPHAMODE 0.0    CLEARSCREEN 0x008000ff    // transparent color    FOR i4% = 0 TO i2% - 1        READ czs1\$        FOR i3% = 0 TO i1% - 1            i5% = ASC(czs1\$, i3%)            IF (i5% = acode1%)  // => if X                DRAWRECT i3% * 4, i4% * 4, 4, 4, color1%     // black border            ELSEIF (i5% = acode2%)  // => if :                DRAWRECT i3% * 4, i4% * 4, 4, 4, color2%     // transparent inside            ENDIF        NEXT    NEXT    ALPHATESTING 1.0    ALPHAMODE 0.0ENDFUNCTION// forcing 4x scaleFUNCTION prepare_text%:    LOCAL i1%, i2%, i3%, i4%, czs1\$, czs2\$, pix%[]    RESTORE napis_glb    READ i1%, i2%   // get size    txt_pos = ret_p2d((640 - i1% * 4) / 2, (480 - i2% * 4) / 2)     // calc position    CREATESCREEN 1, 2, i1% * 4, i2% * 4     // text effect    CREATESCREEN 2, 3, i1% * 4, i2% * 4     // text pink outside    CREATESCREEN 3, 4, i1% * 4, i2% * 4     // text black border    // prepare text sprites    prepare_txt_sprite(2, 88, 0x00000000, 58, 0x00000000)    prepare_txt_sprite(3, 88, 0x00000000, 58, 0x008000ff)    // now we can free those surfaces    CREATESCREEN 2, -1, 0, 0    CREATESCREEN 3, -1, 0, 0    USESCREEN -1    // back to back bufferENDFUNCTIONSTARTDATA napis_glb:// Ascii text made with: www.patorjk.com/software/taag/// used font: DohDATA 126, 16DATA "       XXXXXXXXXXXXXXXXXXXXXXXX              XXXXXXXXXXXXXXXXX                                      XXXX                      "DATA "     XXX::::::::::::XX:::::::::X            X::::::::::::::::X                                     X::::X                     "DATA "   XX:::::::::::::::XX:::::::::X            X::::::XXXXXX:::::X                                     XXXX                      "DATA "  X:::::XXXXXXXX::::XXX:::::::XX            XX:::::X     X:::::X                                                              "DATA " X:::::X       XXXXXX  X:::::X                X::::X     X:::::X  XXXXXXXXXXXXX      XXXXXXXXXX   XXXXXXX     XXXXXXXXXXXXXXXX"DATA "X:::::X                X:::::X                X::::X     X:::::X  X::::::::::::X   XX::::::::::X  X:::::X   XX:::::::::::::::X"DATA "X:::::X                X:::::X                X::::XXXXXX:::::X   XXXXXXXXX:::::XXX:::::::::::::X  X::::X  X:::::::::::::::::X"DATA "X:::::X    XXXXXXXXXX  X:::::X                X:::::::::::::XX             X::::XX::::::XXXX:::::X X::::X X:::::::XXXXXX:::::X"DATA "X:::::X    X::::::::X  X:::::X                X::::XXXXXX:::::X     XXXXXXX:::::X X:::::X  XXXXXX  X::::X X::::::X     XXXXXXX"DATA "X:::::X    XXXXX::::X  X:::::X                X::::X     X:::::X  XX::::::::::::X  XX:::::XX       X::::X X:::::X             "DATA "X:::::X        X::::X  X:::::X                X::::X     X:::::X X::::XXXX::::::X    XX:::::XX     X::::X X:::::X             "DATA " X:::::X       X::::X  X:::::X        XXXXXX  X::::X     X:::::XX::::X    X:::::XXXXXXX XX:::::XX  X::::X X::::::X     XXXXXXX"DATA "  X:::::XXXXXXXX::::XXX:::::::XXXXXXXX:::::XXX:::::XXXXXX::::::XX::::X    X:::::XX:::::XXXX::::::XX::::::XX:::::::XXXXXX:::::X"DATA "   XX:::::::::::::::XX:::::::::::::::::::::XX:::::::::::::::::X X:::::XXXX::::::XX::::::::::::::X X::::::X X:::::::::::::::::X"DATA "     XXX::::::XXX:::XX:::::::::::::::::::::XX::::::::::::::::X   X::::::::::XX:::XX:::::::::::XX  X::::::X  XX:::::::::::::::X"DATA "        XXXXXX   XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX     XXXXXXXXXX  XXXX XXXXXXXXXXX    XXXXXXXX    XXXXXXXXXXXXXXXX"ENDDATA`additional OpenGL functions, paste to second file:
Code: (glbasic) [Select]
`INLINE#ifdef CENTERLINE_CLPP#define signed#endif#define OGL ::typedef unsigned int    GLenum;typedef unsigned char   GLboolean;typedef unsigned int    GLbitfield;typedef void            GLvoid;typedef signed char     GLbyte;typedef short           GLshort;typedef int             GLint;typedef unsigned char   GLubyte;typedef unsigned short  GLushort;typedef unsigned int    GLuint;typedef int             GLsizei;typedef float           GLfloat;typedef float           GLclampf;typedef double          GLdouble;typedef double          GLclampd;ENDINLINEGLOBAL GL_ALPHA_TEST                                      = 0x0BC0GLOBAL GL_ALPHA_TEST_REF                                  = 0x0BC2GLOBAL GL_ALPHA_TEST_FUNC                                 = 0x0BC1GLOBAL GL_BLEND                                           = 0x0BE2GLOBAL GL_BLEND_SRC                                       = 0x0BE1GLOBAL GL_BLEND_DST                                       = 0x0BE0GLOBAL GL_ZERO                                            = 0x0GLOBAL GL_ONE                                             = 0x1GLOBAL GL_SRC_COLOR                                       = 0x0300GLOBAL GL_ONE_MINUS_SRC_COLOR                             = 0x0301GLOBAL GL_SRC_ALPHA                                       = 0x0302GLOBAL GL_ONE_MINUS_SRC_ALPHA                             = 0x0303GLOBAL GL_DST_ALPHA                                       = 0x0304GLOBAL GL_ONE_MINUS_DST_ALPHA                             = 0x0305GLOBAL GL_DST_COLOR                                       = 0x0306GLOBAL GL_ONE_MINUS_DST_COLOR                             = 0x0307GLOBAL GL_SRC_ALPHA_SATURATE                              = 0x0308GLOBAL GL_CONSTANT_COLOR                                  = 0x8001GLOBAL GL_ONE_MINUS_CONSTANT_COLOR                        = 0x8002GLOBAL GL_CONSTANT_ALPHA                                  = 0x8003GLOBAL GL_ONE_MINUS_CONSTANT_ALPHA                        = 0x8004INLINE    }    extern "C" {        #include <cstdio>        void __stdcall glDisable( GLenum cap );        void __stdcall glColorMask( GLboolean red , GLboolean green , GLboolean blue , GLboolean alpha );        void __stdcall glAlphaFunc( GLenum func , GLclampf ref );        void __stdcall glBlendFunc( GLenum sfactor , GLenum dfactor );        void __stdcall glEnable( GLenum cap );        const unsigned char* __stdcall glGetString( int name );        }    namespace __GLBASIC__ {ENDINLINEFUNCTION glColorMask: red, green, blue, alpha INLINE OGL glColorMask(red, green, blue, alpha); ENDINLINEENDFUNCTIONFUNCTION glAlphaFunc: func, ref INLINE OGL glAlphaFunc(func, ref); ENDINLINEENDFUNCTIONFUNCTION glBlendFunc: sfactor, dfactor INLINE OGL glBlendFunc(sfactor, dfactor); ENDINLINEENDFUNCTIONFUNCTION glEnable: cap INLINE OGL glEnable(cap); ENDINLINEENDFUNCTIONFUNCTION glDisable: cap INLINE OGL glDisable(cap); ENDINLINEENDFUNCTIONFUNCTION glGetString\$: id%        INLINE                return DGStr((const char*)glGetString(id));        ENDINLINEENDFUNCTION`
Waiting for entries from others :P
btw. what about shaders? They can be used to make some crazy stuff, maybe separate them to another competition.
Title: Re: GLBasic Contest 02: 2D Art
Post by: Qedo on 2019-Apr-27
And instead another plasma / fire example.
Surely there is something better but I hope you like it and above all that it is useful.

ps It's not entirely my idea. In the program the references of inspiration
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-Apr-27
Fantastic dreamerman, really nice!  :good:
And thank you for this, it might be useful for something i'm working on.
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-Apr-27
Qedo i don't know how that works, but i want to figgure it out!
Looks really cool!
Title: Re: GLBasic Contest 02: 2D Art
Post by: dreamerman on 2019-May-06
@Qedo: Thank You, this will be usefully as it's looking really nice and there is no need to port/rewrite other fire effect if someone needs it :D

Background of fancy sprites with black-hole effect, and text filled with such nice fire as above. This would be great :> I hope that there will be more entries, there is still time.
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-May-07
Sorry for the delay, I was busy with my other projects (especially an important one for my job).
I made this little demo, it uses opengl functions and I'm in 3D mode but all calculations and the final display are done in 2D to stay in the rules of the contest.
I hope you will like it  ;)

Ps1: I have to put a .zip because it uses "gl.gbas".
Ps2: Very nice Fire Effect Qedo  :good:

-EDIT-
I just compiled Dreamerman's demo and that's great too.
Decidedly, there is talent here, it will become difficult to choose  :)
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-May-08
Nice work Snoopy, that high pitch sound though, scared me lol
Title: Re: GLBasic Contest 02: 2D Art
Post by: Kitty Hello on 2019-May-08
@Snoopy - ArtDemo.exe triggers my Norton Antivirus - I have to reboot. It seems bad!
Title: Re: GLBasic Contest 02: 2D Art
Post by: Heiko on 2019-May-08
@Kitty: its a false alarm.Bitdefender says nothing.
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-May-08
For my AVG AV program i think it checks each program on first run, after anything is compiled and run.
Only once, and on first run only.
Title: Re: GLBasic Contest 02: 2D Art
Post by: Hemlos on 2019-May-08
ps snoopy needs to be added to the poll.
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-May-08
@Snoopy - ArtDemo.exe triggers my Norton Antivirus - I have to reboot. It seems bad!

What?? It's a joke?
If so, there is a problem with your GLB compiler.
Moreover, Kaspersky and Comodo don't report anything at all.
Stop using Norton, it's a shit  :puke:

Nice work Snoopy, that high pitch sound though, scared me lol

Thanks Hemlos.
Yes, the pitch of the "beep" is a little too high, I should have lowered the sound a bit  ;)
Title: Re: GLBasic Contest 02: 2D Art
Post by: Moru on 2019-May-09
Agh, I have to stop playing around now  :whip:

Code: (glbasic) [Select]
`// --------------------------------- //// Project: Totalistic Cellular Automaton// Start: Tuesday, May 07, 2019// IDE Version: 15.004//// Simple rules paints a picture. Use arrows to change rules and starting data.// Idea:// http://mathworld.wolfram.com/CellularAutomaton.htmlGLOBAL color_states% = 3GLOBAL x_max% = 320GLOBAL y_max% = 220GLOBAL zoom = 2GLOBAL x%,y%GLOBAL seed% = 380   // The top rule numberGLOBAL rule_number%=1 // decimal representation of ruleGLOBAL rule%[]DIMDATA rule[],1,0,0,1,2,1,0 // rule converted to arrayGLOBAL line_pos%[] // Positions where to change rulesGLOBAL line_dir%[]   // Moving directionGLOBAL line_rule%[]  // Rule number to run at this line (index into nice_rule[])GLOBAL nice_rules%[] // Selection of interesting rulesGLOBAL image_data%[]DIM image_data%[x_max * y_max]GLOBAL data_grid%[]DIM data_grid[x_max][y_max]GLOBAL palette%[]DIMDATA palette[], 0xFF000000, 0xFF70D0EC, 0xFF435BD9, 0xFF4229C0, 0xFF372454, 0xFF7A7753, 0xFF78D0EC, 0xFF435BD9, 0xFF4229C0GLOBAL mx, my, b1, b2SETSCREEN 640, 480, 0SMOOTHSHADING FALSE // Blocky zoom!init_lines()GLOBAL intro = 1WHILE TRUE KeyHitUpdate() buttons() init_screen() recreate() overlay() SHOWSCREEN move_lines()WENDKEYWAITENDFUNCTION buttons: MOUSESTATE mx, my, b1, b2 LOCAL step_size = 1 IF KeyHit(42)>0 OR KeyHit(54)>0 step_size=10 ELSE step_size=1 ENDIF IF KeyHit(57)=2 // Space DEBUG seed + "," ENDIF IF KeyHit(200)>0 THEN seed=seed+step_size IF KeyHit(208)>0 THEN seed=seed-step_size IF KeyHit(203)=2 THEN seed=seed-step_size IF KeyHit(205)=2 THEN seed=seed+step_size IF KeyHit(78)=2 INC line_rule[0], 1 IF line_rule[0] > LEN(nice_rules[])-1 THEN line_rule[0] = LEN(nice_rules[])-1 ENDIF IF KeyHit(74)=2 DEC line_rule[0], 1 IF line_rule[0] < 0 THEN line_rule[0] = 0 ENDIFENDFUNCTIONFUNCTION recreate: FOR y = 1 TO y_max-1 IF y = 1 THEN make_rule(seed) FOR i = 0 TO LEN(line_pos[])-1 IF y = line_pos[i] make_rule(nice_rules[line_rule[i]]) ENDIF NEXT FOR x = 1 TO x_max-2 set(x,y,decide_sum(x,y)) NEXT NEXT // Convert data to sprite: MEM2SPRITE(image_data%[], 1, x_max, y_max) //DRAWSPRITE 1, 0, 30 STRETCHSPRITE 1, 0, 30, x_max*zoom, y_max*zoom ENDFUNCTIONFUNCTION move_lines: IF intro = 1 //380, 38 FOR i = 0 TO LEN(line_pos[])-1 IF line_pos[i] >= y_max-1 OR line_pos[i] <= 1 line_dir[i] = -line_dir[i] INC line_rule[i], 1 IF line_rule[i] > LEN(nice_rules[])-1 THEN line_rule[i] = 0 ENDIF INC line_pos[i], line_dir[i] NEXT IF KeyHit(57) THEN intro = 0 ELSE line_pos[0] = my ENDIFENDFUNCTIONFUNCTION init_lines: DIMDATA line_pos[], 3 // y_max/4 //, y_max/4*3 DIMDATA line_dir[], 1, -1 DIMDATA nice_rules[], 38, 3,10,12,21,24,28,30,31,34,38,43,46,48,49,52,57,65,66,75,83,84,86,92,93,95,96,97,100,102,105,106,109,110,111,113,114,115,128,129,136,137,138,140,141,145,146,147,150,164,170,172,173,177,183,186,194,205,210,219,220,221,224,237,302,308,357,384,422,439,443,497,600,646,804,807,843,844,845,858,867,870,885,888,893,924,925,947 DIMDATA line_rule[], 1, LEN(nice_rules[])/3ENDFUNCTIONFUNCTION init_screen: FOR x = 0 TO x_max-1 set (x, 0, 0) NEXT set(x_max/2, 0, 1)ENDFUNCTION// Foreground layer / instructionsFUNCTION overlay: IF intro = 1 PRINT "Press SPACE", 50, 10 ELSE LOCAL str\$ PRINT "Change rule with arrowkeys, hold shift for faster change.", 0, 0 PRINT "Mouse Y move up and down, + and - on numpad changes rule.", 0, 10 PRINT "Rules: " + seed + " and " + nice_rules[line_rule[0]], 0, 20 str\$="" FOREACH a IN rule[] str\$ = str\$ + a NEXT PRINT str\$, 0, 30 ENDIFENDFUNCTIONFUNCTION decide_sum: x, y LOCAL sum = 0 LOCAL result = 0 y = y - 1 FOR x1 = x-1 TO x+1 sum = sum + get(x1,y) NEXT IF sum >= 0 AND sum < BOUNDS(rule[], 0) result = rule[sum] ENDIF RETURN resultENDFUNCTIONFUNCTION get: x, y IF x >= 0 AND x < x_max AND y >= 0 AND y < y_max RETURN data_grid[x][y] ELSE RETURN 0 ENDIFENDFUNCTIONFUNCTION set: x, y, color image_data%[x + y*x_max] = palette[color] data_grid%[x][y] = colorENDFUNCTIONFUNCTION make_rule: n% rule_number% = n% //rule = dec_to_base(n, color_states) dec_to_base(n, color_states)ENDFUNCTION// ------------------------------------------------------------- //// ---  dec_to_base  ---// ------------------------------------------------------------- //// Convert decimal to any base system// Returns array with LSB first//FUNCTION dec_to_base: num%, base% LOCAL a%[] DIM a%[0] WHILE (num>0) DIMPUSH a[], MOD(num, base) num = INTEGER(num / base) WEND rule = a //RETURN aENDFUNCTION// ------------------------------------------------------------- //// ---  KeyHitUpdate  ---// ------------------------------------------------------------- ////// Update keyboard state, call every screen refresh//GLOBAL gKeyDown[], gKeyState[]FUNCTION KeyHitUpdate: LOCAL  k, i    // First Time call, init    IF BOUNDS(gKeyDown[],0)=0        DIM gKeyDown[256]        DIM gKeyState[256]    ENDIF    // For each key    FOR i=0 TO 255        k = KEY(i)        // Key is pressed        IF k            IF gKeyDown[i]                gKeyState[i]=1            ELSE                gKeyDown[i]=1                gKeyState[i]=2            ENDIF        ELSE            // Key is not pressed            // Has key been pressed before?            IF gKeyDown[i]                gKeyDown[i] = 0                gKeyState[i] = -1            ELSE                gKeyState[i]=0            ENDIF        ENDIF    NEXTENDFUNCTION// ------------------------------------------------------------- //// ---  KeyHit  ---// ------------------------------------------------------------- //// Returns://  0 = not pressed//  2 = just pressed (only triggers on keydown)//  1 = pressed// -1 = release event (only triggers on keyup)//// nkey = key scancode to checkFUNCTION KeyHit: nkey    RETURN gKeyState[nkey]ENDFUNCTION`
Fun competition :-)
Title: Re: GLBasic Contest 02: 2D Art
Ok, I have a few questions and I think we all should discuss this:

• How often should we make a contest? Every month, every 2 months?
• How long should the breaks be between 2 contests?
• How long should the contest itself be?

I have many stupid and funny ideas for little contests like this. Some are harder, others are short and easy. And I think it's really funny, also for me...

But I want everyone to be happy with them and not to spam one contest after another
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-May-10
For the next contest, I run a retro team demo challenge !
The demo must be in console mode ;)

Ps1: I choose to be a Replicant, I'm taking Hemlos to my team if he agrees =D
Ps2: You are welcome in this fun contest Kitty :booze:

-EDIT-
No Opengl, no DirectX, just Software.
If you agree WPShadow, put it in place.
Title: Re: GLBasic Contest 02: 2D Art
Post by: dreamerman on 2019-May-10
Looks like that Norton heuristic is highly restrictive as I just checked that original exe file from Snoopy project with Total Virus (Steam uses this for scanning apps) and only 1 warning per 70 AV scanners.

@Snoppy: I really like those particles - due that shading from color to black, simple but very effective. In addition that music, theme from Space Odyssey is always great :)

@Moru: Nice and interesting, with some additional rules to include more colors could give some spectacular result. This could be used as background for some part of larger demo.

It all depends on the contest, something small doesn't long running time, still at least one month so all interested could code their entry on free weekend (as even this topic shows). Breaks could for example take half of time that contest was running, or at least two-three weeks independently of contest duration.

Console/textmode contest sounds cool, yet will force to work harder to code something interesting – should last longer than this. Additional rules could be added here – for example demo running time max 3 minutes.
Title: Re: GLBasic Contest 02: 2D Art
How about 1,5 month contest running time and two weeks breaks?
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-May-11
@Dreamerman : Thanks, Yes, it's a simple but always spectacular effect.

@Moru : I always liked the fractals, that always gives interesting effects. The one I prefer is the famous Mandelbrot.

As Dreamerman said it's much more difficult so 3 weeks or 1 month would be a good time for this contest.
On the other hand, I think that we will drop the team work, the idea is pleasant but I think it will be difficult to implement :(

We also can not use the console mode but only have the right to use the SETPIXEL function for display, it may be easier for all.

-EDIT-
I still have not voted, the choice is really difficult.
I look at all the choices (except mine because I don't vote for me) and they are all different, some spectacular and others less but interesting by their simplicity.
It's really very very difficult...
Title: Re: GLBasic Contest 02: 2D Art
Post by: dreamerman on 2019-May-16
@WPShadow - for me sounds ok.

@Snoopy - true console mode sounded original, we can have this earlier or later and another contest with limitations for only SetPixel.
For moment I was thinking that we are limited to standard console colors but:

main file
Code: (glbasic) [Select]
`// project -> options -> console programLOCAL i1%, i2%FOR i2 = 0 TO 15 FOR i1 = 0 TO 15 ConsoleSetColor(i1, i2) STDOUT "test" NEXT STDOUT "\n"NEXTKEYWAIT`second file
Code: (glbasic) [Select]
`IMPORT "C" int __stdcall GetStdHandle(int nStdHandle)IMPORT "C" int __stdcall SetConsoleTextAttribute(int hConsoleOutput, int wAttributes)FUNCTION ConsoleSetColor: fg_color%, bg_color% LOCAL console_handle% = GetStdHandle(-11) SetConsoleTextAttribute(console_handle, bg_color% * 16 + fg_color%)ENDFUNCTION`
only question is how fast console window can be refreshed, and some functions to print at selected X,Y position would be also usefully.
Another thing is that you need to have idea for demo that would fit into console/text mode nicely, this may be an issue for me hehe... :D
Title: Re: GLBasic Contest 02: 2D Art
Quote
only question is how fast console window can be refreshed, and some functions to print at selected X,Y position would be also usefully.

That shouldn't be your problem... every developer have to find a way by himself to fix this issue  :D

I will set everything up for the next contest from 01.06 - 14.07. ?

I think 6 weeks should be enough
Title: Re: GLBasic Contest 02: 2D Art
Post by: SnooPI on 2019-May-18
Quote
only question is how fast console window can be refreshed, and some functions to print at selected X,Y position would be also usefully.

That shouldn't be your problem... every developer have to find a way by himself to fix this issue  :D
:D
Nothing better to motivate a programmer ;)

At first, I didn't think of a console demo only in ASCII, but why not, the challenge can be very interesting.
So, you're right Dreamerman, it's a lot harder to find good ideas with only ASCII  O_O

@WPShadow - Yes 6 weeks is good I think.
But when will this poll be finished? (I really have a hard time choosing), I hope you leave a message 24 hours before the closing of this poll.
Title: Re: GLBasic Contest 02: 2D Art