Author Topic: Blitz Basic to GLBasic  (Read 12677 times)

Offline johngood

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: Blitz Basic to GLBasic
« Reply #30 on: 2009-Oct-03 »
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

  • Guest
Re: Blitz Basic to GLBasic
« Reply #31 on: 2009-Oct-03 »
Enm sounds like it hasn't been defined locally

Try (in the appropriate function) :

Code: GLBasic [Select]
LOCAL Enm as SpiderData

Offline johngood

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: Blitz Basic to GLBasic
« Reply #32 on: 2009-Oct-03 »
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()&#39;:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:274: error: could not convert `Enm&#39; to `bool&#39;
*** 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

  • Guest
Re: Blitz Basic to GLBasic
« Reply #33 on: 2009-Oct-03 »
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

Offline johngood

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: Blitz Basic to GLBasic
« Reply #34 on: 2009-Oct-03 »
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

  • Guest
Re: Blitz Basic to GLBasic
« Reply #35 on: 2009-Oct-09 »
Dont worry - I'm around.

Offline johngood

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: Blitz Basic to GLBasic
« Reply #36 on: 2009-Oct-10 »
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_()&#39;:
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\glbasic\gpc_temp0.cpp:24: error: &#39;class __GLBASIC__::DGArray<__GLBASIC__::SHIP>&#39; has no member named &#39;xpos&#39;
*** 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

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1775
    • View Profile
    • Homepage
Re: Blitz Basic to GLBasic
« Reply #37 on: 2009-Oct-10 »
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

Offline johngood

  • Mc. Print
  • *
  • Posts: 34
    • View Profile
Re: Blitz Basic to GLBasic
« Reply #38 on: 2009-Oct-11 »
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