Upgrade menu now acutally works. Game ends when mothership dies. Can be

restarted.
This commit is contained in:
Sage Vaillancourt 2018-05-23 21:35:16 -04:00
parent c73b2c4aeb
commit 094633af4a
26 changed files with 213 additions and 33 deletions

View File

@ -11,6 +11,10 @@ var screensize
var health = 50 var health = 50
var hit_timer = 1000 var hit_timer = 1000
func _on_Visibility_screen_exited():
prints("bye-bye, bad bad")
queue_free()
func _ready(): func _ready():
connect("area_entered", self, "hit") connect("area_entered", self, "hit")
pass pass

View File

@ -33,7 +33,7 @@ collision_mask = 0
audio_bus_override = false audio_bus_override = false
audio_bus_name = "Master" audio_bus_name = "Master"
script = ExtResource( 1 ) script = ExtResource( 1 )
_sections_unfolded = [ "Collision", "Transform" ] _sections_unfolded = [ "Collision", "Transform", "Z Index" ]
SPEED = 50 SPEED = 50
Laser = ExtResource( 2 ) Laser = ExtResource( 2 )

View File

@ -14,6 +14,8 @@ func _ready():
connect("area_entered", self, "hit") connect("area_entered", self, "hit")
pass pass
func _on_Visibility_screen_exited():
queue_free()
func hit(who): func hit(who):
health -= 10 health -= 10

57
GameOver.tscn Normal file
View File

@ -0,0 +1,57 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Node.gd" type="Script" id=1]
[ext_resource path="res://art/gameover.png" type="Texture" id=2]
[sub_resource type="SpriteFrames" id=1]
animations = [ {
"frames": [ ExtResource( 2 ) ],
"loop": true,
"name": "default",
"speed": 5.0
} ]
[node name="Node" type="Node"]
pause_mode = 2
script = ExtResource( 1 )
_sections_unfolded = [ "Pause" ]
[node name="AnimatedSprite" type="AnimatedSprite" parent="." index="0"]
position = Vector2( 524.951, 264.196 )
scale = Vector2( 0.457698, 0.457698 )
z_index = 1
frames = SubResource( 1 )
animation = "default"
_sections_unfolded = [ "Z Index" ]
[node name="Button" type="Button" parent="." index="1"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0
anchor_bottom = 0.0
margin_left = 490.0
margin_top = 480.0
margin_right = 690.0
margin_bottom = 561.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 1
size_flags_vertical = 1
toggle_mode = false
enabled_focus_mode = 2
shortcut = null
group = null
text = "Restart?"
flat = false
align = 1
[connection signal="pressed" from="Button" to="." method="_on_Button_pressed"]

Binary file not shown.

View File

@ -8,6 +8,7 @@ var plasma = false
var current_pen = 0 var current_pen = 0
func _on_Visibility_screen_exited(): func _on_Visibility_screen_exited():
prints("byebye laser boi")
queue_free() queue_free()
func _ready(): func _ready():

14
Main.gd
View File

@ -7,7 +7,10 @@ var position = Vector2(200, 200)
var total_bads_spawned = 0 var total_bads_spawned = 0
var upgrade_cost = 50 var upgrade_cost = 50
const BADDIE_WAIT_TIME_DEFAULT = 5
func _ready(): func _ready():
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT
$BaddieTimer.start() $BaddieTimer.start()
randomize() randomize()
updatePoints() updatePoints()
@ -58,3 +61,14 @@ func updatePoints():
func _on_Player_update_display(): func _on_Player_update_display():
updatePoints() updatePoints()
func _on_Mothership_game_over():
$Player.gameOver()
func _on_Player_restart_game():
for child in self.get_children():
if (child.has_method("_on_Visibility_screen_exited")):
child.queue_free()
total_bads_spawned = 0
$BaddieTimer.wait_time = BADDIE_WAIT_TIME_DEFAULT

View File

@ -48,12 +48,24 @@ texture = ExtResource( 4 )
[node name="BaddieTimer" type="Timer" parent="." index="3"] [node name="BaddieTimer" type="Timer" parent="." index="3"]
process_mode = 1 process_mode = 1
wait_time = 5.0 wait_time = 1.0
one_shot = false one_shot = false
autostart = false autostart = false
[node name="Mothership" parent="." index="4" instance=ExtResource( 6 )] [node name="Mothership" parent="." index="4" instance=ExtResource( 6 )]
[node name="Line2D" type="Line2D" parent="Mothership" index="2"]
position = Vector2( 32.7402, 101.849 )
scale = Vector2( 3.33333, 3.33333 )
points = PoolVector2Array( 100, 200, 900, 200 )
width = 15.0
default_color = Color( 0.037384, 0.683594, 0, 1 )
texture_mode = 31
sharp_limit = 2.0
round_precision = 8
_sections_unfolded = [ "Z Index" ]
[node name="MoneyDisplay" type="Label" parent="." index="5"] [node name="MoneyDisplay" type="Label" parent="." index="5"]
anchor_left = 0.0 anchor_left = 0.0
@ -179,12 +191,20 @@ align = 1
[connection signal="refund" from="Player" to="." method="_on_Player_refund"] [connection signal="refund" from="Player" to="." method="_on_Player_refund"]
[connection signal="restart_game" from="Player" to="." method="_on_Player_restart_game"]
[connection signal="restart_game" from="Player" to="Mothership" method="_on_Player_restart_game"]
[connection signal="shooting_speed_upgrade" from="Player" to="." method="_on_Player_shooting_speed_upgrade"] [connection signal="shooting_speed_upgrade" from="Player" to="." method="_on_Player_shooting_speed_upgrade"]
[connection signal="update_display" from="Player" to="." method="_on_Player_update_display"] [connection signal="update_display" from="Player" to="." method="_on_Player_update_display"]
[connection signal="timeout" from="BaddieTimer" to="." method="BaddieTimer"] [connection signal="timeout" from="BaddieTimer" to="." method="BaddieTimer"]
[connection signal="body_shape_entered" from="Mothership" to="Mothership" method="_on_Mothership_body_shape_entered"]
[connection signal="game_over" from="Mothership" to="." method="_on_Mothership_game_over"]
[connection signal="button_down" from="UpButton" to="Player" method="upPressed"] [connection signal="button_down" from="UpButton" to="Player" method="upPressed"]
[connection signal="button_up" from="UpButton" to="Player" method="upDepressed"] [connection signal="button_up" from="UpButton" to="Player" method="upDepressed"]

View File

@ -6,13 +6,17 @@ export (PackedScene) var Laser
# var a = 2 # var a = 2
# var b = "textvar" # var b = "textvar"
var health = 1000 const STARTING_HEALTH = 500
var health = STARTING_HEALTH
var double_laser = false var double_laser = false
var can_shoot = true var can_shoot = true
var timer = null var timer = null
var bullet_delay = 0.1 var bullet_delay = 0.1
func _ready(): func _ready():
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )
pass pass
# timer = Timer.new() # timer = Timer.new()
# timer.set_one_shot(true) # timer.set_one_shot(true)
@ -21,8 +25,7 @@ func _ready():
# add_child(timer) # add_child(timer)
func _process(delta): func _process(delta):
if health <= 0: pass
emit_signal("game_over")
# # Called every frame. Delta is time since last frame. # # Called every frame. Delta is time since last frame.
# # Update game logic here. # # Update game logic here.
@ -43,3 +46,23 @@ func _process(delta):
# laser2.position.x = position.x + 46 # laser2.position.x = position.x + 46
# can_shoot = false # can_shoot = false
# timer.start() # timer.start()
func _on_Mothership_area_shape_entered(area_id, area, area_shape, self_shape):
health -= 50
prints(health)
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )
if health <= 250:
$AnimatedSprite.frame = 1
if health <= 100:
$AnimatedSprite.frame = 2
if health <= 0:
$AnimatedSprite.frame = 3
emit_signal("game_over")
prints("Game Over!")
func _on_Player_restart_game():
health = STARTING_HEALTH
$AnimatedSprite.frame = 0
var health_bar = Vector2(((health * (.8)) + 100), 200)
$Line2D.set_point_position( 1, health_bar )

View File

@ -1,8 +1,11 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://Mothership.gd" type="Script" id=1] [ext_resource path="res://Mothership.gd" type="Script" id=1]
[ext_resource path="res://Laser.tscn" type="PackedScene" id=2] [ext_resource path="res://Laser.tscn" type="PackedScene" id=2]
[ext_resource path="res://art/mothership/mothership.png" type="Texture" id=3] [ext_resource path="res://art/mothership/mothership.png" type="Texture" id=3]
[ext_resource path="res://art/mothership/mothership_damage1.png" type="Texture" id=4]
[ext_resource path="res://art/mothership/mothership_damage2.png" type="Texture" id=5]
[ext_resource path="res://art/mothership/mothership_ruined.png" type="Texture" id=6]
[sub_resource type="CapsuleShape2D" id=1] [sub_resource type="CapsuleShape2D" id=1]
@ -13,7 +16,7 @@ height = 2377.74
[sub_resource type="SpriteFrames" id=2] [sub_resource type="SpriteFrames" id=2]
animations = [ { animations = [ {
"frames": [ ExtResource( 3 ) ], "frames": [ ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ) ],
"loop": true, "loop": true,
"name": "default", "name": "default",
"speed": 5.0 "speed": 5.0
@ -28,10 +31,12 @@ gravity_vec = Vector2( 0, 1 )
gravity = 98.0 gravity = 98.0
linear_damp = 0.1 linear_damp = 0.1
angular_damp = 1.0 angular_damp = 1.0
collision_layer = 3
collision_mask = 3
audio_bus_override = false audio_bus_override = false
audio_bus_name = "Master" audio_bus_name = "Master"
script = ExtResource( 1 ) script = ExtResource( 1 )
_sections_unfolded = [ "Transform" ] _sections_unfolded = [ "Collision", "Transform" ]
Laser = ExtResource( 2 ) Laser = ExtResource( 2 )
[node name="ShipCollision" type="CollisionShape2D" parent="." index="0"] [node name="ShipCollision" type="CollisionShape2D" parent="." index="0"]
@ -44,4 +49,8 @@ shape = SubResource( 1 )
frames = SubResource( 2 ) frames = SubResource( 2 )
animation = "default" animation = "default"
[connection signal="area_shape_entered" from="." to="." method="_on_Mothership_area_shape_entered"]
[connection signal="body_entered" from="." to="." method="_on_Mothership_body_entered"]

21
Node.gd Normal file
View File

@ -0,0 +1,21 @@
extends Node
signal restart
# class member variables go here, for example:
# var a = 2
# var b = "textvar"
func _ready():
# Called every time the node is added to the scene.
# Initialization here
pass
#func _process(delta):
# # Called every frame. Delta is time since last frame.
# # Update game logic here.
# pass
func _on_Button_pressed():
emit_signal("restart")
queue_free()

View File

@ -6,6 +6,7 @@ signal shooting_speed_upgrade # signals that a shooting speed upgrade has occure
signal ship_speed_upgrade signal ship_speed_upgrade
signal shooting_speed_fully_upgraded signal shooting_speed_fully_upgraded
signal ship_speed_fully_upgraded signal ship_speed_fully_upgraded
signal restart_game
export (PackedScene) var Laser export (PackedScene) var Laser
@ -34,18 +35,20 @@ const SHIP_SPEED_TIER3_COST = 400
const SHIP_SPEED_TIER4_COST = 600 const SHIP_SPEED_TIER4_COST = 600
const SHIP_SPEED_TIER5_COST = 800 const SHIP_SPEED_TIER5_COST = 800
const STARTING_MONEY = 100000
var screensize var screensize
var ship_speed = SHIP_SPEED_TIER1 var ship_speed = SHIP_SPEED_TIER1
var bullet_delay = BULLET_DELAY_TIER1 var bullet_delay = BULLET_DELAY_TIER1
var bullet_delay_tier = 1 var bullet_delay_tier = 0
var laser_penetration = 0 var laser_penetration = 0
var double_laser = false var double_laser = false
var ship_value = 0 var ship_value = 0
var refund_percentage = 1 var refund_percentage = 1
var money = 100 var money = STARTING_MONEY
var shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT var shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
var ship_speed_upgrade = SHIP_SPEED_UPGRADE_DEFAULT var ship_speed_upgrade = SHIP_SPEED_UPGRADE_DEFAULT
@ -55,6 +58,7 @@ func upgradeMenu():
add_child(upgmenu) add_child(upgmenu)
upgmenu.connect("refund", self, "_refund_button") upgmenu.connect("refund", self, "_refund_button")
upgmenu.connect("bullet_delay_upgrade", self, "upgradeBulletDelay_button") upgmenu.connect("bullet_delay_upgrade", self, "upgradeBulletDelay_button")
upgmenu.bullet_delay_tier = bullet_delay_tier
get_tree().paused = true get_tree().paused = true
func upgradeBulletDelay_button(): func upgradeBulletDelay_button():
@ -67,18 +71,22 @@ func upgradeBulletDelay():
bullet_delay = BULLET_DELAY_TIER2 bullet_delay = BULLET_DELAY_TIER2
money -= BULLET_DELAY_TIER2_COST money -= BULLET_DELAY_TIER2_COST
ship_value += BULLET_DELAY_TIER2_COST ship_value += BULLET_DELAY_TIER2_COST
bullet_delay_tier = 1
elif (bullet_delay == BULLET_DELAY_TIER2 && money >= BULLET_DELAY_TIER3_COST): elif (bullet_delay == BULLET_DELAY_TIER2 && money >= BULLET_DELAY_TIER3_COST):
bullet_delay = BULLET_DELAY_TIER3 bullet_delay = BULLET_DELAY_TIER3
money -= BULLET_DELAY_TIER3_COST money -= BULLET_DELAY_TIER3_COST
ship_value += BULLET_DELAY_TIER3_COST ship_value += BULLET_DELAY_TIER3_COST
bullet_delay_tier = 2
elif (bullet_delay == BULLET_DELAY_TIER3 && money >= BULLET_DELAY_TIER4_COST): elif (bullet_delay == BULLET_DELAY_TIER3 && money >= BULLET_DELAY_TIER4_COST):
bullet_delay = BULLET_DELAY_TIER4 bullet_delay = BULLET_DELAY_TIER4
money -= BULLET_DELAY_TIER4_COST money -= BULLET_DELAY_TIER4_COST
ship_value += BULLET_DELAY_TIER4_COST ship_value += BULLET_DELAY_TIER4_COST
bullet_delay_tier = 3
elif (bullet_delay == BULLET_DELAY_TIER4 && money >= BULLET_DELAY_TIER5_COST): elif (bullet_delay == BULLET_DELAY_TIER4 && money >= BULLET_DELAY_TIER5_COST):
bullet_delay = BULLET_DELAY_TIER5 bullet_delay = BULLET_DELAY_TIER5
money -= BULLET_DELAY_TIER5_COST money -= BULLET_DELAY_TIER5_COST
ship_value += BULLET_DELAY_TIER5_COST ship_value += BULLET_DELAY_TIER5_COST
bullet_delay_tier = 4
elif (bullet_delay <= BULLET_DELAY_MINIMUM): elif (bullet_delay <= BULLET_DELAY_MINIMUM):
emit_signal("bullet_delay_fully_upgraded") emit_signal("bullet_delay_fully_upgraded")
elif (bullet_delay <= BULLET_DELAY_TIER5 && money >= shooting_speed_upgrade): elif (bullet_delay <= BULLET_DELAY_TIER5 && money >= shooting_speed_upgrade):
@ -86,6 +94,7 @@ func upgradeBulletDelay():
money -= shooting_speed_upgrade money -= shooting_speed_upgrade
ship_value += shooting_speed_upgrade ship_value += shooting_speed_upgrade
shooting_speed_upgrade *= 1.1 shooting_speed_upgrade *= 1.1
bullet_delay_tier += 1
timer.set_wait_time(bullet_delay) timer.set_wait_time(bullet_delay)
prints(bullet_delay) prints(bullet_delay)
@ -130,6 +139,7 @@ func _ready():
func _refund_button(): func _refund_button():
bullet_delay = BULLET_DELAY_TIER1 bullet_delay = BULLET_DELAY_TIER1
bullet_delay_tier = 0
timer.set_wait_time(bullet_delay) timer.set_wait_time(bullet_delay)
ship_speed = SHIP_SPEED_TIER1 ship_speed = SHIP_SPEED_TIER1
shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
@ -173,8 +183,8 @@ func _process(delta):
if ((Input.is_action_pressed("ui_accept") || shoot_down == true) && can_shoot == true): if ((Input.is_action_pressed("ui_accept") || shoot_down == true) && can_shoot == true):
shoot() shoot()
if (Input.is_action_pressed("ui_select") && can_shoot == true): # if (Input.is_action_pressed("ui_select") && can_shoot == true):
upgradeBulletDelay() # upgradeBulletDelay()
if (Input.is_action_pressed("ui_reset") && can_shoot == true): if (Input.is_action_pressed("ui_reset") && can_shoot == true):
#upgradeShipSpeed() #upgradeShipSpeed()
upgradeMenu() upgradeMenu()
@ -215,3 +225,16 @@ func shoot():
can_shoot = false can_shoot = false
timer.start() timer.start()
func gameOver():
var gameover = preload("res://GameOver.tscn").instance()
add_child(gameover)
gameover.connect("restart", self, "restart_game")
# gameover.connect("bullet_delay_upgrade", self, "upgradeBulletDelay_button")
get_tree().paused = true
func restart_game():
_refund_button()
get_tree().paused = false
money = STARTING_MONEY
emit_signal("restart_game")

View File

@ -6,6 +6,7 @@ signal bullet_delay_upgrade
signal add_laser signal add_laser
signal plasma_lasers signal plasma_lasers
var bullet_delay_tier
var shooting_speed_tier var shooting_speed_tier
var ship_speed_tier var ship_speed_tier
var double_lasers var double_lasers
@ -13,9 +14,10 @@ var double_lasers
func _ready(): func _ready():
pass pass
#func _process(delta): func _process(delta):
# pass $ShootingSpeedIcon.frame = bullet_delay_tier
if (Input.is_action_pressed("ui_quit")):
get_tree().quit()
func _on_Button_pressed(): func _on_Button_pressed():
get_tree().paused = false get_tree().paused = false
@ -34,5 +36,5 @@ func shooting_speed_upgrade_success():
func _on_ShootingSpeedUpgrade_pressed(): func _on_ShootingSpeedUpgrade_pressed():
get_tree().paused = false get_tree().paused = false
emit_signal("bullet_delay_upgrade") emit_signal("bullet_delay_upgrade")
$ShootingSpeedIcon.frame += 1 bullet_delay_tier = get_parent().bullet_delay_tier
pass pass

View File

@ -1,8 +1,11 @@
[gd_scene load_steps=6 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://UpgradeMenu.gd" type="Script" id=1] [ext_resource path="res://UpgradeMenu.gd" type="Script" id=1]
[ext_resource path="res://art/upgrade_menu/shootingspeed1.png" type="Texture" id=2] [ext_resource path="res://art/upgrade_menu/shootingspeed1.png" type="Texture" id=2]
[ext_resource path="res://art/upgrade_menu/shootingspeed2.png" type="Texture" id=3] [ext_resource path="res://art/upgrade_menu/shootingspeed2.png" type="Texture" id=3]
[ext_resource path="res://art/upgrade_menu/shootingspeed3.png" type="Texture" id=4]
[ext_resource path="res://art/upgrade_menu/shootingspeed4.png" type="Texture" id=5]
[ext_resource path="res://art/upgrade_menu/shootingspeed5.png" type="Texture" id=6]
[sub_resource type="Theme" id=1] [sub_resource type="Theme" id=1]
@ -10,13 +13,14 @@
[sub_resource type="SpriteFrames" id=2] [sub_resource type="SpriteFrames" id=2]
animations = [ { animations = [ {
"frames": [ ExtResource( 2 ), ExtResource( 3 ) ], "frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ), ExtResource( 6 ) ],
"loop": true, "loop": true,
"name": "default", "name": "default",
"speed": 5.0 "speed": 5.0
} ] } ]
_sections_unfolded = [ "Resource" ]
[node name="UpgradeMenu" type="Node" index="0"] [node name="UpgradeMenu" type="Node"]
pause_mode = 2 pause_mode = 2
script = ExtResource( 1 ) script = ExtResource( 1 )
@ -70,10 +74,10 @@ anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_left = 618.0 margin_left = 842.0
margin_top = 174.0 margin_top = 420.0
margin_right = 742.0 margin_right = 966.0
margin_bottom = 277.0 margin_bottom = 523.0
rect_pivot_offset = Vector2( 0, 0 ) rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false rect_clip_content = false
focus_mode = 2 focus_mode = 2
@ -91,8 +95,8 @@ align = 1
[node name="ShootingSpeedIcon" type="AnimatedSprite" parent="." index="3"] [node name="ShootingSpeedIcon" type="AnimatedSprite" parent="." index="3"]
position = Vector2( 287.25, 218.906 ) position = Vector2( 525.939, 118.838 )
scale = Vector2( 0.244531, 0.244531 ) scale = Vector2( 0.392712, 0.392712 )
frames = SubResource( 2 ) frames = SubResource( 2 )
animation = "default" animation = "default"
@ -102,10 +106,10 @@ anchor_left = 0.0
anchor_top = 0.0 anchor_top = 0.0
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
margin_left = 210.0 margin_left = 400.0
margin_top = 170.0 margin_top = 40.0
margin_right = 365.0 margin_right = 652.0
margin_bottom = 268.0 margin_bottom = 198.0
rect_pivot_offset = Vector2( 0, 0 ) rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false rect_clip_content = false
focus_mode = 2 focus_mode = 2

BIN
art/gameover.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB