mirror of https://github.com/profan/ld-39-jam.git
wew
This commit is contained in:
parent
240625e5fe
commit
365baa560f
12
Asteroid.gd
12
Asteroid.gd
|
@ -6,6 +6,7 @@ var rot_vel = 0
|
||||||
|
|
||||||
var max_vel = 6 # pixels per second?
|
var max_vel = 6 # pixels per second?
|
||||||
var max_rot_vel = 2.5 # degrees per second
|
var max_rot_vel = 2.5 # degrees per second
|
||||||
|
var health = 100
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
randomize()
|
randomize()
|
||||||
|
@ -29,6 +30,9 @@ func wrap(v, v_min, v_max):
|
||||||
else:
|
else:
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
func explode():
|
||||||
|
queue_free()
|
||||||
|
|
||||||
func _fixed_process(delta):
|
func _fixed_process(delta):
|
||||||
|
|
||||||
# var cur_pos = get_pos()
|
# var cur_pos = get_pos()
|
||||||
|
@ -36,6 +40,14 @@ func _fixed_process(delta):
|
||||||
# cur_pos.y = wrap(cur_pos.y, 1, get_viewport().get_rect().size.y)
|
# cur_pos.y = wrap(cur_pos.y, 1, get_viewport().get_rect().size.y)
|
||||||
# set_pos(cur_pos)
|
# set_pos(cur_pos)
|
||||||
|
|
||||||
|
if is_colliding():
|
||||||
|
var e = get_collider()
|
||||||
|
if e.type() == "Bullet":
|
||||||
|
health -= 25
|
||||||
|
|
||||||
|
if health <= 0:
|
||||||
|
explode()
|
||||||
|
|
||||||
self.move(velocity)
|
self.move(velocity)
|
||||||
self.rotate(rot_vel)
|
self.rotate(rot_vel)
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,19 @@
|
||||||
[gd_scene load_steps=3 format=1]
|
[gd_scene load_steps=4 format=1]
|
||||||
|
|
||||||
[ext_resource path="res://Asteroid.gd" type="Script" id=1]
|
[ext_resource path="res://Asteroid.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://raw/asteroid.png" type="Texture" id=2]
|
[ext_resource path="res://raw/asteroid.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
custom_solver_bias = 0.0
|
||||||
|
extents = Vector2( 25.1672, 26.3172 )
|
||||||
|
|
||||||
[node name="Asteroid" type="KinematicBody2D"]
|
[node name="Asteroid" type="KinematicBody2D"]
|
||||||
|
|
||||||
input/pickable = false
|
input/pickable = false
|
||||||
|
shapes/0/shape = SubResource( 1 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, -0.17482, 3.67132 )
|
||||||
|
shapes/0/trigger = false
|
||||||
collision/layers = 1
|
collision/layers = 1
|
||||||
collision/mask = 1
|
collision/mask = 1
|
||||||
collision/margin = 0.08
|
collision/margin = 0.08
|
||||||
|
@ -15,4 +23,11 @@ script/script = ExtResource( 1 )
|
||||||
|
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
transform/pos = Vector2( -0.17482, 3.67132 )
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -12,8 +12,16 @@ func fire(delta, vel, dir, speed):
|
||||||
velocity = (vel.length() * dir + (dir * speed * delta))
|
velocity = (vel.length() * dir + (dir * speed * delta))
|
||||||
sprite.rotate(dir.angle())
|
sprite.rotate(dir.angle())
|
||||||
|
|
||||||
|
func type():
|
||||||
|
return "Enemy"
|
||||||
|
|
||||||
func _fixed_process(delta):
|
func _fixed_process(delta):
|
||||||
|
|
||||||
move(velocity)
|
move(velocity)
|
||||||
lifetime -= delta
|
lifetime -= delta
|
||||||
|
|
||||||
|
if is_colliding():
|
||||||
|
var e = get_collider()
|
||||||
|
|
||||||
if lifetime <= 0:
|
if lifetime <= 0:
|
||||||
queue_free()
|
queue_free()
|
16
Bullet.tscn
16
Bullet.tscn
|
@ -1,11 +1,19 @@
|
||||||
[gd_scene load_steps=3 format=1]
|
[gd_scene load_steps=4 format=1]
|
||||||
|
|
||||||
[ext_resource path="res://Bullet.gd" type="Script" id=1]
|
[ext_resource path="res://Bullet.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://raw/simple_bullet.png" type="Texture" id=2]
|
[ext_resource path="res://raw/simple_bullet.png" type="Texture" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
|
|
||||||
|
custom_solver_bias = 0.0
|
||||||
|
extents = Vector2( 0.99762, 3.98857 )
|
||||||
|
|
||||||
[node name="Bullet" type="KinematicBody2D"]
|
[node name="Bullet" type="KinematicBody2D"]
|
||||||
|
|
||||||
input/pickable = false
|
input/pickable = false
|
||||||
|
shapes/0/shape = SubResource( 1 )
|
||||||
|
shapes/0/transform = Matrix32( 1, 0, 0, 1, 0, 0 )
|
||||||
|
shapes/0/trigger = false
|
||||||
collision/layers = 1
|
collision/layers = 1
|
||||||
collision/mask = 1
|
collision/mask = 1
|
||||||
collision/margin = 0.08
|
collision/margin = 0.08
|
||||||
|
@ -15,4 +23,10 @@ script/script = ExtResource( 1 )
|
||||||
|
|
||||||
texture = ExtResource( 2 )
|
texture = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
|
|
||||||
|
shape = SubResource( 1 )
|
||||||
|
trigger = false
|
||||||
|
_update_shape_index = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
extends KinematicBody2D
|
extends KinematicBody2D
|
||||||
|
|
||||||
var grunt_rot_speed = deg2rad(22.5) # degrees per second
|
var grunt_rot_speed = deg2rad(22.5) # degrees per second
|
||||||
|
var current_target = null
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
var t = get_tree()
|
var t = get_tree()
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ee80f8310c0716d3d0f917da317607e0d9a20fa40ef02c9981f17d1f62bbe44e
|
oid sha256:19ae97544f084ae4390b575fbd44134e69ba056ca0993a50cdcda21008c5555c
|
||||||
size 934
|
size 950
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:4f8b9553f7da9e0500ddfe73a11dcf865060d559fd6c9b929e1bed2aff6c13df
|
oid sha256:ca8e9d7504871a709af802f1057b1454f32629118ec00f754a84d9ebfd4c0dae
|
||||||
size 720
|
size 732
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 336 B After Width: | Height: | Size: 375 B |
|
@ -1,3 +1,3 @@
|
||||||
version https://git-lfs.github.com/spec/v1
|
version https://git-lfs.github.com/spec/v1
|
||||||
oid sha256:ec423b64d26fc631e98da5910e9f22e0e758e12836a3e6409fac3d76ecc1f6ae
|
oid sha256:47c369c1ae588c03991289f61ea8f4ee12f1027a071f98bc6d383b1fdf15eb25
|
||||||
size 1188
|
size 1262
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
Loading…
Reference in New Issue