Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///CREATE EVENT ///
- ///Player Variables
- // PLAYER MOVEMENT //
- dashing = false
- //speeds
- max_speed = 30;
- min_speed = 0;
- acc_speed = 2;
- //final speeds
- final_xspeed = 0;
- final_yspeed = 0;
- image_speed = 0;
- _start_x = x;
- _start_y = y;
- _move_speed = 8;
- mx = mouse_x;
- my = mouse_y;
- _movement_direction = point_direction(_start_x, _start_y, mx, my)
- /// STEP EVENT ///
- /// PLAYER MOVMENT ///
- //dashing (copy to script later)
- m_pressD = mouse_check_button_pressed(mb_left);
- m_pressR = mouse_check_button_released(mb_left);
- debr =keyboard_check(vk_space); /// just for testing
- if m_pressD && !dashing
- {
- /// LANDING CALCULATION GOES HERE LATER ///
- mx = mouse_x;
- my = mouse_y;
- _movement_direction = point_direction(_start_x, _start_y, mx, my)
- }else if m_pressR
- {
- dashing = true;
- image_index = 1;
- }
- if dashing
- {
- _move_speed += acc_speed;
- final_xspeed = lengthdir_x(clamp(_move_speed,min_speed,max_speed), _movement_direction)
- final_yspeed = lengthdir_y(clamp(_move_speed,min_speed,max_speed), _movement_direction)
- }else
- {
- final_xspeed = 0;
- final_yspeed = 0;
- }
- x += final_xspeed;
- y += final_yspeed;
- if debr dashing = false;
- /// COLLISION STUFF ///
- sprite_bbox_top = bbox_top - y;
- sprite_bbox_bottom = bbox_bottom - y;
- sprite_bbox_right = bbox_right - x;
- sprite_bbox_left = bbox_left - x;
- //Horizontal collisions
- x += final_xspeed;
- //Snap
- if place_meeting(x, y, obj_solid) {
- var wall = instance_place(x,y,obj_solid);
- if (final_xspeed > 0) { //right
- x = (wall.bbox_left-1) - sprite_bbox_right;
- } else if (final_xspeed < 0) { //left
- x = (wall.bbox_right+1)-sprite_bbox_left;
- }
- dashing = false;
- final_xspeed = -_move_speed
- }
- //Vertical collisions
- y += final_yspeed;
- //Snap
- if place_meeting(x, y, obj_solid) {
- var wall = instance_place(x, y, obj_solid);
- if (final_yspeed > 0) { //down
- y = (wall.bbox_top-1) - sprite_bbox_bottom;
- } else if (final_yspeed < 0) { //up
- y = (wall.bbox_bottom+1) - sprite_bbox_top;
- }
- if (coll)
- {
- dashing = false;
- final_yspeed = -_move_speed
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement