Initial commit.
This commit is contained in:
commit
142bf87eca
24 changed files with 356 additions and 0 deletions
6
scripts/event_bus.gd
Normal file
6
scripts/event_bus.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
extends Node
|
||||
|
||||
@warning_ignore_start("unused_signal") # since otherwise Godot will throw a warning that the signal is unused in current scope
|
||||
|
||||
|
||||
@warning_ignore_restore("unused_signal") # put any future signals you add between the two ignore annotations
|
||||
1
scripts/event_bus.gd.uid
Normal file
1
scripts/event_bus.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bv56i5pud2p3x
|
||||
72
scripts/player.gd
Normal file
72
scripts/player.gd
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
extends Area2D
|
||||
|
||||
@export var speed: int = 150
|
||||
@export var shield_max: int = 10
|
||||
|
||||
var shield: int = 0: set = shield_set
|
||||
var can_shoot: bool = true
|
||||
var is_shooting: bool = false
|
||||
|
||||
var weapon_current = load("res://scenes/stock_weapon.tscn")
|
||||
var weapon_cooldown = Timer
|
||||
var weapon_rate: float = 0.1
|
||||
var weapon_timer: float = 0.0
|
||||
|
||||
@onready var screensize = get_viewport_rect().size
|
||||
|
||||
func _process(delta):
|
||||
var input = Input.get_vector("left", "right", "up","down")
|
||||
|
||||
#TODO: sprite frame change on x axis
|
||||
#if input.x > 0:
|
||||
#$Ship.frame = 2
|
||||
#$Ship/Boosters.animation = "right"
|
||||
#elif input.x < 0:
|
||||
#$Ship.frame = 0
|
||||
#$Ship/Boosters.animation = "left"
|
||||
#else:
|
||||
#$Ship.frame = 1
|
||||
#$Ship/Boosters.animation = "forward"
|
||||
|
||||
position += input * speed * delta
|
||||
position = position.clamp(Vector2(12,12), screensize - Vector2(12,12))
|
||||
|
||||
if Input.is_action_pressed("shoot"):
|
||||
print("Spacebar pressed!")
|
||||
is_shooting = true
|
||||
else:
|
||||
is_shooting = false
|
||||
|
||||
if is_shooting == true:
|
||||
weapon_timer += delta
|
||||
print(weapon_timer)
|
||||
if weapon_timer >= weapon_rate:
|
||||
shoot()
|
||||
weapon_timer = 0.0
|
||||
|
||||
if is_shooting == false: return
|
||||
|
||||
func shield_set(_sdvalue: int):
|
||||
return
|
||||
|
||||
|
||||
func _on_weapon_cooldown_timeout() -> void:
|
||||
#print("You can shoot again!")
|
||||
#can_shoot = true
|
||||
return
|
||||
|
||||
|
||||
func shoot():
|
||||
|
||||
#if not can_shoot: return
|
||||
#if can_shoot:
|
||||
var bullet = weapon_current.instantiate()
|
||||
bullet.position = self.position + Vector2(0,-12)
|
||||
get_tree().root.add_child(bullet)
|
||||
weapon_rate = bullet.shot_data.rate
|
||||
print(bullet.shot_data.shot_name, " weapon fired") #Print which weapon is firing
|
||||
#weapon_cooldown = $WeaponCooldown
|
||||
#weapon_cooldown.wait_time = bullet.shot_data.cooldown
|
||||
#weapon_cooldown.start()
|
||||
#can_shoot = not can_shoot
|
||||
|
||||
1
scripts/player.gd.uid
Normal file
1
scripts/player.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://otm88638j7f8
|
||||
9
scripts/player_shot.gd
Normal file
9
scripts/player_shot.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
class_name PlayerShot
|
||||
extends Resource
|
||||
|
||||
@export var shot_name: String
|
||||
@export var damage: int = 1
|
||||
@export var speed: int = 100
|
||||
@export var rate: float = 0.1
|
||||
@export var cooldown: float = 0.25
|
||||
@export var sprite: Texture2D = preload("res://graphics/shot.png")
|
||||
1
scripts/player_shot.gd.uid
Normal file
1
scripts/player_shot.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ccdohs4gduee5
|
||||
9
scripts/stock_weapon.gd
Normal file
9
scripts/stock_weapon.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var bullet = load("res://scenes/stock_weapon.tscn")
|
||||
|
||||
@export var shot_data: PlayerShot
|
||||
|
||||
|
||||
func _process(delta):
|
||||
position.y += shot_data.speed * delta
|
||||
1
scripts/stock_weapon.gd.uid
Normal file
1
scripts/stock_weapon.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d1rwqotmrag1r
|
||||
Loading…
Add table
Add a link
Reference in a new issue