0% found this document useful (0 votes)
6 views2 pages

Testwizardhalfcodes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Testwizardhalfcodes

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

extends CharacterBody2D

const SPEED = 600.0

const JUMP_VELOCITY = -1900.0

func _physics_process(delta: float) -> void:

# Add the gravity.

if not is_on_floor():

velocity += get_gravity() * delta

# Handle jump.

if Input.is_action_just_pressed("Jump") 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 run_multiplier = 1

if Input.is_action_pressed("run"):

run_multiplier = 2

else:

run_multiplier = 1

var direction := Input.get_axis("Left", "Right")

if direction:

velocity.x = direction * SPEED * run_multiplier

else:

velocity.x = move_toward(velocity.x, 0, SPEED * run_multiplier)

if velocity.x < 0:

$AnimatedSprite2D.flip_h = true

if velocity.x > 0:

$AnimatedSprite2D.flip_h = false

if velocity.x != 0:

$AnimatedSprite2D.play("walk")

else:

$AnimatedSprite2D.play("idle")

move_and_slide()
extends Node

var coins = 0

var score = 0

extends AnimatedSprite2D

# Called when the node enters the scene tree for the first time.

func _ready() -> void:

pass # Replace with function body.

# Called every frame. 'delta' is the elapsed time since the previous frame.

func _process(delta: float) -> void:

pass

func _on_area_2d_body_entered(body: Node2D) -> void:

if body.is_in_group('Player'):

GameManager.coins += 1

GameManager.score += 100

queue_free() #coin disappear

print("Coin collected!") # Debugging

queue_free() # Coin disappears

You might also like