Blitz Basic to GLBasic

Previous topic - Next topic

johngood

Hi,
Why am I getting the following Precompiling Error?

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::DrawEnemies()':
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:255: error: could not convert `Enm' to `bool'

It has been there in all the above Precompiling outputs.  :sick:

johngood
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB

MrTAToad

Enm sounds like it hasn't been defined locally

Try (in the appropriate function) :

Code (glbasic) Select
LOCAL Enm as SpiderData

johngood

Hi MrTAToad,

Thanks for persisting with me.  =D

Here are my declarations and the Function


TYPE SPIDERDATA
   xpos
   ypos
   animframe
   animcount
   animpause
   speed
   hit
ENDTYPE

GLOBAL spiderdata[] AS SPIDERDATA

GLOBAL Enemy[] AS SPIDERDATA


FUNCTION DrawEnemies:
LOCAL Enm AS SPIDERDATA  // also tried spiderdata
   FOREACH Enm IN  Enemy[]
      DRAWANIM 8,Enm.animframe,Enm.xpos,Enm.ypos
      Enm.animcount = Enm.animcount + 1
      IF Enm.animcount > Enemy_Anim_Pause
         Enm.animcount = 1
         IF Enm.hit = FALSE
            Enm.animframe = 1 - Enm.animframe
         ELSE
            Enm.animframe = Enm.animframe + 1
            IF Enm.animframe >7
               DELETE Enm
            ENDIF
         ENDIF
      ENDIF
      IF Enm
         Enm.ypos = Enm.ypos - Enm.speed
         IF Enm.ypos <15
            GameOver = TRUE
            DELETE Enm
         ENDIF
      ENDIF
   NEXT
ENDFUNCTION


Regards,
johngood.

Code (glbasic) Select

compiling:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `DGInt __GLBASIC__::DrawEnemies()':
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:274: error: could not convert `Enm' to `bool'
*** FATAL ERROR - Please post this output in the forum
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB

MrTAToad

The problem is :
Code (glbasic) Select
IF Enm

Enm will always exist, so checks for existence wont work.  Thus, the function becomes :

Code (glbasic) Select
FUNCTION DrawEnemies:
LOCAL Enm AS SPIDERDATA  // also tried spiderdata
   FOREACH Enm IN  Enemy[]
      DRAWANIM 8,Enm.animframe,Enm.xpos,Enm.ypos
      Enm.animcount = Enm.animcount + 1
      IF Enm.animcount > Enemy_Anim_Pause
         Enm.animcount = 1
         IF Enm.hit = FALSE
            Enm.animframe = 1 - Enm.animframe
         ELSE
            Enm.animframe = Enm.animframe + 1
            IF Enm.animframe >7
               DELETE Enm
            ENDIF
         ENDIF
      ENDIF
     
     Enm.ypos = Enm.ypos - Enm.speed
     IF Enm.ypos <15
        GameOver = TRUE
        DELETE Enm
     ENDIF
   NEXT
ENDFUNCTION

johngood

Thanks to you MrTAToad. :good:

That fixed that error!

I do hope you are not going on holiday as I still have four Functions to debug! ;/

Thanks once again for your much needed help.

Best Regards,
johngood.

Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB

MrTAToad

Dont worry - I'm around.

johngood

Hi it's me again  O_O
At the moment I am working another game and I am Having more problems with TYPE'S again  :sick:

I have created this small program to simplify debugging
if I enable the line PRINT Ship.xpos,100,130 I get the Error below!

With the same line commented out all is fine even the call to InitShip()
does not generate any Errors!
The same happens with Pilot[]
I have also tried it in Version 7.138, no difference.

Regards,
johngood.



Code (glbasic) Select


// --------------------------------- //
// Project: TypeProblem
// Start: Saturday, October 10, 2009
// IDE Version: 6.248

GLOBAL mx%, my%, imouse%, b1%, b2%

TYPE tMouse
x%
y%
active%
ENDTYPE
GLOBAL Mouse[] AS tMouse

DIM Mouse[5]

TYPE SHIP
    xpos
    ypos
    enabled
ENDTYPE

GLOBAL Ship[] AS SHIP
GLOBAL Pilot[] AS SHIP



SETSCREEN 640,480,0
LIMITFPS 30
InitShip()

// Main loop
WHILE KEY(1) = FALSE
UpdateMice()
PRINT "Mouse  X   Y",40,70
PRINT Mouse[0].x, 100,100
PRINT Mouse[0].y, 130,100
//PRINT Ship.xpos,100,130
SHOWSCREEN

WEND



FUNCTION InitShip:
LOCAL dumy AS SHIP
dumy.xpos = 240
dumy.ypos = 600
dumy.enabled = 1
DIMPUSH Ship[], dumy
ENDFUNCTION

FUNCTION UpdateMice:
MOUSESTATE mx,my,b1,b2
Mouse[0].x = mx
Mouse[0].y = my
ENDFUNCTION







compiling:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp: In function `int __GLBASIC__::__MainGameSub_()':
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:24: error: 'class __GLBASIC__::DGArray<__GLBASIC__::SHIP>' has no member named 'xpos'
*** FATAL ERROR - Please post this output in the forum
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB

Moru

Ship[] is an array but you call it as a variable. You need to type:
PRINT Ship[n].xpos, 100, 130

n = the ID of the ship

johngood

Thanks Moru,
Thats what happens when you block copy TYPE definitions!   ;/

The ship array should have been:
Global ship AS SHIP

As there is only one ship in the game.

regards,
johngood
Dell Dimension 9200: Core 2 Duo 2.40GHz, 2GB Ram, ATI Radeon X1300Pro, Windows XP Pro SP3
Intel Mac SnowLeopard 10.6.4 Core 2 Duo 2.4GHz 2GB Ram
iPod Touch 2G 4.0 16 GB, iPod Touch 4G 4.1 32 GB