/
main.dart
177 lines (127 loc) · 5.67 KB
/
main.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
library example;
import "package:play_phaser/phaser.dart";
import "dart:html" as dom;
//@MirrorsUsed(targets: const [GameObject, Gem, Sprite, Text, Particle], override: '*')
//import "dart:mirrors";
//@MirrorsUsed(symbols: const ["x","y"], override: '*')
//import "dart:mirrors";
//import "package:play_pixi/pixi.dart" as PIXI;
//@MirrorsUsed(targets:const ['PIXI', 'Phaser', 'example'], override: '*')
//@MirrorsUsed(symbols: "*", override: '*')
//import "dart:mirrors";
part "basics/basic_01_load_an_image.dart";
part "basics/basic_02_click_on_an_image.dart";
part "basics/basic_03_image_follow_input.dart";
part "basics/basic_04_load_animation.dart";
part "basics/basics_05_render_text.dart";
part "animation/animation_01_events.dart";
part "animation/animation_02_change_texture_on_click.dart";
part "animation/animation_03_group_creation.dart";
part "animation/animation_08_multiple_anims.dart";
part "audio/audio_01_audio_sprite.dart";
part "audio/audio_02_play_music.dart";
part "tweens/tweens_01_chained_tweens.dart";
part "loader/loader_01_asset_pack.dart";
part "input/input_01_bring_a_child_to_top.dart";
part "particles/particles_01_auto_scale.dart";
part "arcade_physics/arcade_physics_34_quadtree.dart";
part "camera/camera_01_basic_follow.dart";
part "camera/camera_02_camera_cull.dart";
part "camera/camera_03_camera_view.dart";
part "tilemaps/tilemaps_01_blank_map.dart";
part "tilemaps/tilemaps_16_tilemap_ray_cast.dart";
part "display/display_01_alpha_mask.dart";
part "display/display_02_bitmapdata_atlas.dart";
part "display/display_14_bitmapdata_wobble.dart";
part "display/display_19_graphics.dart";
part "display/display_20_bitmapdata_set_hsl.dart";
part "games/games_01_breakout.dart";
part "games/games_02_gemmatch.dart";
part "games/games_03_invaders.dart";
part "games/games_04_matching_pairs.dart";
part "games/games_05_simon.dart";
part "games/games_06_starstruck.dart";
part "games/games_07_tanks.dart";
//Map<String, Map<String, State>> Examples = {
// "Basic":{
// "basic_01_load_an_image": new basic_01_load_an_image(),
// "basic_02_click_on_an_image": new basic_02_click_on_an_image(),
// "basic_03_image_follow_input": new basic_03_image_follow_input(),
// "basic_04_load_animation": new basic_04_load_animation(),
// },
//
//
//};
Map<String, State> examples = {
"basic_01_load_an_image": new basic_01_load_an_image(),
"basic_02_click_on_an_image": new basic_02_click_on_an_image(),
"basic_03_image_follow_input": new basic_03_image_follow_input(),
"basic_04_load_animation": new basic_04_load_animation(),
"basic_05_render_text": new basics_05_render_text(),
"animation_01_events": new animation_01_events(),
"animation_02_change_texture_on_click": new animation_02_change_texture_on_click(),
"animation_03_group_creation": new animation_03_group_creation(),
"animation_08_multiple_anims": new animation_08_multiple_anims(),
"audio_01_audio_sprite": new audio_01_audio_sprite(),
"audio_02_play_music": new audio_02_play_music(),
"tweens_01_chained_tweens": new tweens_01_chained_tweens(),
"loader_01_asset_pack": new loader_01_asset_pack(),
"input_01_bring_a_child_to_top": new input_01_bring_a_child_to_top(),
"particles_01_auto_scale": new particles_01_auto_scale(),
"arcade_physics_34_quadtree": new arcade_physics_34_quadtree(),
"camera_01_basic_follow": new camera_01_basic_follow(),
"camera_02_camera_cull": new camera_02_camera_cull(),
"camera_03_camera_view": new camera_03_camera_view(),
"tilemaps_01_blank_map": new tilemaps_01_blank_map(),
"tilemaps_16_tilemap_ray_cast": new tilemaps_16_tilemap_ray_cast(),
"display_01_alpha_mask":new display_01_alpha_mask(),
"display_02_bitmapdata_atlas":new display_02_bitmapdata_atlas(),
"display_14_bitmapdata_wobble":new display_14_bitmapdata_wobble(),
"display_19_graphics":new display_19_graphics(),
"display_20_bitmapdata_set_hsl":new display_20_bitmapdata_set_hsl(),
"games_01_breakout":new games_01_breakout(),
"games_02_gemmatch":new games_02_gemmatch(),
"games_03_invaders":new games_03_invaders(),
"games_04_matching_pairs":new games_04_matching_pairs(),
"games_05_simon":new games_05_simon(),
"games_06_starstruck":new games_06_starstruck(),
"games_07_tanks":new games_07_tanks(),
};
main() {
// dom.window.console.log("preload");
print("start");
// var w = dom.window.innerWidth * dom.window.devicePixelRatio,
// h = dom.window.innerHeight * dom.window.devicePixelRatio,
// width = (h > w) ? h : w,
// height = (h > w) ? w : h;
//
// // Hack to avoid iPad Retina and large Android devices. Tell it to scale up.
// if (dom.window.innerWidth >= 1024 && dom.window.devicePixelRatio >= 2) {
// width = Math.round(width / 2);
// height = Math.round(height / 2);
// }
// // reduce screen size by one 3rd on devices like Nexus 5
// if (dom.window.devicePixelRatio == 3) {
// width = Math.round(width / 3) * 2;
// height = Math.round(height / 3) * 2;
// }
//var game = new Game(width, height, WEBGL, '');
Game game = new Game(800, 480, WEBGL, '');
dom.SelectElement select = dom.document.getElementById("examples") as dom.SelectElement;
for (String key in examples.keys) {
game.state.add(key, examples[key]);
dom.OptionElement option = new dom.OptionElement();
option.text = key;
select.children.add(option);
}
//
select.onChange.listen((dom.Event e) {
game.state.start(select.children[select.selectedIndex].text);
});
//print("start 1");
//game.state.add("games_02_gemmatch", new games_03_invaders());
game.state.start("basic_01_load_an_image");
//game.canvas.style.cursor = "pointer";
//game.boot();
//print("start");
}