moonwalker

This commit is contained in:
Page Asgardius 2024-01-20 06:58:29 -07:00
parent d3eef9dbac
commit 9dda46397e
12 changed files with 160 additions and 8 deletions

View file

@ -0,0 +1,36 @@
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
var angle = 2
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
@onready var anim := $AnimationPlayer
func _physics_process(delta):
# Add the gravity.
#var velocity = Vector2.ZERO
if Global.live == 1:
velocity = (Vector2.RIGHT.rotated(rotation) * 500 * Global.xm * delta)-Vector2.UP.rotated(rotation) * 500 * Global.ym * delta
#origmpos = get_viewport().get_mouse_position()
#if Input.get_joy_axis(0,JOY_AXIS_LEFT_Y) != 0:
# velocity = Vector2.UP.rotated(rotation) * -400 * Input.get_joy_axis(0,JOY_AXIS_LEFT_Y)
position += velocity
if Global.ym > 0.3:
angle = 2
elif Global.ym < -0.3:
angle = 0
if velocity.y != 0 || velocity.x != 0:
if angle == 0:
anim.play("nwalk")
else:
anim.play("swalk")
else:
if angle == 0:
anim.play("nidle")
else:
anim.play("sidle")
move_and_slide()

View file

@ -1,5 +1,6 @@
[gd_scene load_steps=9 format=3 uid="uid://cehe6sm8ly06u"]
[gd_scene load_steps=10 format=3 uid="uid://cehe6sm8ly06u"]
[ext_resource type="Script" path="res://sprites/common/midori/midori.gd" id="1_6vvcv"]
[ext_resource type="Texture2D" uid="uid://bc2vrf8qggvtp" path="res://sprites/common/midori/sprite.png" id="1_oqq2w"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_dj8gt"]
@ -94,6 +95,7 @@ _data = {
}
[node name="Midori" type="CharacterBody2D"]
script = ExtResource("1_6vvcv")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_oqq2w")