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.

Show posts Menu

Topics - AndyH

Ian's set a precedent for translations, so I was wondering if you could help out with translations for the following?

Code (glbasic) Select
0 English Deutsch French
4 OPTIONS Einstellungen
5 QUIT   Beenden
10 MUSIC Musik
11 ON    Ein
12 OFF   Aus
15 Introducing Ms Fangs
16 Eat the fruit
17 Oh no, here come the germs
18 HA HA HA, that scared them
19 Eat the apples for an extra life
20 Fire button increases speed
21 Eat fruit in sequence for big scores
I've filled in the blanks where they've already been answered in the other thread.  If anyone is also able to help with a French translation I'll put that in too.  "Ms Fangs" and "Germs" are the names of the characters in the game so probably don't need a translation.
Hi Gernot

Stu has been testing my game on his HTC Touch smart phone - running Windows 6.  The LOADBMP command doesn't appear to be working, but all other commands (LOADSPRITE etc) are working fine.  I'm storing the pictures (as PNG's) in a shoebox (named ovine.ram) and use:

LOADBMP "ovine/splash.png"

To load it in but on the HTC it is not displayed.  It is working fine on my Pocket PC's and on Windows.

Any ideas?
Is there anyone out there that could run this code on their GP2X's and report back what Frame Rates you get?

Code (glbasic) Select
SETSCREEN 320,240,0

GLOBAL mb,ma,mx,my


MOUSESTATE mx,my,ma,mb




FUNCTION printfps:l_x,l_y

STATIC fps_time,fps_counter,s_FPS,fps_temp
    fps_time = GETTIMERALL()
    fps_counter = fps_counter + 1
        IF (fps_time-fps_temp)>1000
                fps_temp = fps_time
                s_FPS = fps_counter
                fps_counter = 0
PRINT s_FPS+" Frames",l_x,l_y
        RETURN s_FPS
GLOBAL     Seconds,Minutes,Hours,Days,FR,timeK,time1,frames
    IF time1>1000;
        FR=INTEGER(frames); frames=0;
        IF Seconds>59; Minutes=Minutes+1; Seconds=0; ENDIF;
        IF Minutes>59; Hours=Hours+1; Minutes=0; ENDIF;
        IF Hours>23; Days=Days+1; Hours=0; ENDIF;
        PRINT " FPS: "+FR,X,Y
I've placed a LIMITFPS of 60 in the code.  There's nothing going on but a SHOWSCREEN (which I am guessing will be copying the whole backbuffer data to the display).

On my two pocketpc's (not particularly high spec) I get:

Mio = 32 FPS
Garmin = 42 FPS

Wondering what I should expect for the two types of GP2X?  I can compensate the speed for when the game runs as PocketPC/GP2X and Desktops.

Question for Gernot:- the SHOWSCREEN will not go any faster than my desktop refresh rate (60Hz) even when the LIMITFPS is set higher so it must be tied to the VBL.  Is it possible to add a command to not limit the the monitor refresh rate?  I know it will make the display more choppy, but useful to have in some scenarios (especially 3D).
The scale parameter doesn't work right on ROTOZOOMANIM

ROTOZOOMANIM 2,0, 100,70,0,0.5

This prints the sprite at normal size.  Should be half size.

ROTOZOOMANIM 2,0, 100,70,0,1

This prints the sprite at double size.  Should be normal size.

It's just Scale that doesn't work right.  Angle seems ok.
I'm drawing a rectangle using the transparent colour and then drawing a sprite inside that.

I'm then using GRABSPRITE followed by SAVESPRITE but I get a line of pixels at the top and left of the image that are slightly off the transparent color (255,0,128).  Here's an example:

Found the problem is if I draw at 0,0 and grab from there.  If I draw at 3,3 (away from the top left) and then grab from this position the lines disappear.  Can this be fixed at all?

Another odd thing, I can change what the transparent color is when I use LOADSPRITE or GRABSPRITE with the SETTRANSPARENCY command but there something odd is going on which I can't put my finger on.  

Here's some examples with SAVESPRITE and using a different transparent colour:

This one is where I set the transparency color to 0,0,10 and the color used in the DRAWRECT the same.

This one is where I set the transparency color to 0,0,128 and the color used in the DRAWRECT the same.

This one is a bit odd.  Set the color to 215,0,128 and my sprite when loaded back in does not suffer the border at the top and left like issue #1 reported above.  However, if I put SETTRANSPARENCY RGB(255,0,128) after I have done GRABSPRITE'd and SAVESPRITE and LOADSPRITE, I get the border problem as described in issue #1.  The help file for SETTRANSPARENCY says that this command should only affect the LOADSPRITE and GRABSPRITE.  So perhaps there is a bug with this too?  I'm getting so many different results it is hard to see what is actually happening.
I use:

SETSHOEBOX "gfx.sbx", "music.sbx"

"music.sbx" has been shoeboxed from a folder called "music" and contains an MP3 file.

I use PLAYMUSIC "music/track1.mp3" and I get no music playing.  If I put the music folder back in with the file, the music plays.  Not tried PLAYMOVIE.  Everything in my data shoebox (gfx.sbx) seems to work ok, just the media shoebox having this problem.

This is on Windows.
This is possibly related to the issue with LOCAL where the function is run twice, only this one causes a crash of your program with no explanation:

Code (glbasic) Select
GLOBAL fff  = test()
Caused me no end of headaches tracking this down.

Workaround for now - declare your GLOBAL's (and LOCAL's) and then assign a value to them on a separate line.

fff  = test()
Put this code in

Code (glbasic) Select
TYPE test
Notice the lower case aa.

Now add this code, notice the upper case AA:

Code (glbasic) Select


and the typaa in the TYPE changes blue (or the colour of your functions in the editor) and is now typAA and your code will not compile.

Same happens if you just enter typAA: for a label.
Hi all - bit of a delay in posting this (away at family party) and I haven't finished the bits I wanted to yet (collisions and text print still to do) but here's the BMax-like wrapper I was talking about.

It contains a combination of code I've written, with code found on the forums integrated or modified to fit in.

You have to call oInitialiseSprites() at the start of your program to set up some values.  In BMax I would just write code 'outside' of a function in the sprites include file and it would be run but I don't think GLB supports that (include files must only contain functions, types and global declarations from what I can tell).

Once you've called the initialise function, you are free to start using the functions within.  Note that you must use the functions to load sprites or animations, otherwise you'll get conflicts.

Here's a brief summary of what the functions allow you to do:

= oLoadSprite( "filename" )  // load a single sprite, returns an ovine sprite Id (not a GLB sprite id) for you to reference your sprite

= oReserveSprite()  // just returns and ovine sprite Id - useful if you want to manipulate sprites yourself such as with GRABSPRITE but don't want to load a sprite in - just creates the place holder for it

= oLoadTiles( "filename", width, height ) // load a tilestrip in, returns the ovine sprite Id - uses LOADANIM and keeps the tiles/frames in one sprite.  Tilestrips can not (currently) be rotated, scaled or have colour applied to it.  It is intended for drawing game levels from tilemaps or simple animation.   Gernot has added a function to allow ANIM's to be rotated and scaled so I'll update this to allow that.  If Gernot can also give us the colour parameter for ROTOZOOMANIM (as I believe it uses POLYVECTOR) then this could support the colour modifier too.

= oLoadAnim( "filename", width, height ) // load an animation strip in, returns the ovine sprite Id.  Internally, each animation frame is GRABSPRITE'd into it's own sprite.  This allows the use of rotate, zoom and colour modification commands.  There appears to be a bug with GRABSPRITE where coloured pixels bordering with transparent pixels are altered in the GRABSPRITE version of the sprite which only appears with ZOOM or ROTATION is used.  I'm hoping Gernot will fix this.

oAutoMidHandle( TRUE or FALSE )  // set whether auto mid-handle (the pivot point) is on or off -  automatically sets the handle to the middle of the sprite if TRUE when oLoad.... functions are used.

oSetHandle( ovineSpriteId, hx, hy )  // allow you to set the handle (pivot point) to a specific X and Y position of a sprite / tilemap already loaded in with one of the oLoad... functions

oMidHandle( ovineSpriteId ) // set the handle to the mid-point of the supplied ovine sprite Id

oSetScale( scale ) // set the scale for all sprite drawing from this point on (excludes tilemaps currently).  1=normal, 0.5 = half size, 2.0 = double size

oSetRotation( angle ) // set the rotation for all sprite drawing from this point on

oSetColor( rgbValue ) // sets the colour modifier for all sprite drawing from this point on ( RGB(255,255,255) will draw the sprite normally, RGB(255,0,0) will make the sprite Red etc)

oSetPrecision( TRUE or FALSE ) // if TRUE - your game will use the real SIN / COS functions supplied by GLB.  If FALSE, will use the QSIN and QCOS variants which may be faster on some platforms (eg: GP2X) but with less accuracy.  I've not noticed a problem with these.

oDrawSprite( ovineSpriteId, xPos, yPos, Frame ) // draws the sprite at the X and Y position, with the handle, colour, rotation and scale as set previously.  Note that on platforms that have hardware accelerated support (Windows, Mac, Linux) the rotation, scale and colour modifiers will be pretty quick.  On GP2X, PocketPC and Smart Phones you are advised to use these sparingly as it will all be done in software.


If you have used BMax then the above may not need much explanation.  Here's a brief example of the commands:

Code (glbasic) Select

oAutoMidHandle(TRUE)  // from this point on, all oLoad... commands will set the handle to the centre of the sprite

spr1 = oLoadSprite("sprite1.png") // load a single frame sprite in, variable spr1 contains the Id of that ovineSpriteId
spr2 = oLoadSprite("sprite2.png") // load a second single frame sprite in

oSetHandle( spr2, 16,0 ) // change the handle (pivot point) of sprite 2 to be 16 across, 0 down

oAutoMidHandle(FALSE)  // from this point on, all oLoad/// commands will leave the handle at top/left (0,0)

spr3 = oLoadAnim("player.png", 32,32, 10) // load an animation for the player in this example, where each frame is 32x32 in size and there are 10 frames to load in.

oSetHandle (spr3, 16,32 ) // set the handle for all frames in this animation to the bottom centre (where his feet are)

oSetPrecision( FALSE ) // use the quick QCOS/QSIN functions for rotations and scale

oDrawSprite( spr1, 320, 240, 1 ) // draw the sprite at the centre of the screen (assuming 640x480 game window) but it's handle will mean it will be centred too.  It only has one frame cause we used oLoadSprite

oSetScale( 2 ) // set scale to 2
oSetRotation( 45 ) // set angle
oSetColor( RGB(0,255,128) ) // lets tint the colour value
oDrawSprite( spr2, 320, 240, 1 ) // draws this sprite at a scale of 2, 45 degree angle with a greeny-blue tint
// more sprite drawing from this point on would use same scale, rotation and color values until you set them to a different value

// now a for loop
oSetColor( RGB(255,255,255) )
FOR t = 1 TO 20
  oSetScale (t / 10) // set the scale
  oSetRotation( t * 18 ) // set the scale
  oDrawSprite( spr3, t*40, 100, MOD(t, 10) ) // draw frames from the animation going across the screen using current scale+rotation
// put everything back

Note that I have used variables spr1, spr2 and spr3 in the example above although these variables could be called anything, or in most cases you'd store them in your own types for access later.  These just store the special ovine sprite Id's returned by function and refers to an array index in oSprites[].  You can write more functions to allow access to this, or access the type'd properties directly if you wish.  Confession: I've not actually tried to run the code above as I've just typed in directly into the forum, but should all work, if not probably just a silly typo on my part  

The code:

Well here it is, I've got this in an include file in my project.  Will add more to this, fix bugs, make changes etc as my game develops.  Feel free to use this in your own games if you want, but would appreciate if you'd share your ideas or improvements with the whole GLB community as the idea of all this is to help make things easier to do :D  As per the usual disclaimers - it's work in progress, will probably get optimised as time goes on, and use at your own risk.  

Note: new version(s) can be found in later posts in this thread.  Scroll down to see them.

Code (glbasic) Select
// --------------------------------- //
// Project: A wrapper around SPRITES
// so never need to manage Id's directly
// --------------------------------- //
//   Version:  1.000
// --------------------------------- //
// --------------------------------- //
// Please retain comments-free to use
// these functions in any freeware or
// commercial programs.  Given to the
// community without any warranties
// of any kind.  Please send updates
// or improvements to
// --------------------------------- //

// TODO:
// - PRINT TEXT command (with color and rotation/scaling options)
// - Collision functions - decide to use anim or sprite collide, box collision, point collision with box, point collision with sprite or anim
// (note collisions only work with unscales/rotated sprites/anims)
// note also collisions must take into account the handle!

    id // Sprite Id
    w;h // width and height
    hx;hy // handle X and Y

    maxframes // total num of frames,
    // 0 = Tilemap (use DRAWANIM) - no scale, rotate or color support - but can be used to draw tilemaps quickly
    // 1 = Single Sprite
    // >1 = the count of sprite Id's used, ie:  id+(maxFrames-1) == last sprite Id FOR this animation

GLOBAL oSprites[] AS OSprType

// this global type is used to store settings that modify the way sprites are drawn
TYPE OSpriteSettings
scale // scale for sprite
rotation // current rotation settings for sprite
color // RGB colour to apply (POLYVECTOR)
midHandle // auto-mid handle mode (T/F)
mathPre // maths precision (TRUE = use real COS/SIN, FALSE = use false SIN/COS)

GLOBAL OSprSettings AS OSpriteSettings

FUNCTION oInitialiseSprites:
OSprSettings.color = RGB(255,255,255)
OSprSettings.scale = 1.0
OSprSettings.rotation = 0
OSprSettings.midHandle = TRUE
OSprSettings.mathPre = TRUE


// starts at SPRITE ID = 1, Sprite Id = 0 is reserved for loading
@FUNCTION _GetNextSpriteID:
STATIC _oSprNextId
INC _oSprNextId, 1
    RETURN _oSprNextId

// Get next oSprites, starts at 0
STATIC  _oSprNextArrayId
INC _oSprNextArrayId, 1
    RETURN (_oSprNextArrayId - 1)

// --------------------------------- //
// Project: Loading routines - only load
// sprites at start or when not in middle
// of a gameloop where you are updating the
// screen - do not load sprites directly
// with the GLB LOADSPRITE command
// --------------------------------- //
FUNCTION oLoadSprite: _file$
LOCAL num = _GetNextSpriteID()
    LOADSPRITE _file$,
    t.maxframes = 1  // defines a single sprite
    IF OSprSettings.midHandle
    t.hx = t.w/2
    t.hy = t.h/2
    t.hx = 0
    t.hy = 0
    DIMPUSH oSprites[], t
    RETURN _GetNextOSprID()

// used to reserve a sprite Id and slot for own use (eg: if you want to GRABSPRITE)
FUNCTION oReserveSprite:
LOCAL num = _GetNextSpriteID()
t.maxframes = 1  // defines a single sprite
    t.w = 0
    t.h = 0
  t.hx = 0
  t.hy = 0
    DIMPUSH oSprites[], t
    RETURN _GetNextOSprID()

FUNCTION oLoadTiles: _file$, _w, _h
LOCAL num = _GetNextSpriteID()
    LOADANIM _file$,, _w, _h
    t.maxframes = 0 // defines a tilemap of frames in a sprite
    IF OSprSettings.midHandle
    t.hx = t.w/2
    t.hy = t.h/2
    t.hx = 0
    t.hy = 0
    DIMPUSH oSprites[], t
    RETURN _GetNextOSprID()

FUNCTION oLoadAnim: _file$, _w, _h, _maxframes
    LOADANIM _file$, 0, _w, _h

FOR i=0 TO _maxframes-1
DRAWRECT 0,0, _w,_h, RGB(0,0,0) // transparent colour
DRAWANIM 0, i, 0,0
LOCAL nextSprite
nextSprite = _GetNextSpriteID()
IF = 0 THEN = nextSprite
GRABSPRITE nextSprite, 0,0, _w,_h
    t.maxframes = _maxframes // defines a sequence of grabbed sprites
    t.w = _w
    t.h = _h
    IF OSprSettings.midHandle
    t.hx = t.w/2
    t.hy = t.h/2
    t.hx = 0
    t.hy = 0
    DIMPUSH oSprites[], t
    LOADSPRITE "", 0 // clear out temporary sprite from memory
    RETURN _GetNextOSprID()

// - Modifiers
FUNCTION oAutoMidHandle: x
OSprSettings.midHandle = x

FUNCTION oSetHandle: _sprId, _hx, _hy
oSprites[_sprId].hx = _hx
oSprites[_sprId].hy = _hy

FUNCTION oMidHandle: _sprId
oSprites[_sprId].hx = oSprites[_sprId].w/2
oSprites[_sprId].hy = oSprites[_sprId].h/2

FUNCTION oSetScale: _scale
OSprSettings.scale = _scale

FUNCTION oSetRotation: _rotation
OSprSettings.rotation = _rotation

FUNCTION oSetColor: _color
OSprSettings.color = _color

FUNCTION oSetPrecision: x
OSprSettings.mathPre = x

FUNCTION oDrawSprite: _spr, _x, _y, _frame
SELECT oSprites[_spr].maxframes
CASE 0 // -------- A tilemap --------
DRAWANIM oSprites[_spr].id, _frame, _x - oSprites[_spr].hx, _y - oSprites[_spr].hy

DEFAULT // -------- A Sprite --------

LOCAL dframe
IF _frame > oSprites[_spr].maxframes - 1
dframe = oSprites[_spr].maxframes - 1
dframe = _frame
sprId = oSprites[_spr].id + dframe

IF OSprSettings.color <> RGB(255,255,255)
// must use polyvector to draw the sprite
_oRotoZoomPoly( _spr, sprId, _x, _y, OSprSettings.rotation, OSprSettings.scale, OSprSettings.color)

ELSEIF OSprSettings.scale = 1 AND OSprSettings.rotation <> 0
// must use ROTOSPRITE
_oRotoPivot( _spr, sprId, _x, _y, OSprSettings.rotation)

ELSEIF OSprSettings.scale <> 1 AND OSprSettings.rotation = 0
// must use ZOOMSPRITE
_oZoomSprite( _spr, sprId, _x, _y, OSprSettings.scale)

ELSEIF OSprSettings.scale <> 1 AND OSprSettings.rotation <> 0
_oRotoZoomPivot( _spr, sprId, _x, _y, OSprSettings.rotation, OSprSettings.scale)

DRAWSPRITE sprId, _x - oSprites[_spr].hx, _y - oSprites[_spr].hy


// TODO : Optimise this
@FUNCTION _oZoomSprite: _spr, _id, _x, _y, _scale
LOCAL sx, sy,  hx,hy

    sx = oSprites[_spr].w / 2
    sy = oSprites[_spr].h / 2

    hx = oSprites[_spr].hx
    hy = oSprites[_spr].hy

    DEC hx, sx
    DEC hy, sy

    hx = hx * _scale
    hy = hy * _scale

ZOOMSPRITE _id,  _x-hx-sx, _y-hy-sx, _scale, _scale


@FUNCTION _oRotoZoomPivot: _spr, _id, _x,_y, _angle, _scale
LOCAL sx, sy, rx,ry, px,py
LOCAL cosp, sinp


    sx = oSprites[_spr].w / 2
    sy = oSprites[_spr].h / 2

    px = oSprites[_spr].hx
    py = oSprites[_spr].hy

    // reverse rotate pivot point arount center
    // of sprite
    DEC px, sx
    DEC py, sy
    rx = (px*cosp + py*sinp) * _scale
    ry = (py*cosp - px*sinp) * _scale

    // adjust center
    INC rx,sx
    INC ry,sy

    // perform drawing
    ROTOZOOMSPRITE _id, _x-rx, _y-ry, _angle, _scale


FUNCTION _oRotoZoomPoly: _spr, _id, _x,_y, _angle, _scale, _col
LOCAL sinp, cosp, spw, sph, dx, dy
LOCAL hx, hy, dxp, dxm, dyp, dym

    sinp = QSIN(_angle)
    cosp = QCOS(_angle)

    spw = oSprites[_spr].w
    sph = oSprites[_spr].h


    hx = (dx - oSprites[_spr].hx)
    hy = (dy - oSprites[_spr].hy)

    dxp = (dx+hx) * _scale
    dxm = (dx-hx) * _scale
    dyp = (dy+hy) * _scale
    dym = (dy-hy) * _scale

    POLYVECTOR _x - cosp * dxm - sinp * dym,   _y - cosp * dym + sinp * dxm,   0,   0,    _col
    POLYVECTOR _x - cosp * dxm + sinp * dyp,   _y + cosp * dyp + sinp * dxm,   0,   sph,  _col
    POLYVECTOR _x + cosp * dxp + sinp * dyp,   _y + cosp * dyp - sinp * dxp,   spw, sph,  _col
    POLYVECTOR _x + cosp * dxp - sinp * dym,   _y - cosp * dym - sinp * dxp,   spw, 0,    _col


FUNCTION _oRotoZoomPolyBAK: _spr, _id, _x,_y, _angle, _scale, _col
LOCAL sphi, cphi, spx, spy, dx, dy

    spx = oSprites[_spr].w
    spy = oSprites[_spr].h

    LOCAL hx, hy
    hx = (spx/2-oSprites[_spr].hx)*_scale
    hy= (spy/2-oSprites[_spr].hy)*_scale
//    hx = ((spx/2)*_scale)-(oSprites[_spr].hx*_scale)
//    hy= ((spy/2)*_scale)-(oSprites[_spr].hy*_scale)

    POLYVECTOR _x - cphi* (dx-hx) - sphi* (dy-hy),  _y - cphi*(dy-hy) + sphi*(dx-hx),   0,   0,   _col
    POLYVECTOR _x - cphi* (dx-hx) + sphi* (dy+hy),  _y + cphi*(dy+hy) + sphi*(dx-hx),   0,   spy, _col
    POLYVECTOR _x + cphi* (dx+hx) + sphi*(dy+hy),   _y + cphi*(dy+hy) - sphi*(dx+hx),   spx, spy, _col
    POLYVECTOR _x + cphi* (dx+hx) - sphi*(dy-hy),   _y - cphi*(dy-hy) - sphi*(dx+hx),   spx, 0,   _col


@FUNCTION _oRotoPivot: _spr, _id, _x, _y, _angle
LOCAL sx, sy, rx,ry, px,py
LOCAL cosp, sinp


    sx = oSprites[_spr].w / 2
    sy = oSprites[_spr].h / 2

    px = oSprites[_spr].hx
    py = oSprites[_spr].hy

    DEC px, sx
    DEC py, sy

    rx = px*cosp + py*sinp
    ry = py*cosp - px*sinp

    INC rx,sx
    INC ry,sy

    ROTOSPRITE _id, _x-rx, _y-ry, _angle


IF OSprSettings.mathPre THEN RETURN SIN(x)

    WHILE x>360.0;  DEC x, 360.0; WEND
    WHILE x<0;      INC x, 360.0; WEND
    IF x>180.0 THEN x = 180.0-x

    x = x/57.296
    x = 1.2732 * x -0.4053 * x * ABS(x)

x = 0.225*(x*ABS(x)-x)+x

IF OSprSettings.mathPre THEN RETURN COS(x)

float qInvSqrt(float x){
   float xhalf = 0.5f * x;
   int i = *(int*)&x; // store floating-point bits in integer
   i = 0x5f3759d5 - (i >> 1); // initial guess for Newton's method
   x = *(float*)&i; // convert new bits into float
   x = x*(1.5f - xhalf*x*x); // One round of Newton's method
   return x;

return 1.0f / qInvSqrt(y);
Hi Gernot

Can confirm the latest build does co-exist with MinGW finally.  Thanks for that.

The mouse pointer is lost now though, where as it wasn't before.  If I put this command at the top of the game it pops back on again.


Oh and thanks for including the QSIN/QCOS - look like they work fine (tested in Windows) with no noticeable difference!
GLBasic - en / Pivot points
This is the code Gernot made in another post to use polyvector to rotate and scale.

Code (glbasic) Select
FUNCTION RotoZoomPoly: _spr, _id, _x,_y, _angle, _scale, _col
LOCAL sphi, cphi, spx, spy, dx, dy

    GETSPRITESIZE sprid, spx, spy

    // make it act like ROTOZOOMSPRITE
    // if you remove this line, x+y are
    // the center of the rotation
    INC _x, spx/2; INC _y, spy/2

    POLYVECTOR _x- cphi*dx-sphi*dy, _y-cphi*dy+sphi*dx, 0,0, _col
    POLYVECTOR _x- cphi*dx+sphi*dy, _y+cphi*dy+sphi*dx, 0,spy, _col
    POLYVECTOR _x+ cphi*dx+sphi*dy, _y+cphi*dy-sphi*dx, spx,spy, _col
    POLYVECTOR _x+ cphi*dx-sphi*dy, _y-cphi*dy-sphi*dx, spx,0, _col
It calculates the position of the four corners of the bounding rectangle for the angle and scale with the pivot or handle in the centre of the rectangle.  I'm having problems getting the maths right to allow me to specify a different pivot point for the rectangle to rotate around.  eg: the pivot point might be the top left of the rectangle rather than centre.

Can anyone help solve this before my head explodes :P
GLBasic - en / Rotozoomanim
Hi Gernot

You mentioned that ROTOZOOMANIM (when it's complete) will probably use POLYVECTOR's to draw the animation frame at the size and rotation on screen.  If so, could you add an extra parameter for the color.  I'm using PolyVector to draw sprites and use the same color paramater for each of the four corners to allow me to tint the sprite in any colour I want (or RGB 255,255,255 to leave unchanged).

This would be extremely handy and powerful if the ROTOZOOMANIM command could do this too!
Is it possible to turn off the blue cross (the close button) that appears in the corner of PocketPC apps?  In some apps I've made it doesn't do anything when you click on it, others it does.
Hi Gernot.  Here's a small project simulating some of the things my game is doing (couldn't say if it makes much difference having all this in but it's a hard one to pin down and the more that goes on the quicker it seems to happen).

Run this on the PocketPC and it will eventually lock up making the Pocket PC dead until a reset.

I've put a timer in counting from when the program started, it has a flaw as I use  GETTIMERALL() so when subtracting the start time from the current time I display on screen it sometimes goes in to negative numbers.

On my Garmin PocketPC I have recorded the timer at -956.5, 1260.1 and 1264.8 (spookily close to the previous time) when it locks up and stops responding.  This PocketPC freezes up completely.  It has less available memory than the standard 64Mb because it has a proprietary Sat-Nav software that always loads which you can't kill off, but it only shaves off 10Mb at most.

I've now tested on an older Pocket PC (a Mio) and this started to misbehave at -524.7 but it slowed to a crawl initially rather than stopping alll together, taking anything from 2 seconds to 20 seconds to refresh the display but it did keep running (each refresh when it happened was one SHOWSCREEN).  This went on until -50.1 with no refresh until +55.0 when it finally stopped responding all together.  The Mio has more available memory - perhaps the reason.  It's also a slightly older version of Windows. (some times I recorded for each update were -524.7, -503.3, -483.8, -458.1, -446.7 ...)

I ran it a second time just now and it slowed down at -167.0 - I was able to quit out of it while it was still responding (although 2-20 seconds per SHOWSCREEN).

Hope you can track this down, as it's not practical to compile to PocketPC in this state.  Seems like a memory leak.  If so, could this affect every platform that is using the part of the code causing the issue?  I guess on Windows / Mac / Linux there's a lot more memory to soak up ... if it is this.  Maybe it's something else specific to the PocketPC?

Could you add a memory free command at all?  Maybe be useful to display the free available memory to see if that is the problem as it runs?
I've some code that

* draws a rectangle using the transparent color -RGB(255,0,128)
* draws a sprite into that area
* does a grab sprite
* THEN draws this grabbed sprite using ZOOMSPRITE

I get a purple halo around the image where transparent and non-transparent colours meet, included the outer border of the sprite.  I reported this problem as part of another post which was buried and I forgot about it until coming across it again now.

Code (glbasic) Select
// sprite loaded in Id=1
DRAWRECT 0,0, 32, 32, RGB(255,0,128) // transparent colour
GRABSPRITE 1,0,0,32,32

ZOOMSPRITE 1, 100,100, 2,2
Here's a examples:

It doesn't do it if you only do LOADSPRITE, the problem occurs after doing a drawsprite then grabsprite.  Can this please be fixed.
I have more than one source code file in my project.

I did a search in one of them for "LOCAL".  The cursor / window scroll position would appear to move to the first occurance of this word, but it would not highlight it in the editor.  Pressing F3 and the next one is found but it still does not highlight the found word.

Now change to another source file and then back again to the original source file.  The word is now highlighted and pressing F3 to find the next will now correctly highlight each word found.

It seems the bug is pressing Ctrl+F (or choosing the command from the menu) will not highlight the found words until you change to another source code window.
More requests time ;)

Could you add ZOOMANIM, STRETCHANIM, ROTOANIM and ROTOZOOMANIM so we can display a frame from an animation at a different size and rotation please.
Just a small niggle rather than an issue -

If you declare a FUNCTION that does not start on a line, the Green Bar in the margin of the source code editor that will normally mark the start and end of the function will not register.  Instead, the green bar extends upwards to either the next FUNCTION declaration that is at the start of the line, or the top of the code if there isn't one.  Also the Jumps panel in the editor changes from an F(x) icon to a bullet point.

Similarly, if an ENDFUNCTION is not at the beginning of a line the green bar in the editor margin will ignore it and will extend downwards to the next ENDFUNCTION that starts at the beginning of a line.


Code (glbasic) Select
  // this is OK!

  // this FUNCTION is not recognised in the margin of the editor

  // this functions ENDFUNCTION is not recognised in the margin of the editor

  FUNCTION dohdoh:
    // eek! the solution is to put the FUNCTION and ENDFUNCTION in column 0, the start of every line, no spaces or tabs before
The spaces or tabs in front of FUNCTION / ENDFUNCTION's makes the editor not recognise them in the margin color coding.
Could we have a GETANIMSIZE command to return the size of a frame in an ANIM Sprite, much like GETSPRITESIZE returns the size of a sprite.  Run this command on an anim, and it returns the total size of the graphic, not the size of a frame within - which is correct.  Would be useful to have a separate command to get the size of an anim frame.

In addition, could we have a GETANIMFRAMES command to return the number of frames in the animation?
Is it possible to force music to loop.  I've just started testing this today, playing an MP3.  It will play once then stop.

Also, is it possible to detect if music is playing like the SOUNDPLAYING() function?

If not can the above be added?