Code (2)
Code (2)
Objects
1. Collectables
a. obj_chest (hộp kho báu)
● Create
// Creates a sequence manager object for the chests idle animation
sequence_body = instance_create_layer(x, y, "Stage", obj_sequence_manager);
// Sets the owner to the chest
sequence_body.owner = self;
// Sets the object to use the idle sequence
sequence_body.create_seq(seq_chest_idle, "Stage");
// Sets the shadow instance to chest parameters and targets self as owner of it
_shadow.sprite_index = spr_chest_shadow;
_shadow.owner = self;
_shadow.set_y_offset(40);
}
}
// New temp function to be called after the chest breaking sequence ends
var _new_function = function()
{
// Destroys this object
instance_destroy(self);
}
b. obj_coin_gui
● Create
// Creates a random angle plus or minus 30 degrees to move the gui coin in for
variation
image_adjust = random_range(-30, 30);
// Sets the direction to head left with the added variation
direction = 180 + image_adjust;
// Sets the gui coins current speed to the games current speed
current_speed = obj_game_manager.current_speed;
// Applies this variable to the speed variable for movement updates
speed = current_speed;
// Sets an empty child particle variable, this is set when the instance is created
child_particle = noone;
● Destroy
// Checks if the child particle object still exists
if (instance_exists(child_particle))
{
// Sets the particle to have no parent so its movement will stop tracking
child_particle.owner = noone;
}
● Step
// Checks the game is not curently paused
if (obj_game_manager.current_game_state != GAME_STATE.PAUSED)
{
// Calculates the target direction of where the coin symbol is on the score
GUI
var _target_direction = point_direction(x, y, obj_gui.x - 5, obj_gui.y +
50);
// Calculates the difference in directions between the direction headed
and the target
var _dir_difference = angle_difference(_target_direction, direction);
// Adjusts the direction slowly at a rate of the directional difference
direction += _dir_difference * 0.1;
// Sets the sprite image angle to the new direction with the adjusted
angles added
image_angle = direction - image_adjust + 180;
c. obj_pickup_coin(>>)
● Create
randomise();
current_level = 1;
current_level_gold = 0;
current_distance = 0;
current_gold = 0;
// The speed percentages are used to gradually increase and decrease the
speed using smooth step interpolation
current_speed_percentage = 0.0;
target_speed_percentage = 0.5;
// The rate speed will go up or down so the player will stop or slow
down quicker than speeding up
speed_up_rate = 0.2;
speed_down_rate = 0.5;
// Function used to update the speed with delta time passed though as
that is the time passed this frame meaning more accurate movement
update_speed = function(_delta_time)
{
// Checks if a player has collected 50 gold since the last time they
leveled up
if (current_level_gold >= 50)
{
// Removed the gold from their current count
current_level_gold -= 50;
// Increases the level
current_level++;
// Sets the max speed to be 5% faster
new_max_speed = max_speed * 1.05;
}
d. obj_pickup_coin
● Step
// Checks if the game is currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves the coin objects left at the games current move speed
x -= obj_game_manager.current_speed * 1.0;
● →← obj_player
// Checks if the coins current sprite not collected
if (sprite_index == spr_coin_idle)
{
// Creates a new gui coin object
var _gui_coin = instance_create_layer(x, y, "StageFront", obj_coin_gui);
// Sets the gui coin object to store the particle object it is attached to
_gui_coin.child_particle = _coin_particle;
// Plays coin collected sound
audio_play_sound(snd_coin_collection, 100, false, 1.0);
e. obj_pickup_shield(khiêng)
● Step
// Checks the current game state is not paused (by game state)
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves the pick ups position at the games current speed
x -= obj_game_manager.current_speed * 1.0;
// Creates and sets a new particle handler object with the power up
collected particle effect attached to the player
var _new_aura_particle = instance_create_layer(obj_player.x,
obj_player.y, "Stage", obj_particle_manager);
_new_aura_particle.owner = obj_player;
_new_aura_particle.set_particle(ps_powerup_in, "StageFrontEffects");
2. Enviroment
a. obj_far_bacground
● Create
// Creates an array and stores background sprites to it
sprites[0] = spr_farground_1;
sprites[1] = spr_farground_2;
sprites[2] = spr_farground_3;
// Fetches the sprite array to load them into the system resources
sprite_prefetch_multi(sprites);
● Step
// Checks the game is not currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Reduces the x position by the current speed and move rate
x -= obj_game_manager.current_speed * background_move_rate;
// Check what sprite the last one was set to and then set up
the appropriate sprite to follow
switch(after_sprite)
{
case sprites[0]:
after_sprite = sprites[1];
break;
case sprites[1]:
after_sprite = sprites[2];
break;
case sprites[2]:
after_sprite = sprites[0];
break;
}
// Move the x position forward the sprite width to move
the sprites draw positions
x += sprite_width;
}
}
● Draw
// Draw the before sprite at an offset of minus its width
draw_sprite(before_sprite, 0, x - sprite_get_width(before_sprite), y);
// Draw the main/middle sprite
draw_self();
// Draw the final sprite at an offset of its width
draw_sprite(after_sprite, 0, x + sprite_width, y);
b. obj_firework
● Create
// Variables set up for firework to use after being set
life = 0;
delay = 0;
death = 0;
// Checks if the firework has been alive for longer than the delay
attached so visually only appears after a set time
if (life > delay)
{
// Creates a new particle effect for the trail
create_ps(trail_ps);
}
// Checks if the firework has been alive long enough for its final
explosion
if (life > death)
{
// Creates the final particle effect for the explosions head
create_ps(head_ps);
c. obj_flower
● Step
// Checks if the game has been paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves the flowers x position along at the games current speed
x -= obj_game_manager.current_speed * 1.0;
d. obj_front_ceiling
● Create
// Keeps count of how many vines can be created
fauna_count = 2;
// Temp variables for checking if the position has been set and
how many attempts have been made
var _pos_set = false;
var _attempts = 0;
e. obj_front_floor
● Create
// Variable for how many bushes can exist at once
fauna_count = 5;
// Checks if the bush has left the left side of the screen
if (x_coords[_i] + sprite_get_width(set_sprites[_i]) < 0)
{
// Changes the bushes sprite
set_sprites[_i] = choose(sprite[0], sprite[1], sprite[2],
sprite[3]);
f. obj_interior_bacground
● Create
// Enum state for the interior states used
enum INTERIOR_STATE
{
OUTSIDE,
ENTER,
INSIDE,
EXIT,
SIZE
}
// Sets the count for how many pipe segements will exist
pipe_segment_count = 3;
// Variable for the ground segment count (larger since these sprites are
smaller so more are needed to fill the screen)
ground_segment_count = 5;
// Prefetches all the ground sprites from the array (again preventing
hanging later when needed for the first time)
sprite_prefetch_multi(ground_sprite);
// Function for changing the interior state (swapping inside and outside
environments and back again)
change_interior_state = function()
{
// Checks what the current state is
switch (current_interior_state)
{
// When inside
case INTERIOR_STATE.INSIDE:
// Will only trigger when all environments are in
inside state
if (current_wall_state ==
INTERIOR_STATE.INSIDE &&
current_ground_state ==
INTERIOR_STATE.INSIDE &&
current_pipe_state ==
INTERIOR_STATE.INSIDE)
{
// Enters exit state
current_interior_state =
INTERIOR_STATE.EXIT;
}
break;
// When outside
case INTERIOR_STATE.OUTSIDE:
// Will only trigger when all environments are in
outside state
if (current_wall_state ==
INTERIOR_STATE.OUTSIDE &&
current_ground_state ==
INTERIOR_STATE.OUTSIDE &&
current_pipe_state ==
INTERIOR_STATE.OUTSIDE)
{
// Changes to enter state
current_interior_state =
INTERIOR_STATE.ENTER;
}
break;
}
}
// Tells the gamemanager that this object has prefetched since relies on
many sprite resources so it is safe to start the game
obj_game_manager.has_prefetched = true;
● Step
// Checks if the game is currently paused
if (obj_game_manager.current_game_state != GAME_STATE.PAUSED)
{
// Checks what state the game should be
switch(current_interior_state)
{
// When entering
case INTERIOR_STATE.ENTER:
// Sets walls and pipes to enter and pushes overall state to
inside
current_wall_state = INTERIOR_STATE.ENTER;
current_pipe_state = INTERIOR_STATE.ENTER;
current_interior_state = INTERIOR_STATE.INSIDE;
break;
// When exiting
case INTERIOR_STATE.EXIT:
// Sets a flag for the walls to change and its state to exit
has_wall_changed = true;
current_wall_state = INTERIOR_STATE.EXIT;
// Pushes overall state to outside
current_interior_state = INTERIOR_STATE.OUTSIDE;
break;
}
// Loops through all the pipes again now their positions have been
changed
for (var _i = 0; _i < pipe_segment_count; _i++)
{
// Sets a width variable
var _width = 0;
// Loops throught the group segements again not they have moved
for (var _i = 0; _i < ground_segment_count; _i++)
{
// Check if the segement is off screen to the left
if (ground_x_coords[_i] < -512)
{
// Check what the current ground state is
switch(current_ground_state)
{
// When entering
case INTERIOR_STATE.ENTER:
// Set ground sprite to enter
set_ground_sprites[_i] = ground_sprite[0];
// Change state to inside
current_ground_state =
INTERIOR_STATE.INSIDE;
break;
// When inside
case INTERIOR_STATE.INSIDE:
// Change sprite to inside sprite
set_ground_sprites[_i] = ground_sprite[1];
break;
// When exit
case INTERIOR_STATE.EXIT:
// Set ground to exit
set_ground_sprites[_i] = ground_sprite[2];
// Sets state to outside
current_ground_state =
INTERIOR_STATE.OUTSIDE;
// Also sets the pipe to exit since the ground
is changing
current_pipe_state =
INTERIOR_STATE.EXIT;
break;
// When outside
case INTERIOR_STATE.OUTSIDE:
// Sets the ground sprite to outside in the
pattern it follows (last 3 in array in order looping)
set_ground_sprites[_i] = ground_sprite[3 +
(_i % 3)];
// Sets a random flower create function
var _handle = choose(flower_set_1,
flower_set_2, flower_set_3, flower_set_4);
// Calls the chosen function for making
flowers at new location
_handle(ground_x_coords[_i] + 512 *
ground_segment_count, ground_y_coords);
break;
}
g. obj_mid_background
● Create
// Stores the midground sprites inside an array
sprite[0] = spr_midground_1;
sprite[1] = spr_midground_2;
sprite[2] = spr_midground_3;
sprite[3] = spr_midground_4;
● Step
// Checks the game is not paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves position at the speed and rate
x -= obj_game_manager.current_speed * background_move_rate;
// Checks what the last after sprite used was and swaps the
sprite to the next one along following the pattern
switch(after_sprite)
{
case sprite[0]:
after_sprite = sprite[1];
break;
case sprite[1]:
after_sprite = sprite[2];
break;
case sprite[2]:
after_sprite = sprite[3];
break;
case sprite[3]:
after_sprite = sprite[0];
break;
}
}
// Sets up button refernece
dbg_button("Change Interior", ref_create(self,
"button_interior"), 240, 30);
● Step
// Checks for shift and tab button combo
if (keyboard_check_direct(vk_shift) &&
keyboard_check_pressed(vk_tab))
{
// Toggles debug menu
global.active_debug_menu = !
global.active_debug_menu;
show_debug_log(global.active_debug_menu);
}
b. obj_game_manager
● Create
// Game states.
enum GAME_STATE
{
PLAYING,
DYING,
ENDED,
PAUSED,
TUTORIAL,
SIZE
}
// Decreases the background cooldown timer by the current speed and time
passed
background_cooldown -= current_speed * _delta_time;
// Checks if the speed is currently zero and the player is now invisible
if (current_speed == 0 && obj_player.image_alpha == 0)
{
// Sets the games current state to end
current_game_state = GAME_STATE.ENDED;
// Checks if the current distance has passed the previously set high score
if (current_distance > global.highscore)
{
// Makes a new flag over the players position that will drop into the
level and has its distance set
var _flag = instance_create_layer(obj_player.x, -200, "Stage",
obj_flag_marker);
_flag.has_dropped = false;
_flag.has_passed = true;
_flag.flag_distance = current_distance;
// Plays game over sound effect and changes the global music to
ambience
audio_play_sound(snd_game_over_popup, 100, false, 1.0);
global.music = audio_play_sound(snd_ambience, 100, true, 1.0);
// Plays the game over sequence that creates the gameover menu
var _gameover_seq = layer_sequence_create("GUI", 0, 0,
seq_gameover);
c. obj_particle_manager
● Create
// Empty variable for setting the particle system to
particle_sys = -1;
● Destroy
// Destroys particle system
part_system_destroy(particle_sys);
● Step
// Checks if the owner currently exists
if (owner == noone)
{
// Checks if the move rate is not equal to the current
move rate (Drag)
if (move_rate != move_rate_target)
{
// Adjusts the move rate by lerping to the
target at the set drag rate
move_rate = lerp(move_rate,
move_rate_target, drag_rate);
}
d. obj_sequence_manager
● Create
// Set sequence used
set_sequence = -1;
e. obj_spawn_manager
● Create
_cooldown = 10 + 1.8;
break;
break;
case 1: // 3x3 Set Coins
break;
break;
break;
spawn_reward(choose(0,1,1,1,1,2,2,2,3,3,4,4,5,4,6,7));
}
}
}
f. obj_splash_manager
● Create
// Checks if the platform type is mobile
if (os_type == os_android || os_type == os_ios)
{
// Sets global touch to true
global.is_touch = true;
}
else
{
// Sets global touch to false
global.is_touch = false;
}
a. obj_alert
● Create
// Start object invisible
image_alpha = 0;
// Set target alpha as visible
target_alpha = 1.0;
● Step
// Checks owner exists
if (owner != noone)
{
// Checks owener is offscreen with added buffer distance
if (owner.bbox_left > room_width + buffer)
{
// Will show alert
target_alpha = 1;
}
// Checks if owner is closer than the buffer
else if (owner.bbox_left > room_width)
{
// Scales down the target alpha between 0 and 1
target_alpha = clamp(buffer / (room_width -
owner.bbox_left), 0, 1);
}
else
{
// Sets the target alpha to 0 since owner on screen and
should be invisible
target_alpha = 0;
}
● Animation End
// Plays the final animation after the inital one
sprite_index = spr_alert_final;
b. obj_beam
● Create
// Check for knowing if object has hit the player
has_hit = false;
● Step
// Checks the game is not paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves the beam at the games current speed
x -= obj_game_manager.current_speed * 1.0;
● Draw
// Draws the main beam body
draw_self();
// Draws the top beam head sprite flipped
draw_sprite_ext(spr_beam_head, 0, x, y - 128 - 22, 1, 1, 180,
image_blend, image_alpha);
// Draws the bottom beam head sprite normally
draw_sprite(spr_beam_head, 0, x, y + 128 + 22);
● →←obj_player
// Checks if beam has already hit the player
if (!has_hit)
{
// Plays impact sound
audio_play_sound(snd_force_field_impact, 100, false, 1.0);
c. obj_enemy
● Create
// Flag for knowing if hit and damaged the player
has_hit = false;
// Walking speed variable
walking_speed = 3;
// Creates a shadow object to follow the enemy and sets up the sprite and
offset
var _shadow = instance_create_layer(x, y, "StageShadows",
obj_shadow);
_shadow.sprite_index = spr_enemy_shadow;
_shadow.owner = self;
_shadow.set_y_offset(150);
// Creates an alert object to the position with owner being set
var _alert = instance_create_layer(room_width - 100, y, "GUI",
obj_alert);
_alert.owner = self;
● Step
// Checks if the game is not currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves x position by current speed
x -= obj_game_manager.current_speed * 1.0;
// Checks the for step frame and step hasnt played for the step
if (!has_stepped && (round(image_index) == 4 ||
round(image_index) == 13))
{
// Chooses a random footstep
var _footstep = choose(snd_dino_robot_footstep_1,
snd_dino_robot_footstep_2, snd_dino_robot_footstep_3,
snd_dino_robot_footstep_4, snd_dino_robot_footstep_5,
snd_dino_robot_footstep_6);
● →← obj_player
if (!has_hit)
{
// Plays impact sound
audio_play_sound(snd_dino_robot_impact, 100, false, 1.0);
a. obj_flag_maker
● Create
// Sets the variables for flag placement and behaviours
has_dropped = false;
has_passed = false;
has_cooldown_adjusted = false;
● Step
// Checks the game is not currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Moves the x position by the current speed value
x -= obj_game_manager.current_speed * 1.0;
// Checks if the flag has been passed and a new highscore should
occur
if (!has_passed && obj_game_manager.current_distance >
global.highscore)
{
// Creates particle effect manager and sets up a confetti
effect
var _confetti_particle = instance_create_layer(x - 50, y -
20, "Stage", obj_particle_manager);
_confetti_particle.owner = self;
_confetti_particle.set_particle(ps_confetti,
"StageShadowsEffects");
_confetti_particle.set_offset(-50, -240);
● Draw
draw_self();
draw_set_font(fnt_rowdies_22);
draw_set_color(_text_colour);
draw_set_halign(fa_center);
draw_set_valign(fa_middle);
draw_set_color(c_white);
draw_set_alpha(1.0);
draw_set_halign(fa_left);
draw_set_valign(fa_top);
b. obj_player
● Create
// Sets the inital player position
x = 640;
y = 840;
// Boosting variables
is_boosting = false;
boost_cooldown = 0;
// Jump state
has_jumped = false;
// Footstep state
has_stepped = false;
// Creates a shadow to follow the player with the owner and offset setup
to the player
var _shadow = instance_create_layer(x, y, "StageShadows",
obj_shadow);
_shadow.owner = self;
_shadow.set_y_offset(100);
● Destroy
// Stops the sounds
audio_stop_sound(jet_sound);
audio_stop_sound(air_sound);
● Step
// Checks the game is not currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Set delta time for movements that are time based.
var _delta_time = delta_time * 0.000001;
_new_flame_particle.set_particle(ps_inital_jump_flame,
"StageBackEffects");
_new_flame_particle.set_offset(0,
100);
_new_flame_particle.move_rate = 0;
_new_flame_particle.drag_rate =
0.05;
_dust_particle.set_particle(ps_dust_small, "StageFrontEffects");
_dust_particle.move_rate = 0;
_dust_particle.drag_rate = 0.05;
}
// Checks if the y velocity is greater than the
jump threshold (Stronger jump effect)
else if (y_velo > jump_threshold)
{
// Sets the state to fly big
current_player_state =
PLAYER_STATE.FLY_BIG;
// Resets the player sprite
sprite_index = spr_character_idle;
}
else
{
// Sets the state to fly small
current_player_state =
PLAYER_STATE.FLY_SMALL;
// Resets the player sprite
sprite_index = spr_character_idle;
}
}
// Checks if the player is in air
else if (y < ystart)
{
// Sets the state to released (falling)
current_player_state =
PLAYER_STATE.FLY_RELEASED;
// Resets the player sprite
sprite_index = spr_character_idle;
}
_new_aura_particle.set_particle(ps_powerup_out,
"StageFrontEffects");
// Sets boosting state to false
is_boosting = false;
// Resets the cooldown
boost_cooldown = 0;
}
}
else
{
// Sets the target spped to 50% (Normal
speed)
obj_game_manager.target_speed_percentage
= 0.5;
}
break;
case GAME_STATE.DYING:
break;
case GAME_STATE.ENDED:
// Do nothing
break;
case GAME_STATE.PAUSED:
// Do nothing
break;
case GAME_STATE.TUTORIAL:
break;
}
_new_flame_particle.set_particle(ps_inital_jump_flame,
"StageBackEffects");
_new_flame_particle.set_offset(0,
100);
_new_flame_particle.move_rate = 0;
_new_flame_particle.drag_rate =
0.05;
_dust_particle.set_particle(ps_dust_small, "StageFrontEffects");
_dust_particle.move_rate = 0;
_dust_particle.drag_rate = 0.05;
}
// Check if vertical jump velocity is greater
than the threshold
else if (y_velo > jump_threshold)
{
// Set player state to big jump
current_player_state =
PLAYER_STATE.FLY_BIG;
// Resets the player sprite
sprite_index = spr_character_idle;
}
else
{
// Set player state to small jump
current_player_state =
PLAYER_STATE.FLY_SMALL;
// Resets the player sprite
sprite_index = spr_character_idle;
}
}
// Check if player is in air
else if (y < ystart)
{
// Sets player state to released (falling)
current_player_state =
PLAYER_STATE.FLY_RELEASED;
// Resets the player sprite
sprite_index = spr_character_idle;
}
break;
}
_dust_particle.set_particle(ps_dust_small, "StageFrontEffects");
_dust_particle.move_rate = 0;
_dust_particle.drag_rate = 0.01;
● End Step
// Checks if the game is paused
if (obj_game_manager.current_game_state ==
GAME_STATE.PAUSED)
{
// Fades out the sounds
audio_sound_gain(jet_sound, 0.0, 100);
audio_sound_gain(air_sound, 0.0, 100);
break;
break;
// When boosting
case PLAYER_STATE.BOOST:
_new_flame_particle.set_particle(ps_speed_booster_flame,
"StageBackEffects");
_new_flame_particle.set_angle(270);
_new_flame_particle.set_offset(-100, 30);
_new_smoke_particle.set_particle(ps_speed_booster_smoke,
"StageFrontEffects");
_new_smoke_particle.set_angle(90);
_new_smoke_particle.set_offset(-100, 30);
break;
// Checks the for step frame and step hasnt played for the
step
if (!has_stepped && (round(image_index) == 2 ||
round(image_index) == 7))
{
// Chooses a random footstep
var _footstep = choose(snd_chicken_footstep_1,
snd_chicken_footstep_2, snd_chicken_footstep_3,
snd_chicken_footstep_4, snd_chicken_footstep_5,
snd_chicken_footstep_6, snd_chicken_footstep_7);
// Plays the footstep sound
audio_play_sound(_footstep, 100, false, 1.0);
break;
// When the player is idle
case PLAYER_STATE.IDLE:
break;
break;
}
● Draw
// Change logic depending on the current game state.
switch (obj_game_manager.current_game_state)
{
// Logic for while the game is playing.
case GAME_STATE.PLAYING:
image_speed = 2.0 *
clamp(obj_game_manager.current_speed_percentage, 0.25, 1.0);
break;
draw_self();
● Animation End
// Checks if the player is dead
if (current_player_state == PLAYER_STATE.DEATH)
{
// Sets alpha to zero to hide
image_alpha = 0;
}
// Checks if the player is idle
else if (current_player_state == PLAYER_STATE.IDLE)
{
// Sets the animation to small flying state
current_player_state = PLAYER_STATE.FLY_SMALL;
// Resets the set sprite to idle
sprite_index = spr_character_idle;
}
c. obj_shadow(bóng tối)
● Create
// Checks if the player is dead
if (current_player_state == PLAYER_STATE.DEATH)
{
// Sets alpha to zero to hide
image_alpha = 0;
}
// Checks if the player is idle
else if (current_player_state == PLAYER_STATE.IDLE)
{
// Sets the animation to small flying state
current_player_state = PLAYER_STATE.FLY_SMALL;
// Resets the set sprite to idle
sprite_index = spr_character_idle;
}
● Step
// Checks game isnt paused
if (obj_game_manager.current_game_state != GAME_STATE.PAUSED)
{
// Checks owner has been set
if (owner != noone)
{
// Set x position to follow owner
x = owner.x;
// Temp variables for scaling the shadows size based on how high
the owner is to the ground where it exists
var _delta_y = abs(y - owner.y) - y_offset;
var _scale = 1;
var _shadow_height = 400;
d. obj_shield
● Create
// Sets the shield to initally be invisible
image_alpha = 0;
// Life variable for shield counts down till it should end
life = 0;
● Destroy
audio_stop_sound(shield_sound);
● Step
// Checks if the game is not currently paused
if (obj_game_manager.current_game_state !=
GAME_STATE.PAUSED)
{
// Sets the shield position to the players positions
x = obj_player.x;
y = obj_player.y;
if (sprite_index != spr_shield_off)
{
if (obj_game_manager.current_game_state ==
GAME_STATE.PLAYING)
{
// Sets the gain of shield sound to on
audio_sound_gain(shield_sound, 1.0, 0);
}
else
{
// Sets the gain of shield sound to off
audio_sound_gain(shield_sound, 0.0, 0);
}
}
● Draw
// Checks if game is paused
if (obj_game_manager.current_game_state ==
GAME_STATE.PAUSED)
{
// Pauses animation speed
image_speed = 0;
}
else
{
// Plays animation speed normally
image_speed = 1;
}
// Draws shield
draw_self();
● Animation End
// If the sprite animation for off state has finished
if (sprite_index == spr_shield_off)
{
// Destroy the shield object as it has died fully
instance_destroy();
}
6. UI
7. Particles systems
8. Sprites
9. UI