Heppell08 Posted July 18, 2014 Share Posted July 18, 2014 Is there a way that i can randomize my enemy movement more with moveToObject in my forEach function? I had a bigger post but page reload killed what i originally wanted to post so ill keep it basic. Link to comment Share on other sites More sharing options...
lewster32 Posted July 18, 2014 Share Posted July 18, 2014 I think maybe you need to be a bit clearer about what you're trying to achieve. And yeah, it sucks when you suddenly lose the page with a huge post in the making :/ Heppell08 1 Link to comment Share on other sites More sharing options...
Heppell08 Posted July 18, 2014 Author Share Posted July 18, 2014 I wrote a whole script until the page killed it lol. Anyway: Im making a topdown shooter, theres a "tank" and a bunch of different enemies. I have a piece of code that resets the enemy spawns on randomX/Y. This all works perfectly but there is a major flaw in myy gameplay. You can kite the enemies in a circle and then have them all group up into what can only be described as a single OP health enemy you can keep shooting to kill the enemies. I would really prefer to have the enemies not just converge onto the player in the fashion they already do but to also have some sort of none enemy grouping chase if that makes sense? If you want to see the game i can upload my latest build to dropbox. Link to comment Share on other sites More sharing options...
lewster32 Posted July 18, 2014 Share Posted July 18, 2014 Flocking is maybe the term you're looking for? Combined with a bit of random heading changing: http://gamemechanicexplorer.com/#homingmissiles-6 Link to comment Share on other sites More sharing options...
Heppell08 Posted July 19, 2014 Author Share Posted July 19, 2014 Is there any other examples of a flocking you can give because i cant seem to get that code to work because its done via extending the sprites and prototypes but my code is laid out like that so it wont implement for me on testing. Link to comment Share on other sites More sharing options...
lewster32 Posted July 19, 2014 Share Posted July 19, 2014 I'd suggest you Google for 'javascript flocking' or maybe 'javascript boids' and get a feel for what's involved in this kind of behaviour. I think the example I posted breaks it down pretty clearly though; you don't necessarily have to extend the sprites - though it is the best way to do this kind of thing. Link to comment Share on other sites More sharing options...
Heppell08 Posted July 19, 2014 Author Share Posted July 19, 2014 Yeah i had a google around. Alot of mind melting stuff when it comes to looking at the math involved but i finally got there. I actually had an underlying bug i didn't know of until today and it was my spritesheet was causing my .body to offset from the image quite a bit which cause huge conflict when testing.luckily i spotted it and got it working quite nicely. Thanks Link to comment Share on other sites More sharing options...
Recommended Posts