The Daily Click ::. Forums ::. Klik Coding Help ::. Independent enemy movement?
 

Post Reply  Post Oekaki 
 

Posted By Message

J.C



Registered
  22/03/2013 05:18:14
Points
  118
2nd August, 2014 at 02/08/2014 05:07:11 -

I have my coding set up so that enemies move at random intervals depending on the number of the counter. 1=move left 0=stationary 2=move right

Is there another way to make each enemy move independently from one another without having to create multiple clones of the enemy object?


 
n/a

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
2nd August, 2014 at 02/08/2014 05:40:03 -

Instead of using a counter use one of the enemy's alterable values. The alterable values will be unique to the enemies and something like

'set enemy's value A to Random (50)'

will put a different random number in each of the enemies values.

 
.

J.C



Registered
  22/03/2013 05:18:14
Points
  118
2nd August, 2014 at 02/08/2014 06:36:26 -

Hmm...good idea. I'll try that out.

 
n/a

J.C



Registered
  22/03/2013 05:18:14
Points
  118
4th August, 2014 at 04/08/2014 17:48:29 -


Originally Posted by AndyUK
Instead of using a counter use one of the enemy's alterable values. The alterable values will be unique to the enemies and something like

'set enemy's value A to Random (50)'

will put a different random number in each of the enemies values.



It seems to work well, but it seems that I will need to create a counter so that they will alternate directions and stand idle at random intervals.

 
n/a

One Man Army Games

Possibly Insane

Registered
  23/10/2011
Points
  2036
8th August, 2014 at 08/08/2014 05:02:52 -

Try this.

Image

The up arrow represents "stationary"

Alterable value B would be the number of the counter. This method basically checks through every enemy in the frame and executes events individually.

 
http://www.OneManArmyGaming.com

Pan-tosser



Registered
  24/10/2008
Points
  520

Has Donated, Thank You!
8th August, 2014 at 08/08/2014 19:21:49 -

I'm sorry but i strongly disagree with one man army. Because of his use of spreading a value. The problem being it can cause problems down the road matching up who is currently moving.

lets face it spread value sucks. It never stays constant as the number of enemies grow.

I recommend using pick one at random and storing it's fixed. Then if the alterable that buffers the fixed isn't zero use the condition pick object by fixed and then set its alterable that moves it to Random(3)

add a on every timer condition to go with the pick object to control the intervals

Granted one man army has code that works perfectly fine. Except it will require you to learn all the in and outs of spread number and fastloops. Which is something you should learn anyways.

It all comes down to coding style and taste. But not every project requires fastloops. I think they are way over used.

Edited by Pan-tosser

 
https://www.facebook.com/nathon.brown.7

Jenswa

Possibly Insane

Registered
  26/08/2002
Points
  2723
9th August, 2014 at 09/08/2014 16:37:14 -

Setting a value of the object to a random number should work for multiple objects, in the way that they each receive a random number.

What might be even simpler and shorter is setting multiple directions of an object, because an object can only have one direction at a time, that one will be (randomly) selected for ya.

Moving left or right can be done that way, by setting both left and right in the direction setter window.

So by storing some variable movement data, each enemy can be of the same object and act differently depending on those variable values. Which can be set with some kind of random number generator (expr. calc. or directions).

Happy programming.

 
Image jenswa.neocities.org
   

Post Reply



 



Advertisement

Worth A Click