Skip to content

Instantly share code, notes, and snippets.

@exts exts/MainScene.cs Secret
Created Apr 22, 2019

Embed
What would you like to do?
MainScene script now moves the logo around the screen
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
You can’t perform that action at this time.