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.


Topics - Hemlos

Pages: [1] 2 3 ... 10
1
This Vector lib can be used for 2d or 3d.
The vector is treated as an object, hence OOP style.
It transforms, or analises the vectors as an object.
All known, fundamental, vector functions should be found in this lib, if there is something missing please let me know.
This lib is very stable and tested using Sir Isaac Newton's law of universal gravitation. (in my yet to be revealed game) =D

Notes about normalizing:
A. ||V|| = 1 (it should anyway, if not let me know how!)
B. Can be used to set the absolute length. eg. instead of using a second SCALAR. saves some CPU steps!


VEC3:

Code: GLBasic [Select]
// --------------------------------- //
// Project: Vector Object - OOP
// Start: Saturday, August 29, 2015
// Created By: Neil M. Silver
// Code based on the works done by BigSofty and Jestermon.
//
// ======================================================================================== //
// Vector Object - OOP
//
// This is a Vector Library, true OOP style.
// The Vector object can be analised, or transformed with vector math functions.
//
// Note:
// Declare your vectors ahead of time AS VEC3.
// Your main vector is the main object(VecA), and you pass in secondary vectors(VecB) as inputs.
// VecB as an input is always the OTHER secondary vector being analised.
// CrossProduct function outputs VectorOutput AS Vec3 as the output, to preserve the first vector.
//
// LOCAL My3dVector AS VEC3
// My3dVector._INIT_(1.0,1.0,1.0) //not a normalized vector.
// My3dVector._NORMALIZE()  //My3dVector length is now normalized to 1 which preserves its original direction, eg ||V|| = 1
// My3dVector._SCALE(2.0) // vector is now length = 2, in its original direction.
//
// LOCAL My3dVector2 AS VEC3
// My3dVector2._INIT_(3.0,-1.0,-2.0) //not a normalized vector.
// LOCAL MyProductOutputVector AS VEC3 // no need to init this one...itll be used for the product results.
// My3dVector._CROSSPRODUCT(My3dVector2, MyProductOutputVector ) //MyProductOutputVector contains the results of this function byref.
//
TYPE VEC3 // 3 dimensional Vector Object

        //VecA
        vX#
        vY#
        vZ#

        // Initialise Your Vector Object Here.
        FUNCTION _INIT_: vX#, vY#, vZ# // LIB VEC3 - Vector Object Input
                self.vX# = vX#
                self.vY# = vY#
                self.vZ# = vZ#
        ENDFUNCTION


// Information Analysis function sets:


        // DOT Product
        // Note, Computers arent reliable calcultating DOT
        // IF value is < 0.01 THEN it is really 0!
        // I tested many different values in a vector calculator to find this tolerance number.
        // That said, this DOT function works really well.
        FUNCTION _DOT#: VecB AS VEC3 // LIB VEC3 - Vector DOT Product
                LOCAL DOT# = ( (self.vX*VecB.vX) + (self.vY*VecB.vY) + (self.vZ*VecB.vZ) )
                IF DOT < 0.01 THEN DOT = 0
                RETURN DOT
        ENDFUNCTION



        // Magnitude
        FUNCTION _MAG#: // LIB VEC3 - Vector Magnitude
                RETURN SQR( (self.vX*self.vX) + (self.vY*self.vY) + (self.vZ*self.vZ) )
        ENDFUNCTION



        // Cross Product
        // Returns VecOutput with a vector cross product as its value.
        FUNCTION _CROSS: VecB AS VEC3, VecOutput AS VEC3 // LIB VEC3 - Cross Product - VecOutput is the output.
            VecOutput.vX = (self.vY * VecB.vZ) - (self.vZ * VecB.vY)
            VecOutput.vY = (self.vZ * VecB.vX) - (self.vX * VecB.vZ)
            VecOutput.vZ = (self.vX * VecB.vY) - (self.vY * VecB.vX)
        ENDFUNCTION



// Vector Math Section, These Mutate/Transform/Affect your Vector Object:

        // Normalize, Vector Length = 1 (eg. ||V|| = 1)
        // You can change the Size of the normal, mutates vector absolute size as the product =D
        // This is the same as normalizing your vector then scaling it up!
        // Much faster to scale the absolute size here initially, rather than to normailize and then scale up, saves steps.
        // If you dont feel comfortable with this, then use the regular vector _SCALAR function after normalizing to 1.
        // Leave it as 1.0 for a normal normalization product.
        FUNCTION _NORMALIZE: Size# = 1.0  // LIB VEC3 - Normalize the Vector to length = 1.0
                LOCAL vLEN# = self._MAG()
                self.vX# = self.vX#  * ( Size# / vLEN )
                self.vY# = self.vY#  * ( Size# / vLEN )
                self.vZ# = self.vZ#  * ( Size# / vLEN )
        ENDFUNCTION



        FUNCTION _ADD: VecB AS VEC3 // LIB VEC3 - Vector Addition
                self.vX = self.vX + VecB.vX
                self.vY = self.vY + VecB.vY
                self.vZ = self.vZ + VecB.vZ
        ENDFUNCTION



        FUNCTION _SUBTRACT: VecB AS VEC3 // LIB VEC3 - Vector Subtraction
                self.vX = self.vX - VecB.vX
                self.vY = self.vY - VecB.vY
                self.vZ = self.vZ - VecB.vZ
        ENDFUNCTION



        FUNCTION _SCALAR: Scale# // LIB VEC3 - Vector Scalar
                self.vX = self.vX * Scale
                self.vY = self.vY * Scale
                self.vZ = self.vZ * Scale
        ENDFUNCTION



        FUNCTION _INVERT: // LIB VEC3 - Vector Inversion, flip all signs.
                self.vX = -self.vX
                self.vY = -self.vY
                self.vZ = -self.vZ
        ENDFUNCTION

ENDTYPE





 

2
FAQ / Version info, industry standard
« on: 2015-Aug-29 »
In project options, when i try to change the version info from 000.000 to 015.0829
it resets, and looks like this: 015.829
Also, i cant remove the decimal.
What are the semantics if this inst a bug?

3
music/sound / HUSH(channel%)
« on: 2015-Aug-16 »
HUSH(channel%)

see my sound object below, youll see how it becomes useful.

Code: GLBasic [Select]
TYPE lib_SOUND_Object_
       
        SndObj_Name$
        SndObj_Path$
        SndObj_Buff%
        SndObj_Balance%
        SndObj_ID%
       
        SndObj_Channel% //internal glbasic channel id
       
        SndObj_Volume#
        SndObj_Mute%
        SndObj_IS_Playing%
       

        // This sound is an object.
        // A sound object is preloaded with independant balance and volume.
        // This sounds volume level, can be controlled by a master volume input at playtime.
        FUNCTION _SNDOBJ_LOAD: FilePath$, FileName$, NumBuffers%, Balance%// NumBuffers% [1..4], Returns ID%
                self.SndObj_Name$ = FileName$
                self.SndObj_Path$ = FilePath$
                self.SndObj_Buff% = NumBuffers%
                self.SndObj_Balance% = Balance%
                self.SndObj_ID% = GENSOUND()
                LOADSOUND ( self.SndObj_Path$ + self.SndObj_Name$ ), self.SndObj_ID%, self.SndObj_Buff%
                RETURN self.SndObj_ID%
        ENDFUNCTION
       

        // is this object playing?
        FUNCTION _SNDOBJ_ISPLAYING:
                self.SndObj_IS_Playing% = SOUNDPLAYING(self.SndObj_Channel%)
                RETURN self.SndObj_IS_Playing%
        ENDFUNCTION


        FUNCTION _SNDOBJ_PLAY: MasterVolume% // [0..1]
                self.SndObj_Channel% = PLAYSOUND( self.SndObj_ID%, self.SndObj_Balance%, ( self.SndObj_Volume% * MasterVolume% ))
                RETURN self.SndObj_Channel%
        ENDFUNCTION


        FUNCTION _SNDOBJ_STOP:
                HUSH // HUSH(channel%) command requested
                RETURN self._SNDOBJ_ISPLAYING()
        ENDFUNCTION


ENDTYPE

 

4
Bug Reports / v14.001 setscreen issues
« on: 2015-Aug-14 »
1. In 2d, window mode: work fine when i change resolution of the window, from what i can see,
2. In 3d, window mode: the 3d scene is the old resolution viewport even though the window is resized.
3. I experienced the program completly stops rendered graphics to the screen when using SETSCREEN, when switching from window to fullscreen mode during runtime.

first image is as expected rendering in v12.312
Seconds image is v14.001

5
You can design stars with any specs...fully customizable, inner and outer radius, and number of points.
Skinable too!
This is an AWESOME project, and has alot more potential, as i only made it today.
So far...the stars are perfect from what i can tell.....skys the limit!
Personally...im going to use these stars in my next game for various effect, enjoy!

ps. SF did some stars too, pixel style though, not polyvectors like these.
however sf's are pretty, and they are good for making artsy images.

pps. project is attached to this message below screeny

6
2D-snippets / Randomizing Colors
« on: 2015-Aug-09 »
I just discovered you can add colors...heh silly huh.
This led to a discovery...you can add random colors too.

Color = RGB(128,128,128) + RGB( RND(127), RND(127), RND(127) )
Color = 0x808080 + RGB( RND(127), RND(127), RND(127) )

Want to tint a simple gray with a little red?
Color = RGB(128,128,128) + 0x000040

Heres a code sample that shows colors being randomized


Code: GLBasic [Select]
// --------------------------------- //
// Project: ColorPalette
// Start: Saturday, August 08, 2015
// IDE Version: 12.312


// SETCURRENTDIR("Media") // go to media files


WHILE TRUE
 ColorPalette(10,10,64)
 SHOWSCREEN
WEND


FUNCTION ColorPalette: x%, y%, BlockWidth%
        LOCAL ColorBandColumnID%, xx%

        ColorBandColumnID% = 0
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + (BlockWidth% * i%)
                LOCAL cbC% = (255-(i% * 32))
                LOCAL Color# = RGB( cbC%, 0, 0 )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 1
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCR% = ( 255 - ( i% * 32 ) )
                LOCAL cbCG% = ( 128 - ( i% * 16 ) )
                LOCAL Color# = RGB( cbCR%, cbCG%, 0 )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 2
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCR% = ( 255 - ( i% * 32 ) )
                LOCAL cbCG% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( cbCR%, cbCG%, 0 )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 3
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCR% = ( 128 - ( i% * 16 ) )
                LOCAL cbCG% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( cbCR%, cbCG%, 0 )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 4
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCG% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( 0, cbCG%, 0 )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 5
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCG% = ( 255 - ( i% * 32 ) )
                LOCAL cbCB% = ( 128 - ( i% * 16 ) )
                LOCAL Color# = RGB( 0 ,cbCG%, cbCB%)
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 6
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCG% = ( 255 - ( i% * 32 ) )
                LOCAL cbCB% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( 0, cbCG%, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 7
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCG% = ( 128 - ( i% * 16 ) )
                LOCAL cbCB% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( 0, cbCG%, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 8
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCB% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( 0, 0, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 9
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCB% = ( 255 - ( i% * 32 ) )
                LOCAL cbCR% = ( 128 - ( i% * 16 ) )
                LOCAL Color# = RGB( cbCR%, 0, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT
       
        ColorBandColumnID% = 10
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCB% = ( 255 - ( i% * 32 ) )
                LOCAL cbCR% = ( 255 - ( i% * 32 ) )
                LOCAL Color# = RGB( cbCR%, 0, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT

        ColorBandColumnID% = 11
        xx% = ( x% + (BlockWidth% * ColorBandColumnID% ) )
        FOR i% = 0 TO 7
                LOCAL cby% = y% + ( BlockWidth% * i% )
                LOCAL cbCB% = ( 128 - ( i% * 16 ) )
                LOCAL cbCR% = ( 0xff - ( i% * 0x24 ) )
                LOCAL Color# = RGB( cbCR%, 0, cbCB% )
                ColorBlock( xx%, cby%, Color#, BlockWidth% )
        NEXT
       
        RETURN 0
ENDFUNCTION


FUNCTION ColorBlock: x#,y#, color#, size%
        DRAWRECT x,y,size%,size%,color#+ RGB(RND(32), RND(32), RND(32))
        RETURN 0
ENDFUNCTION
 

7
Bug Reports / [SOLVED] SUB GLB_ON_RESUME
« on: 2014-Sep-06 »
SUB GLB_ON_RESUME

For windows....doesnt seem to work at all.

I tried adjusting type based variables and GLOBALs, and ran comparisons in the main loop to no effect.

8
Bug Reports / GETDESKTOPSIZE
« on: 2014-Sep-06 »
GETDESKTOPSIZE causes this error

ps. gernot could you look into why all windowed binaries on win32 become blacked-out after minimizing them for a 10-15 minutes?

Quote
_______________________________________
*** Configuration: WIN32 ***
precompiling:
GPC - GLBasic Precompiler V.10.053 SN:17b922e3 - 3D, NET
Wordcount:1334 commands
compiling:
C:\Users\A10TRI~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\Users\A10TRI~1\AppData\Local\Temp\glbasic\gpc_temp0.cpp:794: error: no matching function for call to `GETDESKTOPSIZE(DGInt&, DGNat&)'
C:/Program Files (x86)/GLBasic_v12/Compiler/platform/Include/glb.h:1369: note: candidates are: void __GLBASIC__::GETDESKTOPSIZE(DGInt&, DGInt&)
C:/Program Files (x86)/GLBasic_v12/Compiler/platform/Include/glb.h:1370: note:                 void __GLBASIC__::GETDESKTOPSIZE(DGNat&, DGNat&)
*** FATAL ERROR - Please post this output in the forum
_______________________________________
*** Finished ***
Elapsed: 3.0 sec. Time: 01:44
Build: 0 succeeded.
*** 1 FAILED ***


9
New codesnippet...litterally in every sense of it.

This is how you turn time, into a circle =D

Actually, this shows how i fluxuate a color back and forth....smoothly.
In this snipet...the color fades from White to Black To White in one second.

Code: GLBasic [Select]
                // Color Override - Fluxuator
                STATIC ColorRotator% = 0 , ColorWheel% = 1
                LOCAL Circulartime = 2.777777778 // = 1000/360, one second of time divided by 360.  Divide gettimer() with this, and accumulate the value every loop, and you get 360 degrees rotating every second.
                ColorRotator = (GETTIMER()/Circulartime) + ColorRotator
                IF ColorRotator > 359 THEN ColorRotator = 0
                ColorWheel = INTEGER((SIN(ColorRotator) * 127) + 128)
                Color = RGB(ColorWheel,ColorWheel,ColorWheel)
 

10
Media Section: '[FRIED] Free Random Image Export Depository'

The intention here is to have an archive of images that can be used for any purpose, by our GLBasic community.
And now I will thank everyone of you personally ahead of time, for sharing your works of art!

I will be moderating this thread, so be hip with these rules!
Breaking these rules will put all your images into scrutiny of my judgemental eye,
 and possible deletion of your posts.  :rtfm:
Please respect the rules(mainly so i dont have to work harder than i already do),
 and the whole community will be able to really enjoy and use this thread effectively.

Rule #1: If you post to this thread, please share a nice image that you made.
No posts will be permitted without an accompanying image!
As a curtesy to the creators, If you are starting with a screenshot, please post with a link or a reference to the original.
The idea for this rule is to allow you to share really cool looking stuff, as long as you are not breaking any laws by doing so.
And please, keep it RATED G, refrain from sharing images that involve human interactions of any kind.
These images should be useful, like for games, or other cool programs, or maybe wallpapers!

Rule #2: Dont include any text on the images.
When i say any text, this includes watermarks(this could be tricky, especially if you are starting with screenshots) if possible!
If you want to describe it, do so in the main body of your post.
If any symbolism is very noticable in your images, please dont post it.
When i say 'symbolism', I am meaning: No Human Generated Symbolism, period, the end, none at all, sorry, they BETTER be screaming Switzerland!
Exception: fonts for GLBasic

Rule #3: These images must not have any copyrights, totally free, royalty free, re-editable, re-distributable.
Any conflicts that arise due to these images, is a conflict that I may not have mentioned, yet, un-said were implied and you are doing wrong!



11
Bug Reports / Opengl Rendering Ceases..
« on: 2014-Aug-14 »
When i minimize a server(or even a client) for a few minutes(around 10-15minutes), the rendering in the window ceases.
It also stops rendering the title bar of the window...although the X at the top right corner works...but you cant see it(i just guessed where it is and clicked)


12
NOAA GOES - West Hemisphere Satelite Weather Recorder and Time Lapse.

I couldnt hold this back anymore....it works good and its time to share a beta version.

The complete project is attached to this message.
This is a test, yet a fully functioning program.

Downloads the latest imagery, and plays it back in a time lapse.
You need to let it run for a few days to get a good lapse.

Edit:
I uploaded the previous 4 days, dating from the last upload time here, as it is not a cloud database, it is local aquisition.

More information can be found in the project.
Compile in GLBasic.


Version 140910:

13
Bug Reports / LOADSPRITE and Memory
« on: 2014-Aug-06 »
Heyas

Im having an issue with loading images, and my ram being wiped out.
Is there something about LOADSPRITE that im not aware of?

i have 8 gigs of ram installed.
The os uses 2 gig, the program uses about 4 gig, and the gpu is using 2 gig of onboard ram.

When i load about 38 images of around 1mb~2mb each, jpg format, my program ends.
This group of images total about 45 mb.
The windows7 os complaining about resources being depleted, and the program is forced to shutdown.
I was watching my task manager, and i noticed well over 4 gig of ram is being used up by the program, very odd.
The ram was disappearing slowly as the program loads each of the images....it takes about a minute to get to #38 image.

Thats about 1 gig of ram being used for roughly 8 images.





14
Just a reference chart, ive been playing around making ancient technology menus =D

15
GLBasic - en / Happy Holidays!
« on: 2013-Dec-25 »
Merry christmas, and a happy new year!

Happy Holidays to all!

-Neil

Pages: [1] 2 3 ... 10