Compare commits
No commits in common. "bb18edb1be23ceb770568e52536da24bd00a97b1" and "cae134a05443e49c8a1378e65da0560852a9093e" have entirely different histories.
bb18edb1be
...
cae134a054
3 changed files with 28 additions and 52 deletions
|
|
@ -2,9 +2,8 @@ extends Area2D
|
||||||
|
|
||||||
var velocity = Vector2(0, 0)
|
var velocity = Vector2(0, 0)
|
||||||
var rot_velocity = 0
|
var rot_velocity = 0
|
||||||
|
|
||||||
var explosion = preload('res://Scenes/explosion.tscn')
|
var explosion = preload('res://Scenes/explosion.tscn')
|
||||||
var pop = preload("res://Sounds/Explosion.wav")
|
var pop = preload("res://Sounds/Explosion5.wav")
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
connect("body_entered", _on_body_entered)
|
connect("body_entered", _on_body_entered)
|
||||||
|
|
@ -16,16 +15,14 @@ func _physics_process(delta):
|
||||||
Utils.wrap_position(self)
|
Utils.wrap_position(self)
|
||||||
|
|
||||||
func _on_body_entered(body):
|
func _on_body_entered(body):
|
||||||
if body.name == "Ship" and body.hit():
|
if body.name == "Ship":
|
||||||
|
Game.set_lives(Game.lives - 1)
|
||||||
|
|
||||||
|
Utils.play_sound(pop, get_parent())
|
||||||
|
|
||||||
|
var boom = explosion.instantiate()
|
||||||
|
boom.position = body.global_position
|
||||||
|
boom.scale = Vector2(6, 6)
|
||||||
|
get_parent().add_child(boom)
|
||||||
|
body.reset()
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
func hit():
|
|
||||||
Utils.play_sound(pop, get_parent())
|
|
||||||
|
|
||||||
var boom = explosion.instantiate()
|
|
||||||
boom.position = global_position
|
|
||||||
boom.scale = scale
|
|
||||||
get_parent().add_child(boom)
|
|
||||||
|
|
||||||
Game.set_score(Game.score + 100)
|
|
||||||
queue_free()
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
|
var explosion = preload('res://Scenes/explosion.tscn')
|
||||||
|
var pop = preload("res://Sounds/Explosion.wav")
|
||||||
var speed = 750
|
var speed = 750
|
||||||
|
|
||||||
var half_size: Vector2 # half of sprite dimensions (used for wrapping)
|
var half_size: Vector2 # half of sprite dimensions (used for wrapping)
|
||||||
|
|
@ -15,10 +17,21 @@ func _physics_process(delta):
|
||||||
var rect = get_viewport_rect()
|
var rect = get_viewport_rect()
|
||||||
|
|
||||||
if position.x < -half_size.x or position.x > rect.size.x + half_size.x or position.y < -half_size.y or position.y > rect.size.y + half_size.y:
|
if position.x < -half_size.x or position.x > rect.size.x + half_size.x or position.y < -half_size.y or position.y > rect.size.y + half_size.y:
|
||||||
|
#print_debug("FREED")
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|
||||||
func _on_body_entered(body):
|
func _on_body_entered(body):
|
||||||
if body.is_in_group("enemies"):
|
if body.is_in_group("enemies"):
|
||||||
body.hit()
|
body.queue_free()
|
||||||
|
|
||||||
|
Utils.play_sound(pop, get_parent())
|
||||||
|
|
||||||
|
var boom = explosion.instantiate()
|
||||||
|
boom.position = body.global_position
|
||||||
|
boom.scale = body.scale
|
||||||
|
get_parent().add_child(boom)
|
||||||
|
|
||||||
|
Game.set_score(Game.score + 100)
|
||||||
|
|
||||||
queue_free()
|
queue_free()
|
||||||
|
#print_debug("KILLED")
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,15 @@
|
||||||
extends CharacterBody2D
|
extends CharacterBody2D
|
||||||
|
|
||||||
const ROT_SPEED = 4.0
|
const ROT_SPEED = 3.0
|
||||||
const MOVE_ACC = 120
|
const MOVE_ACC = 100
|
||||||
const FRICTION = 0.995
|
const FRICTION = 0.995
|
||||||
const FIRE_RATE = 0.2
|
const FIRE_RATE = 0.2
|
||||||
const INV_FLASH_INT = 0.1
|
|
||||||
|
|
||||||
@export var Laser: PackedScene
|
@export var Laser: PackedScene
|
||||||
@export var pew: Resource
|
@export var pew: Resource
|
||||||
|
|
||||||
var speed = Vector2(0, 0)
|
var speed = Vector2(0, 0)
|
||||||
var last_shot = 0.0
|
var last_shot = 0.0
|
||||||
var last_flash = 0.0
|
|
||||||
var inv_time = 0.0
|
|
||||||
|
|
||||||
var explosion = preload('res://Scenes/explosion.tscn')
|
|
||||||
var pop = preload("res://Sounds/Explosion5.wav")
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
Game.player = self
|
Game.player = self
|
||||||
|
|
@ -53,15 +47,6 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
Utils.wrap_position(self)
|
Utils.wrap_position(self)
|
||||||
|
|
||||||
if is_invincible():
|
|
||||||
inv_time -= delta
|
|
||||||
last_flash += delta
|
|
||||||
if last_flash >= INV_FLASH_INT:
|
|
||||||
$AnimatedSprite2D.visible = !$AnimatedSprite2D.visible
|
|
||||||
last_flash = 0.0
|
|
||||||
else:
|
|
||||||
$AnimatedSprite2D.visible = true
|
|
||||||
|
|
||||||
# --- Fire projectile on space ---
|
# --- Fire projectile on space ---
|
||||||
last_shot += delta
|
last_shot += delta
|
||||||
if Input.is_action_pressed("ui_accept") and last_shot >= FIRE_RATE: # default = Space/Enter
|
if Input.is_action_pressed("ui_accept") and last_shot >= FIRE_RATE: # default = Space/Enter
|
||||||
|
|
@ -73,25 +58,6 @@ func _physics_process(delta: float) -> void:
|
||||||
bullet.transform = $Muzzle.global_transform
|
bullet.transform = $Muzzle.global_transform
|
||||||
last_shot = 0.0
|
last_shot = 0.0
|
||||||
|
|
||||||
func die():
|
func reset():
|
||||||
position = get_viewport_rect().size / 2
|
position = get_viewport_rect().size / 2
|
||||||
speed = Vector2(0, 0)
|
speed = Vector2(0, 0)
|
||||||
inv_time = 3.0
|
|
||||||
|
|
||||||
func is_invincible():
|
|
||||||
return inv_time > 0
|
|
||||||
|
|
||||||
func hit() -> bool:
|
|
||||||
if !is_invincible():
|
|
||||||
Game.set_lives(Game.lives - 1)
|
|
||||||
|
|
||||||
Utils.play_sound(pop, get_parent())
|
|
||||||
|
|
||||||
var boom = explosion.instantiate()
|
|
||||||
boom.position = global_position
|
|
||||||
boom.scale = Vector2(6, 6)
|
|
||||||
get_parent().add_child(boom)
|
|
||||||
die()
|
|
||||||
return true
|
|
||||||
|
|
||||||
return false
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue