Added WIP bouncy platform
This commit is contained in:
BIN
boxboy.xcf
BIN
boxboy.xcf
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
extends CharacterBody2D
|
class_name BoxBoy extends CharacterBody2D
|
||||||
|
|
||||||
@onready var _sprite = $AnimatedSprite2D
|
@onready var _sprite = $AnimatedSprite2D
|
||||||
|
|
||||||
@@ -35,6 +35,7 @@ func _physics_process(_delta) -> void:
|
|||||||
|
|
||||||
#move with a maximum value
|
#move with a maximum value
|
||||||
if move_dir:
|
if move_dir:
|
||||||
|
_sprite.flip_h = move_dir < 0 #fancy
|
||||||
velocity.x += MOVE_FORCE * move_dir
|
velocity.x += MOVE_FORCE * move_dir
|
||||||
if abs(velocity.x) > MAX_MOVE_SPEED:
|
if abs(velocity.x) > MAX_MOVE_SPEED:
|
||||||
velocity.x = MAX_MOVE_SPEED * sign(velocity.x)
|
velocity.x = MAX_MOVE_SPEED * sign(velocity.x)
|
||||||
@@ -43,7 +44,6 @@ func _physics_process(_delta) -> void:
|
|||||||
elif velocity.x != 0:
|
elif velocity.x != 0:
|
||||||
velocity.x = log(abs(velocity.x)) * sign(velocity.x)
|
velocity.x = log(abs(velocity.x)) * sign(velocity.x)
|
||||||
|
|
||||||
print(velocity)
|
|
||||||
#do the thing
|
#do the thing
|
||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
@@ -58,3 +58,7 @@ func _on_animation_finished() -> void:
|
|||||||
func is_airborne() -> bool: return !is_on_floor()
|
func is_airborne() -> bool: return !is_on_floor()
|
||||||
func is_airborne_rising() -> bool: return !is_on_floor() and velocity.y < 0
|
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
|
func is_airborne_falling() -> bool: return !is_on_floor() and velocity.y >= 0
|
||||||
|
|
||||||
|
#external actions
|
||||||
|
func apply_bounce() -> void:
|
||||||
|
velocity.y -= JUMP_FORCE
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 808 B After Width: | Height: | Size: 705 B |
BIN
boxboy/boxboy.xcf
Normal file
BIN
boxboy/boxboy.xcf
Normal file
Binary file not shown.
29
platforms/Bouncy.tscn
Normal file
29
platforms/Bouncy.tscn
Normal file
@@ -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"]
|
||||||
6
platforms/bouncy.gd
Normal file
6
platforms/bouncy.gd
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
extends Area2D
|
||||||
|
|
||||||
|
func _on_body_entered(body) -> void:
|
||||||
|
print("collision")
|
||||||
|
if body is BoxBoy:
|
||||||
|
body.apply_bounce()
|
||||||
1
platforms/bouncy.gd.uid
Normal file
1
platforms/bouncy.gd.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://b11al8kjnoveh
|
||||||
BIN
platforms/bouncy.png
Normal file
BIN
platforms/bouncy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
40
platforms/bouncy.png.import
Normal file
40
platforms/bouncy.png.import
Normal file
@@ -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
|
||||||
BIN
platforms/bouncy.xcf
Normal file
BIN
platforms/bouncy.xcf
Normal file
Binary file not shown.
@@ -15,6 +15,11 @@ run/main_scene="res://scene.tscn"
|
|||||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[display]
|
||||||
|
|
||||||
|
window/size/viewport_width=800
|
||||||
|
window/size/viewport_height=600
|
||||||
|
|
||||||
[input]
|
[input]
|
||||||
|
|
||||||
input_right={
|
input_right={
|
||||||
|
|||||||
@@ -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="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="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="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"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_u3cyc"]
|
||||||
texture = ExtResource("1_3253y")
|
texture = ExtResource("1_3253y")
|
||||||
@@ -71,4 +72,9 @@ animation = &"idle"
|
|||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Boxboy"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Boxboy"]
|
||||||
shape = SubResource("CapsuleShape2D_ulcgi")
|
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"]
|
[connection signal="animation_finished" from="Boxboy/AnimatedSprite2D" to="Boxboy" method="_on_animation_finished"]
|
||||||
|
|||||||
Reference in New Issue
Block a user