playground

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.

Link zu dieser Vergleichsansicht

Nächste Überarbeitung
Vorhergehende Überarbeitung
playground [2023/06/03 08:39] – angelegt silversurferplayground [2023/07/04 21:20] (aktuell) 185.38.49.0
Zeile 1: Zeile 1:
 +====== CodeDoc ======
 +
 <codedoc code:c++> <codedoc code:c++>
 void karelsFirstProgram() void karelsFirstProgram()
Zeile 15: Zeile 17:
  
 <codedoc code:c++> <codedoc code:c++>
-Test+extends KinematicBody2D 
 + 
 +const SPEED = 60 
 +const GRAVITY = 10 
 +const JUMP_POWER = -250 
 +const UP_DIR = Vector2(0, -1) 
 + 
 +var velocity = Vector2() 
 +var on_ground = false 
 +  
 +func _physics_process(delta): 
 + if Input.is_action_pressed("ui_right"): 
 + velocity.x = SPEED 
 + $AnimatedSprite.play("run ") 
 + $AnimatedSprite.flip_h = false 
 + elif Input.is_action_pressed("ui_left"): 
 + velocity.x = -SPEED 
 + $AnimatedSprite.play("run ") 
 + $AnimatedSprite.flip_h = true 
 + else: 
 + velocity.x = 0 
 + if on_ground: 
 + $AnimatedSprite.play("idle"
 +  
 + if Input.is_action_pressed("ui_up"): 
 + if on_ground == true: 
 + velocity.y = JUMP_POWER 
 + on_ground = false 
 + $AnimatedSprite.play("jump"
 +  
 + # velocity.y = velocity.y + GRAVITY 
 + velocity.y += GRAVITY 
 +  
 + if is_on_floor(): 
 + on_ground = true 
 + else: 
 + on_ground = false 
 + if velocity.y < 0: 
 + $AnimatedSprite.play("jump"
 + else: 
 + $AnimatedSprite.play("fall"
 +  
 + velocity = move_and_slide(velocity, UP_DIR)
 </codedoc> </codedoc>
  • playground.1685774399.txt.gz
  • Zuletzt geändert: 2023/06/03 08:39
  • von silversurfer