Skip to content

Commit 1dd3f1e

Browse files
committed
Update forge2d_game
1 parent 1dc81dc commit 1dd3f1e

File tree

19 files changed

+129
-30
lines changed

19 files changed

+129
-30
lines changed

forge2d_game/codelab_rebuild.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,21 @@ steps:
2121
prefer_const_constructors: false
2222
- name: Remove README
2323
rm: forge2d_game/README.md
24+
- name: Add .gemini directory
25+
mkdir: forge2d_game/.gemini
26+
- name: Add .gemini/settings.json
27+
path: forge2d_game/.gemini/settings.json
28+
replace-contents: |
29+
{
30+
"mcpServers": {
31+
"dart": {
32+
"command": "dart",
33+
"args": [
34+
"mcp-server"
35+
]
36+
}
37+
}
38+
}
2439
- name: Add .vscode directory
2540
mkdir: forge2d_game/.vscode
2641
- name: Add .vscode/launch.json

forge2d_game/step_02/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ migrate_working_dir/
2727
**/doc/api/
2828
**/ios/Flutter/.last_build_id
2929
.dart_tool/
30-
.flutter-plugins
3130
.flutter-plugins-dependencies
3231
.pub-cache/
3332
.pub/
3433
/build/
34+
/coverage/
3535

3636
# Symbolication related
3737
app.*.symbols

forge2d_game/step_02/linux/runner/my_application.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ struct _MyApplication {
1414

1515
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1616

17+
// Called when first Flutter frame received.
18+
static void first_frame_cb(MyApplication* self, FlView *view)
19+
{
20+
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
21+
}
22+
1723
// Implements GApplication::activate.
1824
static void my_application_activate(GApplication* application) {
1925
MyApplication* self = MY_APPLICATION(application);
@@ -48,15 +54,23 @@ static void my_application_activate(GApplication* application) {
4854
}
4955

5056
gtk_window_set_default_size(window, 1280, 720);
51-
gtk_widget_show(GTK_WIDGET(window));
5257

5358
g_autoptr(FlDartProject) project = fl_dart_project_new();
5459
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
5560

5661
FlView* view = fl_view_new(project);
62+
GdkRGBA background_color;
63+
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
64+
gdk_rgba_parse(&background_color, "#000000");
65+
fl_view_set_background_color(view, &background_color);
5766
gtk_widget_show(GTK_WIDGET(view));
5867
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
5968

69+
// Show the window when Flutter renders.
70+
// Requires the view to be realized so we can start rendering.
71+
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
72+
gtk_widget_realize(GTK_WIDGET(view));
73+
6074
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
6175

6276
gtk_widget_grab_focus(GTK_WIDGET(view));

forge2d_game/step_02/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212
characters: ^1.4.0
13-
flame: ^1.29.0
14-
flame_forge2d: ^0.19.0+2
15-
flame_kenney_xml: ^0.1.1+12
13+
flame: ^1.30.1
14+
flame_forge2d: ^0.19.0+4
15+
flame_kenney_xml: ^0.1.1+14
1616
xml: ^6.5.0
1717

1818
dev_dependencies:

forge2d_game/step_03/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ migrate_working_dir/
2727
**/doc/api/
2828
**/ios/Flutter/.last_build_id
2929
.dart_tool/
30-
.flutter-plugins
3130
.flutter-plugins-dependencies
3231
.pub-cache/
3332
.pub/
3433
/build/
34+
/coverage/
3535

3636
# Symbolication related
3737
app.*.symbols

forge2d_game/step_03/linux/runner/my_application.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ struct _MyApplication {
1414

1515
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1616

17+
// Called when first Flutter frame received.
18+
static void first_frame_cb(MyApplication* self, FlView *view)
19+
{
20+
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
21+
}
22+
1723
// Implements GApplication::activate.
1824
static void my_application_activate(GApplication* application) {
1925
MyApplication* self = MY_APPLICATION(application);
@@ -48,15 +54,23 @@ static void my_application_activate(GApplication* application) {
4854
}
4955

5056
gtk_window_set_default_size(window, 1280, 720);
51-
gtk_widget_show(GTK_WIDGET(window));
5257

5358
g_autoptr(FlDartProject) project = fl_dart_project_new();
5459
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
5560

5661
FlView* view = fl_view_new(project);
62+
GdkRGBA background_color;
63+
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
64+
gdk_rgba_parse(&background_color, "#000000");
65+
fl_view_set_background_color(view, &background_color);
5766
gtk_widget_show(GTK_WIDGET(view));
5867
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
5968

69+
// Show the window when Flutter renders.
70+
// Requires the view to be realized so we can start rendering.
71+
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
72+
gtk_widget_realize(GTK_WIDGET(view));
73+
6074
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
6175

6276
gtk_widget_grab_focus(GTK_WIDGET(view));

forge2d_game/step_03/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212
characters: ^1.4.0
13-
flame: ^1.29.0
14-
flame_forge2d: ^0.19.0+2
15-
flame_kenney_xml: ^0.1.1+12
13+
flame: ^1.30.1
14+
flame_forge2d: ^0.19.0+4
15+
flame_kenney_xml: ^0.1.1+14
1616
xml: ^6.5.0
1717

1818
dev_dependencies:

forge2d_game/step_04/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ migrate_working_dir/
2727
**/doc/api/
2828
**/ios/Flutter/.last_build_id
2929
.dart_tool/
30-
.flutter-plugins
3130
.flutter-plugins-dependencies
3231
.pub-cache/
3332
.pub/
3433
/build/
34+
/coverage/
3535

3636
# Symbolication related
3737
app.*.symbols

forge2d_game/step_04/linux/runner/my_application.cc

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ struct _MyApplication {
1414

1515
G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION)
1616

17+
// Called when first Flutter frame received.
18+
static void first_frame_cb(MyApplication* self, FlView *view)
19+
{
20+
gtk_widget_show(gtk_widget_get_toplevel(GTK_WIDGET(view)));
21+
}
22+
1723
// Implements GApplication::activate.
1824
static void my_application_activate(GApplication* application) {
1925
MyApplication* self = MY_APPLICATION(application);
@@ -48,15 +54,23 @@ static void my_application_activate(GApplication* application) {
4854
}
4955

5056
gtk_window_set_default_size(window, 1280, 720);
51-
gtk_widget_show(GTK_WIDGET(window));
5257

5358
g_autoptr(FlDartProject) project = fl_dart_project_new();
5459
fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments);
5560

5661
FlView* view = fl_view_new(project);
62+
GdkRGBA background_color;
63+
// Background defaults to black, override it here if necessary, e.g. #00000000 for transparent.
64+
gdk_rgba_parse(&background_color, "#000000");
65+
fl_view_set_background_color(view, &background_color);
5766
gtk_widget_show(GTK_WIDGET(view));
5867
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view));
5968

69+
// Show the window when Flutter renders.
70+
// Requires the view to be realized so we can start rendering.
71+
g_signal_connect_swapped(view, "first-frame", G_CALLBACK(first_frame_cb), self);
72+
gtk_widget_realize(GTK_WIDGET(view));
73+
6074
fl_register_plugins(FL_PLUGIN_REGISTRY(view));
6175

6276
gtk_widget_grab_focus(GTK_WIDGET(view));

forge2d_game/step_04/pubspec.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ dependencies:
1010
flutter:
1111
sdk: flutter
1212
characters: ^1.4.0
13-
flame: ^1.29.0
14-
flame_forge2d: ^0.19.0+2
15-
flame_kenney_xml: ^0.1.1+12
13+
flame: ^1.30.1
14+
flame_forge2d: ^0.19.0+4
15+
flame_kenney_xml: ^0.1.1+14
1616
xml: ^6.5.0
1717

1818
dev_dependencies:

0 commit comments

Comments
 (0)