diff --git a/TODO.md b/TODO.md index 03e75d3..3587aef 100644 --- a/TODO.md +++ b/TODO.md @@ -1,13 +1,11 @@ -1. Visual polish - * multiple square tiles to add variation -2. Sound effects +1. Sound effects * when a unit is killed * if possible, a small bit of background music -3. Gameplay additions: +2. Gameplay additions: * powerups: change movement type, remove pawn's attack and movement restrictions * new units * choose difference board sizes -4. Further visual polish +3. Further visual polish * animate the piece making the attack, and returning to it's spot Bugs of note: diff --git a/assets/export/square_center_1.png b/assets/export/square_center_1.png new file mode 100644 index 0000000..f410649 Binary files /dev/null and b/assets/export/square_center_1.png differ diff --git a/assets/export/square_center_2.png b/assets/export/square_center_2.png new file mode 100644 index 0000000..05fa78a Binary files /dev/null and b/assets/export/square_center_2.png differ diff --git a/assets/source/Squares.xcf b/assets/source/Squares.xcf index b25ae83..87ad11f 100644 Binary files a/assets/source/Squares.xcf and b/assets/source/Squares.xcf differ diff --git a/src/Game.gd b/src/Game.gd index 0f0ee70..6cf1841 100644 --- a/src/Game.gd +++ b/src/Game.gd @@ -239,10 +239,12 @@ func set_piece_position(piece, position, destroy = false): # Called when the node enters the scene tree for the first time. func _ready(): + self.rng = RandomNumberGenerator.new() + self.rng.randomize() var pf = get_node("/root/Game/MarginContainer/Playfield") var start_height = 8 var start_width = 8 - pf.initialize(start_width, start_height) + pf.initialize(start_width, start_height, self.rng) self.height = start_height self.width = start_width # Translate the pf to it sits on top left @@ -260,9 +262,6 @@ func _ready(): 64 * scale )) self.pf_scale = scale - self.rng = RandomNumberGenerator.new() - self.rng.randomize() - get_node("/root/Game/EndMenu/VBoxContainer/New").connect("pressed", self, "_on_new_game_pressed") get_node("/root/Game/EndMenu/VBoxContainer/Quit").connect("pressed", self, "_on_quit_game_pressed") get_node("/root/Game/EndMenu/VBoxContainer/Fail Game").connect("pressed", self, "_on_fail_game") diff --git a/src/Playfield.gd b/src/Playfield.gd index fbfc98e..3f68a61 100644 --- a/src/Playfield.gd +++ b/src/Playfield.gd @@ -10,7 +10,14 @@ var width # holds weakrefs to the square nodes var squares = {} -func initialize(width: int = 8, height: int = 8): +const TILES = [ + "Body", + "Body1", + "Body2", +] + +func initialize(width: int = 8, height: int = 8, rng = null): + rng = null # Remove any Squares beneath us for i in self.squares.values(): if i.get_ref(): @@ -26,6 +33,11 @@ func initialize(width: int = 8, height: int = 8): var j = 0 while j < self.height: var instance = ResourceLoader.load("res://src/Square.tscn").instance() + if rng == null: + instance.get_node("Body").set_visible(true) + else: + var n = rng.randi() % TILES.size() + instance.get_node(TILES[n]).set_visible(true) # @TODO any tweaks to the node by calling custom function initialize() instance.translate(Vector2(128*i, 128*j)) self.squares[Vector2(i, j)] = weakref(instance) diff --git a/src/Square.gd b/src/Square.gd index 910127e..2f72701 100644 --- a/src/Square.gd +++ b/src/Square.gd @@ -12,6 +12,7 @@ const FLASH_MIN = Color(1, 0.75, 0.75, 1) const FLASH_MAX = Color(1, 0.5, 0.5, 1) const DEFAULT_BODY = Color(1, 1, 1, 1) # Called when the node enters the scene tree for the first time. + func _ready(): pass # Replace with function body. diff --git a/src/Square.tscn b/src/Square.tscn index 080b6e1..a157127 100644 --- a/src/Square.tscn +++ b/src/Square.tscn @@ -1,8 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://assets/export/edge.png" type="Texture" id=1] [ext_resource path="res://assets/export/square_center_0.png" type="Texture" id=2] [ext_resource path="res://src/Square.gd" type="Script" id=3] +[ext_resource path="res://assets/export/square_center_2.png" type="Texture" id=4] +[ext_resource path="res://assets/export/square_center_1.png" type="Texture" id=5] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 60, 60 ) @@ -12,8 +14,17 @@ z_index = -1 script = ExtResource( 3 ) [node name="Body" type="Sprite" parent="."] +visible = false texture = ExtResource( 2 ) +[node name="Body1" type="Sprite" parent="."] +visible = false +texture = ExtResource( 5 ) + +[node name="Body2" type="Sprite" parent="."] +visible = false +texture = ExtResource( 4 ) + [node name="Edge" type="Sprite" parent="."] modulate = Color( 0.12549, 0.0980392, 0.0980392, 1 ) texture = ExtResource( 1 )