feandrad

GML movement input script

Jul 30th, 2021
656
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function checkForInputs() {
  3.     if !(x == destination_x and y == destination_y) {return}
  4.    
  5.     var _up =  keyboard_check(ord("W")) or keyboard_check(vk_up)
  6.     var _left =  keyboard_check(ord("A")) or keyboard_check(vk_left)
  7.     var _down =  keyboard_check(ord("S")) or keyboard_check(vk_down)
  8.     var _right =  keyboard_check(ord("D")) or keyboard_check(vk_right)
  9.    
  10.     var _dest_x = x + (_right - _left) * 16
  11.     var _dest_y = y + (_down - _up) * 16
  12.    
  13.     if (destination_x == _dest_x && destination_y == _dest_y) {return}
  14.    
  15.     var _list = ds_list_create();
  16.     var _collision_num = collision_point_list(_dest_x, _dest_y, AbstractBlock, true, 1, _list, true)
  17.     if (_collision_num != 0) {return}
  18.    
  19.     destination_x = _dest_x
  20.     destination_y = _dest_y
  21. }
RAW Paste Data