====== Simple Platformer ====== ===== Teaser ===== Kurz erklären was man in diesem Tutorial lernen kann "In diesem Video lern ihr wie ihr ein eigenes Jump & Run in einer kostenlosen Gameengine baut." ===== Voraussetzungen ===== Godot Installiertes Godot 4.x. Ich entwickle hier auf der aktuellen Version 4.5 aber das Tutorial ist auch auf jeden anderen 4.x Version durchführbar ===== Assets ===== ===== Projekt erstellen ===== Projekt braucht eine leeren Ordner ===== Level erstellen ===== ===== Einstellungen ===== Windows > Size > Width 480 Windows > Size > Height 270 Windows Width Override: 960 Windows Height Override: 540 Stretch > Mode Viewport Stretch > Aspect: keep Rendering > Textures > Default Texture Filter: Nearest ===== Player erstellen ===== * CharacterBody2D * AnimatedSprite2D * CollisionShape2D ===== Assets kopieren ===== ===== Animationen erstellen ===== Spritesheet 8 x 10 Sprites 32 x 32 ===== Profisorischen Boden im Level ===== * Staticbody2D * Collisionshape2D > RectangleShape ===== TileMapLayer erstellen ===== * TileMapLayer-Node erstellen * TileSet erstellen * Physics Layer erstellen > CollisionShapes ===== Input Map ===== Vielleicht später Unter Input Map erstellen wir neue Input Aktionen Left, right, jump Für WASD-Steuerung und Cursor-Tasten ===== Player Script ===== extends CharacterBody2D const GRAVITY = 8.1 const SPEED = 50 const JUMP_VELOCITY = -150 func _physics_process(delta: float) -> void: if Input.is_action_pressed("left"): velocity.x = -SPEED $AnimatedSprite2D.flip_h = true $AnimatedSprite2D.play("run") elif Input.is_action_pressed("right"): velocity.x = SPEED $AnimatedSprite2D.flip_h = false $AnimatedSprite2D.play("run") else: velocity.x = 0 $AnimatedSprite2D.play("idle") if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY velocity.y += GRAVITY move_and_slide()