-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
713 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
extends Area2D | ||
|
||
export (PackedScene) var Box | ||
|
||
var speed = 400 | ||
|
||
var obstacles = 0 | ||
var dropAllowed = false | ||
var dropped = false | ||
|
||
func _ready(): | ||
$DropTimer.start(0.9 + (0.2 - randf()*0.4)) | ||
|
||
func _physics_process(delta): | ||
position += -transform.y * speed * delta | ||
if not dropped and dropAllowed and obstacles == 0: | ||
drop() | ||
|
||
func _on_VisibilityNotifier2D_screen_exited(): | ||
queue_free() | ||
|
||
func drop(): | ||
var box = Box.instance() | ||
box.global_position = global_position | ||
box.apply_central_impulse(-transform.y * 500) | ||
box.rotation = rotation + rand_range(-PI / 2, PI / 2) | ||
var rnd = randf() | ||
if rnd < 0.5: | ||
box.setContent(1) | ||
elif rnd < 0.9: | ||
box.setContent(2) | ||
else: | ||
box.setContent(3) | ||
box.z_index = z_index - 1 | ||
box.collision_layer = 128 | ||
box.collision_mask = 128 | ||
box.set_angular_velocity(5) | ||
get_parent().add_child(box) | ||
box.setScale(Vector2(1.5, 1.5)) | ||
dropped = true | ||
|
||
func _on_DropTimer_timeout(): | ||
dropAllowed = true | ||
|
||
func _on_Aircraft_body_entered(body): | ||
obstacles += 1 | ||
|
||
func _on_Aircraft_body_exited(body): | ||
obstacles -= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[gd_scene load_steps=5 format=2] | ||
|
||
[ext_resource path="res://images/plane.png" type="Texture" id=1] | ||
[ext_resource path="res://Aircraft.gd" type="Script" id=2] | ||
[ext_resource path="res://Box.tscn" type="PackedScene" id=3] | ||
|
||
[sub_resource type="RectangleShape2D" id=1] | ||
extents = Vector2( 15.8861, 14.1277 ) | ||
|
||
[node name="Aircraft" type="Area2D"] | ||
z_index = 10 | ||
script = ExtResource( 2 ) | ||
Box = ExtResource( 3 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
scale = Vector2( 0.063, 0.063 ) | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
position = Vector2( -0.374573, -82.9523 ) | ||
scale = Vector2( 2.04304, 1.96886 ) | ||
shape = SubResource( 1 ) | ||
|
||
[node name="DropTimer" type="Timer" parent="."] | ||
one_shot = true | ||
|
||
[connection signal="body_entered" from="." to="." method="_on_Aircraft_body_entered"] | ||
[connection signal="body_exited" from="." to="." method="_on_Aircraft_body_exited"] | ||
[connection signal="timeout" from="DropTimer" to="." method="_on_DropTimer_timeout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
extends RigidBody2D | ||
|
||
|
||
func _on_PickArea_body_entered(body): | ||
if body.is_in_group("tank") and body.life > 0: | ||
queue_free() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[gd_scene load_steps=5 format=2] | ||
|
||
[ext_resource path="res://images/nitro.png" type="Texture" id=1] | ||
[ext_resource path="res://Barrel.gd" type="Script" id=2] | ||
|
||
[sub_resource type="RectangleShape2D" id=1] | ||
extents = Vector2( 2.76727, 4.33193 ) | ||
|
||
[sub_resource type="CapsuleShape2D" id=2] | ||
radius = 8.06976 | ||
height = 33.491 | ||
|
||
[node name="Barrel" type="RigidBody2D"] | ||
script = ExtResource( 2 ) | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] | ||
scale = Vector2( 3.12, 2.6 ) | ||
shape = SubResource( 1 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
scale = Vector2( 0.063, 0.063 ) | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="PickArea" type="Area2D" parent="."] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickArea"] | ||
scale = Vector2( 2.06014, -0.801646 ) | ||
shape = SubResource( 2 ) | ||
|
||
[connection signal="body_entered" from="PickArea" to="." method="_on_PickArea_body_entered"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
extends RigidBody2D | ||
|
||
export (PackedScene) var Shell | ||
|
||
enum Content { SHELL=0, SMALL_SHELLS=1, BIG_SHELL=2, SPRING=3 } | ||
|
||
var content = null | ||
var targetScale = Vector2(1, 1) | ||
var scaleDelta = Vector2(0.4, 0.4) | ||
var blinks = 5 | ||
var shells = 0 | ||
var life = 8 | ||
|
||
func _ready(): | ||
content = $Sprite/Content.frame | ||
|
||
func setScale(scale): | ||
self.scale = scale | ||
scaleDelta = scale - targetScale | ||
|
||
func _physics_process(delta): | ||
if scale.length() > 1: | ||
var ratio = $FallTimer.time_left / $FallTimer.wait_time | ||
scale = targetScale + ratio * scaleDelta | ||
|
||
func setContent(content): | ||
$Sprite/Content.frame = content | ||
self.content = content | ||
|
||
func hit(damage, source): | ||
life -= damage | ||
if life < 0: | ||
if content != Content.SPRING: | ||
fire(source) | ||
queue_free() | ||
|
||
func fire(source, angle=0): | ||
var s = Shell.instance() | ||
if content == Content.BIG_SHELL: | ||
s.setBig() | ||
elif content == Content.SMALL_SHELLS: | ||
s.setSmall() | ||
if angle == 0: | ||
fire(source, randf() * PI + PI / 3) | ||
fire(source, -randf() * PI + PI / 3) | ||
s.transform = transform | ||
s.rotate(angle) | ||
get_parent().add_child(s) | ||
s.setSource(source) | ||
|
||
func _on_PickArea_body_entered(body): | ||
if body.is_in_group("tank") and body.life > 0: | ||
collision_layer = 256 | ||
collision_mask = 256 | ||
$PickTimer.start() | ||
z_index = 0 | ||
if content == Content.SPRING: | ||
body.addSpring() | ||
if content == Content.SHELL: | ||
body.addPoints(shells) | ||
if content == Content.BIG_SHELL: | ||
body.addBigShell() | ||
if content == Content.SMALL_SHELLS: | ||
body.addSmallShells() | ||
|
||
func _on_FallTimer_timeout(): | ||
z_index = 1 | ||
collision_layer = 1 | ||
set_angular_velocity(0) | ||
|
||
func _on_PickTimer_timeout(): | ||
if blinks % 2: | ||
modulate.a = 0 | ||
else: | ||
modulate.a = 1 | ||
blinks -= 1 | ||
if blinks == 0: | ||
queue_free() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
[gd_scene load_steps=10 format=2] | ||
|
||
[ext_resource path="res://images/box.png" type="Texture" id=1] | ||
[ext_resource path="res://images/shell.png" type="Texture" id=2] | ||
[ext_resource path="res://images/small-shells.png" type="Texture" id=3] | ||
[ext_resource path="res://images/spring.png" type="Texture" id=4] | ||
[ext_resource path="res://images/big-shell.png" type="Texture" id=5] | ||
[ext_resource path="res://Box.gd" type="Script" id=6] | ||
[ext_resource path="res://Shell.tscn" type="PackedScene" id=7] | ||
|
||
[sub_resource type="SpriteFrames" id=1] | ||
animations = [ { | ||
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 5 ), ExtResource( 4 ) ], | ||
"loop": true, | ||
"name": "default", | ||
"speed": 5.0 | ||
} ] | ||
|
||
[sub_resource type="CapsuleShape2D" id=3] | ||
radius = 10.7314 | ||
height = 44.8859 | ||
|
||
[node name="Box" type="RigidBody2D" groups=[ | ||
"heavy", | ||
"target", | ||
]] | ||
z_index = 1 | ||
z_as_relative = false | ||
script = ExtResource( 6 ) | ||
Shell = ExtResource( 7 ) | ||
|
||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] | ||
position = Vector2( 0, -2 ) | ||
scale = Vector2( 0.063, 0.063 ) | ||
polygon = PoolVector2Array( -203.652, -271.332, -96.4444, -272.383, -96.4261, -311.874, 95.2381, -312.128, 95.2381, -273.189, 203.106, -273.434, 203.398, 270.991, 95.1389, 272.042, 94.5607, 310.2, -94.2023, 309.61, -95.0871, 271.858, -203.036, 271.858 ) | ||
|
||
[node name="Sprite" type="Sprite" parent="."] | ||
scale = Vector2( 0.063, 0.063 ) | ||
texture = ExtResource( 1 ) | ||
|
||
[node name="Content" type="AnimatedSprite" parent="Sprite"] | ||
modulate = Color( 0.776471, 0.776471, 0.776471, 1 ) | ||
position = Vector2( 0, -7 ) | ||
rotation = 0.207694 | ||
frames = SubResource( 1 ) | ||
|
||
[node name="PickArea" type="Area2D" parent="."] | ||
|
||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PickArea"] | ||
scale = Vector2( 2.06014, -0.801646 ) | ||
shape = SubResource( 3 ) | ||
|
||
[node name="FallTimer" type="Timer" parent="."] | ||
wait_time = 0.6 | ||
one_shot = true | ||
autostart = true | ||
|
||
[node name="PickTimer" type="Timer" parent="."] | ||
wait_time = 0.06 | ||
|
||
[connection signal="body_entered" from="PickArea" to="." method="_on_PickArea_body_entered"] | ||
[connection signal="timeout" from="FallTimer" to="." method="_on_FallTimer_timeout"] | ||
[connection signal="timeout" from="PickTimer" to="." method="_on_PickTimer_timeout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.