Tower Defense example game

chaosoul

  • *
  • Posts: 260
Hmm array.... I don't have a clue about arrays. Also figuring its going to be a kit I don't think it needs an intro unless requested or someone supplies it. Do you want me to upload what I have right now? I like your help if possible?
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Epic428

  • Posts: 1118
Pathfinding is much more robust when it is used for games with more of a "free roam " aspect. To be honest, you would actually be much better using a method very similar to Greg's sensors in the Cutscene pack. This would actually be a lot easier then using an array as well.

The way the sensors would work, (if I have some time at some point, I can write you the behavior and actor) is like this:

1. Check for collision with enemy.
2. Check direction enemy is coming from (can be done several ways)
3. Based off direction the enemy is coming from, send enemy in new direction.

The reason I suggest you check which way the enemy is coming from is because, it is much easier, when you have intersecting pathways, or in the event of GemCraft, the ability to manipulate the direction in which the enemy moves, it is much easier to determine what the next direction the enemy should move is.


I actually have a number of Ideas running through my head right now in terms of making this as user friendly as possible so that arrays are unnecessary. One method I've though of was using the getActorsAlongLine() method found in one of the actor picker behaviors Alexin made for me. This method would allow you to use ray casting in a cardinal direction so you can look for "blockades" as found in the latest GemCraft.

Then next Idea I had was giving each enemy a behavior and then, depending on where they spawn in the level, they are given an ID. This ID allows the sensor to determine the direction in which it should tell the enemy to move.

There are others but they are not as strong as the two ideas above. The first Idea is great because it means you can make maps like GemCraft where the player is forced to design their own pathways. The second Idea doesn't necessarily give as much freedom as the first, but it is still very good for those Bloons TD games where you have multiple entrances and exits that overlap each other.

I hope using this info you have some ideas for making your own "pathfinding" behavior sets. The best thing about TD games is that, for the most part, they have predefined paths which are much easier to write out than the classes I've posted which use an A* algorithm for find the best path using a given set of coordinates.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

chaosoul

  • *
  • Posts: 260
I suppose I'll try the second idea or maybe the arrays idea. Right now I'm just using a scene behavior that when monster goes in region point to next region and move and goes on till the finish kinda limited and bad though
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Silux

  • Posts: 438
You could also use invisible actors that redirect monsters until the end.(waypoints)

This way you can also set up an in-game editor and it's more easy to set up,because you can place waypoints in the scene editor.
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

chaosoul

  • *
  • Posts: 260
Hmm if I had invisble waypoints how would I do crosspaths?
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Zephilinox

  • Posts: 106
...
1. Check for collision with enemy.
2. Check direction enemy is coming from (can be done several ways)
3. Based off direction the enemy is coming from, send enemy in new direction.

The reason I suggest you check which way the enemy is coming from is because, it is much easier, when you have intersecting pathways, or in the event of GemCraft, the ability to manipulate the direction in which the enemy moves, it is much easier to determine what the next direction the enemy should move is.

...

Then next Idea I had was giving each enemy a behavior and then, depending on where they spawn in the level, they are given an ID. This ID allows the sensor to determine the direction in which it should tell the enemy to move.

There are others but they are not as strong as the two ideas above. The first Idea is great because it means you can make maps like GemCraft where the player is forced to design their own pathways. The second Idea doesn't necessarily give as much freedom as the first, but it is still very good for those Bloons TD games where you have multiple entrances and exits that overlap each other.

...

I cut it down to size for you.

Silux

  • Posts: 438
Gemcraft pathfinding is the best i know, but has only one exit(however two monsters will choose two different paths if they have the same lenght)

I also imagined a lighting-like pathfinding.Every time the scenario changes a 'scout charge' will be sent.The scout charge will follow the Epic428 pathfinding behaviour.Then the scout charge saves all its direction changes.The enemies will follow the directions of the scout charge.
This method would save some CPU (no pathfinding for every enemy).
When more paths have the same lenght the scout charge will place 2 or more wayponts with the same value. Each monster will choose randomly later which to get.
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

Silux

  • Posts: 438
Some attachments!
1st is waypoints dumb behaviour.no problems with crosspaths since every monster has his goal.
If there are more than 1 entry, you can use waypoint 1b, 2b,... ,(n)b.

2nd is 'Scout charge' behaviour (not well done sigh...).Monsters start in the little home and end in the triangle.
The 'line' shows where monsters could go.
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

chaosoul

  • *
  • Posts: 260
...
1. Check for collision with enemy.
2. Check direction enemy is coming from (can be done several ways)
3. Based off direction the enemy is coming from, send enemy in new direction.

The reason I suggest you check which way the enemy is coming from is because, it is much easier, when you have intersecting pathways, or in the event of GemCraft, the ability to manipulate the direction in which the enemy moves, it is much easier to determine what the next direction the enemy should move is.

...

Then next Idea I had was giving each enemy a behavior and then, depending on where they spawn in the level, they are given an ID. This ID allows the sensor to determine the direction in which it should tell the enemy to move.

There are others but they are not as strong as the two ideas above. The first Idea is great because it means you can make maps like GemCraft where the player is forced to design their own pathways. The second Idea doesn't necessarily give as much freedom as the first, but it is still very good for those Bloons TD games where you have multiple entrances and exits that overlap each other.

...

I cut it down to size for you.
Please see that I did read the whole post and replied to it. It's just that I like to pick the easiest and most customizable way and the invisble waypoints seemed to be very easy since you could use it in the scene editor and that be convinient for users who would use the kit
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Zephilinox

  • Posts: 106
...
1. Check for collision with enemy.
2. Check direction enemy is coming from (can be done several ways)
3. Based off direction the enemy is coming from, send enemy in new direction.

The reason I suggest you check which way the enemy is coming from is because, it is much easier, when you have intersecting pathways, or in the event of GemCraft, the ability to manipulate the direction in which the enemy moves, it is much easier to determine what the next direction the enemy should move is.

...

Then next Idea I had was giving each enemy a behavior and then, depending on where they spawn in the level, they are given an ID. This ID allows the sensor to determine the direction in which it should tell the enemy to move.

There are others but they are not as strong as the two ideas above. The first Idea is great because it means you can make maps like GemCraft where the player is forced to design their own pathways. The second Idea doesn't necessarily give as much freedom as the first, but it is still very good for those Bloons TD games where you have multiple entrances and exits that overlap each other.

...

I cut it down to size for you.
Please see that I did read the whole post and replied to it. It's just that I like to pick the easiest and most customizable way and the invisble waypoints seemed to be very easy since you could use it in the scene editor and that be convinient for users who would use the kit

Yeah, I saw your reply, but I thought since the post was so large you may have missed some of it.

Silux

  • Posts: 438
(misunderstanding happens quite often when posting;I often make a lot of grammar mistakes or I don't understand something.So have an happy laugh at former posts and continue reading:)

So we'll go for the waypoints!

Anyone knows a good way to make towers to upgrade?
(kind of
Mouseover and info panel
click on Upgrade; lose money;send 'upgraded' to all tower's behaviour
Some of tower's value increase)

I think this kind of behaviour is necessary, because in TDs player need to place in good places the towers and then improve the ones which can work better.
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

Zephilinox

  • Posts: 106
(misunderstanding happens quite often when posting;I often make a lot of grammar mistakes or I don't understand something.So have an happy laugh at former posts and continue reading:)

So we'll go for the waypoints!

Anyone knows a good way to make towers to upgrade?
(kind of
Mouseover and info panel
click on Upgrade; lose money;send 'upgraded' to all tower's behaviour
Some of tower's value increase)

I think this kind of behaviour is necessary, because in TDs player need to place in good places the towers and then improve the ones which can work better.

You could probably mock something up with just a simple "if U key is down and mouse is pressed on self then.." that could be attached to a turret just to test, then a button in a mouse over panel, overall it doesn't seem very difficult to do.

chaosoul

  • *
  • Posts: 260
Damn I'm a idiot greg has this behavior called follow path that be perfect for this.
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Silux

  • Posts: 438
waypoints will be easy to code 'ad hoc'(in a way that perfectly suit ours need)
There's need of only 6 waypoints.
1) turn 90 clockwise
2) turn 90 counterclockwise
3)choose between turn 90cwise and turn 90ccwise
4)choose between turn 90cwise and go straight
5)choose between turn 90ccwise and go straight
6)choose between turn 90cwise, turn 90ccwise and go straight

In this way we need only to code 6 actors and everyone will be able to create map with winding roads.

monsters will have a behaviourlike this
When created
 set Direction of self to Starting angle

Always
 go towards Direction of Self
when this ears 1)
 turn 90 cwise
...
when this ears 6)
 pick a and integer number from 1 to 3
  if 1
   turn 90 cwise
  otherwise if 2
   go straight
  otherwise if 3
   turn 90 ccwise
Currently working at:
Starwarrior 2097(my main project)
How to make successful games in Kongregate and the world(article)

chaosoul

  • *
  • Posts: 260
O okay so we're going with waypoint idea. Though i would make more waypoints for more possibilities could you upload your game onto forge for me to see what you've done so far or should I?
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS