Enemy movement on the game grid

You must understand the Game Editor concepts, before post here.

Enemy movement on the game grid

Postby DrakeStoel » Sat Aug 29, 2015 5:08 pm

Hi!
So I'm making a game with a bunch of different enemies, but the main feature most of them have in common is to chase down the player when they get close. They are each confined to each game screen (which is just the resolution of my game). The other thing I would like them to do is to move only on a vertical or horizontal axis (in other words not diagonally) and move a complete grid square over (the grid being the grid size while editing the game). My resolution is 256x224, and my grid size is 16x16, making each screen 16x14 tiles, for a total of 224 different grid squares per screen.

Any help would be greatly appreciated!
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: Enemy movement on the game grid

Postby barney12345 » Tue Sep 08, 2015 9:02 am

Split the area into quadrants with the use of filled frame region and have integer goodLoc which is determined by which quadrant the good guy is in and integer badLoc which is determined by which quadrant each enemy is in. Then if the quadrants are something like

1 2
3 4

if goodLoc=1, and enemyLoc=2, x=x-20;
if goodLoc=3, and enemyLoc=4, x=x-20;
and etc for all other quadrants. You can then adjust the movements so that the enemy will always remain within the confides of any square and not be in between.

That's one solution, I expect there are many simpler ones, this one doesn't rely on moveTo at least
Darth Vader called... he wants his cookies back
User avatar
barney12345
 
Posts: 122
Joined: Wed Nov 07, 2012 6:52 am
Location: A land down under
Score: 4 Give a positive score

Re: Enemy movement on the game grid

Postby DrakeStoel » Fri Sep 11, 2015 4:46 pm

Okay, I have simple movement of my enemy now, but I've run into another snag. How can I make my enemy avoid objects like rocks, trees, etc. while still moving on the grid? So instead of just moving through, it moves around while still prohibiting diagonal movement.
DrakeStoel
 
Posts: 43
Joined: Wed Oct 03, 2012 8:53 am
Score: 2 Give a positive score

Re: Enemy movement on the game grid

Postby barney12345 » Sat Sep 19, 2015 12:54 am

make an action where if the object collides with a tree, depending on the direction it is travelling in, it will move one square down, two left/right, one up
Darth Vader called... he wants his cookies back
User avatar
barney12345
 
Posts: 122
Joined: Wed Nov 07, 2012 6:52 am
Location: A land down under
Score: 4 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest