-
-
Save exts/07b3b94245ee270106696a64ee96352c to your computer and use it in GitHub Desktop.
MainScene script now moves the logo around the screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Godot; | |
namespace QuickStart.Core.Scripts | |
{ | |
public class MainScene : Node2D | |
{ | |
public int Speed = 300; | |
private Sprite _logo; | |
public override void _Ready() | |
{ | |
_logo = GetNode<Sprite>("Logo"); | |
GD.Print("Hello IdiotCoder.com"); | |
} | |
public override void _Process(float delta) | |
{ | |
var direction = new Vector2(); | |
var velocity = Speed * delta; | |
if(Input.IsKeyPressed((int) KeyList.W)) | |
{ | |
direction.y = -velocity; | |
} | |
if(Input.IsKeyPressed((int) KeyList.S)) | |
{ | |
direction.y = velocity; | |
} | |
if(Input.IsKeyPressed((int) KeyList.A)) | |
{ | |
direction.x = -velocity; | |
} | |
if(Input.IsKeyPressed((int) KeyList.D)) | |
{ | |
direction.x = velocity; | |
} | |
_logo.Position += direction; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment