Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Update blocks when at start or when an arrow key is pressed. Then move all blocks haven't finished moving
- if (instance_number(obj_block)<1 || keyboard_check_pressed(vk_left) || keyboard_check_pressed(vk_right) || keyboard_check_pressed(vk_down) || keyboard_check_pressed(vk_up)) {with(obj_block){move_contact_all(obj_control.direction,384);
- //Set the slide direction globally using the control object
- obj_control.direction = darctan2(keyboard_check_pressed(vk_up)-keyboard_check_pressed(vk_down),keyboard_check_pressed(vk_right)-keyboard_check_pressed(vk_left));
- //If there is a block to merge into (using same image index), level up the other block
- if (place_meeting(x+dcos(obj_control.direction),y-dsin(obj_control.direction),obj_block) && instance_place(x+dcos(obj_control.direction),y-dsin(obj_control.direction),obj_block).image_index==image_index) {window_set_caption("Score: "+string(real(string_digits(window_get_caption()))+(4<<instance_place(x+dcos(obj_control.direction),y-dsin(obj_control.direction),obj_block).image_index++)));
- //Destroy the merged block
- instance_destroy();}}
- //Loop through all blocks until we find an empty space and place a block there
- for(var i=irandom(15); i<32; i++) {if (!position_meeting(384+64+(i%4)*128,96+64+((i div 4)%4)*128,obj_block)) {instance_create_depth(384+(i%4)*128,96+((i div 4)%4)*128,depth,obj_block).image_index = choose(0,0,0,1);
- //Stop the loop when we've placed one block
- break;}}}
- //Move every moveable block with a speed of 16
- with(obj_block) {move_contact_all(obj_control.direction,16);}
- //Reset the room and score with the "R" key
- if keyboard_check_pressed(ord("R")) window_set_caption("Score: "+string(room_restart()!=undefined));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement