This commit is contained in:
Robin Hübner 2017-08-01 23:28:11 +02:00
parent 240625e5fe
commit 365baa560f
10 changed files with 58 additions and 8 deletions

View File

@ -6,6 +6,7 @@ var rot_vel = 0
var max_vel = 6 # pixels per second?
var max_rot_vel = 2.5 # degrees per second
var health = 100
func _ready():
randomize()
@ -28,6 +29,9 @@ func wrap(v, v_min, v_max):
return v_min - 1
else:
return v
func explode():
queue_free()
func _fixed_process(delta):
@ -36,6 +40,14 @@ func _fixed_process(delta):
# cur_pos.y = wrap(cur_pos.y, 1, get_viewport().get_rect().size.y)
# 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.rotate(rot_vel)

View File

@ -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://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"]
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/mask = 1
collision/margin = 0.08
@ -15,4 +23,11 @@ script/script = ExtResource( 1 )
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

View File

@ -11,9 +11,17 @@ func _ready():
func fire(delta, vel, dir, speed):
velocity = (vel.length() * dir + (dir * speed * delta))
sprite.rotate(dir.angle())
func type():
return "Enemy"
func _fixed_process(delta):
move(velocity)
lifetime -= delta
if is_colliding():
var e = get_collider()
if lifetime <= 0:
queue_free()

View File

@ -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://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"]
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/mask = 1
collision/margin = 0.08
@ -15,4 +23,10 @@ script/script = ExtResource( 1 )
texture = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )
trigger = false
_update_shape_index = 0

View File

@ -1,6 +1,7 @@
extends KinematicBody2D
var grunt_rot_speed = deg2rad(22.5) # degrees per second
var current_target = null
func _ready():
var t = get_tree()

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ee80f8310c0716d3d0f917da317607e0d9a20fa40ef02c9981f17d1f62bbe44e
size 934
oid sha256:19ae97544f084ae4390b575fbd44134e69ba056ca0993a50cdcda21008c5555c
size 950

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4f8b9553f7da9e0500ddfe73a11dcf865060d559fd6c9b929e1bed2aff6c13df
size 720
oid sha256:ca8e9d7504871a709af802f1057b1454f32629118ec00f754a84d9ebfd4c0dae
size 732

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 375 B

View File

@ -1,3 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ec423b64d26fc631e98da5910e9f22e0e758e12836a3e6409fac3d76ecc1f6ae
size 1188
oid sha256:47c369c1ae588c03991289f61ea8f4ee12f1027a071f98bc6d383b1fdf15eb25
size 1262

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB