# enemie spawning problems! (blitz3d)

## Recommended Posts

zabo    101
heres a peice of code----> While Not Keyhit(1) If score#=100 then Dim alien(150) b = 1 to 150 alien(b)=LoadMesh("alien.b3d") PositionEntity alien(b),Rnd(-100,100),100,Rnd(300,1000) score#=score#+1 Next EndIf I originally thought that it would stop creating aliens if it added 1 to the score but instead it creates thousands! how can i make it so it only creates 150 aliens instead of looping hundreds of times creating a huge number of aliens? (p.s. it doesnt create an unlimited amount of aliens just alot maybe cuz i continue to shoot em adding points) how do i solve this problem?

##### Share on other sites
zabo    101
c'mon i need help!

##### Share on other sites
bobwrit    100
Make it so that as soon as the enemy is created you add 1 to b . Otherwise b will stay at 1 and you create an infinite loop.

##### Share on other sites
zabo    101
Quote:
 Original post by bobwritMake it so that as soon as the enemy is created you add 1 to b . Otherwise b will stay at 1 and you create an infinite loop.

score#=score#+1 replace it with
b+1?
so simple! (p.s. how do i create a check point /savepoint or save option for my game?)

##### Share on other sites
3Dgonewild    174

b = b +1

..

##### Share on other sites
bobwrit    100
Quote:
Original post by zabo
Quote:
 Original post by bobwritMake it so that as soon as the enemy is created you add 1 to b . Otherwise b will stay at 1 and you create an infinite loop.

score#=score#+1 replace it with
b+1?

Keep
score#=score#+1
in there but add b=b+1 in the loop.

zabo    101
oh hey thanks!

bobwrit    100

bobwrit    100
triple post

bobwrit    100
triple post

##### Share on other sites
zabo    101
umm not to be rude but how would you make a save option for a game?

##### Share on other sites
zabo    101
umm not to be rude but how would you make a save option for a game?

##### Share on other sites
bobwrit    100
I haven't figured out how to do it in blitz before.

##### Share on other sites
zabo    101
hmmmmm..... i wonder if its possible....... i bet it is .........

##### Share on other sites
3Dgonewild    174
Quote:
 Original post by zabo (p.s. how do i create a check point /savepoint or save option for my game?)

I haven't used blitz3d in the past , but something like this is what you have to do:

Process :
(pseudo-code)

Save state:

Create a file "checkpoint.bin"
write_to_file Level_index
write_to_file Player health
write_to_file Player lives
write_to_file Score
write_to_file Total_Aliens (since you place them at random places you dont have to store x,y,z position of the object)
close the file

checkpoint.bin should look like this:
(lets assume that.. level = 1 , player health = 75 , player lives =3,score =555,total aliens =100)

1
75
3
55
100

How to load the saved game:

Open file "checkpoint.bin"
close the file

Dim alien(total_aliens#)
b = 1 to total_aliens#
PositionEntity alien(b),Rnd(-100,100),100,Rnd(300,1000)
b=b+1
Next

zabo    101
cool!