Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missile defence microgame #257

Merged
merged 12 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
39 changes: 38 additions & 1 deletion Loungeware/Loungeware.yyp

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions Loungeware/objects/wae_missle_arrowkeys/wae_missle_arrowkeys.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions Loungeware/objects/wae_missle_backgroundeffect/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/// @description Insert description here
// You can write your code in this editor

image_xscale = 0.3
image_yscale = 0.3
image_angle = 180 - 45
image_alpha = 0.5
wae_missle_yspd = random(3)
y = room_height
x = random_range(room_width*0.2, room_width*0.4) - room_width/2
var _p = part_type_create()
part_type_shape(_p, pt_shape_sphere);
part_type_size(_p, 0.1, 0.1, -0.001, 0);
part_type_scale(_p, 3, 1);
part_type_orientation(_p, 0, 0, 0, 0, 1);
part_type_color3(_p, c_red, c_yellow, c_black);
part_type_alpha3(_p, 0.3, 0.6, 0);
part_type_blend(_p, 1);
part_type_life(_p, 10, 12);
part_type_speed(_p, 0, 0, 0, 0);
part_type_direction(_p, 0, 360, 0, 0);
part_type_gravity(_p, 0,0)
wae_missle_mytrail = _p

if random(1) > 0.5
{
var _snd_id = sfx_play(wae_snd_missle_misslefire, random_range(0.15,0.2), 0);
audio_sound_pitch(_snd_id, random_range(0.8,1.2));
}
11 changes: 11 additions & 0 deletions Loungeware/objects/wae_missle_backgroundeffect/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/// @description Insert description here
// You can write your code in this editor


y -= wae_missle_yspd
x += wae_missle_yspd
part_type_direction(wae_missle_mytrail,image_angle+90,image_angle+90,0,0)
var rdx = random_range(-3,3)
part_particles_create(wae_missle_flak.wae_missle_background_partsystem,x+rdx,y,wae_missle_mytrail,1)

wae_missle_yspd = min (3, wae_missle_yspd + 0.05)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions Loungeware/objects/wae_missle_flak/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/// @description Insert description here
// You can write your code in this editor

sprite_index = wae_missle_flakSpriteNeutral
wae_missle_fire_delay = 8 - floor(DIFFICULTY/2)
wae_missle_enemy_delay = 30 - DIFFICULTY*5
wae_missle_enemy_delay2 = floor(wae_missle_enemy_delay/2)
wae_missle_cannondist = -10
wae_missle_cannondseparation = [3,-2]
wae_missle_flak_index = 0
wae_missle_counter= 0
wae_missle_keys_alpha = 1
wae_missle_won = false
wae_missle_keys_pressed = false
image_speed = 0
wae_missle_flak_imagecounter = 0

wae_missle_partsystem = part_system_create()
wae_missle_midground_partsystem = part_system_create_layer("midground_particles",false)
wae_missle_midground_partsystem2 = part_system_create_layer("midground_particles",false)
wae_missle_background_partsystem = part_system_create_layer("background_particles",false)

wae_missle_lost = false
wae_missle_lost_delay = 0
layer_background_speed(layer_background_get_id(layer_get_id("Backgrounds3")), 0 )
layer_background_speed(layer_background_get_id(layer_get_id("Backgrounds4")), 0 )


wae_missle_always_shoot = true
if wae_missle_always_shoot
{
wae_missle_arrowkeys.sprite_index = wae_missle_arroykeys_LR
}



5 changes: 5 additions & 0 deletions Loungeware/objects/wae_missle_flak/Draw_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// @description Insert description here
// You can write your code in this editor

draw_sprite(wae_missle_flakBaseSprite,0,x,y)
draw_self()
96 changes: 96 additions & 0 deletions Loungeware/objects/wae_missle_flak/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/// @description Insert description here
// You can write your code in this editor
wae_missle_flak_rotspeed = 5
wae_missle_arrowkeys.image_alpha = wae_missle_keys_alpha


if wae_missle_always_shoot
{
wae_missle_flak_rotspeed = 2.5
}
else
{
if (KEY_PRIMARY or KEY_SECONDARY)
{
wae_missle_flak_rotspeed = 2.5
wae_missle_keys_pressed = true
}
}

if KEY_LEFT
{
image_angle += wae_missle_flak_rotspeed
wae_missle_keys_pressed = true
}
if KEY_RIGHT
{
image_angle -= wae_missle_flak_rotspeed
wae_missle_keys_pressed = true
}
if wae_missle_keys_pressed and wae_missle_keys_alpha > 0
{
wae_missle_keys_alpha -= 0.01
}

wae_missle_counter += 1
var addx = wae_missle_cannondseparation[wae_missle_flak_index]*dcos(image_angle-45+90) + wae_missle_cannondist*dcos(image_angle-45)
var addy = -1*wae_missle_cannondseparation[wae_missle_flak_index]*dsin(image_angle-45+90) - wae_missle_cannondist*dsin(image_angle-45)
//if wae_missle_counter mod wae_missle_fire_delay == 0 and wae_missle_counter > 70 and not wae_missle_lost and instance_number(wae_missle_missle)
if wae_missle_counter mod wae_missle_fire_delay == 0 and not wae_missle_lost and (KEY_PRIMARY or KEY_SECONDARY or wae_missle_always_shoot) and not (instance_number(wae_missle_missle) == 0 and wae_missle_counter > 571 -200) and (wae_missle_counter > 70 or not wae_missle_always_shoot)

{
sprite_index = wae_missle_flakSprite
var _snd_id = sfx_play(wae_snd_missle_shoot, random_range(0.6,0.8), 0);
audio_sound_pitch(_snd_id, random_range(0.8,1.2));

instance_create_depth(x+addx,y+addy,depth+1,wae_missle_flak_bullet)
instance_create_depth(x+addx,y+addy,depth-1,wae_missle_flak_fireeffect, {image_angle : image_angle})
wae_missle_flak_index = not wae_missle_flak_index
image_speed = 2
if wae_missle_flak_index
{
image_index = 1
}
else
{
image_index = 4
}
}
else if image_index == 1 or image_index == 4
{
image_index = 0
image_speed = 0
}

if wae_missle_counter mod wae_missle_enemy_delay == 0 and not wae_missle_lost and wae_missle_counter < 571 -200
{
instance_create_layer(x,y,"midground_instances",wae_missle_missle)
}
if wae_missle_counter mod wae_missle_enemy_delay2 == 0 and not wae_missle_lost and wae_missle_counter < 571 -220
{
instance_create_layer(x,y,"background_instances",wae_missle_backgroundeffect)
}
if wae_missle_lost
{
sprite_index = wae_missle_flakSpriteSad
wae_missle_lost_delay += 1
if wae_missle_lost_delay > 100
{
microgame_end_early()
}
}
if instance_number(wae_missle_missle) == 0 and wae_missle_counter > 571 -200 and not wae_missle_lost
{
if not wae_missle_won
{
microgame_music_stop()
sfx_play(wae_snd_missle_defense_victory)
}
wae_missle_won = true
sprite_index = wae_missle_flakSpriteHappy
wae_missle_lost_delay += 1
if wae_missle_lost_delay > 60
{
microgame_end_early()
}
}
4 changes: 4 additions & 0 deletions Loungeware/objects/wae_missle_flak/Step_1.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/// @description Insert description here
// You can write your code in this editor


39 changes: 39 additions & 0 deletions Loungeware/objects/wae_missle_flak/wae_missle_flak.yy

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions Loungeware/objects/wae_missle_flak_bullet/Create_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/// @description Insert description here
// You can write your code in this editor

speed = -5
image_xscale = 0.5
image_yscale = 0.5
image_angle = wae_missle_flak.image_angle + 45 + 90 + 180
direction = image_angle

wae_missle_mindist = 9999999999
wae_missle_prevmindist = 0
wae_missle_armed = false
wae_missle_closest_missle = -4
wae_missle_arming_dist = 20
wae_missle_explode = false
wae_missle_age = 0

var _p = part_type_create()
part_type_shape(_p, pt_shape_sphere);
part_type_size(_p, 0.06, 0.06, -0.001, 0);
part_type_scale(_p, 3, 1);
part_type_orientation(_p, 0, 0, 0, 0, 1);
part_type_color3(_p, c_yellow, c_white, c_white);
part_type_alpha3(_p, 0.3, 0.2, 0);
part_type_blend(_p, 1);
part_type_life(_p, 10, 10);
part_type_speed(_p, 0, 0, 0, 0);
part_type_direction(_p, 0, 360, 0, 0);
part_type_gravity(_p, 0, 0)
wae_missle_mytrail = _p

38 changes: 38 additions & 0 deletions Loungeware/objects/wae_missle_flak_bullet/Step_0.gml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/// @description Insert description here
// You can write your code in this editor
wae_missle_age += 1
wae_missle_mindist = 99999
image_xscale = 0.5 - wae_missle_age*0.01*0.5
image_yscale = 0.5 - wae_missle_age*0.01*0.5
for (var i = 0; i < instance_number(wae_missle_missle); i++)
{
var mi = instance_find(wae_missle_missle,i)
var dist = point_distance(x,y,mi.x,mi.y)
if dist < wae_missle_arming_dist and not wae_missle_armed
{
wae_missle_prevmindist = dist
wae_missle_armed = true
}
if dist < wae_missle_mindist
{
wae_missle_mindist = dist
}
}
if wae_missle_armed and wae_missle_prevmindist > wae_missle_mindist
{
instance_create_depth(x,y,depth,wae_missle_flak_explosion)
instance_create_depth(x,y,depth,wae_missle_flak_explosiondamage)
instance_destroy(self)
}

if wae_missle_armed
{
wae_missle_prevmindist = wae_missle_mindist
}
part_type_direction(wae_missle_mytrail,image_angle,image_angle,0,0)
part_particles_create(wae_missle_flak.wae_missle_partsystem,x,y,wae_missle_mytrail,1)

if y < 0
{
instance_destroy(self)
}
Loading
Loading