Drag and drop works

This commit is contained in:
Senad Uka
2022-12-31 05:51:34 +01:00
parent f7b7035bf2
commit 90fd7e1ef5
19 changed files with 381 additions and 312 deletions

View File

@@ -0,0 +1,2 @@
34697
/opt/godot-mono/bin/godot.x11.opt.tools.64.mono

View File

@@ -1 +1 @@
{"res://startup.cs":{"modified_time":"1669549042","class":{"namespace":"","class_name":"startup","nested":false}},"res://MainBoard.cs":{"modified_time":"1669562782","class":{"namespace":"","class_name":"MainBoard","nested":false}},"res://Letterbox.cs":{"modified_time":"1669573463","class":{"namespace":"","class_name":"Letterbox","nested":false}},"res://Letter.cs":{"modified_time":"1669573955","class":{"namespace":"","class_name":"Letter","nested":false}},"res://DragAndDrop.cs":{"modified_time":"1670104203","class":{"namespace":"","class_name":"DragAndDrop","nested":false}}} {"res://Letter.cs":{"modified_time":"1671875555","class":{"namespace":"lettergodot","class_name":"Letter","nested":false}},"res://MainBoard.cs":{"modified_time":"1671875608","class":{"namespace":"lettergodot","class_name":"MainBoard","nested":false}},"res://startup.cs":{"modified_time":"1671875632","class":{"namespace":"lettergodot","class_name":"startup","nested":false}},"res://Letterbox.cs":{"modified_time":"1671875588","class":{"namespace":"lettergodot","class_name":"Letterbox","nested":false}},"res://DragAndDrop.cs":{"modified_time":"1672465197","class":{"namespace":"lettergodot","class_name":"DragAndDrop","nested":false}}}

View File

@@ -1 +1 @@
{"res://startup.cs":{"modified_time":"1669549042","class":{"namespace":"","class_name":"startup","nested":false}},"res://MainBoard.cs":{"modified_time":"1669562782","class":{"namespace":"","class_name":"MainBoard","nested":false}},"res://Letterbox.cs":{"modified_time":"1669573463","class":{"namespace":"","class_name":"Letterbox","nested":false}},"res://Letter.cs":{"modified_time":"1669573955","class":{"namespace":"","class_name":"Letter","nested":false}},"res://DragAndDrop.cs":{"modified_time":"1670104203","class":{"namespace":"","class_name":"DragAndDrop","nested":false}}} {"res://Letter.cs":{"modified_time":"1671875555","class":{"namespace":"lettergodot","class_name":"Letter","nested":false}},"res://MainBoard.cs":{"modified_time":"1671875608","class":{"namespace":"lettergodot","class_name":"MainBoard","nested":false}},"res://startup.cs":{"modified_time":"1671875632","class":{"namespace":"lettergodot","class_name":"startup","nested":false}},"res://Letterbox.cs":{"modified_time":"1671875588","class":{"namespace":"lettergodot","class_name":"Letterbox","nested":false}},"res://DragAndDrop.cs":{"modified_time":"1672465197","class":{"namespace":"lettergodot","class_name":"DragAndDrop","nested":false}}}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -45,7 +45,7 @@
"autoReferenced": true "autoReferenced": true
} }
}, },
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.100/RuntimeIdentifierGraph.json" "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"
} }
} }
} }

View File

@@ -458,7 +458,7 @@
"autoReferenced": true "autoReferenced": true
} }
}, },
"runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.100/RuntimeIdentifierGraph.json" "runtimeIdentifierGraphPath": "/usr/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"
} }
} }
} }

View File

@@ -1,6 +1,6 @@
{ {
"version": 2, "version": 2,
"dgSpecHash": "EmtZ/09tYEO9wjOc0n/D4FsMs0naPGZeLD52jVDxbNAkEI9qcpggmZBxGktHLWPsYqetCg+9B9BJ3BhFqNEKcA==", "dgSpecHash": "ECTDL1Vd7HyrBfV1UXJ5zTRdc2QlSw79bnn/Dp2Jz9r9Khz79fosbdHETEOB5l55pPPKrhxRd/z5hwK4gweezA==",
"success": true, "success": true,
"projectFilePath": "/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj", "projectFilePath": "/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj",
"expectedPackageFiles": [ "expectedPackageFiles": [

View File

@@ -1 +1 @@
"restore":{"projectUniqueName":"/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj","projectName":"lettergodot","projectPath":"/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj","outputPath":"/home/hamo/projects/kbr4/lettergodot/.mono/temp/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net472"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net472":{"targetAlias":"net472","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net472":{"targetAlias":"net472","runtimeIdentifierGraphPath":"/usr/lib/mono/msbuild/Current/bin/RuntimeIdentifierGraph.json"}} "restore":{"projectUniqueName":"/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj","projectName":"lettergodot","projectPath":"/home/hamo/projects/kbr4/lettergodot/lettergodot.csproj","outputPath":"/home/hamo/projects/kbr4/lettergodot/.mono/temp/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net472"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net472":{"targetAlias":"net472","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net472":{"targetAlias":"net472","dependencies":{"Microsoft.NETFramework.ReferenceAssemblies":{"suppressParent":"All","target":"Package","version":"[1.0.2, )","autoReferenced":true}},"runtimeIdentifierGraphPath":"/usr/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"}}

View File

@@ -1 +1 @@
16700998578786145 16718715086300475

View File

@@ -1,95 +1,83 @@
using Godot; using Godot;
using System; using System;
public class DragAndDrop : KinematicBody2D namespace lettergodot
{ {
public class DragAndDrop : KinematicBody2D
{
private static ulong dragging = ulong.MaxValue;
/* private bool Dragging
Convert this code to C# {
get => GetInstanceId() == dragging;
extends KinematicBody2D set => dragging = value ? GetInstanceId() : ulong.MaxValue;
}
var dragging = false
signal dragsignal;
func _ready():
connect("dragsignal",self,"_set_drag_pc")
func _process(delta): public override void _Ready()
if dragging: {
var mousepos = get_viewport().get_mouse_position() Connect("dragsignal", this, "DragSignalImplemenmtation");
self.position = Vector2(mousepos.x, mousepos.y) }
public override void _Process(float delta)
{
if (Dragging)
{
var mousepos = GetViewport().GetMousePosition();
Position = new Vector2(mousepos.x, mousepos.y);
}
}
[Signal]
public delegate void dragsignal();
private void DragSignalImplemenmtation()
{
Dragging = !Dragging;
}
public override void _Input(InputEvent @event)
{
func _set_drag_pc(): if (@event is InputEventMouseButton)
dragging=!dragging {
var eventMouseButton = (InputEventMouseButton)@event;
func _on_KinematicBody2D_input_event(viewport, event, shape_idx): if (eventMouseButton.ButtonIndex == (int)ButtonList.Left && eventMouseButton.Pressed)
if event is InputEventMouseButton: {
if event.button_index == BUTTON_LEFT and event.pressed:
emit_signal("dragsignal")
elif event.button_index == BUTTON_LEFT and !event.pressed:
emit_signal("dragsignal")
elif event is InputEventScreenTouch:
if event.pressed and event.get_index() == 0:
self.position = event.get_position()
*/
private bool dragging = false;
public override void _Ready()
{
Connect("dragsignal", this, "DragSignalImplemenmtation");
}
public override void _Process(float delta)
{
if (dragging)
{
var mousepos = GetViewport().GetMousePosition();
Position = new Vector2(mousepos.x, mousepos.y);
}
}
[Signal]
public delegate void dragsignal();
private void DragSignalImplemenmtation()
{
dragging = !dragging;
}
public override void _Input(InputEvent @event)
{
if (@event is InputEventMouseButton)
{
var eventMouseButton = (InputEventMouseButton)@event;
if (eventMouseButton.ButtonIndex == (int)ButtonList.Left && eventMouseButton.Pressed)
{
EmitSignal("dragsignal");
}
else if (eventMouseButton.ButtonIndex == (int)ButtonList.Left && !eventMouseButton.Pressed)
{
EmitSignal("dragsignal");
}
}
else if (@event is InputEventScreenTouch)
{
var eventScreenTouch = (InputEventScreenTouch)@event;
if (eventScreenTouch.Pressed && eventScreenTouch.Index == 0)
{
Position = eventScreenTouch.Position;
}
}
}
// log Position and Position
GD.Print("Position: " + Position);
GD.Print("MousePosition:" + eventMouseButton.Position);
GD.Print("Length:" + (eventMouseButton.Position - Position).Length());
if ((eventMouseButton.Position - Position).Length() < (60) )
{
EmitSignal("dragsignal");
}
}
else if (eventMouseButton.ButtonIndex == (int)ButtonList.Left && !eventMouseButton.Pressed)
{
if ((eventMouseButton.Position - Position).Length() < (60))
{
EmitSignal("dragsignal");
}
}
}
else if (@event is InputEventScreenTouch)
{
var eventScreenTouch = (InputEventScreenTouch)@event;
if ((eventScreenTouch.Position - Position).Length() < (60))
{
if (eventScreenTouch.Pressed && eventScreenTouch.Index == 0)
{
Position = eventScreenTouch.Position;
}
}
}
}
}
} }

View File

@@ -1,44 +1,52 @@
using Godot; using Godot;
using System; using System;
public class Letter : AnimatedSprite namespace lettergodot
{ {
private string letter = "A";
private Label label;
public string Value
public class Letter : AnimatedSprite
{ {
get { return letter; } private string letter = "A";
set private Label label;
public string Value
{ {
letter = value; get { return letter; }
UpdateLetter(); set
{
letter = value;
UpdateLetter();
}
}
public override void _Ready()
{
// create label with a letter assigned as a text
label = new Label();
label.Text = letter;
// make label text bold and centered
label.AddFontOverride("font",
new DynamicFont()
{ FontData = new DynamicFontData() { FontPath = "res://Roboto-Bold.ttf" }, Size = 30 });
// make color of the text dark orange
label.AddColorOverride("font_color", new Color(1, 0.5f, 0));
// make text centered in the sprite
label.RectPosition = new Vector2(-10, -15);
label.RectSize = new Vector2(64, 64);
label.Align = Label.AlignEnum.Left;
label.Valign = Label.VAlign.Top;
// add label to the sprite
AddChild(label);
}
private void UpdateLetter()
{
// update text of the label
// to the letter assigned to the letter variable
label.Text = letter;
} }
} }
public override void _Ready()
{
// create label with a letter assigned as a text
label = new Label();
label.Text = letter;
// make label text bold and centered
label.AddFontOverride("font",
new DynamicFont() { FontData = new DynamicFontData() { FontPath = "res://Roboto-Bold.ttf" }, Size = 30 });
// make color of the text dark orange
label.AddColorOverride("font_color", new Color(1, 0.5f, 0));
// make text centered in the sprite
label.RectPosition = new Vector2(-10, -15);
label.RectSize = new Vector2(64, 64);
label.Align = Label.AlignEnum.Left;
label.Valign = Label.VAlign.Top;
// add label to the sprite
AddChild(label);
}
private void UpdateLetter()
{
// update text of the label
// to the letter assigned to the letter variable
label.Text = letter;
}
} }

View File

@@ -1,28 +1,33 @@
using Godot; using Godot;
using System; using System;
public class Letterbox : Node2D namespace lettergodot
{ {
// Called when the node enters the scene tree for the first time.
public override void _Ready()
public class Letterbox : Node2D
{ {
// assign random letters to all the child nodes of type Letter // Called when the node enters the scene tree for the first time.
foreach (var letter in GetChildren()) public override void _Ready()
{ {
if (letter is Letter) // assign random letters to all the child nodes of type Letter
foreach (var letter in GetChildren())
{ {
((Letter)letter).Value = RandomLetterAsAString(); if (letter is Letter)
{
((Letter)letter).Value = RandomLetterAsAString();
}
} }
}
// method that returns a string with a random capital letter inside
private string RandomLetterAsAString()
{
var random = new Random();
var randomLetter = (char)random.Next('A', 'Z' + 1);
return randomLetter.ToString();
} }
} }
// method that returns a string with a random capital letter inside
private string RandomLetterAsAString()
{
var random = new Random();
var randomLetter = (char)random.Next('A', 'Z' + 1);
return randomLetter.ToString();
}
} }

View File

@@ -1,130 +1,134 @@
using Godot; using Godot;
using System; using System;
using Godot.Collections; using Godot.Collections;
using lettergodot;
public class MainBoard : TileMap namespace lettergodot
{ {
public Dictionary<Vector2, GameManager.FieldType> Points = new Dictionary<Vector2, GameManager.FieldType>();
// Called when the node enters the scene tree for the first time. public class MainBoard : TileMap
public override void _Ready()
{ {
SetupBonusTiles(); public Dictionary<Vector2, GameManager.FieldType> Points = new Dictionary<Vector2, GameManager.FieldType>();
DrawLettersOnBonusTiles();
}
private void DrawLettersOnBonusTiles() // Called when the node enters the scene tree for the first time.
{ public override void _Ready()
// For every bonus tile, draw a label on it
// 'DW" for DoubleWord
// 'TW' for TripleWord
// 'DL' for DoubleLetter
// 'TL' for TripleLetter
foreach (var point in Points)
{ {
var position = point.Key; SetupBonusTiles();
var fieldType = point.Value; DrawLettersOnBonusTiles();
var label = new Label();
// make label text bold
label.AddFontOverride("font", new DynamicFont { FontData = new DynamicFontData { FontPath = "res://Roboto-Bold.ttf" } });
label.AddColorOverride("font_color", new Color(0, 0, 0));
switch (fieldType)
{
case GameManager.FieldType.DoubleWord:
label.Text = "DW";
break;
case GameManager.FieldType.TripleWord:
label.Text = "TW";
break;
case GameManager.FieldType.DoubleLetter:
label.Text = "DL";
break;
case GameManager.FieldType.TripleLetter:
label.Text = "TL";
break;
}
label.RectPosition = new Vector2(position.x * 64 + 20, position.y * 64 + 25);
AddChild(label);
} }
}
private void SetupBonusTiles() private void DrawLettersOnBonusTiles()
{
Points.Add(new Vector2(5, 1), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(9, 1), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(7, 3), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(1, 5), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(13, 5), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(3, 7), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(11, 7), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(1, 9), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(13, 9), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(7, 11), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(5, 13), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(9, 13), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(3, 0), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(11, 0), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(0, 3), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(14, 3), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(0, 11), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(14, 11), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(3, 14), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(11, 14), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(2, 1), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 1), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(1, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(13, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(8, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 6), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 6), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 8), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 8), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(8, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(1, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(13, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 13), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 13), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 0), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(8, 0), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(3, 3), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(11, 3), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(5, 5), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(9, 5), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(0, 6), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(14, 6), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(0, 8), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(14, 8), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(5, 9), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(9, 9), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(3, 11), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(11, 11), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(6, 14), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(8, 14), GameManager.FieldType.TripleLetter);
}
public override void _Input(InputEvent @event)
{
// when user clicks on a tile
// print tile position
if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed)
{ {
var tilePosition = WorldToMap(GetGlobalMousePosition()); // For every bonus tile, draw a label on it
GD.Print(tilePosition); // 'DW" for DoubleWord
// 'TW' for TripleWord
// 'DL' for DoubleLetter
// 'TL' for TripleLetter
foreach (var point in Points)
{
var position = point.Key;
var fieldType = point.Value;
var label = new Label();
// make label text bold
label.AddFontOverride("font",
new DynamicFont { FontData = new DynamicFontData { FontPath = "res://Roboto-Bold.ttf" } });
label.AddColorOverride("font_color", new Color(0, 0, 0));
switch (fieldType)
{
case GameManager.FieldType.DoubleWord:
label.Text = "DW";
break;
case GameManager.FieldType.TripleWord:
label.Text = "TW";
break;
case GameManager.FieldType.DoubleLetter:
label.Text = "DL";
break;
case GameManager.FieldType.TripleLetter:
label.Text = "TL";
break;
}
label.RectPosition = new Vector2(position.x * 64 + 20, position.y * 64 + 25);
AddChild(label);
}
}
private void SetupBonusTiles()
{
Points.Add(new Vector2(5, 1), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(9, 1), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(7, 3), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(1, 5), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(13, 5), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(3, 7), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(11, 7), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(1, 9), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(13, 9), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(7, 11), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(5, 13), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(9, 13), GameManager.FieldType.DoubleWord);
Points.Add(new Vector2(3, 0), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(11, 0), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(0, 3), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(14, 3), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(0, 11), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(14, 11), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(3, 14), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(11, 14), GameManager.FieldType.TripleWord);
Points.Add(new Vector2(2, 1), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 1), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(1, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(13, 2), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(8, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 4), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 6), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 6), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 8), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 8), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(8, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 10), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(1, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(4, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(10, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(13, 12), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(2, 13), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(12, 13), GameManager.FieldType.DoubleLetter);
Points.Add(new Vector2(6, 0), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(8, 0), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(3, 3), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(11, 3), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(5, 5), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(9, 5), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(0, 6), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(14, 6), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(0, 8), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(14, 8), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(5, 9), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(9, 9), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(3, 11), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(11, 11), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(6, 14), GameManager.FieldType.TripleLetter);
Points.Add(new Vector2(8, 14), GameManager.FieldType.TripleLetter);
}
public override void _Input(InputEvent @event)
{
// when user clicks on a tile
// print tile position
if (@event is InputEventMouseButton eventMouseButton && eventMouseButton.Pressed)
{
var tilePosition = WorldToMap(GetGlobalMousePosition());
GD.Print(tilePosition);
}
} }
} }
} }

147
main.tscn
View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=9 format=2]
[ext_resource path="res://main.tres" type="TileSet" id=1] [ext_resource path="res://main.tres" type="TileSet" id=1]
[ext_resource path="res://MainBoard.cs" type="Script" id=2] [ext_resource path="res://MainBoard.cs" type="Script" id=2]
@@ -17,9 +17,6 @@ animations = [ {
"speed": 5.0 "speed": 5.0
} ] } ]
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 49, 53.5 )
[node name="Node2D" type="Node2D"] [node name="Node2D" type="Node2D"]
material = SubResource( 2 ) material = SubResource( 2 )
@@ -27,61 +24,123 @@ material = SubResource( 2 )
position = Vector2( 73, 283 ) position = Vector2( 73, 283 )
tile_set = ExtResource( 1 ) tile_set = ExtResource( 1 )
format = 1 format = 1
tile_data = PoolIntArray( 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 65537, 4, 1, 0, 5, 1, 0, 6, 1, 65538, 7, 1, 0, 8, 1, 65538, 9, 1, 0, 10, 1, 0, 11, 1, 65537, 12, 1, 0, 13, 1, 0, 14, 1, 0, 65536, 1, 0, 65537, 1, 0, 65538, 1, 65539, 65539, 1, 0, 65540, 1, 0, 65541, 1, 131072, 65542, 1, 0, 65543, 1, 0, 65544, 1, 0, 65545, 1, 131072, 65546, 1, 0, 65547, 1, 0, 65548, 1, 65539, 65549, 1, 0, 65550, 1, 0, 131072, 1, 0, 131073, 1, 65539, 131074, 1, 0, 131075, 1, 0, 131076, 1, 65539, 131077, 1, 0, 131078, 1, 0, 131079, 1, 0, 131080, 1, 0, 131081, 1, 0, 131082, 1, 65539, 131083, 1, 0, 131084, 1, 0, 131085, 1, 65539, 131086, 1, 0, 196608, 1, 65537, 196609, 1, 0, 196610, 1, 0, 196611, 1, 65538, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 131072, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 65538, 196620, 1, 0, 196621, 1, 0, 196622, 1, 65537, 262144, 1, 0, 262145, 1, 0, 262146, 1, 65539, 262147, 1, 0, 262148, 1, 0, 262149, 1, 0, 262150, 1, 65539, 262151, 1, 0, 262152, 1, 65539, 262153, 1, 0, 262154, 1, 0, 262155, 1, 0, 262156, 1, 65539, 262157, 1, 0, 262158, 1, 0, 327680, 1, 0, 327681, 1, 131072, 327682, 1, 0, 327683, 1, 0, 327684, 1, 0, 327685, 1, 65538, 327686, 1, 0, 327687, 1, 0, 327688, 1, 0, 327689, 1, 65538, 327690, 1, 0, 327691, 1, 0, 327692, 1, 0, 327693, 1, 131072, 327694, 1, 0, 393216, 1, 65538, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393220, 1, 65539, 393221, 1, 0, 393222, 1, 0, 393223, 1, 0, 393224, 1, 0, 393225, 1, 0, 393226, 1, 65539, 393227, 1, 0, 393228, 1, 0, 393229, 1, 0, 393230, 1, 65538, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 131072, 458756, 1, 0, 458757, 1, 0, 458758, 1, 0, 458759, 1, 131073, 458760, 1, 0, 458761, 1, 0, 458762, 1, 0, 458763, 1, 131072, 458764, 1, 0, 458765, 1, 0, 458766, 1, 0, 524288, 1, 65538, 524289, 1, 0, 524290, 1, 0, 524291, 1, 0, 524292, 1, 65539, 524293, 1, 0, 524294, 1, 0, 524295, 1, 0, 524296, 1, 0, 524297, 1, 0, 524298, 1, 65539, 524299, 1, 0, 524300, 1, 0, 524301, 1, 0, 524302, 1, 65538, 589824, 1, 0, 589825, 1, 131072, 589826, 1, 0, 589827, 1, 0, 589828, 1, 0, 589829, 1, 65538, 589830, 1, 0, 589831, 1, 0, 589832, 1, 0, 589833, 1, 65538, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 589837, 1, 131072, 589838, 1, 0, 655360, 1, 0, 655361, 1, 0, 655362, 1, 65539, 655363, 1, 0, 655364, 1, 0, 655365, 1, 0, 655366, 1, 65539, 655367, 1, 0, 655368, 1, 65539, 655369, 1, 0, 655370, 1, 0, 655371, 1, 0, 655372, 1, 65539, 655373, 1, 0, 655374, 1, 0, 720896, 1, 65537, 720897, 1, 0, 720898, 1, 0, 720899, 1, 65538, 720900, 1, 0, 720901, 1, 0, 720902, 1, 0, 720903, 1, 131072, 720904, 1, 0, 720905, 1, 0, 720906, 1, 0, 720907, 1, 65538, 720908, 1, 0, 720909, 1, 0, 720910, 1, 65537, 786432, 1, 0, 786433, 1, 65539, 786434, 1, 0, 786435, 1, 0, 786436, 1, 65539, 786437, 1, 0, 786438, 1, 0, 786439, 1, 0, 786440, 1, 0, 786441, 1, 0, 786442, 1, 65539, 786443, 1, 0, 786444, 1, 0, 786445, 1, 65539, 786446, 1, 0, 851968, 1, 0, 851969, 1, 0, 851970, 1, 65539, 851971, 1, 0, 851972, 1, 0, 851973, 1, 131072, 851974, 1, 0, 851975, 1, 0, 851976, 1, 0, 851977, 1, 131072, 851978, 1, 0, 851979, 1, 0, 851980, 1, 65539, 851981, 1, 0, 851982, 1, 0, 917504, 1, 0, 917505, 1, 0, 917506, 1, 0, 917507, 1, 65537, 917508, 1, 0, 917509, 1, 0, 917510, 1, 65538, 917511, 1, 0, 917512, 1, 65538, 917513, 1, 0, 917514, 1, 0, 917515, 1, 65537, 917516, 1, 0, 917517, 1, 0, 917518, 1, 0 ) tile_data = PoolIntArray( 0, 1, 0, 1, 1, 0, 2, 1, 0, 3, 1, 65537, 4, 1, 0, 5, 1, 0, 6, 1, 65538, 7, 1, 0, 8, 1, 65538, 9, 1, 0, 10, 1, 0, 11, 1, 65537, 12, 1, 0, 13, 1, 0, 14, 1, 0, 65536, 1, 0, 65537, 1, 0, 65538, 1, 65539, 65539, 1, 0, 65540, 1, 0, 65541, 1, 131072, 65542, 1, 0, 65543, 1, 0, 65544, 1, 0, 65545, 1, 131072, 65546, 1, 0, 65547, 1, 0, 65548, 1, 65539, 65549, 1, 0, 65550, 1, 0, 131072, 1, 0, 131073, 1, 65539, 131074, 1, 0, 131075, 1, 0, 131076, 1, 65539, 131077, 1, 0, 131078, 1, 0, 131079, 1, 0, 131080, 1, 0, 131081, 1, 0, 131082, 1, 65539, 131083, 1, 0, 131084, 1, 0, 131085, 1, 65539, 131086, 1, 0, 196608, 1, 65537, 196609, 1, 0, 196610, 1, 0, 196611, 1, 65538, 196612, 1, 0, 196613, 1, 0, 196614, 1, 0, 196615, 1, 131072, 196616, 1, 0, 196617, 1, 0, 196618, 1, 0, 196619, 1, 65538, 196620, 1, 0, 196621, 1, 0, 196622, 1, 65537, 262144, 1, 0, 262145, 1, 0, 262146, 1, 65539, 262147, 1, 0, 262148, 1, 0, 262149, 1, 0, 262150, 1, 65539, 262151, 1, 0, 262152, 1, 65539, 262153, 1, 0, 262154, 1, 0, 262155, 1, 0, 262156, 1, 65539, 262157, 1, 0, 262158, 1, 0, 327680, 1, 0, 327681, 1, 131072, 327682, 1, 0, 327683, 1, 0, 327684, 1, 0, 327685, 1, 65538, 327686, 1, 0, 327687, 1, 0, 327688, 1, 0, 327689, 1, 65538, 327690, 1, 0, 327691, 1, 0, 327692, 1, 0, 327693, 1, 131072, 327694, 1, 0, 393216, 1, 65538, 393217, 1, 0, 393218, 1, 0, 393219, 1, 0, 393220, 1, 65539, 393221, 1, 0, 393222, 1, 0, 393223, 1, 0, 393224, 1, 0, 393225, 1, 0, 393226, 1, 65539, 393227, 1, 0, 393228, 1, 0, 393229, 1, 0, 393230, 1, 65538, 458752, 1, 0, 458753, 1, 0, 458754, 1, 0, 458755, 1, 131072, 458756, 1, 0, 458757, 1, 0, 458758, 1, 0, 458759, 1, 131073, 458760, 1, 0, 458761, 1, 0, 458762, 1, 0, 458763, 1, 131072, 458764, 1, 0, 458765, 1, 0, 458766, 1, 0, 524288, 1, 65538, 524289, 1, 0, 524290, 1, 0, 524291, 1, 0, 524292, 1, 65539, 524293, 1, 0, 524294, 1, 0, 524295, 1, 0, 524296, 1, 0, 524297, 1, 0, 524298, 1, 65539, 524299, 1, 0, 524300, 1, 0, 524301, 1, 0, 524302, 1, 65538, 589824, 1, 0, 589825, 1, 131072, 589826, 1, 0, 589827, 1, 0, 589828, 1, 0, 589829, 1, 65538, 589830, 1, 0, 589831, 1, 0, 589832, 1, 0, 589833, 1, 65538, 589834, 1, 0, 589835, 1, 0, 589836, 1, 0, 589837, 1, 131072, 589838, 1, 0, 655360, 1, 0, 655361, 1, 0, 655362, 1, 65539, 655363, 1, 0, 655364, 1, 0, 655365, 1, 0, 655366, 1, 65539, 655367, 1, 0, 655368, 1, 65539, 655369, 1, 0, 655370, 1, 0, 655371, 1, 0, 655372, 1, 65539, 655373, 1, 0, 655374, 1, 0, 720896, 1, 65537, 720897, 1, 0, 720898, 1, 0, 720899, 1, 65538, 720900, 1, 0, 720901, 1, 0, 720902, 1, 0, 720903, 1, 131072, 720904, 1, 0, 720905, 1, 0, 720906, 1, 0, 720907, 1, 65538, 720908, 1, 0, 720909, 1, 0, 720910, 1, 65537, 786432, 1, 0, 786433, 1, 65539, 786434, 1, 0, 786435, 1, 0, 786436, 1, 65539, 786437, 1, 0, 786438, 1, 0, 786439, 1, 0, 786440, 1, 0, 786441, 1, 0, 786442, 1, 65539, 786443, 1, 0, 786444, 1, 0, 786445, 1, 65539, 786446, 1, 0, 851968, 1, 0, 851969, 1, 0, 851970, 1, 65539, 851971, 1, 0, 851972, 1, 0, 851973, 1, 131072, 851974, 1, 0, 851975, 1, 0, 851976, 1, 0, 851977, 1, 131072, 851978, 1, 0, 851979, 1, 0, 851980, 1, 0, 851981, 1, 0, 851982, 1, 0, 917504, 1, 0, 917505, 1, 0, 917506, 1, 0, 917507, 1, 65537, 917508, 1, 0, 917509, 1, 0, 917510, 1, 65538, 917511, 1, 0, 917512, 1, 65538, 917513, 1, 0, 917514, 1, 0, 917515, 1, 65537, 917516, 1, 0, 917517, 1, 0, 917518, 1, 0 )
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Letterbox" type="Node2D" parent="."] [node name="Letterbox" type="Node2D" parent="."]
position = Vector2( 1, 4 ) position = Vector2( 1, 4 )
script = ExtResource( 4 ) script = ExtResource( 4 )
[node name="Letter2" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 360, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="Letter3" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 457, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="Letter4" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 554, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="Letter5" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 651, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="Letter6" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 748, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="Letter7" type="AnimatedSprite" parent="Letterbox"]
position = Vector2( 845, 1335 )
scale = Vector2( 1.5, 1.5 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D" type="KinematicBody2D" parent="Letterbox"] [node name="KinematicBody2D" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 263, 1335 ) position = Vector2( 263, 1335 )
scale = Vector2( 1.5, 1.5 ) scale = Vector2( 1.5, 1.5 )
input_pickable = true input_pickable = true
script = ExtResource( 6 ) script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter1" type="AnimatedSprite" parent="Letterbox/KinematicBody2D"] [node name="Letter1" type="AnimatedSprite" parent="Letterbox/KinematicBody2D"]
frames = SubResource( 1 ) frames = SubResource( 1 )
script = ExtResource( 5 ) script = ExtResource( 5 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Letterbox/KinematicBody2D"] [node name="KinematicBody2D2" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 262, 1333.5 ) position = Vector2( 359, 1335 )
shape = SubResource( 3 ) scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D2"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter2" type="AnimatedSprite" parent="Letterbox/KinematicBody2D2"]
scale = Vector2( 1, 1 )
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D3" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 455, 1335 )
scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D3"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter3" type="AnimatedSprite" parent="Letterbox/KinematicBody2D3"]
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D4" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 554, 1335 )
scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D4"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter4" type="AnimatedSprite" parent="Letterbox/KinematicBody2D4"]
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D5" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 650, 1335 )
scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D5"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter5" type="AnimatedSprite" parent="Letterbox/KinematicBody2D5"]
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D6" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 746, 1335 )
scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D6"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter6" type="AnimatedSprite" parent="Letterbox/KinematicBody2D6"]
frames = SubResource( 1 )
script = ExtResource( 5 )
[node name="KinematicBody2D7" type="KinematicBody2D" parent="Letterbox"]
position = Vector2( 845, 1335 )
scale = Vector2( 1.5, 1.5 )
input_pickable = true
script = ExtResource( 6 )
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Letterbox/KinematicBody2D7"]
position = Vector2( -0.400002, 0.394684 )
scale = Vector2( 1.00781, 0.992021 )
polygon = PoolVector2Array( -30.032, -21.2308, -20, -32, 22, -30.6667, 32, -17.3333, 30, 23.3333, 23.3333, 30, -19.3333, 30.6667, -30.032, 19.0909 )
[node name="Letter7" type="AnimatedSprite" parent="Letterbox/KinematicBody2D7"]
frames = SubResource( 1 )
script = ExtResource( 5 )
[connection signal="input_event" from="Letterbox/KinematicBody2D" to="Letterbox/KinematicBody2D" method="_on_KinematicBody2D_input_event"] [connection signal="input_event" from="Letterbox/KinematicBody2D" to="Letterbox/KinematicBody2D" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D2" to="Letterbox/KinematicBody2D2" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D3" to="Letterbox/KinematicBody2D3" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D4" to="Letterbox/KinematicBody2D4" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D5" to="Letterbox/KinematicBody2D5" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D6" to="Letterbox/KinematicBody2D6" method="_on_KinematicBody2D_input_event"]
[connection signal="input_event" from="Letterbox/KinematicBody2D7" to="Letterbox/KinematicBody2D7" method="_on_KinematicBody2D_input_event"]

View File

@@ -1,24 +1,27 @@
using Godot; using Godot;
using System; using System;
public class startup : Node namespace lettergodot
{ {
// Declare member variables here. Examples: public class startup : Node
// private int a = 2;
// private string b = "text";
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{ {
// Declare member variables here. Examples:
// private int a = 2;
// private string b = "text";
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
} }
// // Called every frame. 'delta' is the elapsed time since the previous frame. // // Called every frame. 'delta' is the elapsed time since the previous frame.
// public override void _Process(float delta) // public override void _Process(float delta)
// { // {
// //
// } // }
}
} }