Skip to content

Instantly share code, notes, and snippets.

@exts
Created April 22, 2019 04:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exts/07b3b94245ee270106696a64ee96352c to your computer and use it in GitHub Desktop.
Save exts/07b3b94245ee270106696a64ee96352c to your computer and use it in GitHub Desktop.
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