The Daily Click ::. Forums ::. Klik Coding Help ::. Error Proof Spawn
 

Post Reply  Post Oekaki 
 

Posted By Message

Rycon



Registered
  20/09/2002
Points
  996
3rd September, 2003 at 22:24:22 -

Im having a bit of trouble with my spawn system, it works fine somtimes but othertimes it doesent work right, since in both MMF and TGF, the PICK RANDOM OBJECT condition is a bit shakey. Im trying to think of a new system, but having a bit of trouble. Mabye sombody else can show me a difrent way? I just need it so every say.. 10 secs, it sets a number from random 0 - 10, if the number = 1 then create a object from a random location. The object cannot overlap another object aswell. Any ideas?

 
We are the music makers, we are the dreamers of dreams...

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
4th September, 2003 at 00:27:27 -

Yeah sure:

Every 10 secs - set counter to random(10) + 1

if counter = 1 - create player at 0,0; player.x,y = Random(screenwidth,height); set counter to 0

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
4th September, 2003 at 00:27:48 -

Yeah sure:

Every 10 secs - set counter to random(10) + 1

if counter = 1 - create player at 0,0; player.x,y = Random(screenwidth,height); set counter to 0.

If player is overlapping a player
+ pick player at random - destroy player.

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Rycon



Registered
  20/09/2002
Points
  996
4th September, 2003 at 17:13:37 -

I need set points, like 4 difrent areas it can spawn. Since I dont want a object spawning in a wall.

 
We are the music makers, we are the dreamers of dreams...

Rycon



Registered
  20/09/2002
Points
  996
5th September, 2003 at 09:38:55 -

Well since there is alot of guns, that would take alot of code to make everything move over. Plus, I only want one gun to spawn since it would make the game uneven if a player could get every gun in one spot.

 
We are the music makers, we are the dreamers of dreams...

Kramy



Registered
  08/06/2002
Points
  1888
8th September, 2003 at 18:54:20 -

Try putting all spawned objects in a group, instead of coding them spawning individually.

 
Kramy

Rycon



Registered
  20/09/2002
Points
  996
8th September, 2003 at 20:27:25 -

Actuley thats just the problem. When I spawn a weapon, I check to see if there is already a weapon overlaping the spawn box. And since groups work when they WANT to, it doesent work all the time. :/ (Taking the line of code that checks overlap, makes it work perfectly)

 
We are the music makers, we are the dreamers of dreams...

Rycon



Registered
  20/09/2002
Points
  996
9th September, 2003 at 11:21:41 -

Well again, this system revolves around that one line of code.

X Weapon is overlaping Spawn

That line is *Insert Bad Word*

I tryed checking all weapons instead of checking the group. And for some reason that doesent work, I guess its to much or somthin. If somehow I could check for the group in a box area. This seems to work better, but I want to make it so it auto finds the spawn box, and checks for the group in an area around that spawn. So that if I make a level editor, players can place spawn boxes anywhere they want, and it auto draws a box around it and checks for the group.

Since all the guns stay in the same position, perhaps I should try to ask if a group is at same X,Y pos as spawn box. :/

 
We are the music makers, we are the dreamers of dreams...

Kramy



Registered
  08/06/2002
Points
  1888
9th September, 2003 at 13:54:42 -

the PICK RANDOM OBJECT condition is a bit shakey

That's true. A while ago I made a spawner that spawns monsters at various locations, but for some reason it wasn't working well. Then it worked, and everything was fine...if you want I can send it to you, as it could probably be easily modified for weapons.(Only one possible problem I can see)

 
Kramy

Rycon



Registered
  20/09/2002
Points
  996
9th September, 2003 at 18:14:02 -

Thats exactly what happned to me, its now stable. But when I add a new weapon, somthin will go wrong and some gun wont spawn. But then it seems to fix it self, I only hope they spawn when I release the game.

 
We are the music makers, we are the dreamers of dreams...

Kramy



Registered
  08/06/2002
Points
  1888
10th September, 2003 at 17:22:51 -

It must have something to do with the order the events are added to the lines. Might have to be EXACTLY right for it to work properly...and every time you add a new weapon the events are added in the "wrong" order until you rearrange it and it finally starts working again...

 
Kramy

Rycon



Registered
  20/09/2002
Points
  996
10th September, 2003 at 19:04:56 -

I think your exactly right, its a very touchy group of code.

 
We are the music makers, we are the dreamers of dreams...

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
11th September, 2003 at 00:44:59 -

Actually, that's exactly what my code does.

Every 10 secs - set counter to random(10) + 1

if counter = 1 - create player at 0,0; player.x,y = Random(screenwidth,height); set counter to 0.

If player is overlapping a player
+ pick player at random - destroy player.
^^ This part makes it so the player can't be created on walls, if you don't want him destroyed just change it to:

If player is overlapping a player
+ pick player at random - player.x,y = Random(screenwidth,height)

-Andy



 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Kramy



Registered
  08/06/2002
Points
  1888
11th September, 2003 at 12:04:34 -

I may have just come up with an idea that works...Use "looped" events...

Using fastloop, set "Spawner" to a random spawn point, position, etc.

Loop 0
+ Counter = 1
Spawner NOT overlapping group.weapons

Create weapon 1
add 1 to counter
Stop loop 0
Start loop 0

----------------------

Loop 0
+ Counter = 2
Spawner NOT overlapping group.weapons

Create weapon 2
add 1 to counter
Stop loop 0
Start loop 0

--------------------------------

Counter = Last weapon number + 1

Stop loop 0
Set counter to 0
Deactivate Spawn

It might work.....or maybe not.

Edit: Forgot to mention that during loop 0 fastloop would be cycling through all the spawn points in a random order.

Image Edited by the Author.

 
Kramy

Rycon



Registered
  20/09/2002
Points
  996
11th September, 2003 at 16:42:10 -

Assult andy, I didnt think of Picking Random Gun at random, to destroy. Since I tryed making it so, if a gun is overlaping a gun, destroy gun. But then it just destroyed both the guns.

Kramy, I will defintly try this if my spawn code goes wonky again, thank you.

 
We are the music makers, we are the dreamers of dreams...
   

Post Reply



 



Advertisement

Worth A Click