diff --git a/boxboy.xcf b/boxboy.xcf deleted file mode 100644 index cb99f2c..0000000 Binary files a/boxboy.xcf and /dev/null differ diff --git a/boxboy/boxboy.gd b/boxboy/boxboy.gd index b5087af..fb8c79b 100644 --- a/boxboy/boxboy.gd +++ b/boxboy/boxboy.gd @@ -1,4 +1,4 @@ -extends CharacterBody2D +class_name BoxBoy extends CharacterBody2D @onready var _sprite = $AnimatedSprite2D @@ -35,6 +35,7 @@ func _physics_process(_delta) -> void: #move with a maximum value if move_dir: + _sprite.flip_h = move_dir < 0 #fancy velocity.x += MOVE_FORCE * move_dir if abs(velocity.x) > MAX_MOVE_SPEED: velocity.x = MAX_MOVE_SPEED * sign(velocity.x) @@ -43,7 +44,6 @@ func _physics_process(_delta) -> void: elif velocity.x != 0: velocity.x = log(abs(velocity.x)) * sign(velocity.x) - print(velocity) #do the thing move_and_slide() @@ -58,3 +58,7 @@ func _on_animation_finished() -> void: func is_airborne() -> bool: return !is_on_floor() func is_airborne_rising() -> bool: return !is_on_floor() and velocity.y < 0 func is_airborne_falling() -> bool: return !is_on_floor() and velocity.y >= 0 + +#external actions +func apply_bounce() -> void: + velocity.y -= JUMP_FORCE diff --git a/boxboy/boxboy.png b/boxboy/boxboy.png index 74f5757..a763ca1 100644 Binary files a/boxboy/boxboy.png and b/boxboy/boxboy.png differ diff --git a/boxboy/boxboy.xcf b/boxboy/boxboy.xcf new file mode 100644 index 0000000..d16dd2f Binary files /dev/null and b/boxboy/boxboy.xcf differ diff --git a/platforms/Bouncy.tscn b/platforms/Bouncy.tscn new file mode 100644 index 0000000..67eb85e --- /dev/null +++ b/platforms/Bouncy.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=5 format=3 uid="uid://b1hpr05b5sgww"] + +[ext_resource type="Texture2D" uid="uid://cx77xahl8btw5" path="res://platforms/bouncy.png" id="1_ljpgq"] +[ext_resource type="Script" uid="uid://b11al8kjnoveh" path="res://platforms/bouncy.gd" id="1_uccqy"] + +[sub_resource type="SpriteFrames" id="SpriteFrames_npa0g"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_ljpgq") +}], +"loop": true, +"name": &"default", +"speed": 5.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_qqmjc"] +size = Vector2(32, 16) + +[node name="Bouncy" type="Area2D"] +script = ExtResource("1_uccqy") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_npa0g") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_qqmjc") + +[connection signal="body_entered" from="." to="." method="_on_body_entered"] diff --git a/platforms/bouncy.gd b/platforms/bouncy.gd new file mode 100644 index 0000000..8f7d235 --- /dev/null +++ b/platforms/bouncy.gd @@ -0,0 +1,6 @@ +extends Area2D + +func _on_body_entered(body) -> void: + print("collision") + if body is BoxBoy: + body.apply_bounce() diff --git a/platforms/bouncy.gd.uid b/platforms/bouncy.gd.uid new file mode 100644 index 0000000..951fc77 --- /dev/null +++ b/platforms/bouncy.gd.uid @@ -0,0 +1 @@ +uid://b11al8kjnoveh diff --git a/platforms/bouncy.png b/platforms/bouncy.png new file mode 100644 index 0000000..25caf2c Binary files /dev/null and b/platforms/bouncy.png differ diff --git a/platforms/bouncy.png.import b/platforms/bouncy.png.import new file mode 100644 index 0000000..9921ffb --- /dev/null +++ b/platforms/bouncy.png.import @@ -0,0 +1,40 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cx77xahl8btw5" +path="res://.godot/imported/bouncy.png-55fb36252918d1aab89ea066a7079f67.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://platforms/bouncy.png" +dest_files=["res://.godot/imported/bouncy.png-55fb36252918d1aab89ea066a7079f67.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/uastc_level=0 +compress/rdo_quality_loss=0.0 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/channel_remap/red=0 +process/channel_remap/green=1 +process/channel_remap/blue=2 +process/channel_remap/alpha=3 +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/platforms/bouncy.xcf b/platforms/bouncy.xcf new file mode 100644 index 0000000..9e6a3ad Binary files /dev/null and b/platforms/bouncy.xcf differ diff --git a/project.godot b/project.godot index 8667a48..67d2f76 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,11 @@ run/main_scene="res://scene.tscn" config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" +[display] + +window/size/viewport_width=800 +window/size/viewport_height=600 + [input] input_right={ diff --git a/scene.tscn b/scene.tscn index 4b81203..cdee063 100644 --- a/scene.tscn +++ b/scene.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=10 format=4 uid="uid://b7ndmr6uvnyqb"] +[gd_scene load_steps=11 format=4 uid="uid://b7ndmr6uvnyqb"] [ext_resource type="Texture2D" uid="uid://ddl0kxl0inw6r" path="res://tiles/atlas.png" id="1_3253y"] [ext_resource type="Script" uid="uid://c2x51mppxugpn" path="res://boxboy/boxboy.gd" id="1_nxogm"] [ext_resource type="Texture2D" uid="uid://bpjhq0b2dae1d" path="res://boxboy/boxboy.png" id="1_ulcgi"] +[ext_resource type="PackedScene" uid="uid://b1hpr05b5sgww" path="res://platforms/Bouncy.tscn" id="4_u3cyc"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u3cyc"] texture = ExtResource("1_3253y") @@ -71,4 +72,9 @@ animation = &"idle" [node name="CollisionShape2D" type="CollisionShape2D" parent="Boxboy"] shape = SubResource("CapsuleShape2D_ulcgi") +[node name="Camera2D" type="Camera2D" parent="Boxboy"] + +[node name="Bouncy" parent="." instance=ExtResource("4_u3cyc")] +position = Vector2(622, 475) + [connection signal="animation_finished" from="Boxboy/AnimatedSprite2D" to="Boxboy" method="_on_animation_finished"]