# Enemy Snap Movement

5 replies to this topic

### #1 pikachu123

pikachu123

Pika, pika, pikachu!

• GMC Member
• 555 posts

Posted 03 March 2012 - 04:36 PM

SOLVED

Hi, i would like to make an enemy move by snapping on a 16x grid. The problem is, the enemies keep running into the walls.
```var ii;
ii = round(random(4))
if ii >= 0.5 && ii < 1.33{if place_empty(x-16,y) {x-=16}}
if ii >= 1.33 && ii < 2.16{if place_empty(x+16,y) {x+=16}}
if ii >= 2.16 && ii < 3{if place_empty(y+16,y) {y+=16}}
if ii >= 3 && ii < 4{if place_empty(y-16,y) {y-=16}}
alarm[1] = 50```

Thanks,
--pikachu123--

Edited by pikachu123, 04 March 2012 - 01:01 AM.

• 0

### #2 DcoldSaviour77

DcoldSaviour77

GMC Member

• GMC Member
• 255 posts
• Version:GM8

Posted 03 March 2012 - 08:04 PM

The place empty parts looks good I'm not sure.
what type of game is this?
• 0

### #3 pikachu123

pikachu123

Pika, pika, pikachu!

• GMC Member
• 555 posts

Posted 03 March 2012 - 08:21 PM

The place empty parts looks good I'm not sure.
what type of game is this?

Roguelike.
• 0

### #4 DcoldSaviour77

DcoldSaviour77

GMC Member

• GMC Member
• 255 posts
• Version:GM8

Posted 03 March 2012 - 08:23 PM

The place empty parts looks good I'm not sure.
what type of game is this?

Roguelike.

When you say run into walls do you mean he gets stuck?
• 0

### #5 pikachu123

pikachu123

Pika, pika, pikachu!

• GMC Member
• 555 posts

Posted 03 March 2012 - 08:36 PM

The place empty parts looks good I'm not sure.
what type of game is this?

Roguelike.

When you say run into walls do you mean he gets stuck?

Well no, they can get out. And actually it's not really "run", its more teleport.
• 0

### #6 pikachu123

pikachu123

Pika, pika, pikachu!

• GMC Member
• 555 posts

Posted 04 March 2012 - 01:00 AM

I found out what i did wrong
`(y-16,y)`
xD

Edited by pikachu123, 04 March 2012 - 01:01 AM.

• 0

#### 0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users