init
This commit is contained in:
26
Scripts/Main.cs
Normal file
26
Scripts/Main.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using FOU.Scripts;
|
||||
using Godot;
|
||||
|
||||
public partial class Main : Node2D {
|
||||
[Export] public int BrushSize = 10;
|
||||
|
||||
private TextureRect mLevelDrawer;
|
||||
private Level mLevel;
|
||||
|
||||
public override void _Ready() {
|
||||
mLevel = new Level((int)GetViewportRect().Size.X, (int)GetViewportRect().Size.Y);
|
||||
mLevelDrawer = GetNode<TextureRect>("CanvasLayer/LevelDrawer");
|
||||
}
|
||||
|
||||
public override void _Process(double delta) {
|
||||
mLevelDrawer.Texture = ImageTexture.CreateFromImage(mLevel.DrawLevel());
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event) {
|
||||
if (@event is InputEventMouseButton eventMouseButton) {
|
||||
|
||||
Vector2 mouse = GetViewport().GetMousePosition();
|
||||
mLevel.WritePixel((int)mouse.X, (int)mouse.Y, BrushSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user