BASIC

Show Posts

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.


Messages - dreamerman

Pages: 1 [2] 3 4 ... 19
16
Competitions / Re: GLBasic Contest 02: 2D Art
« 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.


About next contest:
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.

17
GLBasic - en / Re: Inline C++
« on: 2019-May-09 »
hm.. strange, before posting I checked that code with GLB 15 & 16.. low chance, but maybe that lib is missing, check in: 'GLBasic\Compiler\platform\Win32\Include'.
Or maybe I did forgot about something trivial  ;/
Problem appears with all projects using INLINE? (some complete projects from forum too)

18
GLBasic - en / Re: Inline C++
« on: 2019-May-09 »
Another thing that INLINE shouldn't be in main source file (not sure about this), so this will work:
main source:
Code: GLBasic [Select]
GOSUB main

SUB main:

printf1()

PRINT "HELLO",100,100
SHOWSCREEN
KEYWAIT
ENDSUB
 
second file:
Code: GLBasic [Select]
INLINE
        }
                extern "C" {
                        #include <cstdio>
                }
        namespace __GLBASIC__ {
ENDINLINE


FUNCTION printf1:

INLINE

   char z[100] = "I am learning C programming language.";
 
   printf("%s", z);
   
   return 0;
   
ENDINLINE

ENDFUNCTION
 

Take a note that printf writes to standard output stream, so either app should be compiled as console application, use other function as GLBasic debug doesn't catch stdout info (not sure) or write output to file for example with such batch command in Windows (write file as *.bat):
Code: GLBasic [Select]
inline_test.exe >>stdout.txt

19
GLBasic - en / Re: Inline C++
« on: 2019-May-09 »
hm.. shoudn't it be something like this:
Code: GLBasic [Select]
INLINE
        }
                extern "C" {
                        #include <cstdio>
                }
        namespace __GLBASIC__ {
ENDINLINE

20
Competitions / Re: GLBasic Contest 02: 2D Art
« 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.

21
Off Topic / Re: 80ties
« on: 2019-Apr-29 »
Demo from Replicants looks better.
Interesting is that many demos like this were even made after 2000, thanks to internet, people could easily share some programming tricks for particular hardware.
And those 16-bit systems (Atari, Amiga) have some really incredible demos. :)

22
Interesting, another proof that GLB isn't restricted like some other tools and can be used beyond most popular libraries. This engine name sounded familiar, so I googled it and indeed, remember it from my 'VB6 era', but only briefly, TrueVision3d was looking more promising. Now it looks like they switched from standalone engine (3Impact) to some kind of game making tool (3DRad)? I’m curious does they have tutorial or something, as most of those engines ended in oblivion :D

Another thing, and don't get me wrong here, that's great job, this may be helpful for someone (specially if You will release source), but I would prefer to use some solution that would try to maintain cross-platform nature of GLB (just in case). New functions/update for 3d stuff in GLB would be awesome, but newer engines may be overwhelming to adapt into GLB. I'm looking forward for Your next project :p

btw. You can add more examples of usage, maybe something with physic, and launch in a window :)

23
Announcements / Re: Android beta
« on: 2019-Apr-27 »
I have same thoughts that I had in previous topic (https://www.glbasic.com/forum/index.php?topic=11139.15) :P Generally slice screen into big X for detecting taps - much easier to shoot, and shoot cooldown takes to long, or You can add option to buy ship upgrades so player can shoot faster. Different colour enemies or some power-ups may be used in 'hard' mode or something like this. Otherwise it's ok, ah mute doesn't work? Android 7.1 device fluent gameplay, didn't notice other issues.

GLB code to check if point is in polygon: http://www.glbasic.com/forum/index.php?topic=7028.0

24
GLBasic - en / Re: For a new project...
« on: 2019-Apr-26 »
I'm doing it as Schranzor described, additionally with PolyVector you have more freedom and can parse special chars differently - for multiline rendering and so on..

25
Competitions / Re: GLBasic Contest 02: 2D Art
« 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%
ENDTYPE
TYPE point_struct
    pos AS point2d
    vec AS point2d
    target AS point2d
    dir_num%
    color%
ENDTYPE
   
   
   
GLOBAL my_point[] AS point_struct
GLOBAL my_point_count% = 1000       // how many moving rectangles
GLOBAL endit% = 0
GLOBAL i1%, anim_pos%, txt_pos AS point2d
DIM my_point[my_point_count%]

SMOOTHSHADING FALSE         // prefer stronk pixels
LIMITFPS 60
CREATESCREEN 0, 1, 640, 480
prepare_text()



// set some points
FOR 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 :D
NEXT


REPEAT
    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
    SHOWSCREEN
UNTIL endit% = 1

END

// return point2d type
FUNCTION ret_p2d AS point2d: x%, y%
    LOCAL temp AS point2d
    temp.x% = x%
    temp.y% = y%
    RETURN temp
ENDFUNCTION

// find new target-direction for rectangle
FUNCTION 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
    ENDIF
ENDFUNCTION

// load image from Data section and draw with desired colors
FUNCTION 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.0
ENDFUNCTION


// forcing 4x scale
FUNCTION 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 buffer
ENDFUNCTION



STARTDATA napis_glb:

// Ascii text made with: www.patorjk.com/software/taag/
// used font: Doh
DATA 126, 16
DATA "       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;
ENDINLINE
GLOBAL GL_ALPHA_TEST                                      = 0x0BC0
GLOBAL GL_ALPHA_TEST_REF                                  = 0x0BC2
GLOBAL GL_ALPHA_TEST_FUNC                                 = 0x0BC1
GLOBAL GL_BLEND                                           = 0x0BE2
GLOBAL GL_BLEND_SRC                                       = 0x0BE1
GLOBAL GL_BLEND_DST                                       = 0x0BE0
GLOBAL GL_ZERO                                            = 0x0
GLOBAL GL_ONE                                             = 0x1
GLOBAL GL_SRC_COLOR                                       = 0x0300
GLOBAL GL_ONE_MINUS_SRC_COLOR                             = 0x0301
GLOBAL GL_SRC_ALPHA                                       = 0x0302
GLOBAL GL_ONE_MINUS_SRC_ALPHA                             = 0x0303
GLOBAL GL_DST_ALPHA                                       = 0x0304
GLOBAL GL_ONE_MINUS_DST_ALPHA                             = 0x0305
GLOBAL GL_DST_COLOR                                       = 0x0306
GLOBAL GL_ONE_MINUS_DST_COLOR                             = 0x0307
GLOBAL GL_SRC_ALPHA_SATURATE                              = 0x0308
GLOBAL GL_CONSTANT_COLOR                                  = 0x8001
GLOBAL GL_ONE_MINUS_CONSTANT_COLOR                        = 0x8002
GLOBAL GL_CONSTANT_ALPHA                                  = 0x8003
GLOBAL GL_ONE_MINUS_CONSTANT_ALPHA                        = 0x8004



INLINE
    }
    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__ {
ENDINLINE


FUNCTION glColorMask: red, green, blue, alpha
        INLINE
                OGL glColorMask(red, green, blue, alpha);
        ENDINLINE
ENDFUNCTION

FUNCTION glAlphaFunc: func, ref
        INLINE
                OGL glAlphaFunc(func, ref);
        ENDINLINE
ENDFUNCTION

FUNCTION glBlendFunc: sfactor, dfactor
        INLINE
                OGL glBlendFunc(sfactor, dfactor);
        ENDINLINE
ENDFUNCTION

FUNCTION glEnable: cap
        INLINE
                OGL glEnable(cap);
        ENDINLINE
ENDFUNCTION

FUNCTION glDisable: cap
        INLINE
                OGL glDisable(cap);
        ENDINLINE
ENDFUNCTION

FUNCTION glGetString$: id%
        INLINE
                return DGStr((const char*)glGetString(id));
        ENDINLINE
ENDFUNCTION
 

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.

26
GLBasic - en / Re: The power of GLBasic !
« on: 2019-Apr-25 »

It may be somewhere in help file but I'm not sure, yet on forum there is plenty of examples, just not marked specificly as OOP.
Simple example how to use function in types:
Code: GLBasic [Select]
TYPE point2d
        x%
        y%
ENDTYPE

TYPE point_str
        pos AS point2d
        FUNCTION init%:
                self.pos.x% = RND(10)
                self.pos.y% = RND(10)
        ENDFUNCTION
        FUNCTION move%: dx%, dy%
                INC self.pos.x%, dx%
                INC self.pos.y%, dy%
        ENDFUNCTION
ENDTYPE


GLOBAL i1%, tx%, ty%, points[] AS point_str
DIM points[10]
FOR i1% = 0 TO 9
        points[i1].init()
        DEBUG "point " + i1 + ", pos: " + points[i1].pos.x + "x" + points[i1].pos.y + "\n"
NEXT

tx% = RND(5) - 2; ty% = RND(5) - 2
DEBUG "vector: " + tx + "," + ty% + "\n"

FOR i1% = 0 TO 9
        points[i1].move(tx, ty)
        DEBUG "point " + i1 + ", pos: " + points[i1].pos.x + "x" + points[i1].pos.y + "\n"
NEXT
 
So You can have for example math library and use it to calculations like this;
value% = Math.something(arg1%, arg2#)


About Basic's, yeah, whole industry changed a lot since then, there was many more commonly used compilers than now - Borland, Watcom, Digital Mars...
Love is only one, Basic.. :)

27
GLBasic - en / Re: The power of GLBasic !
« on: 2019-Apr-25 »
GoTo is here rather to have compatibility with some older Basic programs, like for example porting from QuickBasic, but in today more like OOP style it isn't advised.
From what I know ‘bad reputation’ of Basic’s started in 8/16bit era, and it significantly increased with Windows due the QuickBasic and later Visual Basic. It was so easy to play with simple commands, and this encourage people to learn programming. QuickBasic was a big thing for amateurs/home enthusiast, it showed that you don't need to buy top-end PC and expensive C compiler to write something (as generally Basic's were interpreted not compiled so instant run&test and You know, that was bad for some companies :D) Of course there were many other tools (ASM, Pascal) but none of them so easy to use.

There are some really interesting stories about Basic, for example thing about 'build engine' that’s powering Duke Nukem 3D, Blood..
Quote from: Ken Silverman author of 'Build Engine'
I first develop algorithms in QuickBasic because it has a great debugger. When I'm satisfied, I then port the code to C. The final step is converting some critical parts of the C code to assembly.
And he is using a lot of GoTo there ;)


btw. kirkdev You can use OOP and have hidden functions accessible through custom UDT..

28
Beta Tests / Re: 3d Space Sim
« on: 2019-Apr-22 »
Just waiting patiently to see this in action, at least in video..  :)

29
GLBasic - en / Re: GPC - C++ files
« on: 2019-Apr-22 »
Yes, this is some kind of 'issue' if You have multiple projects opened and want to compile them, as each time temp directory is cleared and whole project need to be recompiled.
About that html5, I have no idea, from what I see, now emscripten needs to be downloaded separately and some environment variables need to be set, and I don't want to play with this for now. But there are some users that should help You with this questions ;)

30
GLBasic - en / Re: Issue with case sensitivity
« on: 2019-Apr-22 »
Never saw such issue, can You check previous GLBasic version? You can download v15 demo from main web page - download section. Also please specify what OS you are using, may be helpful.

Pages: 1 [2] 3 4 ... 19