diff --git a/assets/bare_tree.png b/assets/bare_tree.png new file mode 100644 index 0000000..d6eea7a Binary files /dev/null and b/assets/bare_tree.png differ diff --git a/assets/bare_tree.png.import b/assets/bare_tree.png.import new file mode 100644 index 0000000..e84d162 --- /dev/null +++ b/assets/bare_tree.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/bare_tree.png-8e3f706bd49c6629bd8ef416386571ce.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/bare_tree.png" +dest_files=[ "res://.import/bare_tree.png-8e3f706bd49c6629bd8ef416386571ce.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/assets/giraffe_head.png b/assets/giraffe_head.png index b201098..c6b7f84 100644 Binary files a/assets/giraffe_head.png and b/assets/giraffe_head.png differ diff --git a/assets/tree.png b/assets/tree.png index ac919f6..29a2bab 100644 Binary files a/assets/tree.png and b/assets/tree.png differ diff --git a/project.godot b/project.godot index 612acaf..1cc1176 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,12 @@ config/name="giraffesnake" run/main_scene="res://scenes/World.tscn" config/icon="res://icon.png" +[display] + +window/size/width=1920 +window/size/height=1080 +window/stretch/mode="2d" + [input] left={ diff --git a/scenes/GiraffeHead.tscn b/scenes/GiraffeHead.tscn index bc17262..35b00ee 100644 --- a/scenes/GiraffeHead.tscn +++ b/scenes/GiraffeHead.tscn @@ -3,12 +3,15 @@ [ext_resource path="res://assets/giraffe_head.png" type="Texture" id=1] [ext_resource path="res://scripts/GiraffeHead.gd" type="Script" id=2] -[sub_resource type="RectangleShape2D" id=1] +[sub_resource type="CapsuleShape2D" id=1] +radius = 39.8424 +height = 10.5097 [node name="GiraffeHead" type="KinematicBody2D"] script = ExtResource( 2 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2( 9.54593, -0.353554 ) shape = SubResource( 1 ) [node name="Sprite" type="Sprite" parent="."] diff --git a/scenes/Tree.tscn b/scenes/Tree.tscn index e707dd6..589c635 100644 --- a/scenes/Tree.tscn +++ b/scenes/Tree.tscn @@ -1,8 +1,33 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://assets/tree.png" type="Texture" id=1] +[ext_resource path="res://scripts/Tree.gd" type="Script" id=2] +[ext_resource path="res://assets/bare_tree.png" type="Texture" id=3] -[node name="Tree" type="Node2D"] +[sub_resource type="SpriteFrames" id=2] +animations = [ { +"frames": [ ExtResource( 1 ), ExtResource( 3 ) ], +"loop": true, +"name": "default", +"speed": 5.0 +} ] -[node name="Sprite" type="Sprite" parent="."] -texture = ExtResource( 1 ) +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 112.784, 53.9413 ) + +[sub_resource type="RectangleShape2D" id=3] +extents = Vector2( 49.9564, 83.1256 ) + +[node name="Tree" type="KinematicBody2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="AnimatedSprite" parent="."] +frames = SubResource( 2 ) + +[node name="Leaves" type="CollisionShape2D" parent="."] +position = Vector2( 0.629959, -28.6632 ) +shape = SubResource( 1 ) + +[node name="Trunk" type="CollisionShape2D" parent="."] +position = Vector2( -57.0114, 4.03472 ) +shape = SubResource( 3 ) diff --git a/scenes/World.tscn b/scenes/World.tscn index 4b6c7d1..51c5a5e 100644 --- a/scenes/World.tscn +++ b/scenes/World.tscn @@ -9,4 +9,4 @@ position = Vector2( 362.448, 402.091 ) [node name="Tree" parent="." instance=ExtResource( 2 )] -position = Vector2( 118.928, 186.887 ) +position = Vector2( 105.083, 177.89 ) diff --git a/scripts/GiraffeHead.gd b/scripts/GiraffeHead.gd index 1fc0bd2..0993e0d 100644 --- a/scripts/GiraffeHead.gd +++ b/scripts/GiraffeHead.gd @@ -1,6 +1,6 @@ extends KinematicBody2D -export var speed = 50 +export var speed = 5 # Called when the node enters the scene tree for the first time. @@ -8,7 +8,9 @@ func _ready(): pass # Replace with function body. func _physics_process(delta): - var input_movement = int(Input.is_action_pressed("right")) - int(Input.is_action_pressed("left")) - - - self.move_and_slide(Vector2(input_movement * speed, 0), Vector2(0, -1)) + if Input.is_action_pressed("right"): + self.move_and_collide(Vector2(speed,0)) + $Sprite.flip_h = true + elif Input.is_action_pressed("left"): + $Sprite.flip_h = false + self.move_and_collide(Vector2(-speed,0)) diff --git a/scripts/Tree.gd b/scripts/Tree.gd new file mode 100644 index 0000000..a07f814 --- /dev/null +++ b/scripts/Tree.gd @@ -0,0 +1,18 @@ +extends KinematicBody2D + +signal death +signal eaten +onready var speed = 1 +# Called when the node enters the scene tree for the first time. +func _ready(): + pass # Replace with function body. + set_physics_process(true) + +func _physics_process(delta): + var col = self.move_and_collide(Vector2(0,speed)) + if col != null and col.local_shape == $Leaves: + $Sprite.frame = 1 + emit_signal("eaten") + $Leaves.disabled = true + elif col != null and col.local_shape == $Trunk: + emit_signal("death")