Second Prototype
This commit is contained in:
parent
885351b624
commit
632eeddc64
60 changed files with 680 additions and 1013 deletions
5
scenes/Blocks/Patterns/1x3/1x3_Collision.tscn
Normal file
5
scenes/Blocks/Patterns/1x3/1x3_Collision.tscn
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
[gd_scene format=3 uid="uid://yw2cspv5rkwh"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
position = Vector2(32, 32)
|
||||
polygon = PackedVector2Array(48, -16, 48, -48, -112, -48, -112, -16)
|
||||
18
scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn
Normal file
18
scenes/Blocks/Patterns/1x3/1x3_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://b6aa24lk0ush1"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_cqyb4"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_4ivv2"]
|
||||
[ext_resource type="PackedScene" uid="uid://yw2cspv5rkwh" path="res://scenes/Blocks/Patterns/1x3/1x3_Collision.tscn" id="3_vkhdr"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_cqyb4")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_4ivv2")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_4ivv2")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_4ivv2")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_vkhdr")]
|
||||
4
scenes/Blocks/Patterns/2x2/2x2_Collision.tscn
Normal file
4
scenes/Blocks/Patterns/2x2/2x2_Collision.tscn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://dw1dt1jp6e06h"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(48, 48, 48, -48, -48, -48, -48, 48)
|
||||
21
scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn
Normal file
21
scenes/Blocks/Patterns/2x2/2x2_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://dneih4b0e2snv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_sj41y"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_csenr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dw1dt1jp6e06h" path="res://scenes/Blocks/Patterns/2x2/2x2_Collision.tscn" id="3_10q5w"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_sj41y")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_csenr")]
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_csenr")]
|
||||
position = Vector2(0, -64)
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_csenr")]
|
||||
position = Vector2(-64, -64)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_csenr")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_10q5w")]
|
||||
position = Vector2(-32, -32)
|
||||
4
scenes/Blocks/Patterns/I/I_Collision.tscn
Normal file
4
scenes/Blocks/Patterns/I/I_Collision.tscn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://ufbeturvvirh"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(112, -16, 112, -48, -112, -48, -112, -16)
|
||||
22
scenes/Blocks/Patterns/I/I_block_pattern.tscn
Normal file
22
scenes/Blocks/Patterns/I/I_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://hlwbhtymstbv"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_ri22b"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_6qvmy"]
|
||||
[ext_resource type="PackedScene" uid="uid://ufbeturvvirh" path="res://scenes/Blocks/Patterns/I/I_Collision.tscn" id="3_1ktcx"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_ri22b")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_6qvmy")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_6qvmy")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_6qvmy")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_6qvmy")]
|
||||
position = Vector2(128, 0)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_1ktcx")]
|
||||
position = Vector2(32, 32)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://w0ak23cjswln"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(48, -16, 48, -48, -80, -48, -80, -112, -112, -112, -112, -16)
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://1ubuiryqny62"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_y8gyp"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_tsq70"]
|
||||
[ext_resource type="PackedScene" uid="uid://w0ak23cjswln" path="res://scenes/Blocks/Patterns/L-Reverse/L-Reverse_Collision.tscn" id="3_k23nd"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_y8gyp")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_tsq70")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_tsq70")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_tsq70")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_tsq70")]
|
||||
position = Vector2(-64, -64)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_k23nd")]
|
||||
position = Vector2(32, 32)
|
||||
4
scenes/Blocks/Patterns/L/L_Collision.tscn
Normal file
4
scenes/Blocks/Patterns/L/L_Collision.tscn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://663ocu3x6tjb"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(48, 48, 48, -48, 16, -48, 16, 16, -112, 16, -112, 48)
|
||||
22
scenes/Blocks/Patterns/L/L_block_pattern.tscn
Normal file
22
scenes/Blocks/Patterns/L/L_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://d00ywshnytrdo"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_e7pv8"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_q62gn"]
|
||||
[ext_resource type="PackedScene" uid="uid://663ocu3x6tjb" path="res://scenes/Blocks/Patterns/L/L_Collision.tscn" id="3_ji3us"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_e7pv8")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_q62gn")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_q62gn")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_q62gn")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_q62gn")]
|
||||
position = Vector2(64, -64)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_ji3us")]
|
||||
position = Vector2(32, -32)
|
||||
4
scenes/Blocks/Patterns/T/T_Collision.tscn
Normal file
4
scenes/Blocks/Patterns/T/T_Collision.tscn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://dwfkvfcrbxr43"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(-48, 48, 112, 48, 112, 16, 48, 16, 48, -48, 16, -48, 16, 16, -48, 16)
|
||||
22
scenes/Blocks/Patterns/T/T_block_pattern.tscn
Normal file
22
scenes/Blocks/Patterns/T/T_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://c25mwygtprl08"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_1p2cg"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_pponh"]
|
||||
[ext_resource type="PackedScene" uid="uid://dwfkvfcrbxr43" path="res://scenes/Blocks/Patterns/T/T_Collision.tscn" id="3_svqqd"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_1p2cg")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_pponh")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_pponh")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_pponh")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_pponh")]
|
||||
position = Vector2(0, -64)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_svqqd")]
|
||||
position = Vector2(-24, -32)
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
[gd_scene format=3 uid="uid://wv65ib41nt8v"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
position = Vector2(32, -32)
|
||||
polygon = PackedVector2Array(48, 48, 48, 16, -16, 16, -16, -48, -112, -48, -112, -16, -48, -16, -48, 48)
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bnpmnhr43ls40"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_skje3"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_prllt"]
|
||||
[ext_resource type="PackedScene" uid="uid://wv65ib41nt8v" path="res://scenes/Blocks/Patterns/Z-Reverse/Z-Reverse_Collision.tscn" id="3_xf113"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_skje3")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_prllt")]
|
||||
position = Vector2(-64, -64)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_prllt")]
|
||||
position = Vector2(0, -64)
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_prllt")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_prllt")]
|
||||
position = Vector2(64, 0)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_xf113")]
|
||||
4
scenes/Blocks/Patterns/Z/Z-Collision.tscn
Normal file
4
scenes/Blocks/Patterns/Z/Z-Collision.tscn
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://dkugrxq2fo1vh"]
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D"]
|
||||
polygon = PackedVector2Array(16, 16, 16, -48, 80, -48, 80, -80, -16, -80, -16, -16, -80, -16, -80, 16)
|
||||
21
scenes/Blocks/Patterns/Z/Z_block_pattern.tscn
Normal file
21
scenes/Blocks/Patterns/Z/Z_block_pattern.tscn
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://ba70ybe7ico7f"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://7knb2yqvkw6i" path="res://scenes/Blocks/Patterns/block_pattern.tscn" id="1_ccvbw"]
|
||||
[ext_resource type="PackedScene" uid="uid://2v7wok4hnr6c" path="res://scenes/Blocks/Patterns/position_marker.tscn" id="2_y06oe"]
|
||||
[ext_resource type="PackedScene" uid="uid://dkugrxq2fo1vh" path="res://scenes/Blocks/Patterns/Z/Z-Collision.tscn" id="3_0127o"]
|
||||
|
||||
[node name="BlockPattern" instance=ExtResource("1_ccvbw")]
|
||||
|
||||
[node name="PositionMarker" parent="Positions" index="0" instance=ExtResource("2_y06oe")]
|
||||
position = Vector2(-64, 0)
|
||||
|
||||
[node name="PositionMarker2" parent="Positions" index="1" instance=ExtResource("2_y06oe")]
|
||||
turningPoint = true
|
||||
|
||||
[node name="PositionMarker3" parent="Positions" index="2" instance=ExtResource("2_y06oe")]
|
||||
position = Vector2(0, -64)
|
||||
|
||||
[node name="PositionMarker4" parent="Positions" index="3" instance=ExtResource("2_y06oe")]
|
||||
position = Vector2(64, -64)
|
||||
|
||||
[node name="CollisionPolygon2D" parent="CollisionTest" index="0" instance=ExtResource("3_0127o")]
|
||||
104
scenes/Blocks/Patterns/block_pattern.gd
Normal file
104
scenes/Blocks/Patterns/block_pattern.gd
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
extends Node2D
|
||||
|
||||
@onready var positions = $Positions
|
||||
@onready var collision = $CollisionTest
|
||||
|
||||
var lastDirection = null
|
||||
|
||||
func getPositions():
|
||||
return positions.get_children()
|
||||
|
||||
func checkDirection():
|
||||
var leftCollision = true
|
||||
var rightCollision = true
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
if await getCollidingAreas() != []:
|
||||
positions.position.x += GLOBAL.GRID
|
||||
collision.position.x += GLOBAL.GRID
|
||||
if await getCollidingAreas() == []:
|
||||
rightCollision = false
|
||||
else:
|
||||
rightCollision = true
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
if await getCollidingAreas() != []:
|
||||
positions.position.x -= GLOBAL.GRID
|
||||
collision.position.x -= GLOBAL.GRID
|
||||
if await getCollidingAreas() == []:
|
||||
leftCollision = false
|
||||
else:
|
||||
leftCollision = true
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
if not rightCollision:
|
||||
positions.position.x += GLOBAL.GRID
|
||||
collision.position.x += GLOBAL.GRID
|
||||
elif not leftCollision:
|
||||
positions.position.x -= GLOBAL.GRID
|
||||
collision.position.x -= GLOBAL.GRID
|
||||
else:
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
|
||||
func turn(direction,newPosition):
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
position = newPosition
|
||||
match direction:
|
||||
GLOBAL.Direction.LEFT:
|
||||
positions.rotation_degrees += 90
|
||||
collision.rotation_degrees += 90
|
||||
if await getCollidingAreas() != []:
|
||||
checkDirection()
|
||||
if await getCollidingAreas() != []:
|
||||
positions.rotation_degrees += 90
|
||||
collision.rotation_degrees += 90
|
||||
|
||||
GLOBAL.Direction.RIGHT:
|
||||
positions.rotation_degrees -= 90
|
||||
collision.rotation_degrees -= 90
|
||||
if await getCollidingAreas() != []:
|
||||
checkDirection()
|
||||
if await getCollidingAreas() != []:
|
||||
positions.rotation_degrees -= 90
|
||||
collision.rotation_degrees -= 90
|
||||
#positions.rotation_degrees += 90
|
||||
#collision.rotation_degrees += 90
|
||||
|
||||
|
||||
|
||||
func getCollidingAreas():
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
var collidingAreas = []
|
||||
for i in collision.get_overlapping_areas():
|
||||
if i.is_in_group("Block"):
|
||||
if i.UID != GLOBAL.currentUID:
|
||||
collidingAreas.append(i)
|
||||
else:
|
||||
collidingAreas.append(i)
|
||||
return collidingAreas
|
||||
|
||||
|
||||
#func _on_collision_test_area_entered(area: Area2D) -> void:
|
||||
#if lastDirection == null:
|
||||
#checkLeft()
|
||||
#else:
|
||||
#if lastDirection == GLOBAL.Direction.LEFT:
|
||||
#print(getCollidingAreas())
|
||||
#checkRight()
|
||||
#if lastDirection == GLOBAL.Direction.LEFT:
|
||||
#print(getCollidingAreas())
|
||||
#print(collision.get_overlapping_areas())
|
||||
#print(getCollidingAreas())
|
||||
#print(checkLeft())
|
||||
#print(checkRight())
|
||||
|
||||
func reset(newPosition):
|
||||
position = newPosition
|
||||
positions.position.x = 0
|
||||
collision.position.x = 0
|
||||
rotation_degrees = 0
|
||||
12
scenes/Blocks/Patterns/block_pattern.tscn
Normal file
12
scenes/Blocks/Patterns/block_pattern.tscn
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://7knb2yqvkw6i"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Blocks/Patterns/block_pattern.gd" id="1_ne3bj"]
|
||||
|
||||
[node name="BlockPattern" type="Node2D"]
|
||||
script = ExtResource("1_ne3bj")
|
||||
|
||||
[node name="Positions" type="Node2D" parent="."]
|
||||
|
||||
[node name="CollisionTest" type="Area2D" parent="."]
|
||||
collision_layer = 8
|
||||
collision_mask = 3
|
||||
3
scenes/Blocks/Patterns/position_marker.gd
Normal file
3
scenes/Blocks/Patterns/position_marker.gd
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
extends Marker2D
|
||||
|
||||
@export var turningPoint = false
|
||||
6
scenes/Blocks/Patterns/position_marker.tscn
Normal file
6
scenes/Blocks/Patterns/position_marker.tscn
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://2v7wok4hnr6c"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/Blocks/Patterns/position_marker.gd" id="1_775kb"]
|
||||
|
||||
[node name="PositionMarker" type="Marker2D"]
|
||||
script = ExtResource("1_775kb")
|
||||
Loading…
Add table
Add a link
Reference in a new issue