diff --git a/boxboy/boxboy.gd b/boxboy/boxboy.gd index b3ccfd1..99186b9 100644 --- a/boxboy/boxboy.gd +++ b/boxboy/boxboy.gd @@ -12,45 +12,20 @@ const GRAVITY_FALLING: int = 30 const BOUNCE_FORCE: int = -820 #about 10 tiles var just_bounced: bool = false #allow max bounce height (i.e. ignore jump input) -#floaty field -const FLOATY_RISING: int = -10 -const FLOATY_FALLING: int = -30 -const FLOATY_HEIGHT_CLEAR: float = 1_000_000_000 -var floaty_height: float = FLOATY_HEIGHT_CLEAR - #limits const MAX_MOVE_SPEED: int = 300 const MAX_FALL_SPEED: int = 500 -const MAX_FLOATY_SPEED: int = -300 #boilerplate func _ready(): - clear_floaty_height() _sprite.play("idle", 1) #movement func _physics_process(_delta) -> void: - #print(position.y, " ", floaty_height) - #jump input if is_on_floor() and Input.is_action_just_pressed("input_jump"): velocity.y -= JUMP_FORCE - #vertical movement - elif is_floaty() and position.y >= floaty_height: #below the floaty surface - if is_rising(): - velocity.y += FLOATY_RISING - else: - velocity.y += FLOATY_FALLING - - elif is_floaty() and position.y < floaty_height: ##above the floaty surface, but still floaty - if is_rising(): - velocity.y += GRAVITY_FALLING #rise slower? - else: - var diff = floaty_height - position.y - position.y += log(diff) - velocity.y = 0 - #normally, fall faster than you rise elif is_rising() and (Input.is_action_pressed("input_jump") or just_bounced): velocity.y += GRAVITY_RISING @@ -70,8 +45,6 @@ func _physics_process(_delta) -> void: velocity.x = log(abs(velocity.x)) * sign(velocity.x) #terminal velocity (in all directions) - if position.y > floaty_height and velocity.y < MAX_FLOATY_SPEED: - velocity.y = MAX_FLOATY_SPEED if is_falling() and velocity.y > MAX_FALL_SPEED: velocity.y = MAX_FALL_SPEED if abs(velocity.x) > MAX_MOVE_SPEED: @@ -96,11 +69,3 @@ func is_falling() -> bool: return velocity.y >= 0 func apply_bounce() -> void: velocity.y = BOUNCE_FORCE just_bounced = true - -func set_floaty_height(height: float) -> void: - floaty_height = height - -func clear_floaty_height() -> void: - floaty_height = FLOATY_HEIGHT_CLEAR - -func is_floaty() -> bool: return floaty_height != FLOATY_HEIGHT_CLEAR diff --git a/platforms/Floaty.tscn b/platforms/Floaty.tscn deleted file mode 100644 index 4d95576..0000000 --- a/platforms/Floaty.tscn +++ /dev/null @@ -1,34 +0,0 @@ -[gd_scene load_steps=5 format=3 uid="uid://8gd74f7ltuwk"] - -[ext_resource type="Script" uid="uid://6xvc47rc3xnp" path="res://platforms/floaty.gd" id="1_nilcs"] -[ext_resource type="Texture2D" uid="uid://uo0dn2kbqhh8" path="res://platforms/floaty.png" id="1_tt70t"] - -[sub_resource type="SpriteFrames" id="SpriteFrames_nilcs"] -animations = [{ -"frames": [{ -"duration": 1.0, -"texture": ExtResource("1_tt70t") -}], -"loop": true, -"name": &"default", -"speed": 5.0 -}] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_cftfe"] -size = Vector2(64, 64) - -[node name="Floaty" type="Area2D"] -script = ExtResource("1_nilcs") -metadata/_edit_group_ = true - -[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] -z_index = -100 -sprite_frames = SubResource("SpriteFrames_nilcs") -metadata/_edit_lock_ = true - -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_cftfe") -metadata/_edit_lock_ = true - -[connection signal="body_entered" from="." to="." method="_on_body_entered"] -[connection signal="body_exited" from="." to="." method="_on_body_exited"] diff --git a/platforms/floaty.gd b/platforms/floaty.gd deleted file mode 100644 index c23a569..0000000 --- a/platforms/floaty.gd +++ /dev/null @@ -1,10 +0,0 @@ -extends Area2D - -func _on_body_entered(body) -> void: - #print("collision") - if body is BoxBoy: - body.set_floaty_height(position.y + $CollisionShape2D.shape.get_rect().position.y) - -func _on_body_exited(body) -> void: - if body is BoxBoy: - body.clear_floaty_height() diff --git a/platforms/floaty.gd.uid b/platforms/floaty.gd.uid deleted file mode 100644 index d68f2fa..0000000 --- a/platforms/floaty.gd.uid +++ /dev/null @@ -1 +0,0 @@ -uid://6xvc47rc3xnp diff --git a/platforms/floaty.png b/platforms/floaty.png deleted file mode 100644 index fe08a12..0000000 Binary files a/platforms/floaty.png and /dev/null differ diff --git a/platforms/floaty.png.import b/platforms/floaty.png.import deleted file mode 100644 index cacf3cd..0000000 --- a/platforms/floaty.png.import +++ /dev/null @@ -1,40 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://uo0dn2kbqhh8" -path="res://.godot/imported/floaty.png-42918432e8e7ab00ea08963791112ec0.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://platforms/floaty.png" -dest_files=["res://.godot/imported/floaty.png-42918432e8e7ab00ea08963791112ec0.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/scene.tscn b/scene.tscn index 5f209a2..0a1de9c 100644 --- a/scene.tscn +++ b/scene.tscn @@ -1,10 +1,9 @@ -[gd_scene load_steps=12 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"] -[ext_resource type="PackedScene" uid="uid://8gd74f7ltuwk" path="res://platforms/Floaty.tscn" id="5_m7jmp"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u3cyc"] texture = ExtResource("1_3253y") @@ -81,7 +80,4 @@ metadata/_edit_lock_ = true [node name="Bouncy" parent="." instance=ExtResource("4_u3cyc")] position = Vector2(528, 408) -[node name="Floaty" parent="." instance=ExtResource("5_m7jmp")] -position = Vector2(224, 384) - [connection signal="animation_finished" from="Boxboy/AnimatedSprite2D" to="Boxboy" method="_on_animation_finished"]