Sprite:
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Children
obj_block
obj_player
Mask: obj_block
obj_player
No Physics Object
Information about object: obj_block
Sprite: spr_block
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: obj_pushable
Children:
Mask:
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent: obj_pushable
Children:
Mask:
No Physics Object
Begin Step Event:
execute code: global.collisions=0;
End Step Event:
execute code:
if position_meeting(x,y,obj_hole)
{
global.collisions++;
}
Information about object: obj_player
Sprite: spr_player
Solid: false
Visible: true
Depth:
-2
Persistent: false
Parent: obj_pushable
Children:
Mask:
No Physics Object
Create Event:
execute code:
move_dx = 0;
move_dy = 0;
move_amt = 0;
global.collisions=0;//set up
Step Event:
execute code:
if (move_amt > 0)
{
// moving towards destination
if (soko_move(move_dx, move_dy))
{
move_amt -= 1;
}
else move_amt = 0; // if hit a wall, stop moving
}
else
{
var spd = 4; // movement speed (grid size should divide by it w/o remainder)
move_amt = 32 div spd; // calculate number of steps for movement
move_dx = 0;
move_dy = 0;
if (keyboard_check(vk_left)) && !((position_meeting(x-18,y,obj_block) && (position_meeting(x-50,y,obj_block))))
{
move_dx = -spd;
}
else if (keyboard_check(vk_right))&& !((position_meeting(x+18,y,obj_block) && (position_meeting(x+50,y,obj_block))))
{
move_dx = spd;
}
else if (keyboard_check(vk_up)) && !((position_meeting(x,y-18,obj_block) && (position_meeting(x,y-50,obj_block))))
{
move_dy = -spd;
}
else if (keyboard_check(vk_down))&& !((position_meeting(x,y+18,obj_block) && (position_meeting(x,y+50,obj_block))))
{
move_dy = spd;
}
else move_amt = 0; // don't move if no buttons are pressed
}
End Step Event:
execute code:
if global.collisions==instance_number(obj_hole) && move_amt <= 0//check if all crates in place and stopped movi
{
show_message("You Win");
game_end();
}
Draw Event:
execute code:
draw_self();
draw_text(20,20,"Done="+string(global.collisions)+" of "+string(instance_number(obj_hole)));
Information about object: obj_wall
Sprite: spr_wall
Solid: true
Visible: true
Depth: 0
Persistent:
false
Parent:
Children:
Mask:
No Physics Object
Information about object: obj_hole
Sprite: spr_hole
Solid: false
Visible: true
Depth:
3
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Information about object: obj_restart
Sprite: spr_restart
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Mouse Event for Left Released:
execute code:
room_restart();
Information about object: obj_gameend
Sprite: spr_gameover
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Information about object: obj_get_from_net
Sprite:
Solid: false
Visible: true
Depth:
0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:
//Next line sets file to path and target
file = http_get_file("https://gist.githubusercontent.com/edward1986/677ee8c3dacb018d6b07d37d7542512c/raw/d7ce0a54d4433c3bfebcde73be8e15144324988b/sokoban.txt",working_directory +"test.txt");
str[0]="";//initiate array
done=false;//this will be used as a flag to detect if file is downloaded
Step Event:
execute code:
if done room_goto(room_from_file);//when saved goto game rooom
Async Event: HTTP:
execute code:
if ds_map_find_value(async_load, "id") == file//sets up map
{
var status = ds_map_find_value(async_load, "status");//gets status
if status == 0//status 0 means file is finished downloading
{
show_message("got file");//for test
done=true;
}
}
num=0;
file=file_text_open_read("test.txt");//open file for reading
while (!file_text_eof(file))//loops until end of file
{
str[num] = file_text_read_string(file);
file_text_readln(file);
num++;
}
file_text_close(file);//closes file
grid_size=32;
//create a loop for however many lines
for (i = 0; i < num; i += 1)
{
line=(str[i]);
line_width=string_length(line);
//line_width=string_width)
for (j = 0; j < line_width+1; j+= 1)
{
//check each position, create appropriate block
if string_char_at(line, j)=="#" instance_create(16+j*grid_size,16+i*grid_size,obj_wall);
if string_char_at(line, j)=="." instance_create(16+j*grid_size,16+i*grid_size,obj_hole);
if string_char_at(line, j)=="$" instance_create(16+j*grid_size,16+i*grid_size,obj_block);
if string_char_at(line, j)=="@" instance_create(16+j*grid_size,16+i*grid_size,obj_player);
}
}
No comments:
Post a Comment