## News:

*NEW* Current Version on STEAM16.793

Webchat:
Visit the chat

### 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 - AndyH

#61
##### Code Snippets / Circle collisions and draw circles
2008-Jan-19
Hi all

I have made a circle to circle collision test function (would be nice to have one of these built in *hint* *hint*).  I've also half-inched a nice circle drawing routine and ellipse drawing routine off these forums (I think Minion and Gernot to credit) to show the collisions visually.  Again, would be nice to have a fast and optimised version of these two functions built in (*hint* *hint*)

I would gladly welcome any suggestions for optimising the circoll collision function.

Code (glbasic) Select
`SETSCREEN 640,480,0LIMITFPS 60BLACKSCREENGLOBAL x1=320GLOBAL y1=240GLOBAL rad1= 100GLOBAL x2=320GLOBAL y2=240GLOBAL rad2= 50WHILE TRUE drawCircle(x1,y1,rad1, RGB(255,255,255)) LOCAL a,b MOUSESTATE x2,y2, a,b drawCircle(x2,y2, rad2, RGB(200,100,100)) IF circoll(x1,y1,rad1, x2,y2,rad2) THEN PRINT "Collision!", 10,10 SHOWSCREENWEND// ------------------------------------------------------------- //// -=#  CIRCOLL  #=-// ------------------------------------------------------------- //FUNCTION circoll: x1,y1,radius1, x2,y2,radius2 LOCAL dx, dy IF x1 dx = x2 - x1 ELSE dx = x1 - x2 ENDIF IF y1 dy = y2 - y1 ELSE dy = y1 - y2 ENDIF LOCAL dist= SQR( (dx*dx) + (dy*dy) ) IF dist < (radius1+radius2) RETURN TRUE ELSE RETURN FALSE ENDIFENDFUNCTION// ------------------------------------------------------------- //// -=#  ELLPISE  #=-// ------------------------------------------------------------- //FUNCTION drawEllipse: x, y, w, h, colLOCAL dy, xi    w=w/2    h=h/2    x=x+w    FOR dy = -h TO h        xi = w/h * SQR(h*h - dy*dy)        DRAWLINE x-xi, y+dy+h, x+xi, y+dy+h, col    NEXTENDFUNCTION // ELLIPSE// ------------------------------------------------------------- //// -=#  CIRC  #=-// ------------------------------------------------------------- //FUNCTION drawCircle: x, y, r, c    // These values are defined LOCAL: // x, y, r, c LOCAL x1=SIN(0)*r LOCAL y1=COS(0)*r FOR j=1 TO 360    LOCAL x2=SIN(j)*r    LOCAL y2=COS(j)*r    DRAWLINE x+x1,y+y1,x+x2,y+y2,c    x1=x2    y1=y2 NEXT ENDFUNCTION // CIRC`
#62
##### GLBasic - en / Compiler directives?
2008-Jan-16
Hi

Has GLB got any compiler directives for platforms you want to target specific code to ?  I couldn't find anything in the help or forums about it.

For example, I'd like to make one source code project where my target compilation systems would be PC, Mac, GPX and PocketPC.  I'd want to include extra features in the PC and Mac version but not waste the memory by including code I do not want in the GPX and Pocket PC versions.

I found a runtime command ( info\$ = PLATFORMINFO\$(what\$) ) but obviously this is not changing what is compiled.

If there's not a method of targeting code for specific platform(s) do you think it is a possibility for a future version?  Would be handy to be able to use one project and not have to split / spread source code over separate projects to achieve the same result (or produce a bloated exe especially as GPX/PocketPC have limited memory).

eg:

#IF PLATFORM=GPX OR PLATFORM=POCKETPC

REM some code only compliled for GPX and POCKETPC

#ELSE

REM code compiled only for any other platform

#ENDIF
#63
##### GLBasic - en / Const
2008-Jan-13
I see const (lowercase) is recognised in the editor color coding.  I assume for inline C?  Any chance of having a GLB version too?

For example

INLINE
const int xorigin = 320;
const int yorigin = 240;
ENDINLINE

But I'd like (or somegthing similar)

CONST xorigin = 320
CONST yorigin = 240

So I can define my global constants somewhere (or even local ones in functions) rather than waste memory on variables.
#64
##### GLBasic - en / Loadanim Drawanim
2008-Jan-07
A new update is available - boy do you work quick!

// New Command:
// LOADANIM, DRAWANIM - Tilesets solved internally

Thank you!!!  I'll start playing with these in the morning

All we need now is compatibility with SprColl and the rotation / scaling versions.  But thank you so much!!
#65
##### GLBasic - en / Pocket PC / WinCE compile questions
2008-Jan-06
Hi - new owner of the Premium SDK so thought I'd try out the Pocket PC compilation.

I've SETSCREEN 240,320,0 which is my PocketPC's resolution (a Garmin iQue M4) and it compiled with quite a lot of compiler messages.  Doe these look OK:

Code (glbasic) Select
`*** Configuration: WINCE ***precompiling:GPC - GLBasic Precompiler V.2007.348 - 3D, NETWordcount:46 commandscompile+link:C:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (4384): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A7000, reserve_size 28672, allocsize 28672, page_const 4096     11 [main] gcc 6096 sync_with_child: child 4384(0x138) died before initialization with status code 0x1 119615 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (4324): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A7000, reserve_size 28672, allocsize 28672, page_const 40961378710 [main] gcc 6096 sync_with_child: child 4324(0x140) died before initialization with status code 0x11624715 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (4104): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A7000, reserve_size 28672, allocsize 28672, page_const 40963885862 [main] gcc 6096 sync_with_child: child 4104(0x154) died before initialization with status code 0x14133487 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (5212): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A7000, reserve_size 28672, allocsize 28672, page_const 40968498217 [main] gcc 6096 sync_with_child: child 5212(0x13C) died before initialization with status code 0x110830797 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (2400): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A7000, reserve_size 28672, allocsize 28672, page_const 409612102893 [main] gcc 6096 sync_with_child: child 2400(0x128) died before initialization with status code 0x112347905 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (440): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A8000, reserve_size 32768, allocsize 32768, page_const 409614882430 [main] gcc 6096 sync_with_child: child 440(0x160) died before initialization with status code 0x115061058 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (3204): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A8000, reserve_size 32768, allocsize 32768, page_const 409616326270 [main] gcc 6096 sync_with_child: child 3204(0x134) died before initialization with status code 0x116569464 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (532): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A8000, reserve_size 32768, allocsize 32768, page_const 409618833737 [main] gcc 6096 sync_with_child: child 532(0x130) died before initialization with status code 0x119076481 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (5044): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9A8000, reserve_size 32768, allocsize 32768, page_const 409623486645 [main] gcc 6096 sync_with_child: child 5044(0x154) died before initialization with status code 0x123583537 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (6076): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9AA000, reserve_size 40960, allocsize 40960, page_const 409624907286 [main] gcc 6096 sync_with_child: child 6076(0x154) died before initialization with status code 0x125090619 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (5072): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9AA000, reserve_size 40960, allocsize 40960, page_const 409626354332 [main] gcc 6096 sync_with_child: child 5072(0x168) died before initialization with status code 0x126597699 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpC:\Program Files\GLBasic\Compiler\platform\WinCE\Bin\gcc.exe (3432): *** couldn't allocate cygwin heap, Win32 error 0, base 0x9A0000, top 0x9AA000, reserve_size 40960, allocsize 40960, page_const 409628861211 [main] gcc 6096 sync_with_child: child 3432(0x160) died before initialization with status code 0x129105842 [main] gcc 6096 sync_with_child: *** child state waiting for longjmpsuccess_______________________________________*** Finished ***Time: 35.2 secBuild: 1 succeeded`I compiled as WinCE - I presume that WINCE_MediaQ is for a compaq device?

Anyway it runs on my pocket PC, but I notice a few oddities:

1. The screen is on its side.

On my PC my window is 240 x 320 so it is taller than it is wide.  I have some sprites moving across from left to right.

On the PocketPC the window is full screen (fine) but the text and sprites I am displaying start from the bottom left and go up to top right - its on its side.  X, Y = 0 is the bottom left of my screen, x=320, y=240 is the top right of my screen.  Shouldn't it be top left is X/Y = 0 and bottom right is x=240 and y=320 ?  Do you see what I mean.

I'm also testing for left and right cursor keys.  These work on the pocket PC but they are orientated with the screen, so up and down on the physical unit are acting as left and right to stay in-line with the orientation of the GLBasic's screen.

I guess it makes sense for it to be orientated that way as a games device but what if I want it to be portrait in orientation rather than landscape?  Is there an option I am missing for this?

2. Close box in top right but does not work

There is a close box at the top right of the physical unit.  I click this with the pen but nothing happens.... I can't end my program without reseting my PocketPC.   I am not issueing a hide or show of mouse pointer... do I need to?

3. Alpha PNG's not working

I have an alpha channel on a PNG, this is displaying as WHITE solid.  Is this a restriction on the Pocket PC version?  Should I use the transparent colour only and not alpha channels or should they be working?

4. Stalled after running for a few minutes

As I was typing this, after some time the app has stopped running.  The screen shows the app, but everything has stopped moving and responding (it seems).

Is there any information on things like this you can point me to?  I could find anything on the forums or the website.  I'm wanting to enter the GPX competition.  What sort of limitations can we expect on that device?  I haven't got one to test with.

BTW, I can get 120 sprites (64x64) on screen before it slows down.  That seems pretty good as my Pocket PC is not the fastest thing on the block.  Any idea what sort of performance we can expect from the GPX devices?
#66
##### GLBasic - en / Uninitialised variables
2008-Jan-05
Is there an option to force GLBasic to throw an error or warning if you reference and uninitialised variable in the code?  It's one of those things that can lead to mind-boggling annoying errors in your own code when you misspell one of your own variables!

Blitzmax has strict and superstrict to deal with this.
#67
##### GLBasic - en / Quickie questions
2008-Jan-05
Hi

For cross platform development, GLBasic looks to be an easy and simple way to do the job.  I'm impressed by it so far.  I've just a few questions which I wasn't sure about after looking through the examples and I could not find anything specific on the website that answers them so I hope you don't mind me asking these (perhaps obvious) questions here... I've also sneaked in a couple of enhancement requests...

SPRITES - does GLBasic attempt to use any hardware acceleration (eg: your 3D card) if it is available or is it always software rendering it?  I see there is an X_SPRITE but I'm not going anywhere near the 3D stuff yet.

LOADSPRITE, LOADSOUND and LOADFONT all use an index number that we must specify ourselves.  How does GLBasic handle these indexes internally.  For example if I use LOADSPRITE "Blah.png", 1000, will GLBasic store  1000 pointers in memory all null except for number 1000?  Is there a limit on the number of sprites you can have.  Every graphic item you want to display has to be a sprite too right?

Types look great.  Any possibility of expanding them in the future to allow for methods also, so the following might work:

Code (glbasic) Select
`TYPE Enemy  xpos  ypos  FUNCTION display: string\$  PRINT string\$, xpos, ypos  ENDFUNCTION ENDTYPE   LOCAL test AS Enemy  Test.xpos =10 test.ypos =4 test.display("Hello Object World")  SHOWSCREEN MOUSEWAIT`This one is a bug/request - any chance of making the Backspace key work in the editor when holding SHIFT key?  I find it obstructive for it to do nothing when holding SHIFT.

Another enhancement request, unless I've missed it, you have to handle the animation of sprites yourself by switching the sprite number displayed.  Could you extend the DRAWSPRITE command set to handle an optional frame number too.  Eg:

Code (glbasic) Select
`LOADANIMATEDSPRITE "SpriteStrip.png", width, height, 0  // width and height of each sprite in the sheetDRAWSPRITE 0, x, y, frameNumber`LOADANIMATEDSPRITE would be a new command to specify the width and height of each sprite in the spritesheet.  The spritesheet would need to the right size, so for example I could make a PNG that is 64 by 32 in size.  I would split this into a grid of 16 x 16 giving me 4 columns and 2 rows.  GLBasic would number each cell in the spritesheet from 1 to 8 if I load it in with LOADANIMATEDSPRITE "SpriteSheet.png", 16,16, 0

You'd need to update other commands such as the SPRCOLL, GRABSPRITE etc to also be able to specify an optional frame number.  When a user omits this, then frame 1 is assumed - which you'd also need for normal sprites that have been loaded with the normal LOADSPRITE command.

I think this is much needed functionality so that I don't have to load each frame of my animations into separate sprites.

Finally, has anyone written a function to allow me to draw part of a sprite simply so that I don't have to use the STARTPOLY-POLYVECTOR-ENDPLOY commands?  I'm looking for something like COPYSPRITE spr, x, y, startx, starty, width, height  where x and y are where the sprite will be displayed on screen, startx and starty the part of the sprite to copy from for the witdh and height.  Would be handy to have something like this built in like we have for STRETCHSPRITE and ZOOMSPRITE.
#68
##### GLBasic - en / Linking error (demo)
2008-Jan-02
Hi - I get the following error when I try to run any code... this is from the hello world example:

Code (glbasic) Select
`*** Configuration: WIN32 ***precompiling:GPC - GLBasic Precompiler V.2007.348 - 2D, WIN32Wordcount:3 commandscompiling:linking:/mingw/lib/crt2.o:crt1.c:(.text+0x167): undefined reference to `__cpu_features_init'*** FATAL ERROR - Please post this output in the forum_______________________________________*** Finished ***Time: 4.9 secBuild: 0 succeeded*** 1 FAILED ***`Any suggestions?