mirror of https://github.com/profan/ld-39-jam.git
fighting them bollets
This commit is contained in:
parent
4f553abc0f
commit
0a8e9f5cc0
13
Bullet.gd
13
Bullet.gd
|
@ -1,7 +1,18 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var velocity = Vector2(1, 0)
|
||||
var lifetime = 16 # seconds
|
||||
|
||||
onready var sprite = get_node("Sprite")
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
|
||||
func fire(vel, dir, speed):
|
||||
velocity = vel + (dir * speed)
|
||||
|
||||
func _fixed_process(delta):
|
||||
pass
|
||||
move(velocity * delta)
|
||||
lifetime -= delta
|
||||
if lifetime <= 0:
|
||||
queue_free()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=2 format=1]
|
||||
[gd_scene load_steps=3 format=1]
|
||||
|
||||
[ext_resource path="res://Bullet.gd" type="Script" id=1]
|
||||
[ext_resource path="res://raw/simple_bullet.png" type="Texture" id=2]
|
||||
|
||||
[node name="Bullet" type="KinematicBody2D"]
|
||||
|
||||
|
@ -10,4 +11,8 @@ collision/mask = 1
|
|||
collision/margin = 0.08
|
||||
script/script = ExtResource( 1 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
extends Sprite
|
||||
|
||||
var Bullet = load("res://Bullet.tscn")
|
||||
|
||||
var gun_cooldown = 0
|
||||
var gun_delay = 0.25
|
||||
|
||||
func _ready():
|
||||
set_fixed_process(true)
|
||||
|
||||
func _fixed_process(delta):
|
||||
gun_cooldown = gun_cooldown - delta
|
||||
|
||||
func fire(vel, dir):
|
||||
if gun_cooldown <= 0:
|
||||
var new_bullet = Bullet.instance()
|
||||
var gun_pos = get_global_pos()
|
||||
new_bullet.set_pos(gun_pos)
|
||||
get_tree().get_root().add_child(new_bullet)
|
||||
new_bullet.fire(vel, dir, 256)
|
||||
gun_cooldown += gun_delay
|
|
@ -3,6 +3,8 @@ extends KinematicBody2D
|
|||
onready var sprite = get_node("Sprite")
|
||||
onready var camera = get_node("Camera2D")
|
||||
onready var particles = get_node("Sprite/Particles2D")
|
||||
onready var left_gun = get_node("Sprite/LeftGun")
|
||||
onready var right_gun = get_node("Sprite/RightGun")
|
||||
|
||||
var mov_speed = 64 # pixels per second
|
||||
var ship_vel = Vector2(0, 0)
|
||||
|
@ -41,10 +43,11 @@ func _fixed_process(delta):
|
|||
is_moving = false
|
||||
|
||||
if Input.is_action_pressed("player_attack_primary"):
|
||||
pass
|
||||
left_gun.fire(ship_vel, -ship_dir)
|
||||
right_gun.fire(ship_vel, -ship_dir)
|
||||
elif Input.is_action_pressed("player_attack_secondary"):
|
||||
pass
|
||||
|
||||
|
||||
if Input.is_action_pressed("player_switch_up"):
|
||||
pass
|
||||
elif Input.is_action_pressed("player_switch_down"):
|
||||
|
|
17
Player.tscn
17
Player.tscn
|
@ -1,8 +1,9 @@
|
|||
[gd_scene load_steps=4 format=1]
|
||||
[gd_scene load_steps=5 format=1]
|
||||
|
||||
[ext_resource path="res://Player.gd" type="Script" id=1]
|
||||
[ext_resource path="res://img/player_ship.tex" type="Texture" id=2]
|
||||
[ext_resource path="res://raw/exhaust.png" type="Texture" id=3]
|
||||
[ext_resource path="res://Gun.gd" type="Script" id=3]
|
||||
[ext_resource path="res://raw/exhaust.png" type="Texture" id=4]
|
||||
|
||||
[node name="Player" type="KinematicBody2D"]
|
||||
|
||||
|
@ -17,6 +18,16 @@ script/script = ExtResource( 1 )
|
|||
|
||||
texture = ExtResource( 2 )
|
||||
|
||||
[node name="LeftGun" type="Sprite" parent="Sprite"]
|
||||
|
||||
transform/pos = Vector2( -13.0319, -4.86733 )
|
||||
script/script = ExtResource( 3 )
|
||||
|
||||
[node name="RightGun" type="Sprite" parent="Sprite"]
|
||||
|
||||
transform/pos = Vector2( 12.0375, -4.97201 )
|
||||
script/script = ExtResource( 3 )
|
||||
|
||||
[node name="Particles2D" type="Particles2D" parent="Sprite"]
|
||||
|
||||
transform/pos = Vector2( 0, 13.1031 )
|
||||
|
@ -24,7 +35,7 @@ config/amount = 256
|
|||
config/lifetime = 2.0
|
||||
config/process_mode = 1
|
||||
config/local_space = false
|
||||
config/texture = ExtResource( 3 )
|
||||
config/texture = ExtResource( 4 )
|
||||
params/direction = 0.0
|
||||
params/spread = 24.0
|
||||
params/linear_velocity = 32.0
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
filter=false
|
Loading…
Reference in New Issue