Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ~create
- xspd = 0;
- yspd = 0;
- walk_timer = 0;
- move_spd = 1
- frame_speed = 0.7;
- image_speed = 1;
- flashlight = 25;
- flashlight_max = flashlight;
- flashlight_width = 295;
- flashlight_height = 100;
- flashlight_x = (1366/2) - (flashlight_width/2);
- flashlight_y = ystart - 100;
- keys = 0;
- image_angle_ = 0;
- audio_listener_orientation(0, 1, 0, 0, 0, 1);
- depth = obj_player.depth - 1;
- alarm[0] = 1;
- -------------
- ~step
- right_key = keyboard_check(ord("D"));
- left_key = keyboard_check(ord("A"));
- up_key = keyboard_check(ord("W"));
- down_key = keyboard_check(ord("S"));
- if keyboard_check_pressed(vk_shift){
- move_spd = 1.5;
- frame_speed = 0.8;
- }
- if keyboard_check_released(vk_shift){
- move_spd = 1;
- frame_speed = 0.7;
- }
- xspd = (right_key - left_key) * move_spd;
- yspd = (down_key - up_key) * move_spd;
- direction = point_direction(x, y, mouse_x, mouse_y);
- image_angle_ = direction;
- //collision
- if place_meeting(x + xspd, y, obj_wall) == true {
- xspd = 0;
- }
- if place_meeting(x, y + yspd, obj_wall) == true {
- yspd = 0;
- }
- x += xspd;
- y += yspd;
- if (xprevious == x and yprevious == y){
- image_speed = 0; walk_timer = 0;
- }
- else{
- image_speed = 1; walk_timer++;
- }
- var target_x = x - cam_w()/2;
- var target_y = y - 150;
- var camX = lerp(cam_x(), target_x, .1);
- var camY = lerp(cam_y(), target_y, .1);
- cam_x = clamp(camX, 0, room_width-cam_w());
- cam_y = clamp(camY, 0, room_height-cam_h());
- cam_pos(camX, camY);
- audio_listener_position(x, y, 0);
- dist = point_distance(x, y, obj_enemy.x, obj_enemy.y);
- --------------------
- ~draw
- if walk_timer > 5{
- draw_sprite_ext(spr_legs, image_index, x + 0.01, y, image_xscale - 0.4, image_yscale - 0.3, image_angle_, image_blend, image_alpha);
- image_index += frame_speed;
- }
- draw_sprite_ext(sprite_index, image_index, x, y, image_xscale, image_yscale, image_angle_, image_blend, image_alpha);
- ---------------------
- ~draw gui
- if instance_exists(obj_player){
- for (i = 0; i < keys; i++){
- draw_sprite_ext(spr_key, 0, 550 + (i*150), 600, 5, 5, 0, c_white, 1)
- }
- draw_sprite(spr_fl_bg, 0, 500, flashlight_y);
- draw_sprite_stretched(spr_fl_bar, 0, 500, flashlight_y, (flashlight/flashlight_max) * flashlight_width, flashlight_height);
- draw_sprite(spr_fl_outline, 0, 500, flashlight_y);
- }
- --------------------
- ~alarm 0
- flashlight -= 1;
- alarm_set(0, 60);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement