The Daily Click ::. Forums ::. Klik Coding Help ::. Shadows for Enemies
 

Post Reply  Post Oekaki 
 

Posted By Message

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
11th July, 2006 at 08:08:01 -

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!

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
11th July, 2006 at 08:31:59 -

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.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 10:00:10 -

No need for that. You can do this:

*Always
-Destroy "shadow"

*Always
-Create "shadow" at (0;0) from "enemy"

Just be sure to have the destroy event before the create event.

 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
11th July, 2006 at 10:34:53 -

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!

Werbad



Registered
  18/09/2002
Points
  235
11th July, 2006 at 11:51:08 -

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

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
11th July, 2006 at 11:54:39 -

Lol, axels way won't work
Learn how to use spread value

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 12:18:16 -

Yes it will, fool. I'll make an example.

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 12:25:15 -

http://aggggge.frac.dk/shadowexample.gam

There. See? It even works in TGF. No spread a value, no fastloops.

 
n/a

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
11th July, 2006 at 13:11:52 -

So? Your shadows will lag behind wen they move

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 15:06:59 -

No they won't. Not if have the right event order.

http://aggggge.frac.dk/shadowexample.gam (updated)

See? I win.

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
11th July, 2006 at 16:45:09 -

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.

Image Edited by the Author.

 
This is a signature. Have this one on me.

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 18:03:06 -

My method only takes two lines of code. Is that inefficient? And I have used it in many games before, and never had any problems with it

Well, do however you like. It's the final product that really matters anyway.

Image Edited by the Author.

 
n/a

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
11th July, 2006 at 20:29:20 -

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.

 
http://www.klik-me.com

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 21:58:52 -

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:

http://aggggge.frac.dk/shadowexample.cca

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
11th July, 2006 at 22:48:57 -

... Okay...?

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?

Image Edited by the Author.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click