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 - Bursar

In my code I have:
Code (glbasic) Select
gkeyDesc$[86] = "\\"
It causes my app to close down as soon as it gets to that line. If I comment out that line, it works fine.
The same happens if I use "\"" to try and get a quote symbol into a string.

Using a single \ I get a syntax error when trying to compile. Am I making another school boy error?
I'm trying to use GENSPRITE() to make assigning numbers to sprites easier, but it just crashes my game.

If I do this:
Code (glbasic) Select

GLOBAL menuPointerSprite = GENSPRITE()
LOADSPRITE "/Menu/pointer.png", menuPointerSprite

As indicated in the help file, the game compiles correctly, but when it runs I just get the spiny circle icon, and my app never appears. I have to go into Task Manager and kill it off.

I've also tried this:
Code (glbasic) Select

GLOBAL menuPointerSprite = 0
menuPointerSprite = GENSPRITE()
LOADSPRITE "/Menu/pointer.png", menuPointerSprite

My game compiles and runs, but it always assigns 0 to menuPointerSprite.

For instance:
Code (glbasic) Select

GLOBAL screenGrab = 0
screenGrab = GENSPRITE()

GLOBAL menuPointerSprite = 0
menuPointerSprite = GENSPRITE()
LOADSPRITE "/Menu/pointer.png", menuPointerSprite

PRINT screenGrab, 10,10
PRINT menuPointerSprite, 10,20

Shows me that both screenGrab and menuPointerSprite are equal to 0. I don't think I'm doing anything wrong (famous last words!)...

This is running under Windows 7 Ultimate, 64bit.
So it's a rubbishy title, but what did you expect from an Asteroids clone? ;)

Couple of screenshots attached so you can see what it looks like. Download linkage (3MB) is here

Source code now available:

Makes use of MrTAToads vector code and PeeJays bitmap font routine - thanks guys, the game looks much because of that :)

[attachment deleted by admin]
So here's the output from a quick blast at my current game:
Code (glbasic) Select
                Date     Time       QuerPerfFreq
         Sep 11 2010 08:37:18               2610
            Function    Calls Tot.with childs[s] Exec.only[s] Av.Exe[s/call]
TVector_GetNextIndex   352821              0.000        0.000          0.000
                Line   352821              0.000        0.000          0.000
     TVector_Display    40411              0.000        0.000          0.000
        TVector_Load        9              0.000        0.000          0.000
            playGame        1             62.335       60.579         60.579
          startLevel        3              0.000        0.000          0.000
      __MainGameSub_        1             65.938        0.017          0.017
     playerCrashRock     3492              0.000        0.000          0.000
         spawnPlayer      243              0.000        0.000          0.000
      playerShotRock     4923              0.000        0.000          0.000
       playerShotUFO     4923              0.000        0.000          0.000
          displayHUD     3731              0.000        0.000          0.000
updatePlayerBullets     3731              0.000        0.000          0.000
         playerShoot       94              0.000        0.000          0.000
       explodePlayer        2              0.000        0.000          0.000
        updateSparks     3731              0.000        0.000          0.000
        createSparks      363              0.000        0.000          0.000
        updatePlayer     3731              0.000        0.000          0.000
       defineGlobals        1              0.052        0.052          0.052
     loadRockVectors        1              0.002        0.000          0.000
             cirColl    35140              0.000        0.000          0.000
           startGame        1              0.001        0.001          0.001
         displayMenu        1              3.501        3.400          3.400
CalculateKern_fancy        1              0.015        0.015          0.015
            DrawChar    49518              0.000        0.000          0.000
            DrawText     8747              0.001        0.001          0.000
           RightText     3762              0.000        0.000          0.000
           TextColor      209              0.000        0.000          0.000
           TextAlpha        1              0.000        0.000          0.000
             AddFont        1              0.030        0.014          0.014
         updateRocks     3940              0.000        0.000          0.000
          spawnRocks       15              0.000        0.000          0.000
    updateExplosions     3731              0.000        0.000          0.000
         explodeRock       28              0.000        0.000          0.000
            spawnUFO        1              0.000        0.000          0.000
           updateUFO     3731              0.000        0.000          0.000
               Total   883860            131.875       64.079

Am I right in thinking that despite there being over 350,000 calls to TVector_GetNetIndex, because the times are all 0.00, it's not causing any particular delays in my code?

I'm just trying to figure out why I'm getting some rather random looking stuttering/lag on screen and some rather variable frame rates, despite having set the FPS limiter to 60. My FPS counter shows that the game is fluctuating constantly between about 49FPS and 97FPS. (it's an Asteroids game, so imagine the player just sitting in the middle with a few asteroids making their way across the screen. I'd have thought after a second or two, things would have calmed down and the game would run at a more or less constant rate. If I were constantly creating and destroying objects, I could maybe understand spikes and dips, but not when the game is sitting doing very little.

I appreciate it's a little difficult for you guys to guess stuff sithout seeing my code, but if you have any starting points that I can use to figure out what be causing this problem, I'd appreciate it.

Edit -> OK, so I've found the cause of the stuttering, but I'm not sure how to fix it.

When my game starts up, I use PlayMusic to set an MP3 file looping in the background. This plays whilst the player is on the menu screen, but I don't want it to play during the game. When the player starts the game proper, one of the last calls the menu function makes is to StopMusic. The music stops, but that's what introduces the lag.

As soon as I comment out the StopMusic command, I get a constant 60FPS all through my game. I've tried moving the StopMusic command around, but it doesn't seem to help. Anyone else had this, or is it just me?

Edit 2 -> Changed thread title to something more appropriate
Apologies if this is covered somewhere, but documentation seems to be a bit lacking, and tracking down the commands I'm looking for seems to be a bit of a hit and miss affair.

I was wondering if there's some way of changing the colour or 'tint' of a sprite? For instance I could have a white bullet sprite, but use GLB to tint it different colours based on who fired it.

Would save having to double up on sprites just so I can change the colour.
I'm in need of a bit of maths help. I have an vague notion of what's needed, but not how to implement it. I have a player (created using the Vector Editor by MrTaToad). It sits staionary in the middle of the screen, but as I move the mouse around, the player rotates to face the pointer. When I click, the player fires a bullet (also a Vector Editor object) towards the pointer. The bullet is correctly angled, and moves in the right direction.

So the bit I need help with... When the player is facing right, the bullet needs to be offset 11 pixels * scale in order to appear at the end of the player gun (so offset is x=11*scale, y=0*scale). Now I can't just add 11*scale as it all goes wrong as the player rotates. I'm guessing I need to use SIN and COS, but they confuse the heck out of me, so a point in the right direction (no pun intended!) would be appreciated :)

Ofcourse the other option is that I have a 'handle' on the player (that I create with the Vector Editor) at the gun location, and I can retrieve it's actual screen position and place the bullet there.