# Alexander_Q

Member Since 23 Nov 2007
Offline Last Active Yesterday, 02:20 AM

### AI Loses Path When Player Nears Wall

09 February 2013 - 12:47 PM

I'm making a game with AI that navigate around obstacles. The AI code works great, however, when the player stands close to a wall, the AI is unable to compute a path at all. I have attached my project file in the topic here. In the game, the skeletons turn red when the path to the player is lost (though they keep moving towards him without a path, just fail to navigate). The code can be found in the scr_movement_close script. I also include it below:

Spoiler

### Isometric Tile Drawing Match Room Editor

07 February 2013 - 12:05 PM

I am toying with isometric graphics. I have isometric tiles drawn to a surface for the background, and have made isometric blocks and buildings which seem able to do their depth correctly. I have a few questions and clarifications to make about how I've done things, and I've attached my project file here.

My questions are:

• What is the best way to make the background in-game fit to the apparent grid of the block objects? *The origins of the isometric blocks and buildings must remain as they are for the sake of the depth code.
• Is there a way I can make the room editor's isometric grid match the apparent grid of the block objects?
• Are my masks done right, given the perspective I've chosen?

### Array Android Lag

06 February 2013 - 10:17 AM

I have an array in my game for drawing isometric tiles on android.

```var i, j;
for (i = 0; i < gridWidth; i += 1)
{
var st,c;
st="";
for (j = 0; j < gridHeight; j += 1)
{
// Determine the x/y position for the sprite
var xx, yy;
xx = xorigin + (((i * 0.5) - (j * 0.5)) * sprite_get_width(templateTile));
yy = yorigin + (((j * 0.5) + (i * 0.5)) * sprite_get_height(templateTile));

draw_sprite(gridCell[i, j], 0, xx, yy);
draw_text(xx,yy,string(i)+"/"+string(j));
}
}
```

It has a very potent effect on my fps. With the gride size at 10,10 I can get up around 250 FPS, however at size 32,32 my frames drop to about 40. I had intended to have a significantly larger grid even than this.

Is the problem simply that I'm looping too many times in the draw event? If so, how can I make this more efficient/avoid this problem?

### AI Collides with AI Pathfinding

06 February 2013 - 09:59 AM

I have multiple AI that moves towards the players using mp_grid pathfinding. They have a collide event with other AI, and are solid (with a mask).

CREATE
```mypath=path_add();
if !mp_grid_path(global.AI_grid,mypath,x,y,obj_player.x,obj_player.y,true) {
speed=0;
}
else {
mp_grid_path(global.AI_grid,mypath,x,y,obj_player.x,obj_player.y,true);
path_set_kind(mypath,1);
path_set_precision(mypath,8);
path_start(mypath,var_movespeed,0,false);
}```

STEP
```path_end();
if !mp_grid_path(global.AI_grid,mypath,x,y,obj_player.x,obj_player.y,true) {
speed=0;
}
else {
mp_grid_path(global.AI_grid,mypath,x,y,obj_player.x,obj_player.y,true);
path_set_kind(mypath,1);
path_set_precision(mypath,8);
path_start(mypath,var_movespeed,0,false);
}
image_blend=c_white;
```

COLLISION WITH SELF
```image_blend=c_green; //Yes, I make them turn green
x=x+lengthdir_x(1,point_direction(other.x,other.y,x, y))
y=y+lengthdir_y(1,point_direction(other.x,other.y,x, y))```

I expected that upon colliding with each other they would move away from each other and then continue on their way. However, instead, they simply stop. Can anyone figure out why?

### GUI Element Relative to View

04 February 2013 - 12:44 PM

I want the player to be able to click to place a gui element, and for that element to remain in its position relative to the view. I tried the following:

STEP
```if mouse_check_button_pressed(mb_left) {
xx = window_views_mouse_get_x();
yy = window_views_mouse_get_y();
}```

DRAW
```x=view_xview[0]+xx;
y=view_yview[0]+yy
draw_sprite_ext(sprite_index,-1,x,y,1,1,0,c_white,0.25);```

I expected that the code in the step event would grab the relative position, and the draw code would place the element correctly and draw it. Unfortunately, it only works until the view is moved in the room, at which point it behaves erratically. Can anyone help?

EDIT: It seems like it's always grabbing the position relative to the initial position of the view, [0,0], not the current position of the view. I don't know why this should be the case. Ideas?