commit b1a4e83b9192bd04fc232ac16dd3f32418d1c164 Author: karl Date: Wed Nov 17 16:30:13 2021 +0100 Add basic setup with moving shape diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f48ad7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +# Godot-specific ignores +.import/ +export.cfg +export_presets.cfg + +# Imported translations (automatically generated from CSV files) +*.translation + +# Mono-specific ignores +.mono/ +data_*/ diff --git a/Block.tscn b/Block.tscn new file mode 100644 index 0000000..31ba5b1 --- /dev/null +++ b/Block.tscn @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://brick.png" type="Texture" id=1] + +[node name="Block" type="Node2D"] + +[node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 0.125, 0.125 ) +texture = ExtResource( 1 ) diff --git a/GameBoard.gd b/GameBoard.gd new file mode 100644 index 0000000..20593db --- /dev/null +++ b/GameBoard.gd @@ -0,0 +1,39 @@ +extends Node2D + + +onready var active_shape: Node2D = $ShapeSquare + +const RASTER_SIZE = 64 + + +func _ready(): + $GravityTimer.connect("timeout", self, "update_board") + + +func update_board(): + if active_shape.position.y == RASTER_SIZE * 9: + # TODO: Turn into static blocks + return + + active_shape.position.y += RASTER_SIZE + + +func move_left(): + # TODO: Check for collision + active_shape.position.x -= RASTER_SIZE + + +func move_right(): + # TODO: Check for collision + active_shape.position.x += RASTER_SIZE + + +func _input(event): + if event.is_action_pressed("move_left"): + move_left() + elif event.is_action_pressed("move_right"): + move_right() + elif event.is_action_pressed("rotate"): + pass + elif event.is_action_pressed("drop"): + pass diff --git a/GameBoard.tscn b/GameBoard.tscn new file mode 100644 index 0000000..8f2ae00 --- /dev/null +++ b/GameBoard.tscn @@ -0,0 +1,19 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://background.png" type="Texture" id=1] +[ext_resource path="res://GameBoard.gd" type="Script" id=2] +[ext_resource path="res://ShapeSquare.tscn" type="PackedScene" id=3] + +[node name="GameBoard" type="Node2D"] +script = ExtResource( 2 ) + +[node name="Sprite" type="Sprite" parent="."] +scale = Vector2( 1.25, 1.25 ) +texture = ExtResource( 1 ) + +[node name="GravityTimer" type="Timer" parent="."] +process_mode = 0 +wait_time = 0.5 +autostart = true + +[node name="ShapeSquare" parent="." instance=ExtResource( 3 )] diff --git a/Main.tscn b/Main.tscn new file mode 100644 index 0000000..640b627 --- /dev/null +++ b/Main.tscn @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://GameBoard.tscn" type="PackedScene" id=1] + +[node name="Main" type="Node2D"] + +[node name="GameBoard" parent="." instance=ExtResource( 1 )] +position = Vector2( 547, 813 ) diff --git a/ShapeSquare.tscn b/ShapeSquare.tscn new file mode 100644 index 0000000..35ebad9 --- /dev/null +++ b/ShapeSquare.tscn @@ -0,0 +1,17 @@ +[gd_scene load_steps=2 format=2] + +[ext_resource path="res://Block.tscn" type="PackedScene" id=1] + +[node name="ShapeSquare" type="Node2D"] + +[node name="Block" parent="." instance=ExtResource( 1 )] +position = Vector2( 32, 32 ) + +[node name="Block2" parent="." instance=ExtResource( 1 )] +position = Vector2( 32, -32 ) + +[node name="Block3" parent="." instance=ExtResource( 1 )] +position = Vector2( -32, -32 ) + +[node name="Block4" parent="." instance=ExtResource( 1 )] +position = Vector2( -32, 32 ) diff --git a/background.png b/background.png new file mode 100644 index 0000000..256b38f Binary files /dev/null and b/background.png differ diff --git a/background.png.import b/background.png.import new file mode 100644 index 0000000..1e8ce85 --- /dev/null +++ b/background.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/background.png-98289422cd7d93003950872a7b97021f.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://background.png" +dest_files=[ "res://.import/background.png-98289422cd7d93003950872a7b97021f.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/brick.png b/brick.png new file mode 100644 index 0000000..c279ca6 Binary files /dev/null and b/brick.png differ diff --git a/brick.png.import b/brick.png.import new file mode 100644 index 0000000..f35588f --- /dev/null +++ b/brick.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://brick.png" +dest_files=[ "res://.import/brick.png-3b7e2d2d29430a475fb75656e3e81471.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/default_env.tres b/default_env.tres new file mode 100644 index 0000000..20207a4 --- /dev/null +++ b/default_env.tres @@ -0,0 +1,7 @@ +[gd_resource type="Environment" load_steps=2 format=2] + +[sub_resource type="ProceduralSky" id=1] + +[resource] +background_mode = 2 +background_sky = SubResource( 1 ) diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..c98fbb6 Binary files /dev/null and b/icon.png differ diff --git a/icon.png.import b/icon.png.import new file mode 100644 index 0000000..a4c02e6 --- /dev/null +++ b/icon.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://icon.png" +dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=true +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..c5b9213 --- /dev/null +++ b/project.godot @@ -0,0 +1,54 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=4 + +[application] + +config/name="Tetris" +run/main_scene="res://Main.tscn" +config/icon="res://icon.png" + +[display] + +window/size/width=1080 +window/size/height=1920 +window/size/test_width=576 +window/size/test_height=1024 +window/stretch/mode="2d" + +[input] + +move_left={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777231,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +move_right={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777233,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +rotate={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777232,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} +drop={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777234,"physical_scancode":0,"unicode":0,"echo":false,"script":null) + ] +} + +[physics] + +common/enable_pause_aware_picking=true + +[rendering] + +environment/default_environment="res://default_env.tres"