From efbcd5cf222ba395688e9a748771a5eef7209da1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robin=20H=C3=BCbner?= Date: Fri, 11 Aug 2017 21:59:26 +0200 Subject: [PATCH] bullet layer and such, dont collide bullets with other bullets --- Asteroid.tscn | 2 +- Bullet.gd | 4 ++-- Bullet.tscn | 3 ++- EnemyGrunt.tscn | 2 +- Gun.gd | 5 +++-- Player.tscn | 2 +- PowerStation.tscn | 2 +- raw/simple_bullet.ase | 4 ++-- raw/simple_bullet.png | Bin 110 -> 138 bytes 9 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Asteroid.tscn b/Asteroid.tscn index 8db07fa..87b192c 100644 --- a/Asteroid.tscn +++ b/Asteroid.tscn @@ -15,7 +15,7 @@ input/pickable = false shapes/0/shape = SubResource( 1 ) shapes/0/transform = Matrix32( 1, 0, 0, 1, -0.17482, 1.87222 ) shapes/0/trigger = false -collision/layers = 1 +collision/layers = 3 collision/mask = 1 collision/margin = 0.08 script/script = ExtResource( 1 ) diff --git a/Bullet.gd b/Bullet.gd index 3e1be9c..f843396 100644 --- a/Bullet.gd +++ b/Bullet.gd @@ -10,8 +10,8 @@ func _ready(): func fire(delta, vel, dir, speed): velocity = (vel.length() * dir + (dir * speed * delta)) - sprite.rotate(dir.angle()) - + sprite.set_rot(dir.angle()) + func type(): return "Bullet" diff --git a/Bullet.tscn b/Bullet.tscn index 4270b7c..02315b8 100644 --- a/Bullet.tscn +++ b/Bullet.tscn @@ -11,11 +11,12 @@ extents = Vector2( 0.99762, 3.98857 ) [node name="Bullet" type="KinematicBody2D"] transform/rot = 180.0 +transform/scale = Vector2( 2, 2 ) 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 = 2 collision/mask = 1 collision/margin = 0.08 script/script = ExtResource( 1 ) diff --git a/EnemyGrunt.tscn b/EnemyGrunt.tscn index 524b181..49e3037 100644 --- a/EnemyGrunt.tscn +++ b/EnemyGrunt.tscn @@ -8,7 +8,7 @@ transform/scale = Vector2( 2, 2 ) input/pickable = false -collision/layers = 1 +collision/layers = 3 collision/mask = 1 collision/margin = 0.08 script/script = ExtResource( 1 ) diff --git a/Gun.gd b/Gun.gd index 6902900..11dce87 100644 --- a/Gun.gd +++ b/Gun.gd @@ -4,7 +4,8 @@ var Bullet = load("res://Bullet.tscn") var gun_cooldown = 0 var gun_delay = 0.1125 -var gun_spread_max = deg2rad(1) # degrees max +var gun_spread_max = deg2rad(4) # degrees max +var gun_bullet_speed = 384 func _ready(): set_fixed_process(true) @@ -19,5 +20,5 @@ func fire(delta, vel, dir): new_bullet.set_pos(gun_pos + vel) get_tree().get_root().add_child(new_bullet) var rot = rand_range(-gun_spread_max, gun_spread_max) - new_bullet.fire(delta, vel, dir.rotated(rot), 512) + new_bullet.fire(delta, vel, dir.rotated(rot), gun_bullet_speed) gun_cooldown += gun_delay diff --git a/Player.tscn b/Player.tscn index 18d5ad9..a9c1856 100644 --- a/Player.tscn +++ b/Player.tscn @@ -10,7 +10,7 @@ transform/scale = Vector2( 2, 2 ) input/pickable = false -collision/layers = 1 +collision/layers = 3 collision/mask = 1 collision/margin = 0.08 script/script = ExtResource( 1 ) diff --git a/PowerStation.tscn b/PowerStation.tscn index 3f9af69..3cc563b 100644 --- a/PowerStation.tscn +++ b/PowerStation.tscn @@ -6,7 +6,7 @@ [node name="PowerStation" type="KinematicBody2D"] input/pickable = false -collision/layers = 1 +collision/layers = 3 collision/mask = 1 collision/margin = 0.08 script/script = ExtResource( 1 ) diff --git a/raw/simple_bullet.ase b/raw/simple_bullet.ase index 23c687b..01e06f5 100644 --- a/raw/simple_bullet.ase +++ b/raw/simple_bullet.ase @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4d43c431b9848d37f00b63f37a5f0a4a72b482591f925ffe609a723f6fe06ad5 -size 552 +oid sha256:72293b378ae4057d8742c1346ae48daf38d5ca68a987529d5a4a700edd16fd79 +size 568 diff --git a/raw/simple_bullet.png b/raw/simple_bullet.png index 9e33a2cec87f5d6c102b28abdbf5473f6126c146..34e1b8d4fcd5a3f561eec8ab3edbe38f63625a45 100644 GIT binary patch delta 108 zcmV-y0F(c2iUE)$W>HB*K~xx(h0QSvz#tTZ;h*9;9D4%K?MaHOH)uh@j$O*rrCkDI zmcR!g09Xv&V(0)4fZbmJaIhh9U!MxELQ;4XszUx@dRr9k<-`=)bTR;C#Ss|EIaB`t O0000IROZMl&ik@zhB$&zodkO#0-fG4BS)fIE4=cGzOn$yRqL