The Daily Click ::. Forums ::. Klik Coding Help ::. Problem with Tower Defense game!
 

Post Reply  Post Oekaki 
 

Posted By Message

Sergiocarp



Registered
  24/05/2009
Points
  294
11th January, 2012 at 18:20:33 -

Hi!

I'm making a game like "tower defense", but i have a problem that can't solve, I think i know what is the problem, but I don't know how to fix it.

It's a problem I have when I make the towers shoot the enemy when they are in their range of vision.
When there are many enemies and towers created on stage, the towers do not fire in order or all enemies.

I would appreciate much if someone helps me find a solution to my problem.

----

Here is an example for you to see the problem:

http://www.mediafire.com/?75gf1c86kfb6qn8


[Sorry for my english]




 
__________________________________

www.mmfzone.com (para miembros que hablen espaņol)*(for spanish members)

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 January, 2012 at 18:46:33 -

Are you using fastloops and spread variables for your tower and enemy objects?

That SOUNDS like what could be causing the problem. I can't check out your example right now during work though, sorry.

 
--

"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!

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
11th January, 2012 at 21:55:39 -

Yup, the problem is that you're not specifying instances of objects. When you don't specify, MMF will compare events to the last created instance. I won't waste your time with a long and complicated explanation on how to set things up, better programmers have already made wonderful examples on how to achieve that crucial basic of TD games;

http://www.castles-of-britain.com/mmf2examplespage18.htm

Study "Basic Tower Defence Example"(by Assualt Andy ^^), it's a great example!

//EE

 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image

Sergiocarp



Registered
  24/05/2009
Points
  294
12th January, 2012 at 06:19:06 -

I have downloaded and analyzed the example, but at move forward with the programming appear some problems (I do not want to go into details). The example is good only for a very basic tower defense game, but it becomes useless for more complex games.

I think it would be better for me if someone modified my example and fix this error, it would be for me the best way to understand based on the MFA file, because my English is bad and if someone gives me a long explanation I probably not understand much.

Sorry to be so annoying and for my bad english.


Thanks for all!

Edited by Sergiocarp

 
__________________________________

www.mmfzone.com (para miembros que hablen espaņol)*(for spanish members)

Eternal Man [EE]

Pitied the FOO

Registered
  18/01/2007
Points
  2955

Game of the Week WinnerHero of TimeLOL SignI am an April Fool
12th January, 2012 at 15:30:00 -

I'm sorry, I don't have the time to make your engine for you, it's a somewhat complicated procedure, plus the fact that you wouldn't know how it is set up, making for more problems in the future. What you need to do is this;

- Find a means to loop through every instance of the turret. The ForEach-extension or spreadvalue+fastloop is what you're going to want to use.

-When you have a way of going through every instance of the turret, you now need to check if any target is in range of the turret. And you can't just do an 'anonymous' check either, cause MMF will only check range for the last created instance in that case. You need to differentiate between instances.

-Any target in range? FIRE!

Here's an article on object scope by Pixel Thief; http://www.create-games.com/article.asp?id=1942
You need to have a grasp on the matter if you intend to make this kind of game.

//EE


 
Eternal Entertainment's Code'n'Art Man

E_E = All Indie


...actually Ell Endie, but whatever.
Image
Image
   

Post Reply



 



Advertisement

Worth A Click