Browse Source

Add basic setup with moving shape

main
karl 1 year ago
commit
b1a4e83b91
  1. 11
      .gitignore
  2. 9
      Block.tscn
  3. 39
      GameBoard.gd
  4. 19
      GameBoard.tscn
  5. 8
      Main.tscn
  6. 17
      ShapeSquare.tscn
  7. BIN
      background.png
  8. 35
      background.png.import
  9. BIN
      brick.png
  10. 35
      brick.png.import
  11. 7
      default_env.tres
  12. BIN
      icon.png
  13. 35
      icon.png.import
  14. 54
      project.godot

11
.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_*/

9
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 )

39
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

19
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 )]

8
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 )

17
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 )

BIN
background.png

After

Width: 512  |  Height: 1024  |  Size: 3.3 KiB

35
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

BIN
brick.png

After

Width: 512  |  Height: 512  |  Size: 6.2 KiB

35
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

7
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 )

BIN
icon.png

After

Width: 64  |  Height: 64  |  Size: 3.2 KiB

35
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

54
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"
Loading…
Cancel
Save