The Daily Click ::. Forums ::. Klik Coding Help ::. Simultaneous Object Creation problems, again I
 

Post Reply  Post Oekaki 
 

Posted By Message

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
31st January, 2007 at 12:41:06 -

It seems this issue comes up a lot for me, and I cant seem to remember how to fix it.

Imagine a standard platformer, with a player just moving around. Then we have a simple enemy that walks around, until he encounters the player.

When that enemy encounters the player, its supposed to shoot fire at the player. The fire object is just a normal object that has a bouncing ball movement, speed 60 and decel 60, when its animation is finished it's destroyed. All of this works fine.

The event structure is something like this:
*all the junk for enemy is close to player*
-Create *fire* at (0,0) from enemy
-set direction of fire to Direction(Enemy) + random(2) - 1

So that should create the fire object, and shoot it off in the direction its facing, along with the direction above and below it. (right?)

Well it seems to work perfectly when theres only one of these enemies in the frame. If I have two enemies in the frame, each one on the opposite side of the player, the "set direction" event seems to choose the wrong Enemy when gettings it's direction.

Heres some images to illustrate this crap:
http://people.clarkson.edu/~pulverkl/enemy1.jpg
http://people.clarkson.edu/~pulverkl/enemy2.jpg

Note: In the second shot the player is invisible because hes flashing with temporary invincibility. Also in that second shot, there was a third enemy walking around to the left of the window, I dont know if that had any effect on it.

Well I'm stuck. I'm not really good at fast loops and all that jazz. I tried making it do something along the lines of "If fire is overlapping enemy, and fire flag 0 is off, then set fire direction to direction of enemy, set fire flag 0 on" but that still screws up.

So I need halp ;( I'm using MMF2 by the way ;D

 
n/a

Joe.H

Evil Faker

Registered
  19/08/2002
Points
  3305
31st January, 2007 at 13:56:06 -

Spread a value of 0 between all enemies.

Compare the spread value of the enemy when the player is in range, and create the fire at (0,0) from the enemy with this value.

That's the theory of it.


 
My signature is never too big!!!

Fifth

Quadruped

Registered
  07/05/2003
Points
  5715

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
31st January, 2007 at 14:00:59 -

Hmm... are the enemies themselves actually facing left and right as it appears?

If so, the easiest way would be to set the direction as you're creating it.

That is, when you're choosing where the object is created, you can press "options" (assuming this hasn't changed in MMF2) and set the object being created to inheret the directional orientation of the object it's being created relative to.

Then you can add that random direction jitter afterwards if you want.

 
Go Moon!

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
31st January, 2007 at 15:00:24 -

Joe: Yeah, I'm never good at thinking with the spreading value thing.. what if I'm creating enemies on the fly?

Fifth: Applying your suggestion seems to work, I had no idea such options existed for creating objects... Thanks ;D

Image Edited by the Author.

 
n/a

deadeye



Registered
  22/07/2006
Points
  73
5th February, 2007 at 08:02:10 -

It doesn't matter if you're creating enemies on the fly because MMF will keep track of them for you. When you spread value into them they each get assigned a number based on the order in which they were created. Just do your fastloop for the number of enemies you currently have and then run the firing events inside the loop.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click