cause it really messy
Itâs supposed to be a cute and kid friendly platformer.
How should I re-write, re-organize the code?
do you have discord? we can talk there.
Unfortunately I do not; why donât we continue talking on this forum thread?
ok, so there isnt really anything in your game as of now. If you can explain more that would be helpful?
I just wanted it to be a cute, simple, kid friendly platformer game like Mario Bros, with gray textured floors and spikes and a Halloween themed character and background
Ok, so first you need a platform player movement, luckily godot has a basic build-in platformer movement how about we use that?
Do you wanna just create a new fresh godot project first, or use the same one?
How about we use the example given and start over from that? Sounds like an awesome idea.
Ok, hereâs a basic player movement code, erase everything you got in your playerâs code and paste this:
extends CharacterBody2D
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# Handle jump.
if Input.is_action_just_pressed("ui_accept") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var direction = Input.get_axis("ui_left", "ui_right")
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()
In the code you provide, you are extending an Area2d node but you are using a Character2d, do know why that is there but doesnât matter.
Now go to you main scene and add the playerâs scene there.
Awesome! It works.
Did you add the player to the main scene?
if you didnât, click this button in the main scene and add the player as a child. The button looks like a chain, like this:
Yes, I did. It works/compiles fine still.
Ok, so currently your are running the playerâs scene, you want to run the main scene with the player inside of it, so go to project settings, select run, and click on reset main scene, and then add the main.tsec as the main scene.
Hit run, and now the background image should appear
Yes indeed, it does work correctly. Thank you for the help!
Now, does the player fall of the map when you run the game?