Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Set some rules for the aiming cursor
- if (input_source_using(INPUT_GAMEPAD))
- {
- //If we're using a gamepad, limit the cursor to 130px away from the player
- //We also set an "elastic" rule so that the cursor automatically springs back towards the player
- input_cursor_limit_circle(x, y, 130);
- input_cursor_elastic_set(x,y, 0.2);
- if (!input_check("aim_up"))&&(!input_check("aim_down"))&&(!input_check("aim_left"))&&(!input_check("aim_right"))
- {
- input_cursor_set(oPlayer1.x, oPlayer1.y,)
- oCursor.image_alpha = 0;
- rightstick = false;
- }
- else
- {
- oCursor.image_alpha = 1;
- rightstick = true;
- }
- }
- else
- {
- //If we're not using the gamepad then remove both the limit and the elastic
- //This allows the cursor to move totally freely as you'd expect with mouse aiming
- input_cursor_elastic_remove();
- input_cursor_limit_remove();
- }
- //Move the point of aim if the cursor is far enough away from the player
- //We perform this distance check so that we don't get twitching when using a gamepad
- if (point_distance(x, y, input_cursor_x(), input_cursor_y()) > 10)
- {
- aim_direction = point_direction(x, y, input_cursor_x(), input_cursor_y());
- image_angle = aim_direction;
- if (input_source_using(INPUT_GAMEPAD))
- {
- if(shoot_timer = 0)
- {
- shoot_timer = 1*shoot_rate; //shoot_timer controls the rate of fire
- image_speed = 20;
- //The speed of the bullet is set in the Create event for obj_example_bullet
- var _xx = x + lengthdir_x(28, image_angle);
- var _yy = y + lengthdir_y(28, image_angle);
- with(instance_create_layer(_xx, _yy, "Shots", oShot))
- {
- input_vibrate_constant(0.05, 0, 5)
- creator = other.id;
- direction = other.aim_direction;
- }
- }
- if (shoot_timer > 0)
- {
- --shoot_timer;
- image_speed = 0;
- }
- }
- else
- {
- //Handle shooting
- if (shoot_timer > 0)
- {
- --shoot_timer;
- image_speed = 0;
- }
- else if (input_check("shoot"))
- {
- shoot_timer = 1*shoot_rate; //shoot_timer controls the rate of fire
- image_speed = 20;
- //The speed of the bullet is set in the Create event for obj_example_bullet
- var _xx = x + lengthdir_x(28, image_angle);
- var _yy = y + lengthdir_y(28, image_angle);
- with(instance_create_layer(_xx, _yy, "Shots", oShot))
- {
- input_vibrate_constant(0.05, 0, 5)
- creator = other.id;
- direction = other.aim_direction;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment