Skip to content

Commit 177884f

Browse files
authored
Merge pull request #401 from aaronfranke/2d
Update the rest of the 2D demos for Godot 3.1.2
2 parents 704ebee + 87f42b7 commit 177884f

File tree

122 files changed

+902
-1032
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+902
-1032
lines changed

2d/gd_paint/PaintControl.gd

Lines changed: 94 additions & 104 deletions
Large diffs are not rendered by default.

2d/gd_paint/PaintTools.png.import

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[remap]
2+
3+
importer="texture"
4+
type="StreamTexture"
5+
path="res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex"
6+
metadata={
7+
"vram_texture": false
8+
}
9+
10+
[deps]
11+
12+
source_file="res://PaintTools.png"
13+
dest_files=[ "res://.import/PaintTools.png-636e86a6d210b52282c946752bbcc6f1.stex" ]
14+
15+
[params]
16+
17+
compress/mode=0
18+
compress/lossy_quality=0.7
19+
compress/hdr_mode=0
20+
compress/bptc_ldr=0
21+
compress/normal_map=0
22+
flags/repeat=0
23+
flags/filter=true
24+
flags/mipmaps=false
25+
flags/anisotropic=false
26+
flags/srgb=2
27+
process/fix_alpha_border=true
28+
process/premult_alpha=false
29+
process/HDR_as_SRGB=false
30+
process/invert_color=false
31+
stream=false
32+
size_limit=0
33+
detect_3d=true
34+
svg/scale=1.0

2d/gd_paint/Paint_root.tscn

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ margin_left = 20.0
3737
margin_top = 10.0
3838
margin_right = 330.0
3939
margin_bottom = 24.0
40-
text = "Selected tool: pencil"
40+
text = "Selected tool: Pencil"
4141
align = 1
4242

4343
[node name="ButtonToolPencil" type="Button" parent="ToolsPanel"]
@@ -105,52 +105,59 @@ margin_left = 20.0
105105
margin_top = 140.0
106106
margin_right = 330.0
107107
margin_bottom = 190.0
108-
color = Color( 1, 1, 1, 1 )
109108

110-
[node name="LabelBrushSize" type="Label" parent="ToolsPanel"]
109+
[node name="BrushSettings" type="Control" parent="ToolsPanel"]
110+
margin_top = 200.0
111+
margin_right = 350.0
112+
margin_bottom = 375.0
113+
114+
[node name="LabelBrushSize" type="Label" parent="ToolsPanel/BrushSettings"]
111115
margin_left = 20.0
112-
margin_top = 210.0
116+
margin_top = 10.0
113117
margin_right = 330.0
114-
margin_bottom = 224.0
118+
margin_bottom = 24.0
115119
text = "Brush size: 32px"
116120
align = 1
117121

118-
[node name="HScrollBarBrushSize" type="HScrollBar" parent="ToolsPanel"]
122+
[node name="HScrollBarBrushSize" type="HScrollBar" parent="ToolsPanel/BrushSettings"]
119123
margin_left = 20.0
120-
margin_top = 230.0
124+
margin_top = 30.0
121125
margin_right = 330.0
122-
margin_bottom = 260.0
123-
min_value = 1.0
126+
margin_bottom = 60.0
127+
min_value = 2.0
128+
step = 1.0
124129
value = 32.0
125130

126-
[node name="LabelBrushShape" type="Label" parent="ToolsPanel"]
131+
[node name="LabelBrushShape" type="Label" parent="ToolsPanel/BrushSettings"]
127132
margin_left = 20.0
128-
margin_top = 280.0
133+
margin_top = 80.0
129134
margin_right = 330.0
130-
margin_bottom = 294.0
131-
text = "Brush shape: circle"
135+
margin_bottom = 94.0
136+
text = "Brush shape: Circle"
132137
align = 1
133138

134-
[node name="ButtonShapeBox" type="Button" parent="ToolsPanel"]
139+
[node name="ButtonShapeBox" type="Button" parent="ToolsPanel/BrushSettings"]
140+
editor/display_folded = true
135141
margin_left = 100.0
136-
margin_top = 300.0
142+
margin_top = 100.0
137143
margin_right = 160.0
138-
margin_bottom = 360.0
144+
margin_bottom = 160.0
139145

140-
[node name="Sprite" type="Sprite" parent="ToolsPanel/ButtonShapeBox"]
146+
[node name="Sprite" type="Sprite" parent="ToolsPanel/BrushSettings/ButtonShapeBox"]
141147
position = Vector2( 30, 30 )
142148
scale = Vector2( 2.5, 2.5 )
143149
texture = ExtResource( 3 )
144150
region_enabled = true
145151
region_rect = Rect2( 0, 16, 16, 16 )
146152

147-
[node name="ButtonShapeCircle" type="Button" parent="ToolsPanel"]
153+
[node name="ButtonShapeCircle" type="Button" parent="ToolsPanel/BrushSettings"]
154+
editor/display_folded = true
148155
margin_left = 190.0
149-
margin_top = 300.0
156+
margin_top = 100.0
150157
margin_right = 250.0
151-
margin_bottom = 360.0
158+
margin_bottom = 160.0
152159

153-
[node name="Sprite" type="Sprite" parent="ToolsPanel/ButtonShapeCircle"]
160+
[node name="Sprite" type="Sprite" parent="ToolsPanel/BrushSettings/ButtonShapeCircle"]
154161
position = Vector2( 30, 30 )
155162
scale = Vector2( 2.5, 2.5 )
156163
texture = ExtResource( 3 )
@@ -209,5 +216,5 @@ margin_bottom = 400.0
209216
resizable = true
210217
access = 2
211218
filters = PoolStringArray( "*.png" )
212-
current_dir = "/home/ubuntu_noah/Documents/New_2019_GitHub_Repositories/godot-demo-projects/2d/gd_paint"
213-
current_path = "/home/ubuntu_noah/Documents/New_2019_GitHub_Repositories/godot-demo-projects/2d/gd_paint/"
219+
current_dir = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint"
220+
current_path = "/home/aaronfranke/workspace/godot-demo-projects/2d/gd_paint/"

2d/gd_paint/ToolsPanel.gd

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,80 @@
11
extends Panel
22

3-
43
var paint_control
54

6-
var label_tools
7-
var label_brush_size
8-
var label_brush_shape
9-
var label_stats
5+
onready var brush_settings = $BrushSettings
6+
onready var label_tools = $LabelTools
7+
onready var label_brush_size = $BrushSettings/LabelBrushSize
8+
onready var label_brush_shape = $BrushSettings/LabelBrushShape
9+
onready var label_stats = $LabelStats
1010

1111
var save_dialog
1212

13-
1413
func _ready():
15-
# Get PaintControl and SaveFileDialog
14+
# Get PaintControl and SaveFileDialog.
1615
paint_control = get_parent().get_node("PaintControl")
1716
save_dialog = get_parent().get_node("SaveFileDialog")
1817

1918
# warning-ignore-all:return_value_discarded
20-
# Assign all of the needed signals for the oppersation buttons
21-
get_node("ButtonUndo").connect("pressed", self, "button_pressed", ["undo_stroke"])
22-
get_node("ButtonSave").connect("pressed", self, "button_pressed", ["save_picture"])
23-
get_node("ButtonClear").connect("pressed", self, "button_pressed", ["clear_picture"])
24-
25-
# Assign all of the needed signals for the brush buttons
26-
get_node("ButtonToolPencil").connect("pressed", self, "button_pressed", ["mode_pencil"])
27-
get_node("ButtonToolEraser").connect("pressed", self, "button_pressed", ["mode_eraser"])
28-
get_node("ButtonToolRectangle").connect("pressed", self, "button_pressed", ["mode_rectangle"])
29-
get_node("ButtonToolCircle").connect("pressed", self, "button_pressed", ["mode_circle"])
30-
get_node("ButtonShapeBox").connect("pressed", self, "button_pressed", ["shape_rectangle"])
31-
get_node("ButtonShapeCircle").connect("pressed", self, "button_pressed", ["shape_circle"])
32-
33-
# Assign all of the needed signals for the other brush settings (and ColorPickerBackground)
34-
get_node("ColorPickerBrush").connect("color_changed", self, "brush_color_changed")
35-
get_node("ColorPickerBackground").connect("color_changed", self, "background_color_changed")
36-
get_node("HScrollBarBrushSize").connect("value_changed", self, "brush_size_changed")
37-
38-
# Assign the 'file_selected' signal in SaveFileDialog
19+
# Assign all of the needed signals for the oppersation buttons.
20+
$ButtonUndo.connect("pressed", self, "button_pressed", ["undo_stroke"])
21+
$ButtonSave.connect("pressed", self, "button_pressed", ["save_picture"])
22+
$ButtonClear.connect("pressed", self, "button_pressed", ["clear_picture"])
23+
24+
# Assign all of the needed signals for the brush buttons.
25+
$ButtonToolPencil.connect("pressed", self, "button_pressed", ["mode_pencil"])
26+
$ButtonToolEraser.connect("pressed", self, "button_pressed", ["mode_eraser"])
27+
$ButtonToolRectangle.connect("pressed", self, "button_pressed", ["mode_rectangle"])
28+
$ButtonToolCircle.connect("pressed", self, "button_pressed", ["mode_circle"])
29+
$BrushSettings/ButtonShapeBox.connect("pressed", self, "button_pressed", ["shape_rectangle"])
30+
$BrushSettings/ButtonShapeCircle.connect("pressed", self, "button_pressed", ["shape_circle"])
31+
32+
# Assign all of the needed signals for the other brush settings (and ColorPickerBackground).
33+
$ColorPickerBrush.connect("color_changed", self, "brush_color_changed")
34+
$ColorPickerBackground.connect("color_changed", self, "background_color_changed")
35+
$BrushSettings/HScrollBarBrushSize.connect("value_changed", self, "brush_size_changed")
36+
37+
# Assign the 'file_selected' signal in SaveFileDialog.
3938
save_dialog.connect("file_selected", self, "save_file_selected")
4039

41-
# Get all of the labels so we can update them when settings change
42-
label_tools = get_node("LabelTools")
43-
label_brush_size = get_node("LabelBrushSize")
44-
label_brush_shape = get_node("LabelBrushShape")
45-
label_stats = get_node("LabelStats")
46-
47-
# Set physics process so we can update the status label
40+
# Set physics process so we can update the status label.
4841
set_physics_process(true)
4942

5043

5144
func _physics_process(_delta):
52-
# Update the status label with the newest brush element count
45+
# Update the status label with the newest brush element count.
5346
label_stats.text = "Brush objects: " + String(paint_control.brush_data_list.size())
5447

5548

5649
func button_pressed(button_name):
57-
# If a brush mode button is pressed
50+
# If a brush mode button is pressed.
5851
var tool_name = null
5952
var shape_name = null
6053

6154
if button_name == "mode_pencil":
62-
paint_control.brush_mode = paint_control.BRUSH_MODES.pencil
63-
tool_name = "pencil"
55+
paint_control.brush_mode = paint_control.BrushModes.PENCIL
56+
brush_settings.modulate = Color(1, 1, 1, 1)
57+
tool_name = "Pencil"
6458
elif button_name == "mode_eraser":
65-
paint_control.brush_mode = paint_control.BRUSH_MODES.eraser
66-
tool_name = "eraser"
59+
paint_control.brush_mode = paint_control.BrushModes.ERASER
60+
brush_settings.modulate = Color(1, 1, 1, 1)
61+
tool_name = "Eraser"
6762
elif button_name == "mode_rectangle":
68-
paint_control.brush_mode = paint_control.BRUSH_MODES.rectangle_shape
69-
tool_name = "rectangle shape"
63+
paint_control.brush_mode = paint_control.BrushModes.RECTANGLE_SHAPE
64+
brush_settings.modulate = Color(1, 1, 1, 0.5)
65+
tool_name = "Rectangle shape"
7066
elif button_name == "mode_circle":
71-
paint_control.brush_mode = paint_control.BRUSH_MODES.circle_shape
72-
tool_name = "circle shape"
67+
paint_control.brush_mode = paint_control.BrushModes.CIRCLE_SHAPE
68+
brush_settings.modulate = Color(1, 1, 1, 0.5)
69+
tool_name = "Circle shape"
7370

7471
# If a brush shape button is pressed
7572
elif button_name == "shape_rectangle":
76-
paint_control.brush_shape = paint_control.BRUSH_SHAPES.rectangle
77-
shape_name = "rectangle"
73+
paint_control.brush_shape = paint_control.BrushShapes.RECTANGLE
74+
shape_name = "Rectangle"
7875
elif button_name == "shape_circle":
79-
paint_control.brush_shape = paint_control.BRUSH_SHAPES.circle
80-
shape_name = "circle";
76+
paint_control.brush_shape = paint_control.BrushShapes.CIRCLE
77+
shape_name = "Circle";
8178

8279
# If a opperation button is pressed
8380
elif button_name == "clear_picture":
@@ -88,33 +85,32 @@ func button_pressed(button_name):
8885
elif button_name == "undo_stroke":
8986
paint_control.undo_stroke()
9087

91-
# Update the labels (in case the brush mode or brush shape has changed)
88+
# Update the labels (in case the brush mode or brush shape has changed).
9289
if tool_name != null:
9390
label_tools.text = "Selected tool: " + tool_name
9491
if shape_name != null:
9592
label_brush_shape.text = "Brush shape: " + shape_name
9693

9794

9895
func brush_color_changed(color):
99-
# Change the brush color to whatever color the color picker is
96+
# Change the brush color to whatever color the color picker is.
10097
paint_control.brush_color = color
10198

10299

103100
func background_color_changed(color):
104-
# Change the background color to whatever colorthe background color picker is
101+
# Change the background color to whatever colorthe background color picker is.
105102
get_parent().get_node("DrawingAreaBG").modulate = color
106103
paint_control.bg_color = color
107-
# Because of how the eraser works we also need to redraw the paint control
104+
# Because of how the eraser works we also need to redraw the paint control.
108105
paint_control.update()
109106

110107

111108
func brush_size_changed(value):
112-
# Change the size of the brush, and update the label to reflect the new value
109+
# Change the size of the brush, and update the label to reflect the new value.
113110
paint_control.brush_size = ceil(value)
114111
label_brush_size.text = "Brush size: " + String(ceil(value)) + "px"
115112

116113

117114
func save_file_selected(path):
118-
# Call save_picture in paint_control, passing in the path we recieved from SaveFileDialog
115+
# Call save_picture in paint_control, passing in the path we recieved from SaveFileDialog.
119116
paint_control.save_picture(path)
120-
File renamed without changes.

2d/grid_based_movement/grid/grid.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
extends TileMap
22

3-
enum CellType { EMPTY = -1, ACTOR, OBSTACLE, OBJECT}
3+
enum CellType { EMPTY = -1, ACTOR, OBSTACLE, OBJECT }
44

55
func _ready():
66
for child in get_children():

2d/grid_based_movement/pawns/Actor.tscn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,3 @@ position = Vector2( 1.43051e-06, -1.90735e-06 )
8282
texture = ExtResource( 2 )
8383
centered = false
8484
offset = Vector2( -32, -32 )
85-

2d/grid_based_movement/pawns/actor.gd

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
extends "pawn.gd"
22

3-
onready var Grid = get_parent()
3+
onready var grid = get_parent()
44

55
func _ready():
6-
update_look_direction(Vector2(1, 0))
6+
update_look_direction(Vector2.RIGHT)
77

88

99
func _process(_delta):
@@ -12,7 +12,7 @@ func _process(_delta):
1212
return
1313
update_look_direction(input_direction)
1414

15-
var target_position = Grid.request_move(self, input_direction)
15+
var target_position = grid.request_move(self, input_direction)
1616
if target_position:
1717
move_to(target_position)
1818
else:
@@ -21,8 +21,8 @@ func _process(_delta):
2121

2222
func get_input_direction():
2323
return Vector2(
24-
int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left")),
25-
int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up"))
24+
Input.get_action_strength("move_right") - Input.get_action_strength("move_left"),
25+
Input.get_action_strength("move_down") - Input.get_action_strength("move_up")
2626
)
2727

2828

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
extends Node2D
22

33
enum CellType { ACTOR, OBSTACLE, OBJECT }
4+
#warning-ignore:unused_class_variable
45
export(CellType) var type = CellType.ACTOR

2d/grid_based_movement/project.godot

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,41 @@ window/size/height=720
2626
window/stretch/mode="2d"
2727
window/stretch/aspect="expand"
2828

29+
[input]
30+
31+
move_right={
32+
"deadzone": 0.5,
33+
"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":68,"unicode":0,"echo":false,"script":null)
34+
, 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,"unicode":0,"echo":false,"script":null)
35+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":15,"pressure":0.0,"pressed":false,"script":null)
36+
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
37+
]
38+
}
39+
move_left={
40+
"deadzone": 0.5,
41+
"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":65,"unicode":0,"echo":false,"script":null)
42+
, 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,"unicode":0,"echo":false,"script":null)
43+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null)
44+
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
45+
]
46+
}
47+
move_down={
48+
"deadzone": 0.5,
49+
"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":83,"unicode":0,"echo":false,"script":null)
50+
, 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,"unicode":0,"echo":false,"script":null)
51+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null)
52+
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
53+
]
54+
}
55+
move_up={
56+
"deadzone": 0.5,
57+
"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":87,"unicode":0,"echo":false,"script":null)
58+
, 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,"unicode":0,"echo":false,"script":null)
59+
, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null)
60+
, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
61+
]
62+
}
63+
2964
[rendering]
3065

3166
environment/default_environment="res://default_env.tres"

0 commit comments

Comments
 (0)