The Daily Click ::. Forums ::. Klik Coding Help ::. OK now Ive got a Spread problem,(I think)
 

Post Reply  Post Oekaki 
 

Posted By Message

Kai Proton



Registered
  31/01/2005
Points
  201

Wii Owner
30th September, 2007 at 09:13:15 -

so after loads of R&D Ive found that I can have more than one enemy on the map, based on the same sprite,

not in groups, like I used to use, but by Spread value,

so ive programmed a patrol routine in, based on collisions with other sprites,
Yay!

also added , a chase routine so when the player gets too close the badguy chases after them, Ive used the spread routine to add detectors to the bad guys, so they move like the player, (Yay!) all works so far,

I re-add another bad guy on patrol, and BANG it all stops working,

if I use the spread value in the chase routine(checks players distance by Pytagororas) but then the other bad guy never gives chase when its time,
also if I take the Spread value out of the distance check, both the enemys chase when you get close to one of them,

I feel like I should be using a for i loop, to check distance for all the bad guys, but im not sure how to do it in MMF..

ARGH!!

anyone know what im talking about, and can anyone help ?

 
----------------------
Time for a Sexy Party!
----------------------

DaVince

This fool just HAD to have a custom rating

Registered
  04/09/2004
Points
  7998

Game of the Week WinnerClickzine StaffHas Donated, Thank You!Cardboard BoxDos Rules!
30th September, 2007 at 10:31:39 -

I don't get how you're trying to use Spread value here. Spreading a value is intended to make each sprite unique by giving each instance a new value.

Spreading a value of 0 will make sprite 1 have the value 0, sprite 2 have the value 1, sprite 3 have the value 2...

If you spread a value of 234, sprite 1 will get a value of 234, sprite 2 will get a value of 235, and sprite 3 will get a value of 236. As you see, the number you can pass onto it is just an offset.

I think what you think Spread Value is for is "change all enemies' Alterable Value #s to the following", but that's not how it works. To do that, you just use "set alterable value # to #" without narrowing down for who it counts.


To properly store the distance:
- Start of frame (or on creation of new enemy):
spread value 0 in alterable value of sprite
- Always:
Start loop "check distances" (amount of enemies) times
- On loop "check distances"
AND alterable value of sprite = LoopIndex("check distances"):
calculate pythagoras, store it in another alterable value of sprite

This will make each enemy hold their own unique ID (using Spread Value), and their own distance calculation (using the loop and loop index).
You can make more events like the last one to check if that enemy should be chasing now, too.

EDIT: Also, READ THIS! http://www.create-games.com/article.asp?id=1798

Image Edited by the Author.

 
Old member (~2004-2007).

Kai Proton



Registered
  31/01/2005
Points
  201

Wii Owner
30th September, 2007 at 11:16:43 -

I understand how the Spread worked,

its was the article you pointed to that taut me,

but I figured it would allow enemy1 to chase the player, while enemy2 did his own thing,

I cant get it to reference one with out the other, like if I just worked it without spread the value,

I also used the spread to add detectors to the enemies, for ther collision and it worked...
??

 
----------------------
Time for a Sexy Party!
----------------------
   

Post Reply



 



Advertisement

Worth A Click