im just trying to creat a simple spaceship game as my first attempt at a game but If i have any Dim commands i cant test out my game it doesnt say nething about syntax... whats the problem??? without dim commands it works fine....
FOR z=0 TO 4
DIM bullet[z][0][1]
LOADSPRITE "bullet.bmp",x+20
FOR x=0 TO 1
FOR y=0 TO 1
bullet[z]
NEXT
NEXT
NEXT
whats da problem?
dont laugh at my code im a first timer
you DIM the 2nd level array to size '0' -> that is empty. If you want to have index
- available, you must at least allocate DIM buttet[z][1][1], but then again
FOR z=0 TO 4
DIM a[z]
a[z] = 0
NEXT
will give an error, since DIM a[5] defines a[0]...a[4] only (that's 5 pieces)
Also: you have the DIM in the loop -> everytime you reach the DIM, all you did before gets dropped.
What are you trying to archive? A shoot-array where you can add shots?
yea i cleaned it up a little bit im trying to get it to fire a bullet and when the bullet leaves the screen what should i do with it and how can i get multiple bullets sorta thing
Hmm?
I'd make an array of shots
DIM shots[0][2]
then is [number][x,y]
anmd a function for adding one
FUNCTION Shoot: x,y
LOCAL m
m = BOUNDS(shots[], 0)
REDIM shots[m+1][2]
shots[m][0] = x
shots[m][1] = y
ENDFUNCTION
and then moving them
FUNCTION MoveShots
LOCAL i
FOR i=0 TO BOUNDS(shots[],0)-1
DEC shots[i][1]
// wenn er oben rausfliegt, wegmachen
IF shots[i][1] < 0 THEN DIMDEL shots[], i
NEXT
ENDFUNCTION
and showing them
FUNCTION MoveShots
LOCAL i
FOR i=0 TO BOUNDS(shots[],0)-1
SPRITE st, shots[i][0], shots[i][1]
NEXT
ENDFUNCTION
:booze:
linking:
gpc_temp0.o:gpc_temp0.cpp:(.text+0x1e0): undefined reference to `__GLBASIC__::Bullet'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x20a): undefined reference to `__GLBASIC__::Bullet'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x250): undefined reference to `__GLBASIC__::Bullet'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x273): undefined reference to `__GLBASIC__::Bullet'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x304): undefined reference to `__GLBASIC__::Bullet'
gpc_temp0.o:gpc_temp0.cpp:(.text+0x371): more undefined references to `__GLBASIC__::Bullet' follow
*** FATAL ERROR - Please post this output in the forum
pfft i *love*ed up nvm something so simple as adding an s to some vars
sounds strange. I never used the variable "Bullet" anywhere. Post your code if it does not work.
lol nah i put my own vars in i already had em all thru my coding i didnt wanna change the rest.
code works but its constant shooting and its limitless i need to have a pause or soemthing and it needs to be limited to like 5 shots why is there no wait command in this program? bah :P
or is there?!?!?!??!!
ne ideas? want my code?
not that im going to need it but how would i make a bullet get shot from an enemy at a random angle and to mvoe to theb ottom of the screen on an angle?
god damn this is taking so long... and im getting *love* all done....
If you want to slow down shooting, set a variable to a given value when you add a shot. then as long as the var has value>0, decrease the value and disable shooting:
IF sleepy
DEC sleepy, 1
ELSE
IF KEY(xy) THEN AddShot(x,y)
sleepy = 100
ENDIF