Skip to content

Commit

Permalink
Initial game commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Piepkorn committed Apr 26, 2021
1 parent e32b938 commit d96c311
Show file tree
Hide file tree
Showing 66 changed files with 1,436 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="eb66c7dc1b1b58b9d321ef9992599487"
dest_md5="7585c160f835f8ed32d4da170bb25f00"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/Hit_Hurt.wav-e35a9a626e412bd050e57f54fb8f6f56.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="af14246f1f6727f6d97d0b4d37b02cd3"
dest_md5="f9d270becba640198df2bb641f47717e"

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="63ab22c25c84669b84f04c8e4dcb233a"
dest_md5="1bad5e8481ddc30458968b46329f5d64"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/ball-grey.png-d00286a716a96ecf7a9105009576e182.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="a8bc67e62863d07970d7c7b83bfd2aa7"
dest_md5="a42e2c843b7561fd10a134e214e86b43"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/chain.png-40a65e105e3052733dfec7f73e6a2028.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="30ddc8a2bbe9c142d0d0088f2f0e860a"
dest_md5="686ea14ffb721fe4a377231a2153d3ea"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/dollar-crate.png-c7b060f615d26f65f1a5f12f910cbf9b.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="16fc68b438315c3f73728141f45dab4b"
dest_md5="e5c2aeb101a5429e30db4e1e46f295c1"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/hook.png-75e1f4fcaca6e01ae9951d13bcfec6f3.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="c9b25e023c273748623b084147e081da"
dest_md5="becb4d945324cebf9b34275dcc40b69d"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/icon.png-487276ed1e3a0c39cad0279d744ee560.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="47313fa4c47a9963fddd764e1ec6e4a8"
dest_md5="2ded9e7f9060e2b530aab678b135fc5b"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/light.png-06e94102f0cce323cff7daad56cf3030.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="7fa6ef2827a0ab8776857290813b7275"
dest_md5="95cd43934ec86b0d318fdbef764d50be"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/light256.png-a4c3c1f048850e66cf8dcc0e64bb5a94.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="e4527ea39b903bc5f1fed9e59780aa86"
dest_md5="41f410b9dc50b93e65bce2dc2f2a5f9d"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/noise.mp3-d8ed4762a41834bd51d826e5127cf656.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="b02b4fd325409eec20969fbcb6e88dfb"
dest_md5="f9f6ed36c30ba000083c3b3f7994cfa8"

Binary file not shown.
3 changes: 3 additions & 0 deletions .import/ship.png-232cf3806b465084ad9b06c70afe8991.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source_md5="995d8f68491f5e84df8d5fb3abb06157"
dest_md5="965d8647a51f6f961c14ed50a370b294"

Binary file not shown.
Binary file added Blip_Select10.wav
Binary file not shown.
21 changes: 21 additions & 0 deletions Blip_Select10.wav.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[remap]

importer="wav"
type="AudioStreamSample"
path="res://.import/Blip_Select10.wav-2060b5c57d013afd587fbf6823b7b2e0.sample"

[deps]

source_file="res://Blip_Select10.wav"
dest_files=[ "res://.import/Blip_Select10.wav-2060b5c57d013afd587fbf6823b7b2e0.sample" ]

[params]

force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop=false
compress/mode=0
88 changes: 88 additions & 0 deletions Chain.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
extends Node2D

var velocity = 0
var length = 0
var speed = 50
var bodies = Array()
var anchor: Node2D = null;
var linkRadius = 5;

onready var linkTemplate: PackedScene = preload("res://ChainLink.tscn")
onready var anchorTemplate: PackedScene = preload("res://ChainAnchor.tscn")
onready var anim: AnimationPlayer = get_node("/root/UI/AnimationPlayer")

func get_input():
velocity = 0
if (get_node("/root/Global").gameOver):
return;
if Input.is_action_pressed("down"):
velocity += 1
if Input.is_action_pressed("up"):
velocity -= 1

func _physics_process(delta):
get_input();
length = max(0, length + velocity*delta*speed);
updateBodies();

func _process(_delta):
if (is_instance_valid(anchor)):
get_node("../Camera2D").position = anchor.position;
get_node("../../Level/BackgroundNoise").volume_db = -25
else:
get_node("../Camera2D").position = Vector2(0, 50);
get_node("../../Level/BackgroundNoise").volume_db = -15

func updateBodies():
var num = floor(length / (linkRadius*2));
#var rest = length - num * linkRadius*2;
while (bodies.size() < num):
var body = linkTemplate.instance()
var parentBody = get_parent();
var p0 = Vector2(0, 0);
body.position = Vector2(p0.x, p0.y + linkRadius*2)
body.visible = true
bodies.push_front(body)
add_child(body)

var joint = PinJoint2D.new()
joint.softness = 0.1;
joint.node_a = parentBody.get_path()
joint.node_b = body.get_path();
body.add_child(joint);

if (bodies.size() > 1):
var j1 = bodies[1].get_child(2);
j1.queue_free();
bodies[1].position = Vector2(bodies[1].position.x, bodies[1].position.y + linkRadius*2)
j1 = PinJoint2D.new()
j1.softness = 0.1;
j1.node_a = body.get_path()
j1.node_b = bodies[1].get_path();
bodies[1].add_child(j1);
else:
anchor = anchorTemplate.instance();
anchor.position = Vector2(p0.x, p0.y + linkRadius*5)
add_child(anchor);
var j2 = PinJoint2D.new()
j2.position = Vector2(0, -3)
j2.softness = 0.1;
j2.node_a = body.get_path()
j2.node_b = anchor.get_path();
anchor.add_child(j2);
anim.play("In")
while (bodies.size() > num):
bodies.pop_front().queue_free();
if (bodies.size() > 0):
var j1 = bodies[0].get_child(2);
j1.queue_free();
bodies[0].position = Vector2(0, linkRadius*2)
j1 = PinJoint2D.new()
j1.softness = 0.1;
j1.node_a = get_parent().get_path();
j1.node_b = bodies[0].get_path();
bodies[0].add_child(j1);
else:
anchor.queue_free()
anim.play("Out")

43 changes: 43 additions & 0 deletions ChainAnchor.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extends RigidBody2D

var crate: RigidBody2D;
var joint: DampedSpringJoint2D;
export (bool) var attached = false;
var nextLoss = 0.0;

func _ready():
pass # Replace with function body.

#func _process(delta):
# pass

func _input(event):
if event.is_action_pressed("jump") && is_instance_valid(crate) && (crate.global_position - global_position).length() < 20:
print("attach")
joint = DampedSpringJoint2D.new()
joint.node_a = self.get_path();
joint.node_b = crate.get_path();
joint.length = 10;
joint.rest_length = 10;
joint.stiffness = 64.0;
add_child(joint);
attached = true
get_node("/root/UI/Panel2/CrateImage").visible = true
elif event.is_action_pressed("jump") && is_instance_valid(joint):
print("detach")
joint.queue_free()
attached = false
get_node("/root/UI/Panel2/CrateImage").visible = false

func _physics_process(delta):
nextLoss = clamp(nextLoss - delta, 0.0, 0.5)
for b in get_colliding_bodies():
if b.collision_mask & 4 > 0 && nextLoss <= 0.0:
get_node("/root/Global").addPoints(-50)
$Hit.play();
nextLoss = 0.5

func _on_Anchor_body_entered(body):
if body.collision_layer & 32 > 0:
crate = body;
print(crate);
29 changes: 29 additions & 0 deletions ChainAnchor.tscn
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://hook.png" type="Texture" id=1]
[ext_resource path="res://ChainAnchor.gd" type="Script" id=2]
[ext_resource path="res://Hit_Hurt.wav" type="AudioStream" id=3]

[sub_resource type="CircleShape2D" id=1]

[node name="Anchor" type="RigidBody2D"]
collision_layer = 1025
contacts_reported = 10
contact_monitor = true
can_sleep = false
linear_damp = 3.139
angular_damp = 1.0
script = ExtResource( 2 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )

[node name="Sprite" type="Sprite" parent="."]
position = Vector2( -0.0150032, 1.21534 )
scale = Vector2( 0.102784, 0.102784 )
texture = ExtResource( 1 )

[node name="Hit" type="AudioStreamPlayer2D" parent="."]
stream = ExtResource( 3 )

[connection signal="body_entered" from="." to="." method="_on_Anchor_body_entered"]
20 changes: 20 additions & 0 deletions ChainLink.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[gd_scene load_steps=3 format=2]

[ext_resource path="res://chain.png" type="Texture" id=1]

[sub_resource type="CircleShape2D" id=1]
radius = 5.0

[node name="ChainLink" type="RigidBody2D"]
collision_layer = 1026
mass = 0.1
can_sleep = false
linear_damp = 1.0
angular_damp = 10.0

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 1 )

[node name="Sprite" type="Sprite" parent="."]
scale = Vector2( 0.12, 0.12 )
texture = ExtResource( 1 )
21 changes: 21 additions & 0 deletions Crate.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
extends RigidBody2D

signal collect;
var player: RigidBody2D;
var maxDepth = 0;

var COLLECT_DIST = 75;

# Called when the node enters the scene tree for the first time.
func _ready():
player = get_node("/root/UI/ViewportContainerMain/Viewport/Game/Player");

func collect():
get_node("/root/Global").addPoints(floor(maxDepth/75.0)*50);
emit_signal("collect", self)
queue_free();

func _physics_process(delta):
maxDepth = max(maxDepth, position.y)
if (player.global_position - global_position).length() < COLLECT_DIST:
collect();
23 changes: 23 additions & 0 deletions Crate.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[gd_scene load_steps=4 format=2]

[ext_resource path="res://dollar-crate.png" type="Texture" id=1]
[ext_resource path="res://Crate.gd" type="Script" id=2]

[sub_resource type="CapsuleShape2D" id=1]
radius = 5.80426
height = 7.66226

[node name="Crate" type="RigidBody2D"]
position = Vector2( 250, 300 )
collision_layer = 33
collision_mask = 1025
linear_damp = 2.0
script = ExtResource( 2 )

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
rotation = 1.5708
shape = SubResource( 1 )

[node name="Sprite" type="Sprite" parent="."]
scale = Vector2( 0.15, 0.15 )
texture = ExtResource( 1 )
10 changes: 10 additions & 0 deletions Currents.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="NoiseTexture" load_steps=2 format=2]

[sub_resource type="OpenSimplexNoise" id=13]
octaves = 1
period = 128.0

[resource]
width = 1024
height = 1024
noise = SubResource( 13 )
Loading

0 comments on commit d96c311

Please sign in to comment.