Closed viperfx closed 10 years ago
Off the top:
Lots more but that should get you going :-)
@collinhover Thanks for your comments. I have been trying to implement the creeps so that they follow the pathfinding map that I have defined in the editor. However, it just seems to ignore it.
Here is a snippet of the Creep Entity
ig.EntityCreep = ig.global.EntityCreep = ig.Creature.extend({
animSheet: new ig.AnimationSheet( "media/alien-creep.png", 48, 48),
animInit: "move",
animSettings: {
move: { sequence: [0,1,2,3,4,5], frameTime: 0.1 }
},
preyName:'Target',
collides: ig.EntityExtended.COLLIDES.ACTIVE,
// no wandering
canWanderX: false,
canWanderY: false,
reactionDistance: Infinity,
// search as far as needed to find path to prey
moveToPreySettings: {
searchDistance: Infinity
},
});
Also I am not sure what you mean when you say make the entities 1x1 tilesize.
Hi @viperfx,
I think @collinhover meant with 1x1 tilesize, that the dimensions of your entities should be identical to the dimensions of your collision map. So if you you have a 16 x 16 tilesize on your collision map, your entities should also have the same size of 16 x 16. But don't worry, you can fiddle around with size
and offset
to create entities that are optical bigger than your base tilesize.
A wild guess, is your collision map the same size as your pathfinding map? This is necessary for proper pathfinding.
Also, could you upload a demo here to GitHub? It's easier to help that way, because we could have a closer look at the code, and we could try out different solutions on the fly without posting wild guesses back and forth.
@Pattentrick Yes, I thought that is what he had meant. Yes, my collision map is the same tile size as the path finding map.
Okay I have put together a demo. https://github.com/viperfx/aliendefense
The creep should follow the a path between the metal tiles. The tower should shoot and damage the creep. The entities are not also rotated properly but I guess that is just because I have some missing sprites. The tower should rotate quite freely though, pointing at the enemy while shooting.
@viperfx Okay, I fiddled around a little bit with your game. First of, you also have to paint some of the red pathfinding tiles at your pathfinding map.
As far as I know, by default green tiles are treated the same way that normal tiles are treated, without any pathfinding tiles attached to them. That's the reason why your creep moves around the map without any restrictions. Paint some red tiles to every section where the creep should not travel to.
But even if I do that, your creep has pathfinding problems. Especially when he tries to get around corners. I think this is related to your tilesize of 16 x 10
. My guess is that your tiles have to be even for pathfinding, like 8 x 8
or 16 x 16
. This is maybe related to what @collinhover meant with the 1 x 1 tilesize.
Am I right on this @collinhover?
Corners were always an issue but for side scrolling it should work very well. I've spent most of my time building path finding for side scrolling, so top down could be less stable. Have you tried setting the collision box of your enemies to exactly that of a single tile?
Green path finding map tiles should be treated as far cheaper than blank path finding map tiles. I think the difference is green = cost of near 0, blank = cost of 1 x config pathing weight. But you can use the red tiles to block certain areas, and anything that is a solid collision map tile will also block path finding.
Just tested your demo, pathfinding works fine but you're missing several key components:
// make sure to set the exact name of the target
preyName: "Target",
// find the prey anywhere
reactionDistance: Infinity,
// by default creatures won't find a target unless they can see it
// you don't need this in a TD
needsLineOfSightPrey: false,
// your enemy creatures were wandering
// which is why pathfinding looked funny (but it was correct wandering)
canWanderX:false,
canWanderY:false,
// when creatures get to low health, they will run away from predators
// you don't need this in a TD
canFlee:false,
// now for the pathfinding settings
moveToPreySettings: {
// search for ever and ever and ever
searchDistance: Infinity,
// by default creatures try to avoid each other
// you don't need this in a TD
avoidEntities: false,
// this forces the creature to calculate the entire path
// not just one node at a time
simple: false,
// these are not technically needed in top down
// but they force the creature to pathfind on the wild side
unsafe: true,
avoidUngrounded: false,
avoidSlopes: false,
},
Two things I forgot: I'd recommend setting your collision map tilesize to 32x32, your enemy size to 32x32, and your enemy offset to 12x8. This seem to work best together (and fit your art assets).
Hi guys,
I am taking a look at impact++ after a long time and I am amazed at the progress and that demo is just something! I am about to create a tower defence game and I was hoping to use impact++ to make it a bit easier. Since I am quite new, could you give me some hints on what features to utilise that would be beneficial for a tower defence game? I am going through the tutorials now, so maybe I have asked this prematurely. I would still like to hear your thoughts, however simple.