Hey guys, I don't know if this is possible or not but what I'd like to do is everytime an enemy active object is created, I want to have a separate active object follow him around underneath him for a shadow. I've done this successfully with the main hero character, but the problem is how can you make sure that ALL the shadows won't follow the same enemy instead of one for each?
If it has something to do with the spread value I'm afraid I don't really get it. I know arrays really well though, could I do it using an array?
Thanks!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
Uh, I suppose it's possible to do with an array, but that'd be serious overkill. I don't feel like explaining spread values, so if you can't do that just have a counter that is incremented every time an enemy is created and set some alterable value of both the enemy and the shadow object to its current value when they appear. Then use those values for your object focus.
I'll have to try that out Axel. Yeah, sorry about being a total spread value n00b Radix, I don't blame ya. I tried to do something with spread values before but it didn't work out so hot.
If I didn't need to distinguish flying enemies from ground ones I wouldn't put the shadows in at all, by giving them some transparency (which is why I need the secondary object instead of just drawing it as part of the enemy's sprite) it looks more realistic. Of course, nothing else in the game looks realistic, so maybe drawing them in solid isn't such a bad idea afterall.
Thanks for your replies!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
When you create the enemy, create a shadow aswell
then just always position the shadow at the enemy
as long as there is as many shadows as enemies they should be positioned one per enemy
Pretty inefficient way of doing things though.
Spreading values is probably the best way - easy to do, plus you're not always destroying and creating new objects. I'm not sure - I would have thought that creating and destroying objects every single split of a second would cause some performance problems on crappy computers. Whereas I am fairly sure you wouldn't have a single problem with spreading values.
Also spreading values allows you to destroy both the object and shadow together, as well as changing animation and stuff. It can be pretty buggy if you do these things using Axel's method.
Use the Spread Values command for some random Alterable Value for both your shadows and enemies. Then, use a fastloop to position the shadow with its corresponding enemy.
I believe Ben Mercer has a shadow engine, or you can use this one: http://www.klik-me.com/KMv2/article.asp?id=24 if you need any help.
As for the Spread Value command: think of it like assigning each object an ID. The first object's alterable value is the initial value (usually 0), the second object's alterable value is the initial value plus one, and so on. Remember to respread the alterable value whenever you create or destroy an object.
Really, you can use whatever you like. I know that it sounds crazy, creating and destroying a lot of objects 50 times per second, but I've never had any problems with it, so what can be so wrong about it?
Now, the exact same thing, but with spread a value/fastloop. It's CCA because I don't have fastloop on my TGF:
I tested shadowexample.gam with 200 smiley-objects; no problems and no slowdown at all. Will you have 200+ flying enemies on screen at the same time in your game, Del Duio?
I gotta go with Axel on this one, as I'd rather do two lines, then a whole slew of code to get shadows.
Btw this works, and works well enough, as I tested it at work, and even when I gave EVERYTHING a shadow, the game ran fine. The only way this is going to slow things down, is if your computer is a outdated POS.
Flava, Phizzy: How do you even know that it really DOES slow the game down? Right now you're just assuming so because it's (to you) an awkward way of coding it. At least prove me wrong before jumping to conclusions. o_O
No, it's called common sense.
If you want to be unprofessional then fine be lazy and use a two line piece of code. I've just run both programs on my computer and your method uses up more memory. Try it yourself. Okay, it doesn't use up much more memory - but put the rest of your games objects in there and it could prove to be a difference on certain computers.
Your method works fine - if you want a ton of bouncing balls with no animation and no actions at all, then you can use your methods. I'm just saying that spreading values is more efficient, uses less memory and allows the creator/developer to do more things with the objects (such as animating, destroying .etc). And even if it is a few more lines of code - the idea to being a game creator is not to be lazy. If you're lazy, then your game will suck.
I'm just saying - you'll have to add backdrops, scrolling, characters, weapons and all kinds of other things moving at once. And while the player is playing a shadow (which will probably have semi-transparency?) will be created every single split of a second and then destroyed.
Sure, use Axel's method - it probably won't make too much a difference. But please don't be lazy with anything else.
It may be a lazy and unproffessional approach, but it's not the end of the world, and it's a lot easier than messing around with spread a value and fastloops, which can be pretty hard unless you know what you're doing.
I'd probably use the spread a value version myself actually, but it's Del Duio's own choice which method he wants to use in his game
So it sounds to me like a spread value basically makes active objects into a single dimensional array. If so, that's just what I want then. Thank you for all of your replies!
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
That will only work for a single object. It may kinda-work for several (MMF showing rare intelligence) but the game will get confused before long, and there's no way to manage destructions. So no. That's almost as horrible as Axel's method.
Spreading values allows you to somewhat assign a 'unique ID' to each shadow and object.
So a shadow with ID 1 will assign to the object with ID 1 .etc
This way, you can delete both the object and the correct shadow, or change animations of each or whatever.
Basically spreading values lets you do more things and is completely bug free (if you do it correctly)
See my last post. That does work thanks to some sort of magic, but it can get confused and there's no guaranteed way to manage destructions. I would use either spread values or my original suggestion, depending whether the enemies are already in the frame or are created at runtime.
Keep in mind that just because you can do something in less events doesn't mean that less instructions are required to actually achieve it: I'm not sure exactly what happens when you use that method, but I can imagine it being some complex stuff, each and every frame, to determine which objects aren't paired with a shadow and vise versa, then allocation, then the actual positioning. While on the other hand if alt values are used to find the object focus directly, it's conceivably (and I'd say likely to be) more efficient.
What Werbad said is correct... works fine! It's simple to manage destructions as well.. when a unit dies, destroy 1 shadow.. when a unit is summoned add 1 shadow...
"See my last post. That does work thanks to some sort of magic, but it can get confused and there's no guaranteed way to manage destructions."
I think Radix' description of it as 'some sort of magic' is probably quite accurate, lol. I'm not certain, but I have a feeling that object pairing in MMF is a quirk of the Runtime rather than an intended feature.
MMF seems to handle objects in the order they were created, with older objects being processed first. This applies to events, but it also applies to the Spread Value routine. They're indexed according to the same basis.
The result is that if you spread values in two objects and then tell those objects to follow each other, the objects with the same spread values will naturally line up.
I've personally never found a problem with MMF's auto allocation, but I don't doubt there are some. This IS mmf we're talking about after all!
My favourite method for doing the shadiw thing would just be to spread a value so that they have ID numbers. Then use a simple Always event to auto-position them. When an object dies, select the shadow with the same ID and kill that too. If an object is created, create a shadow as well. At the start, use a fastloop to make sure that the number of shadows is equal to the number of enemies (fastloop prevents a momentary delay at the start).
That's the way I do it, and it's never gone wrong for me.
Since MMF auto-positions objects, you CAN do this without Spread values. Just delete any old shadow (using the 'pick at random...' condition to make sure you only delete one of them, not all). MMF will reposition them again. But this leaves a visible flicker as MMF re-sorts the objects, so it's not recommended.
the "auto allocation" is one of the few things in MMF that is actually working (unless you're completley worthless)
I have never had any problems that I haven't been able to solve using this...
Well, there are going to be a lot of active objects in the game in general (land objects like trees, bushes, water sources and etc. I'm glad they give you a 10,000 active limit- I hope I don't use half of it though!
So far, all enemies are going to be created when your invisible line of sight collides with an invisible active picture named "encounter". Then a random enemy is created on that spot. So far, all I've done is ground enemies. There will still be flying enemies, but I may have them on the frame beforehand. Since the ground enemies so far all have an appearing animation of them crawling out of the dirt, creating them this way seems to work, and they don't need a shadow.
Okay, so I was messing around with the spread values last night a bit, and I have a question about it. You have the option to Spread a Value to an active's alterable variable, right? Now if you want to assign it an incrementing ID#, what's the best way to do this? A counter? Oh, and yes the shadows all have semi-transparency to make them look better, and 3 frames of animation where they grow and shrink depending on the relative altitude of the flying creature (in the case I have now, a bat).
--
"Del Duio has received 0 trophies. Click here to see them all."
"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"
DXF Games, coming next: Hasslevania 2- This Space for Rent!
We all got translators, I know japanese
there is a slight difference
Anyways, there has been posted quite alot of examples, use whichever one you feel like...
"Okay, so I was messing around with the spread values last night a bit, and I have a question about it. You have the option to Spread a Value to an active's alterable variable, right? Now if you want to assign it an incrementing ID#, what's the best way to do this? A counter? Oh, and yes the shadows all have semi-transparency to make them look better, and 3 frames of animation where they grow and shrink depending on the relative altitude of the flying creature (in the case I have now, a bat)."
Spreading a Value should give your objects an incremental ID, unless I'm misunderstanding your question.
Also, I've had a lot of problems with MMF auto-allocation, epescially with shadows.