why doesnt my TYPE work?

Previous topic - Next topic

WAAAAAA

based on
Code (glbasic) Select
LOCAL Bible AS BOOK, Another AS BOOK
MakeBible(Bible)
Another = Bible // copy 'Bible' to 'Another'

FUNCTION MakeBible: any AS BOOK
   any.NumberOfPages=4500
   any.Label$ = "The Holy Bible"
   any.Author$ = "King James"
ENDFUNTCTION
i made
Code (glbasic) Select
IF KEY(57) AND bulls   i=CHR$(bulls+1)
   GLOBAL i AS BULLET
   Create_bullet(i)
ENDIF

FUNCTION Create_bullet: ind AS Bullet
ind.x=P.x+16
ind.y=P.y
INC bulls,1
ENDFUNCTION
the top one works but mine doesnt.... why not???

Kitty Hello

What is "P"? Why does it have a ".x" member? Please post compact, but complete snippets.
Next:
GLOBAL i AS BULLET // is a bad idea
It makes a global variable called "i" of type "BULLET". You should have an array of bullets globally, like:

GLOBAL gBullets[] AS BULLET

WAAAAAA

there is no way to handle types on a mass scale is there?not without entering each name in itself.... or larger coding???

Code (glbasic) Select
TYPE ENEMYSHIP
x;y;sx;sy;shld;state;speed;typ
ENDTYPE

FUNCTION Create_enemyships:
LOCAL i
FOR i=0 TO BOUNDS(es[],0)-1
es[i].x=32*i+32
es[i].y=20
es[i].typ=1
es[i].state=1
NEXT
ENDFUNCTION
gives me this error:
Code (glbasic) Select
compiling:
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp: In function `DGInt __GLBASIC__::Create_enemyships()':
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:125: error: `x' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:125: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:126: error: `y' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:126: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:127: error: `typ' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:127: error: request for member of non-aggregate type before '=' token
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:128: error: `state' has not been declared
C:\Program Files\GLBasic\Compiler\platform\gpc_temp0.cpp:128: error: request for member of non-aggregate type before '=' token

linking:
success
_______________________________________
*** Finished ***
Time: 1.3 sec
Build: 1 succeeded, 0 failed

Kitty Hello

where did you define es[] ??
If you add a GLOBAL es[] AS ENEMYSHIP it will surely work.

WAAAAAA

dunno ive given up on types :P ill just stick to arrays i just keep a list of what i need 5 vars for or i forget :|
how can i make a function that lays out enemies?
like 5 or 7 aliens per level and each level adds another row?
i got a way for it to lay them out across but i dunno about down maybe ill try something just came to me ill let u know how it goes

Kitty Hello

Code (glbasic) Select
FOR x = 1 TO 5
   AddEnemy(x * 32, 64) // x,y position e.g.
NEXT

FUNCTION AddEnemy: x,y
   LOCAL m
   m = BOUNDS(enepos[], 0)
   REDIM enepos[m+1][2]
   enepos[m][0] = x
   enepos[m][1] = y

ENDFUNCTION