Sign in to follow this  

enemie spawning problems! (blitz3d)

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 this post


Link to post
Share on other sites
Quote:
Original post by bobwrit
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.


so instead of
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 this post


Link to post
Share on other sites
Quote:
Original post by zabo
Quote:
Original post by bobwrit
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.


so instead of
score#=score#+1 replace it with
b+1?

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

Share this post


Link to post
Share on other sites
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:

//note: by reading a line you jump to the next
Open file "checkpoint.bin"
level# = read line
player_health# =read line
player_lives# = read line
score# = read line
total_aliens# = read line
close the file

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







tada!

Share this post


Link to post
Share on other sites

This topic is 3679 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this