Skip to content

Commit

Permalink
added more comments on code and made the pieces be different colors a…
Browse files Browse the repository at this point in the history
…mong other things
  • Loading branch information
gerblesh committed Mar 18, 2022
1 parent 5841063 commit 91322ff
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 22 deletions.
81 changes: 76 additions & 5 deletions MAIN.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=9 format=3 uid="uid://brwi2intnbh1k"]
[gd_scene load_steps=12 format=3 uid="uid://brwi2intnbh1k"]

[ext_resource type="Script" path="res://blocks.gd" id="2_7cxfx"]
[ext_resource type="AudioStream" uid="uid://dlrtkx3aurod6" path="res://Sounds/Verbalase Low Tetris Beatbox (FULL VIDEO) - Bruh Momento-jElSLP9-iJM.mp3" id="3_oc5c2"]
Expand All @@ -12,7 +12,11 @@ flip_faces = true
size = Vector3(2.3, 80, 40.2)

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_uxlqc"]
albedo_color = Color(0.376471, 0.376471, 0.376471, 1)
albedo_color = Color(0, 0, 0, 1)

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_mg13p"]
rough = true
absorbent = true

[sub_resource type="ConcavePolygonShape3D" id="ConcavePolygonShape3D_fuwlr"]
custom_solver_bias = 1.0
Expand All @@ -21,11 +25,73 @@ data = PackedVector3Array(1.15, 40, 20.1, -1.15, 40, 20.1, -1.15, -40, 20.1, 1.1
backface_collision = true

[sub_resource type="Environment" id="Environment_mv7jf"]
background_mode = 2
background_mode = 1
ambient_light_source = 2
ambient_light_color = Color(0.611765, 0.611765, 0.611765, 1)
ambient_light_color = Color(0.486275, 0.486275, 0.486275, 1)
tonemap_mode = 2
glow_enabled = true
fog_enabled = true
fog_light_color = Color(0, 0.286275, 1, 1)
fog_density = 0.0
fog_height = 9.35
fog_height_density = 0.0211

[sub_resource type="Animation" id="Animation_7uxp4"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("WorldEnvironment:environment:fog_height_density")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0211]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Camera3D:fov")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [100.0]
}

[sub_resource type="Animation" id="Animation_frllc"]
resource_name = "t"
length = 0.375
loop_mode = 1
step = 0.005
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("WorldEnvironment:environment:fog_height_density")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.37),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [0.0211, 0.001]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Camera3D:fov")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.375),
"transitions": PackedFloat32Array(1, 1),
"update": 0,
"values": [100.0, 99.5]
}

[node name="MAIN" type="Node3D"]

Expand All @@ -41,7 +107,7 @@ script = ExtResource( "6_gro3x" )
shape = SubResource( "BoxShape3D_dseq0" )

[node name="blocks" type="Node3D" parent="Node3D"]
transform = Transform3D(-1, 0, -4.37114e-08, 0, 1, 0, 4.37114e-08, 0, -1, 0, 72.7373, 6.55671e-07)
transform = Transform3D(-1, 0, -4.37114e-08, 0, 1, 0, 4.37114e-08, 0, -1, 0, 64.7373, 6.55671e-07)
script = ExtResource( "2_7cxfx" )

[node name="box" type="MeshInstance3D" parent="."]
Expand All @@ -52,6 +118,7 @@ surface_material_override/0 = SubResource( "StandardMaterial3D_uxlqc" )
[node name="StaticBody3D" type="StaticBody3D" parent="box"]
collision_layer = 2
collision_mask = 0
physics_material_override = SubResource( "PhysicsMaterial_mg13p" )

[node name="@@33914" type="CollisionShape3D" parent="box/StaticBody3D"]
shape = SubResource( "ConcavePolygonShape3D_fuwlr" )
Expand All @@ -76,8 +143,12 @@ far = 4000.46

[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( "3_oc5c2" )
volume_db = -10.0
autoplay = true

[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "t"
anims/RESET = SubResource( "Animation_7uxp4" )
anims/t = SubResource( "Animation_frllc" )

[connection signal="timeout" from="Timer" to="Node3D/trigger_manager" method="_on_timer_timeout"]
8 changes: 6 additions & 2 deletions Pieces/L.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://liglphqd6meu"]
[gd_scene load_steps=8 format=3 uid="uid://liglphqd6meu"]

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_l4ig4"]
friction = 0.05
Expand Down Expand Up @@ -40,6 +40,9 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource( "ArrayMesh_mbmd4" )

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rra86"]
resource_local_to_scene = true

[node name="L" type="RigidDynamicBody3D"]
collision_mask = 3
mass = 0.23
Expand All @@ -53,7 +56,8 @@ shape = SubResource( "BoxShape3D_1xygi" )
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 9.53674e-07)
shape = SubResource( "BoxShape3D_te7x2" )

[node name="L" type="MeshInstance3D" parent="."]
[node name="mesh" type="MeshInstance3D" parent="."]
gi_mode = 1
mesh = SubResource( "ArrayMesh_x81tx" )
skeleton = NodePath("")
surface_material_override/0 = SubResource( "StandardMaterial3D_rra86" )
8 changes: 6 additions & 2 deletions Pieces/S.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://cm2lv27qnk6yw"]
[gd_scene load_steps=7 format=3 uid="uid://cm2lv27qnk6yw"]

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_l4ig4"]
bounce = 0.1
Expand Down Expand Up @@ -37,6 +37,9 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource( "ArrayMesh_4by8t" )

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rra86"]
resource_local_to_scene = true

[node name="S" type="RigidDynamicBody3D"]
collision_mask = 3
mass = 0.5
Expand All @@ -50,7 +53,8 @@ shape = SubResource( "BoxShape3D_jrqy2" )
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 3, 2)
shape = SubResource( "BoxShape3D_jrqy2" )

[node name="S" type="MeshInstance3D" parent="."]
[node name="mesh" type="MeshInstance3D" parent="."]
gi_mode = 1
mesh = SubResource( "ArrayMesh_7i1cf" )
skeleton = NodePath("")
surface_material_override/0 = SubResource( "StandardMaterial3D_rra86" )
8 changes: 6 additions & 2 deletions Pieces/line.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://cveqmvb6a070w"]
[gd_scene load_steps=7 format=3 uid="uid://cveqmvb6a070w"]

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_l4ig4"]
friction = 0.05
Expand Down Expand Up @@ -43,6 +43,9 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource( "ArrayMesh_mphh4" )

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rra86"]
resource_local_to_scene = true

[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_tr5jw"]
points = PackedVector3Array(-1, -1, -6.82449, 1, 1, 0.704189, 1, -0.968254, 0.704189, -1, -1, 0.823691, -0.968254, 1, 0.704189, 1, 1, -6.70498, 1, -0.968254, -6.70498, -0.968254, 1, -6.70498)

Expand All @@ -51,10 +54,11 @@ collision_mask = 3
mass = 0.5
physics_material_override = SubResource( "PhysicsMaterial_l4ig4" )

[node name="Line" type="MeshInstance3D" parent="."]
[node name="mesh" type="MeshInstance3D" parent="."]
gi_mode = 1
mesh = SubResource( "ArrayMesh_86afs" )
skeleton = NodePath("")
surface_material_override/0 = SubResource( "StandardMaterial3D_rra86" )

[node name="34002" type="CollisionShape3D" parent="."]
shape = SubResource( "ConvexPolygonShape3D_tr5jw" )
8 changes: 6 additions & 2 deletions Pieces/square.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://ccyv3i28628p4"]
[gd_scene load_steps=7 format=3 uid="uid://ccyv3i28628p4"]

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_l4ig4"]
bounce = 0.1
Expand Down Expand Up @@ -37,6 +37,9 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource( "ArrayMesh_yluwy" )

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rra86"]
resource_local_to_scene = true

[node name="square" type="RigidDynamicBody3D"]
collision_mask = 3
mass = 0.5
Expand All @@ -46,7 +49,8 @@ physics_material_override = SubResource( "PhysicsMaterial_l4ig4" )
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, -1)
shape = SubResource( "BoxShape3D_sjfxn" )

[node name="Square" type="MeshInstance3D" parent="."]
[node name="mesh" type="MeshInstance3D" parent="."]
gi_mode = 1
mesh = SubResource( "ArrayMesh_4cugn" )
skeleton = NodePath("")
surface_material_override/0 = SubResource( "StandardMaterial3D_rra86" )
8 changes: 6 additions & 2 deletions Pieces/wither.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=7 format=3 uid="uid://dlwyxlqflynxs"]
[gd_scene load_steps=8 format=3 uid="uid://dlwyxlqflynxs"]

[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_l4ig4"]
bounce = 0.1
Expand Down Expand Up @@ -40,6 +40,9 @@ _surfaces = [{
blend_shape_mode = 0
shadow_mesh = SubResource( "ArrayMesh_2jlac" )

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_rra86"]
resource_local_to_scene = true

[node name="wither" type="RigidDynamicBody3D"]
collision_mask = 3
mass = 0.5
Expand All @@ -53,7 +56,8 @@ shape = SubResource( "BoxShape3D_n6c43" )
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2, -2)
shape = SubResource( "BoxShape3D_hnxr3" )

[node name="Wither" type="MeshInstance3D" parent="."]
[node name="mesh" type="MeshInstance3D" parent="."]
gi_mode = 1
mesh = SubResource( "ArrayMesh_rktay" )
skeleton = NodePath("")
surface_material_override/0 = SubResource( "StandardMaterial3D_rra86" )
34 changes: 27 additions & 7 deletions blocks.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,61 @@ var block_array = [
preload("res://Pieces/square.tscn"),
preload("res://Pieces/wither.tscn")
]

var color_array = [
Color(1,1,0),
Color(0,1,0),
Color(0,0,1)
]
var current = 0
var next = 0
var current_piece: RigidDynamicBody3D
var move_speed = 30
var rotation_speed = 10
var y_speed = 14

func _ready():
_next()

#moving to next piece
func _next():
current = next
#randomizing piece
randomize()
next = randi() % 5
instance_piece()

func instance_piece():
current_piece = block_array[current].instantiate()
#piece properties
current_piece.position = position
current_piece.mass = 0.2
current_piece.contact_monitor = true
current_piece.set_max_contacts_reported(1)
#setting color
var rand_color = color_array[randi() % 3]
current_piece.get_node("mesh").get_surface_override_material(0).albedo_color = rand_color
#await because for some reason godot don't wanna add it to scene tree unless you wait a frame
await get_tree().process_frame
get_parent().add_child(current_piece)

#piece update
func _physics_process(delta):
#checking for when to release the piece
if Input.is_action_just_pressed("release") or current_piece.get_colliding_bodies().size() > 0:
return await release_piece()

#left right movement axis
var linear_axis = Input.get_action_strength("left") - Input.get_action_strength("right")
var rotation_axis = Input.get_action_strength("rotate_right") - Input.get_action_strength("rotate_left")
current_piece.linear_velocity.y = -7
#up down movement axis
var rotation_axis = Input.get_action_strength("rotate_left") - Input.get_action_strength("rotate_right")
#moving the piece
current_piece.linear_velocity.y = -y_speed
current_piece.linear_velocity.z = linear_axis * move_speed
current_piece.angular_velocity.x = rotation_axis * -10

current_piece.angular_velocity.x = rotation_axis * rotation_speed

#releasing the piece
func release_piece():
set_physics_process(false)
current_piece = null
#waiting to reinstance another piece
await get_tree().create_timer(0.7,false).timeout
_next()
set_physics_process(true)

0 comments on commit 91322ff

Please sign in to comment.