Skip to content

Commit 39ffe4a

Browse files
author
Tyler Wozniak
committed
Updated to .9.0
1 parent 9bd74ef commit 39ffe4a

File tree

7 files changed

+50
-70
lines changed

7 files changed

+50
-70
lines changed

Config/Input.yml

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Left:
99
Space:
1010
Keyboard: Space
1111
Select:
12-
Keyboard: MouseLeft
12+
Mouse: Left
1313
Toggle1:
14-
Keyboard: M
14+
Keyboard: M
15+
Exit:
16+
Keyboard: Delete

Objects/environment.yml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
---
22
Name: Grid
3-
Behaviors:
4-
- Class: grid.Grid
5-
Fields:
6-
Rows: 8
7-
Cols: 8
3+
Grid:
4+
Rows: 8
5+
Cols: 8
86
Transform:
97
Position: !Vector3 -15.75 15.66 -50
108
Rotation: !Vector3 90 0 0
@@ -18,6 +16,7 @@ Transform:
1816
Rotation: !Vector3 0 0 0
1917
---
2018
Name: DirLight
21-
Light: !Light-Directional
19+
DirectionalLight:
2220
Color: !Vector3 1 1 1
23-
Direction: !Vector3 -.3 -.7 -1
21+
Direction: !Vector3 -1
22+
-1 -.7

Prefabs/highlight.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
---
22
Name: Highlight
33
Transform:
4-
54
Position: !Vector3 0 3 0
6-
Light: !Light-Point
5+
PointLight:
76
Color: !Vector3 1.0 1.0 1.0
87
Radius: 6
98
FalloffRate: .5

Prefabs/tiles.yml

+16-32
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,40 @@
11
---
22
Name: EmptyTile
3-
Behaviors:
4-
- Class: grid.Tile
5-
Fields:
6-
Color: Empty
3+
Tile:
4+
Color: Empty
75
Mesh: tileyer
86
---
97
Name: RedTile
10-
Behaviors:
11-
- Class: grid.Tile
12-
Fields:
13-
Color: Red
8+
Tile:
9+
Color: Red
1410
Mesh: tileyer
1511
---
1612
Name: OrangeTile
17-
Behaviors:
18-
- Class: grid.Tile
19-
Fields:
20-
Color: Orange
13+
Tile:
14+
Color: Orange
2115
Mesh: tileyer
2216
---
2317
Name: YellowTile
24-
Behaviors:
25-
- Class: grid.Tile
26-
Fields:
27-
Color: Yellow
18+
Tile:
19+
Color: Yellow
2820
Mesh: tileyer
2921
---
3022
Name: GreenTile
31-
Behaviors:
32-
- Class: grid.Tile
33-
Fields:
34-
Color: Green
23+
Tile:
24+
Color: Green
3525
Mesh: tileyer
3626
---
3727
Name: BlueTile
38-
Behaviors:
39-
- Class: grid.Tile
40-
Fields:
41-
Color: Blue
28+
Tile:
29+
Color: Blue
4230
Mesh: tileyer
4331
---
4432
Name: PurpleTile
45-
Behaviors:
46-
- Class: grid.Tile
47-
Fields:
48-
Color: Purple
33+
Tile:
34+
Color: Purple
4935
Mesh: tileyer
5036
---
5137
Name: BlackTile
52-
Behaviors:
53-
- Class: grid.Tile
54-
Fields:
55-
Color: Black
38+
Tile:
39+
Color: Black
5640
Mesh: tileyer

Scripts/game.d

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class Game : DGame
1111

1212
logInfo( "Initializing TestGame..." );
1313

14-
Input.addKeyDownEvent( Keyboard.Delete, ( uint kc ) { currentState = EngineState.Quit; } );
14+
Input.addButtonDownEvent( "Exit", ( uint kc ) { currentState = EngineState.Quit; } );
1515

1616
activeScene = new Scene;
1717
activeScene.loadObjects( "" );

Scripts/grid.d

+21-25
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import core, components, utility;
44
import gl3n.linalg, gl3n.math, gl3n.interpolate;
55
import std.conv, std.random, std.algorithm;
66

7+
mixin( registerComponents!q{grid} );
8+
79
public enum Color
810
{
911
Empty,
@@ -26,17 +28,10 @@ public enum GameStep
2628
public enum TILE_SIZE = 4.5f;
2729
public enum FALL_TIME = .2f;
2830

29-
class GridArgs
30-
{
31-
int Rows;
32-
int Cols;
33-
}
34-
35-
final class Grid : Behavior!GridArgs
31+
@yamlComponent("Grid")
32+
final class Grid : Component
3633
{
3734
private:
38-
39-
int rows, cols;
4035
Tile[] state;
4136
int selection;
4237
GameStep step;
@@ -46,11 +41,14 @@ private:
4641
PointLight highlight;
4742

4843
public:
44+
@field( "Rows" )
45+
int rows;
46+
@field( "Cols" )
47+
int cols;
4948

50-
override void onInitialize()
49+
override void initialize()
5150
{
52-
rows = initArgs.Rows;
53-
cols = initArgs.Cols;
51+
logDebug( rows, ",", cols );
5452
step = GameStep.Input;
5553

5654
state = new Tile[size];
@@ -61,7 +59,7 @@ public:
6159
owner.addChild(hl);
6260
highlight = cast(PointLight)(hl.light);
6361

64-
Input.addKeyDownEvent( Keyboard.MouseLeft, &mouseDown );
62+
Input.addButtonDownEvent( "Select", &mouseDown );
6563
}
6664

6765
this()
@@ -468,7 +466,7 @@ public:
468466
{
469467
auto obj = Prefabs[to!string(c) ~ "Tile"].createInstance;
470468
owner.addChild(obj);
471-
return obj.behaviors.get!Tile;
469+
return obj.getComponent!Tile;
472470
}
473471

474472
Color randomColor()
@@ -494,7 +492,7 @@ public:
494492
if( step == GameStep.Input )
495493
{
496494
auto selected = Input.mouseObject;
497-
auto tile = selected.behaviors.get!Tile;
495+
auto tile = selected.getComponent!Tile;
498496
if( tile )
499497
{
500498
auto index = tile.index;
@@ -529,7 +527,7 @@ public:
529527
logDebug("Patience, I'm animating");
530528
}
531529

532-
override void onUpdate()
530+
override void update()
533531
{
534532
debug
535533
{
@@ -629,20 +627,18 @@ class Match
629627
}
630628
}
631629

632-
class TileFields
633-
{
634-
string Color;
635-
}
636-
637-
class Tile : Behavior!TileFields
630+
@yamlComponent( "Tile" )
631+
class Tile : Component
638632
{
639633
private:
640634
bool _animating;
635+
Color color;
641636
vec3 start;
642637
vec3 target;
643638
float startTime;
644639
public:
645-
Color color;
640+
@field( "Color" )
641+
string initColor;
646642
uint index;
647643
mixin( Property!_animating );
648644

@@ -654,9 +650,9 @@ public:
654650
return owner.transform.position;
655651
}
656652

657-
override void onInitialize()
653+
override void initialize()
658654
{
659-
changeColor( to!Color(initArgs.Color) );
655+
changeColor( to!Color(initColor) );
660656
}
661657

662658
this()

dub.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"Tyler Wozniak"
88
],
99
"dependencies": {
10-
"dash": "==0.8.1"
10+
"dash": "==0.9.0"
1111
},
1212
"sourcePaths": [
1313
"Scripts/"

0 commit comments

Comments
 (0)