Boss help

Previous topic - Next topic

WAAAAAA

wow it crashed in debug mode and debug didnt pick it up and a red bar came up outline in white and that not in my coding at all lol

WAAAAAA

how could u use types on a mass scale? like if u had all these enemies as types how would u handle movement for each one? bliztbasic has an for each command sorta thing happening....

Kitty Hello

you mean  a "for each ... in ..." command? Does not exist. What is the Blitz way. I might implement it.

WAAAAAA

its for types specifically blizt has soem nice stuff on it
For EnemyShips.Ship = Each Ship
   EnemyShips\iX = EnemyShips\iX + iDirectionX
   EnemyShips\iY = EnemyShips\iY + iDirectionY
Next

Kitty Hello

OK. "FOR EACH" is a nice method. I'll implement it some day.
For now you do:

Code (glbasic) Select
LOCAL es AS EnemyShip
FOR i=0 TO BOUNDS(EnemyShips.Ship[], 0) -1
   // Get that thing
   es = EnemyShips[i]
  // change data of es.xxx
  // ...
  // put es pack into the array:
  EnemyShip[i] = es
NEXT
It's a bit awkard, since TYPEs are new in GLBasic. I'll fix that.

WAAAAAA

yea i dont get it

WAAAAAA

format$ doesnt work? atleast the help file version all it does is cut down how many numbers are after the decimal

WAAAAAA

i think i found an easier way
CHR$()
Code (glbasic) Select
TYPE THING
x;y
ENDTYPE
FOR i=0 to BOUNDS(num_things,0)
x=CHR$(i+64)
x.thing=x.thing+1
NEXT
reckon it will work?

WAAAAAA

coz u cant use numbers as types so u cant just go FOR TO

WAAAAAA

lol
Code (glbasic) Select
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Create_player()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: `x' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:29: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:30: error: `y' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:30: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:31: error: `shld' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:31: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:32: error: `lives' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:32: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:33: error: `state' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:33: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:34: error: `speed' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:34: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Reset_player(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:41: error: no match for 'operator=' in 'i = __GLBASIC__::CHR_Str(DGInt)()'
C:\Program Files\GLBasic\Compiler\platform\/gpc_temp.h:35: note: candidates are: __GLBASIC__::PLAYER& __GLBASIC__::PLAYER::operator=(const __GLBASIC__::PLAYER&)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Update_player(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:50: error: no match for 'operator=' in 'i = __GLBASIC__::CHR_Str(DGInt)()'
C:\Program Files\GLBasic\Compiler\platform\/gpc_temp.h:35: note: candidates are: __GLBASIC__::PLAYER& __GLBASIC__::PLAYER::operator=(const __GLBASIC__::PLAYER&)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Render_player(DGInt)':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:69: error: no match for 'operator=' in 'i = __GLBASIC__::CHR_Str(DGInt)()'
C:\Program Files\GLBasic\Compiler\platform\/gpc_temp.h:35: note: candidates are: __GLBASIC__::PLAYER& __GLBASIC__::PLAYER::operator=(const __GLBASIC__::PLAYER&)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Update_Game()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:77: error: no match for 'operator=' in 'i = 1'
C:\Program Files\GLBasic\Compiler\platform\/gpc_temp.h:35: note: candidates are: __GLBASIC__::PLAYER& __GLBASIC__::PLAYER::operator=(const __GLBASIC__::PLAYER&)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:77: error: no match for 'operator<=' in 'i <= __GLBASIC__::num_players'
../../Include/glb.h:230: note: candidates are: DGInt __GLBASIC__::operator<=(int, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(int, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(float, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(float, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(double, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(double, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, int)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, float)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, double)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, int)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, float)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, double)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:77: error: no `operator++(int)' declared for postfix `++', trying prefix operator instead
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:77: error: no match for 'operator++' in '++i'
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Render_Game()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:87: error: no match for 'operator=' in 'i = 1'
C:\Program Files\GLBasic\Compiler\platform\/gpc_temp.h:35: note: candidates are: __GLBASIC__::PLAYER& __GLBASIC__::PLAYER::operator=(const __GLBASIC__::PLAYER&)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:87: error: no match for 'operator<=' in 'i <= __GLBASIC__::num_players'
../../Include/glb.h:230: note: candidates are: DGInt __GLBASIC__::operator<=(int, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(int, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(float, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(float, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(double, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(double, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, int)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, float)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(__GLBASIC__::CGStr, double)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, __GLBASIC__::CGStr)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, const __GLBASIC__::DGStr&)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, int)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, float)
../../Include/glb.h:230: note:                 DGInt __GLBASIC__::operator<=(const __GLBASIC__::DGStr&, double)
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:87: error: no `operator++(int)' declared for postfix `++', trying prefix operator instead
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:87: error: no match for 'operator++' in '++i'

linking:
gpc_temp0.o:gpc_temp0.cpp:(.text+0x36): undefined reference to `__GLBASIC__::a'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x4c): undefined reference to `__GLBASIC__::a'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xa5): undefined reference to `__GLBASIC__::a'
gpc_temp0.o:gpc_temp0.cpp:(.text+0xb1): undefined reference to `__GLBASIC__::a'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x1df): undefined reference to `__GLBASIC__::a'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x1f8): more undefined references to `__GLBASIC__::a' follow
*** FATAL ERROR - Please post this output in the forum

WAAAAAA

Code (glbasic) Select
FUNCTION Create_player:
LOCAL i
num_players=num_players+1
i=CHR$(65+num_players)
GLOBAL i AS PLAYER
i.x=sx/2-16
i.y=sy-45
i.shld=3
i.lives=3
i.state=1
i.speed=2
ENDFUNCTION

WAAAAAA

nvm i think i see problem i dunno how to fix but

Kitty Hello

The FORMAT$ function goes: FORMAT$(minimum_number_of_characters, number_of_digits_after_the_comma, the_number_to_format);

the BOUNDS function takes an array as first argument. To pass an array, you must specify the name, followed by a [ ] like:
Code (glbasic) Select
DIM arr[5]
FOR i=0 TO BOUNDS( arr[], 0 )
   PRINT arr[i], 0, i*20
NEXT
Working with types as a beginner might be frustrating, since the precompiler errors are not covering all problems. As said - it's very new in GLBasic. If you keep the syntax, it works perfectly, if not, you might get into trouble.

Please, do post source code that gives the error, not just the smallest potion of it.

The error basically starts with:
In function "CreatePlayer", you used a member variable called ".x", which does not exist in the type you are using.

You got my mail? Send me the code, I'll fix it for you.

Kitty Hello

Code (glbasic) Select
FUNCTION Create_player:
LOCAL i // now i is a number
num_players=num_players+1
i=CHR$(65+num_players) // now you assign a string of word ('A', or 'B') to a number -> that results in '0'
GLOBAL i AS PLAYER // yuck!!!! you're creating a GLOBAL with the same name as the local 'i'
i.x=sx/2-16 // here you're referencing the LOCAL i
// writing:
GLOBAL i.x = sx/2-16
// would do, but...
// why not writing
Code (glbasic) Select
LOCAL ply AS PLAYER
ply.y=sy-45
ply.shld=3
ply.lives=3
ply.state=1
ply.speed=2
ENDFUNCTION