Cleaned up the Code; reworked the Block Physics

This commit is contained in:
Exobyt 2024-08-27 22:35:24 +02:00
parent ed9f671256
commit 9f6750b08a
48 changed files with 1237 additions and 1116 deletions

View file

@ -2,9 +2,9 @@ extends Node
var points = 0
const minSpeed = 0.5
const maxSpeed = 0.15
var currentSpeed := minSpeed
enum SPEED {MIN=30, MAX=100}
var currentSpeed := SPEED.MIN
var hasSelectedSpeed = false
@ -12,21 +12,27 @@ const GRID := 64
enum BLOCKTYPES {LIGHT=1, HEAVY=3}
const BLOCKSPATTERS : Dictionary = {
"Z": "res://scenes/Blocks/Patterns/Z/Z_block_pattern.tscn",
"L": "res://scenes/Blocks/Patterns/L/L_block_pattern.tscn",
"L-Reverse": "res://scenes/Blocks/Patterns/L-Reverse/L-Reverse_block_pattern.tscn",
"Z-Reverse": "res://scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_block_pattern.tscn",
"2x2": "res://scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn",
"T": "res://scenes/Blocks/Patterns/T/T_block_pattern.tscn",
#"I": "res://scenes/Blocks/Patterns/I/I_block_pattern.tscn",
"1x3": "res://scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn"
var blockStopped = false
var testingPhase = false
var rowRemoved = false
const BLOCKS : Dictionary = {
#"1x1": "res://scenes/NewBlocks/1x1/1x1.tscn",
"1x3": "res://scenes/NewBlocks/1x3/1x3.tscn",
#"1x4": "res://scenes/NewBlocks/1x4/1x4.tscn",
"2x2": "res://scenes/NewBlocks/2x2/2x2.tscn",
"L": "res://scenes/NewBlocks/L/L.tscn",
"L_Reverse": "res://scenes/NewBlocks/L_Reverse/L_Reverse.tscn",
"Z": "res://scenes/NewBlocks/Z/Z.tscn",
"Z_Reverse": "res://scenes/NewBlocks/Z_Reverse/Z_Reverse.tscn",
}
enum Direction {BOTTOM, LEFT, RIGHT, TOP}
var lastUID = 1
var currentUID : int = 0
var currentUID = lastUID
var currentID : int = 0
var time = 60
@ -36,16 +42,22 @@ enum MODES {INFINITE, TIME}
var currentMode = MODES.INFINITE
func getNewUID() -> int:
lastUID += 1
return lastUID
func getNewUID() -> int:
currentUID += 1
return currentUID
func getNewID() -> int:
currentID += 1
return currentID
func resetGame():
rowRemoved = false
blockStopped = false
testingPhase = false
lost = false
points = 0
lastUID = 0
currentUID = lastUID
currentUID = 0
resetTime()
lost = false
@ -69,3 +81,9 @@ func convertIntToTime(value) -> String:
if seconds < 10:
seconds = "0"+ str(seconds)
return str(minutes) + ":" + str(seconds)
func speedUp():
if currentSpeed + 1 <= SPEED.MAX:
currentSpeed += 1
else:
currentSpeed = SPEED.MAX