Dead simple, but it's a start
This commit is contained in:
36
boxboy/boxboy.gd
Normal file
36
boxboy/boxboy.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@onready var _sprite = $AnimatedSprite2D
|
||||
|
||||
const GRAVITY: Vector2 = Vector2(0, 9.8)
|
||||
const MAX_SPEED: int = 500
|
||||
const IMPULSE: int = 80
|
||||
const JUMP: int = -400 #TODO: proper jump arch
|
||||
|
||||
func _ready():
|
||||
_sprite.play("idle", 1)
|
||||
|
||||
#physics and controls
|
||||
func _physics_process(_delta) -> void:
|
||||
#falling or jumping
|
||||
if is_on_floor() and Input.is_action_just_pressed("input_jump"):
|
||||
velocity.y = JUMP
|
||||
|
||||
velocity += GRAVITY
|
||||
|
||||
var direction = Input.get_axis("input_left", "input_right")
|
||||
if direction:
|
||||
velocity.x += IMPULSE * direction
|
||||
if abs(velocity.x) > MAX_SPEED:
|
||||
velocity.x = MAX_SPEED * sign(velocity.x)
|
||||
elif velocity.x != 0:
|
||||
velocity.x = log(abs(velocity.x)) * sign(velocity.x)
|
||||
|
||||
move_and_slide()
|
||||
|
||||
#animation stuff
|
||||
func _on_animation_finished() -> void:
|
||||
if randf() < 0.2:
|
||||
_sprite.play("idle_glance", 2)
|
||||
else:
|
||||
_sprite.play("idle", 2)
|
||||
1
boxboy/boxboy.gd.uid
Normal file
1
boxboy/boxboy.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2x51mppxugpn
|
||||
BIN
boxboy/boxboy.png
Normal file
BIN
boxboy/boxboy.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 808 B |
40
boxboy/boxboy.png.import
Normal file
40
boxboy/boxboy.png.import
Normal file
@@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bpjhq0b2dae1d"
|
||||
path="res://.godot/imported/boxboy.png-42da31f64cf96e900fd482e99903aaa1.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://boxboy/boxboy.png"
|
||||
dest_files=["res://.godot/imported/boxboy.png-42da31f64cf96e900fd482e99903aaa1.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
|
||||
Reference in New Issue
Block a user