Merge branch 'master' into gui
Conflicts: include/Game/GUI/HUD.h src/game/Core/Renderer.cpp
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Bricks.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture.png
|
||||
|
After Width: | Height: | Size: 124 B |
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Bricks.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd StickyTexture.png
|
||||
|
After Width: | Height: | Size: 122 B |
|
After Width: | Height: | Size: 120 B |
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Bricks.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.004
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd White.png
|
||||
@@ -0,0 +1,513 @@
|
||||
# Blender v2.75 (sub 0) OBJ File: 'Bricks.blend'
|
||||
# www.blender.org
|
||||
mtllib WhiteBrick.mtl
|
||||
o OriginalBrick.001_Cube.003
|
||||
v 0.416882 0.151013 0.189181
|
||||
v 0.383459 0.157800 0.197587
|
||||
v 0.427922 0.161606 0.161784
|
||||
v 0.383459 0.180000 0.161784
|
||||
v 0.432779 0.125616 0.202365
|
||||
v 0.383459 0.126000 0.215784
|
||||
v 0.450000 0.126000 0.161784
|
||||
v -0.416882 0.151013 0.189181
|
||||
v 0.000000 0.157800 0.197587
|
||||
v -0.383459 0.157800 0.197587
|
||||
v -0.427922 0.161606 0.161784
|
||||
v 0.000000 0.180000 0.161784
|
||||
v -0.383459 0.180000 0.161784
|
||||
v -0.432779 0.125616 0.202365
|
||||
v 0.000000 0.126000 0.215784
|
||||
v -0.383459 0.126000 0.215784
|
||||
v -0.450000 0.126000 0.161784
|
||||
v 0.427922 0.161606 0.000000
|
||||
v 0.416882 0.151013 -0.189181
|
||||
v 0.383459 0.180000 0.000000
|
||||
v 0.383459 0.157800 -0.197587
|
||||
v 0.427922 0.161606 -0.161784
|
||||
v 0.383459 0.180000 -0.161784
|
||||
v 0.450000 0.126000 0.000000
|
||||
v 0.432779 0.125616 -0.202365
|
||||
v 0.383459 0.126000 -0.215784
|
||||
v 0.450000 0.126000 -0.161784
|
||||
v 0.000000 0.180000 0.000000
|
||||
v -0.427922 0.161606 0.000000
|
||||
v -0.416882 0.151013 -0.189181
|
||||
v 0.000000 0.157800 -0.197587
|
||||
v -0.383459 0.180000 0.000000
|
||||
v -0.383459 0.157800 -0.197587
|
||||
v -0.427922 0.161606 -0.161784
|
||||
v 0.000000 0.180000 -0.161784
|
||||
v -0.383459 0.180000 -0.161784
|
||||
v -0.450000 0.126000 0.000000
|
||||
v -0.432779 0.125616 -0.202365
|
||||
v 0.000000 0.126000 -0.215784
|
||||
v -0.383459 0.126000 -0.215784
|
||||
v -0.450000 0.126000 -0.161784
|
||||
v 0.416882 -0.151013 0.189181
|
||||
v 0.383459 -0.157800 0.197587
|
||||
v 0.427922 -0.161606 0.161784
|
||||
v 0.383459 -0.180000 0.161784
|
||||
v 0.432779 -0.125616 0.202365
|
||||
v 0.383459 -0.126000 0.215784
|
||||
v 0.450000 -0.126000 0.161784
|
||||
v 0.432723 0.000000 0.202132
|
||||
v 0.383459 0.000000 0.215784
|
||||
v 0.450000 0.000000 0.161784
|
||||
v -0.416882 -0.151013 0.189181
|
||||
v 0.000000 -0.157800 0.197587
|
||||
v -0.383459 -0.157800 0.197587
|
||||
v -0.427922 -0.161606 0.161784
|
||||
v 0.000000 -0.180000 0.161784
|
||||
v -0.383459 -0.180000 0.161784
|
||||
v -0.432779 -0.125616 0.202365
|
||||
v 0.000000 -0.126000 0.215784
|
||||
v -0.383459 -0.126000 0.215784
|
||||
v -0.450000 -0.126000 0.161784
|
||||
v -0.432723 0.000000 0.202132
|
||||
v 0.000000 0.000000 0.215784
|
||||
v -0.383459 0.000000 0.215784
|
||||
v -0.450000 0.000000 0.161784
|
||||
v 0.427922 -0.161606 0.000000
|
||||
v 0.416882 -0.151013 -0.189181
|
||||
v 0.383459 -0.180000 0.000000
|
||||
v 0.383459 -0.157800 -0.197587
|
||||
v 0.427922 -0.161606 -0.161784
|
||||
v 0.383459 -0.180000 -0.161784
|
||||
v 0.450000 -0.126000 0.000000
|
||||
v 0.432779 -0.125616 -0.202365
|
||||
v 0.383459 -0.126000 -0.215784
|
||||
v 0.450000 -0.126000 -0.161784
|
||||
v 0.450000 0.000000 0.000000
|
||||
v 0.432723 0.000000 -0.202132
|
||||
v 0.383459 0.000000 -0.215784
|
||||
v 0.450000 0.000000 -0.161784
|
||||
v 0.000000 -0.180000 0.000000
|
||||
v -0.427922 -0.161606 0.000000
|
||||
v -0.416882 -0.151013 -0.189181
|
||||
v 0.000000 -0.157800 -0.197587
|
||||
v -0.383459 -0.180000 0.000000
|
||||
v -0.383459 -0.157800 -0.197587
|
||||
v -0.427922 -0.161606 -0.161784
|
||||
v 0.000000 -0.180000 -0.161784
|
||||
v -0.383459 -0.180000 -0.161784
|
||||
v -0.450000 -0.126000 0.000000
|
||||
v -0.432779 -0.125616 -0.202365
|
||||
v 0.000000 -0.126000 -0.215784
|
||||
v -0.383459 -0.126000 -0.215784
|
||||
v -0.450000 -0.126000 -0.161784
|
||||
v -0.450000 0.000000 0.000000
|
||||
v -0.432723 0.000000 -0.202132
|
||||
v 0.000000 0.000000 -0.215784
|
||||
v -0.383459 0.000000 -0.215784
|
||||
v -0.450000 0.000000 -0.161784
|
||||
vt 0.732824 0.651596
|
||||
vt 0.497063 0.656145
|
||||
vt 0.498352 0.561696
|
||||
vt 0.835737 0.544092
|
||||
vt 0.832410 0.574334
|
||||
vt 0.728776 0.549797
|
||||
vt 0.733409 0.516110
|
||||
vt 0.747921 0.523504
|
||||
vt 0.498691 0.536867
|
||||
vt 0.754013 0.503366
|
||||
vt 0.838288 0.518944
|
||||
vt 0.716137 0.523643
|
||||
vt 0.711494 0.504530
|
||||
vt 0.498984 0.515399
|
||||
vt 0.734485 0.500579
|
||||
vt 0.734742 0.443967
|
||||
vt 0.756687 0.444264
|
||||
vt 0.500002 0.440769
|
||||
vt 0.708811 0.443615
|
||||
vt 0.842574 0.445423
|
||||
vt 0.261516 0.645162
|
||||
vt 0.268342 0.543511
|
||||
vt 0.164088 0.565217
|
||||
vt 0.161584 0.534899
|
||||
vt 0.264629 0.509713
|
||||
vt 0.281689 0.517713
|
||||
vt 0.159717 0.509691
|
||||
vt 0.244381 0.496413
|
||||
vt 0.249922 0.516708
|
||||
vt 0.263977 0.494158
|
||||
vt 0.286851 0.498734
|
||||
vt 0.243317 0.437260
|
||||
vt 0.265263 0.437561
|
||||
vt 0.291193 0.437916
|
||||
vt 0.157430 0.436083
|
||||
vt 0.495722 0.754363
|
||||
vt 0.939579 0.572784
|
||||
vt 0.950008 0.538976
|
||||
vt 0.966270 0.556108
|
||||
vt 0.495366 0.780443
|
||||
vt 0.733578 0.753608
|
||||
vt 0.929866 0.518425
|
||||
vt 0.931317 0.541897
|
||||
vt 0.953950 0.520177
|
||||
vt 0.983612 0.534778
|
||||
vt 0.733699 0.802691
|
||||
vt 0.495056 0.803167
|
||||
vt 0.935351 0.446668
|
||||
vt 0.962999 0.447038
|
||||
vt 0.733787 0.881463
|
||||
vt 0.493987 0.881463
|
||||
vt 0.999906 0.447531
|
||||
vt 0.057009 0.560761
|
||||
vt 0.047501 0.526686
|
||||
vt 0.066106 0.530111
|
||||
vt 0.257977 0.747114
|
||||
vt 0.068193 0.506688
|
||||
vt 0.030782 0.543370
|
||||
vt 0.014024 0.521580
|
||||
vt 0.256516 0.796175
|
||||
vt 0.044070 0.507787
|
||||
vt 0.037002 0.434429
|
||||
vt 0.064650 0.434809
|
||||
vt 0.254277 0.874915
|
||||
vt 0.000094 0.433923
|
||||
vt 0.501652 0.319843
|
||||
vt 0.502941 0.225399
|
||||
vt 0.738475 0.236380
|
||||
vt 0.731650 0.338024
|
||||
vt 0.835884 0.316299
|
||||
vt 0.838396 0.346613
|
||||
vt 0.735366 0.371817
|
||||
vt 0.718307 0.363820
|
||||
vt 0.501313 0.344671
|
||||
vt 0.840268 0.371818
|
||||
vt 0.755614 0.385114
|
||||
vt 0.750071 0.364821
|
||||
vt 0.736021 0.387371
|
||||
vt 0.713148 0.382798
|
||||
vt 0.501020 0.366139
|
||||
vt 0.267194 0.229946
|
||||
vt 0.164293 0.337419
|
||||
vt 0.167628 0.307183
|
||||
vt 0.271241 0.331739
|
||||
vt 0.266605 0.365420
|
||||
vt 0.252095 0.358025
|
||||
vt 0.246001 0.378160
|
||||
vt 0.161736 0.362565
|
||||
vt 0.283877 0.357890
|
||||
vt 0.288517 0.377003
|
||||
vt 0.265527 0.380951
|
||||
vt 0.504282 0.127186
|
||||
vt 0.942953 0.320724
|
||||
vt 0.952471 0.354792
|
||||
vt 0.933866 0.351373
|
||||
vt 0.742013 0.134433
|
||||
vt 0.504638 0.101108
|
||||
vt 0.931787 0.374794
|
||||
vt 0.969182 0.338104
|
||||
vt 0.985946 0.359886
|
||||
vt 0.504948 0.078385
|
||||
vt 0.743473 0.085376
|
||||
vt 0.955907 0.373688
|
||||
vt 0.506017 0.000095
|
||||
vt 0.745712 0.006641
|
||||
vt 0.060470 0.308697
|
||||
vt 0.050030 0.342497
|
||||
vt 0.033776 0.325361
|
||||
vt 0.266441 0.127940
|
||||
vt 0.070165 0.363055
|
||||
vt 0.068721 0.339584
|
||||
vt 0.046081 0.361294
|
||||
vt 0.016425 0.346681
|
||||
vt 0.266320 0.078861
|
||||
vt 0.266232 0.000094
|
||||
vt 0.733646 0.779865
|
||||
vt 0.257192 0.773359
|
||||
vt 0.742798 0.108190
|
||||
vt 0.266373 0.101685
|
||||
vn 0.194900 0.980800 0.000000
|
||||
vn 0.000000 1.000000 0.000000
|
||||
vn 0.000000 0.961700 0.273900
|
||||
vn 0.647300 0.762200 0.000000
|
||||
vn 0.178700 0.949500 0.257800
|
||||
vn 0.457300 0.661600 0.594300
|
||||
vn 0.631200 0.737600 0.239800
|
||||
vn 0.000000 0.694500 0.719500
|
||||
vn 0.939500 0.276000 0.202600
|
||||
vn 0.961700 0.274000 0.000000
|
||||
vn 0.151600 0.685100 0.712500
|
||||
vn 0.135500 0.258500 0.956400
|
||||
vn 0.000000 0.256900 0.966400
|
||||
vn 0.632300 0.305000 0.712100
|
||||
vn 0.658300 0.000000 0.752800
|
||||
vn 0.979700 0.000000 0.200600
|
||||
vn 0.000000 0.000000 1.000000
|
||||
vn 0.134200 0.000000 0.990900
|
||||
vn 1.000000 0.000000 0.000000
|
||||
vn -0.194900 0.980800 0.000000
|
||||
vn -0.178700 0.949500 0.257800
|
||||
vn -0.647300 0.762200 0.000000
|
||||
vn -0.457300 0.661600 0.594300
|
||||
vn -0.151600 0.685100 0.712500
|
||||
vn -0.961700 0.274000 0.000000
|
||||
vn -0.939500 0.276000 0.202600
|
||||
vn -0.631200 0.737600 0.239800
|
||||
vn -0.632300 0.305000 0.712100
|
||||
vn -0.135500 0.258500 0.956400
|
||||
vn -0.979700 0.000000 0.200600
|
||||
vn -0.658300 0.000000 0.752800
|
||||
vn -0.134200 0.000000 0.990900
|
||||
vn -1.000000 0.000000 0.000000
|
||||
vn 0.000000 0.961700 -0.273900
|
||||
vn 0.178700 0.949500 -0.257800
|
||||
vn 0.457300 0.661600 -0.594300
|
||||
vn 0.151600 0.685100 -0.712500
|
||||
vn 0.000000 0.694500 -0.719500
|
||||
vn 0.939500 0.276000 -0.202600
|
||||
vn 0.631200 0.737600 -0.239800
|
||||
vn 0.632300 0.305000 -0.712100
|
||||
vn 0.135500 0.258500 -0.956400
|
||||
vn 0.000000 0.256900 -0.966400
|
||||
vn 0.979700 0.000000 -0.200600
|
||||
vn 0.658300 0.000000 -0.752800
|
||||
vn 0.134200 0.000000 -0.990900
|
||||
vn 0.000000 0.000000 -1.000000
|
||||
vn -0.178700 0.949500 -0.257800
|
||||
vn -0.457300 0.661600 -0.594300
|
||||
vn -0.631200 0.737600 -0.239800
|
||||
vn -0.939500 0.276000 -0.202600
|
||||
vn -0.151600 0.685100 -0.712500
|
||||
vn -0.135500 0.258500 -0.956400
|
||||
vn -0.632300 0.305000 -0.712100
|
||||
vn -0.658300 0.000000 -0.752800
|
||||
vn -0.979700 0.000000 -0.200600
|
||||
vn -0.134200 0.000000 -0.990900
|
||||
vn 0.000000 -0.961700 0.273900
|
||||
vn 0.000000 -1.000000 0.000000
|
||||
vn 0.194900 -0.980800 0.000000
|
||||
vn 0.178700 -0.949500 0.257800
|
||||
vn 0.647300 -0.762200 0.000000
|
||||
vn 0.457300 -0.661600 0.594300
|
||||
vn 0.151600 -0.685100 0.712500
|
||||
vn 0.000000 -0.694500 0.719500
|
||||
vn 0.961700 -0.274000 0.000000
|
||||
vn 0.939500 -0.276000 0.202600
|
||||
vn 0.631200 -0.737600 0.239800
|
||||
vn 0.632300 -0.305000 0.712100
|
||||
vn 0.135500 -0.258500 0.956400
|
||||
vn 0.000000 -0.256900 0.966400
|
||||
vn -0.194900 -0.980800 0.000000
|
||||
vn -0.647300 -0.762200 0.000000
|
||||
vn -0.178700 -0.949500 0.257800
|
||||
vn -0.457300 -0.661600 0.594300
|
||||
vn -0.631200 -0.737600 0.239800
|
||||
vn -0.939500 -0.276000 0.202600
|
||||
vn -0.961700 -0.274000 0.000000
|
||||
vn -0.151600 -0.685100 0.712500
|
||||
vn -0.135500 -0.258500 0.956400
|
||||
vn -0.632300 -0.305000 0.712100
|
||||
vn 0.000000 -0.961700 -0.273900
|
||||
vn 0.178700 -0.949500 -0.257800
|
||||
vn 0.457300 -0.661600 -0.594300
|
||||
vn 0.631200 -0.737600 -0.239800
|
||||
vn 0.000000 -0.694500 -0.719500
|
||||
vn 0.939500 -0.276000 -0.202600
|
||||
vn 0.151600 -0.685100 -0.712500
|
||||
vn 0.135500 -0.258500 -0.956400
|
||||
vn 0.000000 -0.256900 -0.966400
|
||||
vn 0.632300 -0.305000 -0.712100
|
||||
vn -0.178700 -0.949500 -0.257800
|
||||
vn -0.457300 -0.661600 -0.594300
|
||||
vn -0.151600 -0.685100 -0.712500
|
||||
vn -0.939500 -0.276000 -0.202600
|
||||
vn -0.631200 -0.737600 -0.239800
|
||||
vn -0.632300 -0.305000 -0.712100
|
||||
vn -0.135500 -0.258500 -0.956400
|
||||
usemtl Material.004
|
||||
s 1
|
||||
f 20/1/1 28/2/2 12/3/3
|
||||
f 18/4/4 20/5/1 4/6/5
|
||||
f 1/7/6 3/8/7 4/6/5
|
||||
f 4/6/5 12/3/3 9/9/8
|
||||
f 3/8/7 7/10/9 24/11/10
|
||||
f 1/7/6 2/12/11 6/13/12
|
||||
f 9/9/8 15/14/13 6/13/12
|
||||
f 1/7/6 5/15/14 7/10/9
|
||||
f 5/15/14 49/16/15 51/17/16
|
||||
f 15/14/13 63/18/17 50/19/18
|
||||
f 5/15/14 6/13/12 50/19/18
|
||||
f 7/10/9 51/17/16 76/20/19
|
||||
f 12/3/3 28/2/2 32/21/20
|
||||
f 13/22/21 32/23/20 29/24/22
|
||||
f 8/25/23 10/26/24 13/22/21
|
||||
f 9/9/8 12/3/3 13/22/21
|
||||
f 37/27/25 17/28/26 11/29/27
|
||||
f 8/25/23 14/30/28 16/31/29
|
||||
f 16/31/29 15/14/13 9/9/8
|
||||
f 17/28/26 14/30/28 8/25/23
|
||||
f 65/32/30 62/33/31 14/30/28
|
||||
f 64/34/32 63/18/17 15/14/13
|
||||
f 14/30/28 62/33/31 64/34/32
|
||||
f 94/35/33 65/32/30 17/28/26
|
||||
f 35/36/34 28/2/2 20/1/1
|
||||
f 23/37/35 20/5/1 18/4/4
|
||||
f 19/38/36 21/39/37 23/37/35
|
||||
f 31/40/38 35/36/34 23/41/35
|
||||
f 24/11/10 27/42/39 22/43/40
|
||||
f 19/38/36 25/44/41 26/45/42
|
||||
f 26/46/42 39/47/43 31/40/38
|
||||
f 27/42/39 25/44/41 19/38/36
|
||||
f 79/48/44 77/49/45 25/44/41
|
||||
f 78/50/46 96/51/47 39/47/43
|
||||
f 25/44/41 77/49/45 78/52/46
|
||||
f 76/20/19 79/48/44 27/42/39
|
||||
f 32/21/20 28/2/2 35/36/34
|
||||
f 29/24/22 32/23/20 36/53/48
|
||||
f 30/54/49 34/55/50 36/53/48
|
||||
f 36/56/48 35/36/34 31/40/38
|
||||
f 34/55/50 41/57/51 37/27/25
|
||||
f 30/54/49 33/58/52 40/59/53
|
||||
f 31/40/38 39/47/43 40/60/53
|
||||
f 30/54/49 38/61/54 41/57/51
|
||||
f 38/61/54 95/62/55 98/63/56
|
||||
f 39/47/43 96/51/47 97/64/57
|
||||
f 38/61/54 40/59/53 97/65/57
|
||||
f 41/57/51 98/63/56 94/35/33
|
||||
f 56/66/58 80/67/59 68/68/60
|
||||
f 45/69/61 68/70/60 66/71/62
|
||||
f 42/72/63 43/73/64 45/69/61
|
||||
f 53/74/65 56/66/58 45/69/61
|
||||
f 72/75/66 48/76/67 44/77/68
|
||||
f 42/72/63 46/78/69 47/79/70
|
||||
f 47/79/70 59/80/71 53/74/65
|
||||
f 48/76/67 46/78/69 42/72/63
|
||||
f 51/17/16 49/16/15 46/78/69
|
||||
f 50/19/18 63/18/17 59/80/71
|
||||
f 46/78/69 49/16/15 50/19/18
|
||||
f 76/20/19 51/17/16 48/76/67
|
||||
f 84/81/72 80/67/59 56/66/58
|
||||
f 81/82/73 84/83/72 57/84/74
|
||||
f 52/85/75 55/86/76 57/84/74
|
||||
f 57/84/74 56/66/58 53/74/65
|
||||
f 55/86/76 61/87/77 89/88/78
|
||||
f 52/85/75 54/89/79 60/90/80
|
||||
f 53/74/65 59/80/71 60/90/80
|
||||
f 52/85/75 58/91/81 61/87/77
|
||||
f 58/91/81 62/33/31 65/32/30
|
||||
f 59/80/71 63/18/17 64/34/32
|
||||
f 58/91/81 60/90/80 64/34/32
|
||||
f 61/87/77 65/32/30 94/35/33
|
||||
f 68/68/60 80/67/59 87/92/82
|
||||
f 66/71/62 68/70/60 71/93/83
|
||||
f 67/94/84 70/95/85 71/93/83
|
||||
f 71/96/83 87/92/82 83/97/86
|
||||
f 70/95/85 75/98/87 72/75/66
|
||||
f 67/94/84 69/99/88 74/100/89
|
||||
f 83/97/86 91/101/90 74/102/89
|
||||
f 67/94/84 73/103/91 75/98/87
|
||||
f 73/103/91 77/49/45 79/48/44
|
||||
f 91/101/90 96/104/47 78/105/46
|
||||
f 73/103/91 74/100/89 78/52/46
|
||||
f 75/98/87 79/48/44 76/20/19
|
||||
f 87/92/82 80/67/59 84/81/72
|
||||
f 88/106/92 84/83/72 81/82/73
|
||||
f 82/107/93 85/108/94 88/106/92
|
||||
f 83/97/86 87/92/82 88/109/92
|
||||
f 89/88/78 93/110/95 86/111/96
|
||||
f 82/107/93 90/112/97 92/113/98
|
||||
f 92/114/98 91/101/90 83/97/86
|
||||
f 93/110/95 90/112/97 82/107/93
|
||||
f 98/63/56 95/62/55 90/112/97
|
||||
f 97/115/57 96/104/47 91/101/90
|
||||
f 90/112/97 95/62/55 97/65/57
|
||||
f 94/35/33 98/63/56 93/110/95
|
||||
f 4/6/5 20/1/1 12/3/3
|
||||
f 3/8/7 18/4/4 4/6/5
|
||||
f 2/12/11 1/7/6 4/6/5
|
||||
f 2/12/11 4/6/5 9/9/8
|
||||
f 18/4/4 3/8/7 24/11/10
|
||||
f 5/15/14 1/7/6 6/13/12
|
||||
f 2/12/11 9/9/8 6/13/12
|
||||
f 3/8/7 1/7/6 7/10/9
|
||||
f 7/10/9 5/15/14 51/17/16
|
||||
f 6/13/12 15/14/13 50/19/18
|
||||
f 49/16/15 5/15/14 50/19/18
|
||||
f 24/11/10 7/10/9 76/20/19
|
||||
f 13/22/21 12/3/3 32/21/20
|
||||
f 11/29/27 13/22/21 29/24/22
|
||||
f 11/29/27 8/25/23 13/22/21
|
||||
f 10/26/24 9/9/8 13/22/21
|
||||
f 29/24/22 37/27/25 11/29/27
|
||||
f 10/26/24 8/25/23 16/31/29
|
||||
f 10/26/24 16/31/29 9/9/8
|
||||
f 11/29/27 17/28/26 8/25/23
|
||||
f 17/28/26 65/32/30 14/30/28
|
||||
f 16/31/29 64/34/32 15/14/13
|
||||
f 16/31/29 14/30/28 64/34/32
|
||||
f 37/27/25 94/35/33 17/28/26
|
||||
f 23/41/35 35/36/34 20/1/1
|
||||
f 22/43/40 23/37/35 18/4/4
|
||||
f 22/43/40 19/38/36 23/37/35
|
||||
f 21/116/37 31/40/38 23/41/35
|
||||
f 18/4/4 24/11/10 22/43/40
|
||||
f 21/39/37 19/38/36 26/45/42
|
||||
f 21/116/37 26/46/42 31/40/38
|
||||
f 22/43/40 27/42/39 19/38/36
|
||||
f 27/42/39 79/48/44 25/44/41
|
||||
f 26/46/42 78/50/46 39/47/43
|
||||
f 26/45/42 25/44/41 78/52/46
|
||||
f 24/11/10 76/20/19 27/42/39
|
||||
f 36/56/48 32/21/20 35/36/34
|
||||
f 34/55/50 29/24/22 36/53/48
|
||||
f 33/58/52 30/54/49 36/53/48
|
||||
f 33/117/52 36/56/48 31/40/38
|
||||
f 29/24/22 34/55/50 37/27/25
|
||||
f 38/61/54 30/54/49 40/59/53
|
||||
f 33/117/52 31/40/38 40/60/53
|
||||
f 34/55/50 30/54/49 41/57/51
|
||||
f 41/57/51 38/61/54 98/63/56
|
||||
f 40/60/53 39/47/43 97/64/57
|
||||
f 95/62/55 38/61/54 97/65/57
|
||||
f 37/27/25 41/57/51 94/35/33
|
||||
f 45/69/61 56/66/58 68/68/60
|
||||
f 44/77/68 45/69/61 66/71/62
|
||||
f 44/77/68 42/72/63 45/69/61
|
||||
f 43/73/64 53/74/65 45/69/61
|
||||
f 66/71/62 72/75/66 44/77/68
|
||||
f 43/73/64 42/72/63 47/79/70
|
||||
f 43/73/64 47/79/70 53/74/65
|
||||
f 44/77/68 48/76/67 42/72/63
|
||||
f 48/76/67 51/17/16 46/78/69
|
||||
f 47/79/70 50/19/18 59/80/71
|
||||
f 47/79/70 46/78/69 50/19/18
|
||||
f 72/75/66 76/20/19 48/76/67
|
||||
f 57/84/74 84/81/72 56/66/58
|
||||
f 55/86/76 81/82/73 57/84/74
|
||||
f 54/89/79 52/85/75 57/84/74
|
||||
f 54/89/79 57/84/74 53/74/65
|
||||
f 81/82/73 55/86/76 89/88/78
|
||||
f 58/91/81 52/85/75 60/90/80
|
||||
f 54/89/79 53/74/65 60/90/80
|
||||
f 55/86/76 52/85/75 61/87/77
|
||||
f 61/87/77 58/91/81 65/32/30
|
||||
f 60/90/80 59/80/71 64/34/32
|
||||
f 62/33/31 58/91/81 64/34/32
|
||||
f 89/88/78 61/87/77 94/35/33
|
||||
f 71/96/83 68/68/60 87/92/82
|
||||
f 70/95/85 66/71/62 71/93/83
|
||||
f 69/99/88 67/94/84 71/93/83
|
||||
f 69/118/88 71/96/83 83/97/86
|
||||
f 66/71/62 70/95/85 72/75/66
|
||||
f 73/103/91 67/94/84 74/100/89
|
||||
f 69/118/88 83/97/86 74/102/89
|
||||
f 70/95/85 67/94/84 75/98/87
|
||||
f 75/98/87 73/103/91 79/48/44
|
||||
f 74/102/89 91/101/90 78/105/46
|
||||
f 77/49/45 73/103/91 78/52/46
|
||||
f 72/75/66 75/98/87 76/20/19
|
||||
f 88/109/92 87/92/82 84/81/72
|
||||
f 86/111/96 88/106/92 81/82/73
|
||||
f 86/111/96 82/107/93 88/106/92
|
||||
f 85/119/94 83/97/86 88/109/92
|
||||
f 81/82/73 89/88/78 86/111/96
|
||||
f 85/108/94 82/107/93 92/113/98
|
||||
f 85/119/94 92/114/98 83/97/86
|
||||
f 86/111/96 93/110/95 82/107/93
|
||||
f 93/110/95 98/63/56 90/112/97
|
||||
f 92/114/98 97/115/57 91/101/90
|
||||
f 92/113/98 90/112/97 97/65/57
|
||||
f 89/88/78 94/35/33 93/110/95
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Lifebuoy.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture1.png
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Lifebuoy.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture2.png
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Lifebuoy.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture3.png
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Lifebuoy.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture4.png
|
||||
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Lifebuoy.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.640000 0.640000 0.640000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd LifebuoyTexture5.png
|
||||
|
After Width: | Height: | Size: 122 B |
|
After Width: | Height: | Size: 133 B |
|
After Width: | Height: | Size: 139 B |
|
After Width: | Height: | Size: 135 B |
|
After Width: | Height: | Size: 142 B |
|
After Width: | Height: | Size: 130 B |
@@ -0,0 +1,12 @@
|
||||
# Blender MTL File: 'Ship.blend'
|
||||
# Material Count: 1
|
||||
|
||||
newmtl Material.001
|
||||
Ns 96.078431
|
||||
Ka 0.000000 0.000000 0.000000
|
||||
Kd 0.800000 0.800000 0.800000
|
||||
Ks 0.500000 0.500000 0.500000
|
||||
Ni 1.000000
|
||||
d 1.000000
|
||||
illum 2
|
||||
map_Kd ShipTexture.png
|
||||
|
After Width: | Height: | Size: 64 KiB |
|
After Width: | Height: | Size: 52 KiB |
|
After Width: | Height: | Size: 56 KiB |
|
After Width: | Height: | Size: 120 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 600 KiB |
|
After Width: | Height: | Size: 44 KiB |
@@ -53,7 +53,8 @@ public:
|
||||
|
||||
/// Register a destruction listener. The listener is owned by you and must
|
||||
/// remain in scope.
|
||||
void SetDestructionListener(b2DestructionListener* listener);
|
||||
void
|
||||
SetDestructionListener(b2DestructionListener* listener);
|
||||
|
||||
/// Register a contact filter to provide specific control over collision.
|
||||
/// Otherwise the default filter is used (b2_defaultFilter). The listener is
|
||||
|
||||
@@ -654,7 +654,7 @@ int32 b2ParticleSystem::CreateParticle(const b2ParticleDef& def)
|
||||
// If the oldest particle should be destroyed...
|
||||
if (m_def.destroyByAge)
|
||||
{
|
||||
DestroyOldestParticle(0, false);
|
||||
DestroyOldestParticle(0, true);
|
||||
// Need to destroy this particle *now* so that it's possible to
|
||||
// create a new particle.
|
||||
SolveZombie();
|
||||
|
||||
@@ -299,7 +299,7 @@ public:
|
||||
/// b2World::Step()).
|
||||
void DestroyParticle(int32 index)
|
||||
{
|
||||
DestroyParticle(index, false);
|
||||
DestroyParticle(index, true);
|
||||
}
|
||||
|
||||
/// Destroy a particle.
|
||||
@@ -330,7 +330,7 @@ public:
|
||||
/// @return Number of particles destroyed.
|
||||
int32 DestroyParticlesInShape(const b2Shape& shape, const b2Transform& xf)
|
||||
{
|
||||
return DestroyParticlesInShape(shape, xf, false);
|
||||
return DestroyParticlesInShape(shape, xf, true);
|
||||
}
|
||||
|
||||
/// Destroy particles inside a shape.
|
||||
|
||||
@@ -41,6 +41,9 @@ struct Transform : public Component
|
||||
glm::vec3 Velocity;
|
||||
/** Physical scale multiplier. */
|
||||
glm::vec3 Scale;
|
||||
|
||||
// Sticky is if it sticks with the player or not. True means it will follow the camera.
|
||||
bool Sticky;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -43,9 +43,13 @@
|
||||
#include "Game/PadSystem.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/BallSystem.h"
|
||||
#include "Game/HitLagSystem.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
|
||||
#include "Physics/PhysicsSystem.h"
|
||||
@@ -110,6 +114,8 @@ public:
|
||||
m_World->ComponentFactory.Register<Components::Brick>();
|
||||
m_World->ComponentFactory.Register<Components::Pad>();
|
||||
m_World->ComponentFactory.Register<Components::Life>();
|
||||
m_World->ComponentFactory.Register<Components::Lifebuoy>();
|
||||
m_World->ComponentFactory.Register<Components::Projectile>();
|
||||
|
||||
m_World->ComponentFactory.Register<Components::PowerUp>();
|
||||
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
|
||||
@@ -126,6 +132,12 @@ public:
|
||||
m_World->SystemFactory.Register<Systems::HitLagSystem>(
|
||||
[this]() { return new Systems::HitLagSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::HitLagSystem>();
|
||||
m_World->SystemFactory.Register<Systems::LifebuoySystem>(
|
||||
[this]() { return new Systems::LifebuoySystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::LifebuoySystem>();
|
||||
m_World->SystemFactory.Register<Systems::ProjectileSystem>(
|
||||
[this]() { return new Systems::ProjectileSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::ProjectileSystem>();
|
||||
m_World->SystemFactory.Register<Systems::PhysicsSystem>(
|
||||
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
|
||||
m_World->AddSystem<Systems::PhysicsSystem>();
|
||||
@@ -143,6 +155,7 @@ public:
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(-3.f, 6.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 20.f;
|
||||
pl->Diffuse = glm::vec3(0.8f, 0.7f, 0.05f);
|
||||
@@ -154,6 +167,7 @@ public:
|
||||
auto t_Light = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_Light);
|
||||
transform->Position = glm::vec3(3.f, -5.f, -5.f);
|
||||
transform->Sticky = true;
|
||||
auto pl = m_World->AddComponent<Components::PointLight>(t_Light);
|
||||
pl->Radius = 15.f;
|
||||
pl->Diffuse = glm::vec3(0.1f, 0.5f, 0.8f);
|
||||
@@ -168,13 +182,26 @@ public:
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 0.f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(1.f, 0.f, 0.f, 0.3f);
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
{
|
||||
auto t_halfPipe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_halfPipe);
|
||||
transform->Position = glm::vec3(0.f, 34.6f, -15.f);
|
||||
transform->Scale = glm::vec3(6.f, 6.f, 10.f);
|
||||
transform->Sticky = false;
|
||||
auto model = m_World->AddComponent<Components::Model>(t_halfPipe);
|
||||
model->ModelFile = "Models/Test/halfpipe/Halfpipe.obj";
|
||||
model->Color = glm::vec4(0.8f, 0.8f, 0.8f, 0.3f);
|
||||
m_World->CommitEntity(t_halfPipe);
|
||||
}
|
||||
|
||||
//Background
|
||||
|
||||
{
|
||||
auto background = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(background);
|
||||
@@ -185,55 +212,55 @@ public:
|
||||
m_World->CommitEntity(background);
|
||||
}
|
||||
|
||||
//ParticleTest
|
||||
// {
|
||||
// auto Pe = m_World->CreateEntity();
|
||||
// auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||
// auto particleEmitter= m_World->AddComponent<Components::Emitter>(Pe);
|
||||
//
|
||||
// transform->Position = glm::vec3(0.f, -5.f, -10.f);
|
||||
// particleEmitter->GravityScale = 0.0f;
|
||||
// particleEmitter->SpawnRate = 1.0f;
|
||||
//
|
||||
// {
|
||||
// auto Pt = m_World->CreateEntity(Pe);
|
||||
// auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
// auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
// //auto PtModel = m_World->AddComponent<Components::Model>(Pt);
|
||||
// auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
|
||||
// auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
|
||||
//
|
||||
// PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
// PtTransform->Position = transform->Position;
|
||||
// PtSprite->SpriteFile = "Textures/Ball.png";
|
||||
//
|
||||
// //PtModel->ModelFile = "Models/Brick/Brick.obj";
|
||||
// PtParticle->LifeTime = 1000.f;
|
||||
// PtParticle->Flags = ParticleFlags::Type::powderParticle;
|
||||
// }
|
||||
// m_World->CommitEntity(Pe);
|
||||
// }
|
||||
|
||||
// {
|
||||
// auto Pt = m_World->CreateEntity();
|
||||
// auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
// auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
//
|
||||
// PtTransform->Position = glm::vec3(2.f, 0.f, -10.f);
|
||||
// PtSprite->SpriteFile = "Textures/Ball.png";
|
||||
// }
|
||||
|
||||
//Water test
|
||||
{
|
||||
auto t_waterBody = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(t_waterBody);
|
||||
transform->Position = glm::vec3(0.f, -5.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.f, 1.5f, 1.f);
|
||||
transform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
transform->Scale = glm::vec3(7.0f, 1.5f, 1.f);
|
||||
transform->Sticky = true;
|
||||
auto water = m_World->AddComponent<Components::WaterVolume>(t_waterBody);
|
||||
auto body = m_World->AddComponent<Components::RectangleShape>(t_waterBody);
|
||||
m_World->CommitEntity(t_waterBody);
|
||||
}
|
||||
|
||||
//ParticleTest
|
||||
|
||||
|
||||
/*{
|
||||
auto Pe = m_World->CreateEntity();
|
||||
auto transform = m_World->AddComponent<Components::Transform>(Pe);
|
||||
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(Pe);
|
||||
auto emitteSprite = m_World->AddComponent<Components::Sprite>(Pe);
|
||||
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
emitteSprite->SpriteFile = "Textures/Test/Brick_Normal.png";
|
||||
particleEmitter->GravityScale = 0.0f;
|
||||
particleEmitter->SpawnRate = 1.f;
|
||||
particleEmitter->NumberOfTicks = 2;
|
||||
particleEmitter->Speed = 1.f;
|
||||
particleEmitter->ParticlesPerTick = 5;
|
||||
particleEmitter->Spread = glm::pi<float>()*2;
|
||||
particleEmitter->EmittingAngle = glm::pi<float>();
|
||||
particleEmitter->LifeTime = 50;
|
||||
|
||||
{
|
||||
auto Pt = m_World->CreateEntity(Pe);
|
||||
auto PtTransform = m_World->AddComponent<Components::Transform>(Pt);
|
||||
auto PtSprite = m_World->AddComponent<Components::Sprite>(Pt);
|
||||
auto PtParticle = m_World->AddComponent<Components::Particle>(Pt);
|
||||
auto PtTemplate = m_World->AddComponent<Components::Template>(Pt);
|
||||
|
||||
//PtTransform->Velocity = glm::vec3(1.0f, 0.f, 0.f);
|
||||
PtTransform->Position = transform->Position;
|
||||
PtSprite->SpriteFile = "Textures/Background.png";
|
||||
PtParticle->LifeTime = 3.f;
|
||||
PtParticle->Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Type::Powder | ParticleFlags::Type::ParticleContactFilter | ParticleFlags::Type::FixtureContactFilter);
|
||||
}
|
||||
m_World->CommitEntity(Pe);
|
||||
}*/
|
||||
|
||||
//TODO: Why does the ball not collide with these bricks?
|
||||
//BottomBox
|
||||
{
|
||||
@@ -247,6 +274,9 @@ public:
|
||||
rectangleShape->Dimensions = glm::vec2(20.f, 0.5f);
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(BottomWall);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::LifeBuoy);
|
||||
transform->Sticky = true;
|
||||
m_World->CommitEntity(BottomWall);
|
||||
}
|
||||
|
||||
@@ -266,6 +296,7 @@ public:
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(topWall);
|
||||
}
|
||||
@@ -287,6 +318,7 @@ public:
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(leftWall);
|
||||
}
|
||||
@@ -308,11 +340,11 @@ public:
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::Wall;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick);
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(rightWall);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &Engine::OnGameStart);
|
||||
m_EGameStart = decltype(m_EGameStart)(std::bind(&Engine::OnGameStart, this, std::placeholders::_1));
|
||||
m_EventBroker->Subscribe(m_EGameStart);
|
||||
|
||||
@@ -21,10 +21,16 @@
|
||||
#include "Game/EResetBall.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -89,7 +95,12 @@ private:
|
||||
int m_PastLives = 3;
|
||||
bool m_ReplaceBall = false;
|
||||
bool m_Pause = false;
|
||||
EntityID m_LastCollision = 999999;
|
||||
bool m_Waiting = true;
|
||||
bool m_Sticky = false;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_InkAttached = false;
|
||||
bool m_BlockedWaiting = false;
|
||||
int m_StickyCounter = 5;
|
||||
|
||||
glm::vec3 m_SavedSpeed;
|
||||
bool m_InitializePause = false;
|
||||
@@ -103,15 +114,23 @@ private:
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBallLost> m_EMultiBallLost;
|
||||
dd::EventRelay<BallSystem, dd::Events::ResetBall> m_EResetBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::MultiBall> m_EMultiBall;
|
||||
dd::EventRelay<BallSystem, dd::Events::StickyPad> m_EStickyPad;
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<BallSystem, dd::Events::InkBlasterOver> m_EInkBlasterOver;
|
||||
dd::EventRelay<BallSystem, dd::Events::Pause> m_EPause;
|
||||
EventRelay<BallSystem, Events::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
|
||||
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
|
||||
bool Contact(const Events::Contact &event);
|
||||
bool OnLifeLost(const dd::Events::LifeLost &event);
|
||||
bool OnMultiBallLost(const dd::Events::MultiBallLost &event);
|
||||
bool OnResetBall(const dd::Events::ResetBall &event);
|
||||
bool OnMultiBall(const dd::Events::MultiBall &event);
|
||||
bool OnStickyPad(const dd::Events::StickyPad &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnInkBlasterOver(const dd::Events::InkBlasterOver &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -19,6 +19,10 @@ struct Ball : Component
|
||||
float Speed = 5.f;
|
||||
int Combo = 0;
|
||||
bool Paused = false;
|
||||
bool Waiting = true;
|
||||
bool InkBlaster = false;
|
||||
bool Sticky = false;
|
||||
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
|
||||
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CLIFEBUOY_H
|
||||
#define DAYDREAM_CLIFEBUOY_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Lifebuoy : Component
|
||||
{
|
||||
int Hits = 4;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CLIFEBUOY_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_CPROJECTILE_H
|
||||
#define DAYDREAM_CPROJECTILE_H
|
||||
|
||||
#include "Core/Component.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Components
|
||||
{
|
||||
|
||||
struct Projectile : Component
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_CPROJECTILE_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Administrator on 2015-10-07.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EACTIONBUTTON_H
|
||||
#define DAYDREAM_EACTIONBUTTON_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ActionButton : Event
|
||||
{
|
||||
glm::vec3 Position;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EACTIONBUTTON_H
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifndef DAYDREAM_ECLUSTERCLEAR_H
|
||||
#define DAYDREAM_ECLUSTERCLEAR_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct ClusterClear : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ECLUSTERCLEAR_H
|
||||
@@ -6,6 +6,7 @@
|
||||
#define DAYDREAM_EHITPAD_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -13,7 +14,8 @@ namespace Events
|
||||
{
|
||||
struct HitPad : Event
|
||||
{
|
||||
|
||||
EntityID Pad;
|
||||
EntityID Ball;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EINKBLASTER_H
|
||||
#define DAYDREAM_EINKBLASTER_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct InkBlaster : Event
|
||||
{
|
||||
Components::Transform* Transform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EINKBLASTER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_EINKBLASTEROVER_H
|
||||
#define DAYDREAM_EINKBLASTEROVER_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct InkBlasterOver : Event
|
||||
{
|
||||
EntityID Ball;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_EINKBLASTEROVER_H
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ELIFEBUOY_H
|
||||
#define DAYDREAM_ELIFEBUOY_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct Lifebuoy : Event
|
||||
{
|
||||
Components::Transform* Transform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ELIFEBUOY_H
|
||||
@@ -0,0 +1,26 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-29.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ELIFEBUOYHIT_H
|
||||
#define DAYDREAM_ELIFEBUOYHIT_H
|
||||
|
||||
#include "Core/Entity.h"
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct LifebuoyHit : Event
|
||||
{
|
||||
EntityID Lifebuoy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ELIFEBUOYHIT_H
|
||||
@@ -9,13 +9,18 @@
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct StageCleared : Event
|
||||
{
|
||||
|
||||
int ClearedStage = 0;
|
||||
int StageCluster = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ESTAGECLEARED_H
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_ESTICKYPAD_H
|
||||
#define DAYDREAM_ESTICKYPAD_H
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct StickyPad : Event
|
||||
{
|
||||
Components::Transform* Transform;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_ESTICKYPAD_H
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "Core/EKeyUp.h"
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/GUI/FPSCounter.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -44,6 +46,8 @@ public:
|
||||
m_FPSCounter = new GUI::FPSCounter(this, "FPSCounter");
|
||||
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EScore, &HUD::OnScore);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameOver, &HUD::OnGameOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ClusterClear, &HUD::OnClusterClear);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -53,14 +57,32 @@ private:
|
||||
NumberFrame* m_StageNumberFrame = nullptr;
|
||||
NumberFrame* m_ScoreNumberFrame = nullptr;
|
||||
FPSCounter* m_FPSCounter = nullptr;
|
||||
TextureFrame* m_GameOverFrame = nullptr;
|
||||
TextureFrame* m_ClusterClearFrame = nullptr;
|
||||
|
||||
EventRelay<Frame, Events::ScoreEvent> m_EScore;
|
||||
EventRelay<Frame, Events::GameOver> m_EGameOver;
|
||||
EventRelay<Frame, Events::ClusterClear> m_ClusterClear;
|
||||
|
||||
bool OnScore(const Events::ScoreEvent& event)
|
||||
{
|
||||
m_ScoreNumberFrame->SetNumber(m_ScoreNumberFrame->Number() + event.Score);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnGameOver(const Events::GameOver& event)
|
||||
{
|
||||
m_GameOverFrame = new GUI::TextureFrame(this, "HUDGameOverFrame");
|
||||
m_GameOverFrame->SetTexture("Textures/GUI/HUD/GameOverScreen.png");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool OnClusterClear(const Events::ClusterClear& event)
|
||||
{
|
||||
m_ClusterClearFrame = new GUI::TextureFrame(this, "HUDGameOverFrame");
|
||||
m_ClusterClearFrame->SetTexture("Textures/GUI/HUD/WinScreen.png");
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CLife.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CPowerUp.h"
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/ELifeLost.h"
|
||||
@@ -22,13 +23,17 @@
|
||||
#include "Game/EScoreEvent.h"
|
||||
#include "Game/EComboEvent.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/EStickyPad.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EMultiBall.h"
|
||||
#include "Game/EMultiBallLost.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EGameOver.h"
|
||||
#include "Game/EClusterClear.h"
|
||||
#include "Game/ECreatePowerUp.h"
|
||||
#include "Game/EPowerUpTaken.h"
|
||||
#include "Game/Bricks/CPowerUpBrick.h"
|
||||
//#include "Game/Bricks/CPowerUpBrick.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
@@ -39,6 +44,8 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -66,8 +73,8 @@ public:
|
||||
void Initialize() override;
|
||||
|
||||
void CreateBasicLevel(int, int, glm::vec2, float);
|
||||
void CreateLevel();
|
||||
void CreateBrick(int, int, glm::vec2, float, int, int);
|
||||
void CreateLevel(int);
|
||||
void CreateBrick(int, int, glm::vec2, float, int, int, int, glm::vec4);
|
||||
|
||||
void OnEntityRemoved(EntityID entity);
|
||||
|
||||
@@ -108,7 +115,7 @@ private:
|
||||
bool m_Initialized = false;
|
||||
bool m_Pause = false;
|
||||
int m_LooseBricks = 0;
|
||||
int m_CurrentCluster = 2;
|
||||
int m_CurrentCluster = 1;
|
||||
int m_CurrentLevel = 1;
|
||||
int m_MultiBalls = 0;
|
||||
int m_PowerUps = 0;
|
||||
@@ -123,10 +130,14 @@ private:
|
||||
const int EmptyBrickSpace = 0;
|
||||
const int StandardBrick = 1;
|
||||
const int MultiBallBrick = 2;
|
||||
const int LifebuoyBrick = 3;
|
||||
const int StickyBrick = 4;
|
||||
const int InkBlasterBrick = 5;
|
||||
|
||||
EntityID m_BrickTemplate;
|
||||
|
||||
std::array<int, 42> m_Bricks;
|
||||
std::array<glm::vec4, 42> m_Colors;
|
||||
|
||||
dd::EventRelay<LevelSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LevelSystem, dd::Events::ScoreEvent> m_EScoreEvent;
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-09.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
#define DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/ELifebuoy.h"
|
||||
#include "Game/ELifebuoyHit.h"
|
||||
#include "Game/CLifebuoy.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class LifebuoySystem : public System
|
||||
{
|
||||
public:
|
||||
LifebuoySystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
bool m_Pause = false;
|
||||
EntityID m_Template;
|
||||
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::Lifebuoy> m_ELifebuoy;
|
||||
dd::EventRelay<LifebuoySystem, dd::Events::LifebuoyHit> m_ELifebuoyHit;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
|
||||
bool OnLifebuoyHit(const dd::Events::LifebuoyHit &event);
|
||||
|
||||
struct LifebuoyInfo
|
||||
{
|
||||
EntityID Entity;
|
||||
//int Hits = 4;
|
||||
};
|
||||
|
||||
float m_LeftEdge = -3.8f;
|
||||
float m_RightEdge = 3.8f;
|
||||
float m_DownLimit = -5.3f;
|
||||
float m_DownEdge = -9.2f;
|
||||
std::list<LifebuoyInfo> m_Lifebuoys;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_LIFEBUOYSYSTEM_H
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EHitLag.h"
|
||||
#include "Game/EActionButton.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-09-09.
|
||||
//
|
||||
|
||||
#ifndef DAYDREAM_PROJECTILESYSTEM_H
|
||||
#define DAYDREAM_PROJECTILESYSTEM_H
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Rendering/CModel.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/EInkBlaster.h"
|
||||
#include "Game/EInkBlasterOver.h"
|
||||
#include "Game/EActionButton.h"
|
||||
#include "Game/EHitPad.h"
|
||||
#include "Game/CProjectile.h"
|
||||
#include "Game/CBall.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
namespace Systems
|
||||
{
|
||||
|
||||
class ProjectileSystem : public System
|
||||
{
|
||||
public:
|
||||
ProjectileSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
: System(world, eventBroker)
|
||||
{ }
|
||||
|
||||
void Initialize() override;
|
||||
|
||||
void Update(double dt) override;
|
||||
void UpdateEntity(double dt, EntityID entity, EntityID parent) override;
|
||||
|
||||
bool IsPaused() const { return m_Pause; }
|
||||
void SetPause(const bool& pause) { m_Pause = pause; }
|
||||
|
||||
private:
|
||||
bool m_Pause = false;
|
||||
bool m_InkBlaster = false;
|
||||
bool m_SquidLoaded = false;
|
||||
int m_Shots = 0;
|
||||
EntityID m_InkBlastTemplate;
|
||||
EntityID m_AttachedSquid;
|
||||
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Contact> m_EContact;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::Pause> m_EPause;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::InkBlaster> m_EInkBlaster;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::HitPad> m_EHitPad;
|
||||
dd::EventRelay<ProjectileSystem, dd::Events::ActionButton> m_EActionButton;
|
||||
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
bool OnInkBlaster(const dd::Events::InkBlaster &event);
|
||||
bool OnHitPad(const dd::Events::HitPad &event);
|
||||
bool OnActionButton(const dd::Events::ActionButton &event);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //DAYDREAM_PROJECTILESYSTEM_H
|
||||
@@ -9,10 +9,18 @@ namespace Components
|
||||
|
||||
struct ParticleEmitter : public Component
|
||||
{
|
||||
int Amount = 10.f;
|
||||
EntityID Parent = 0;
|
||||
int NumberOfTicks = 10.f;
|
||||
float InitialSpeed = 1.f;
|
||||
double SpawnRate = 1.f;
|
||||
double TimeSinceLastSpawn = 0;
|
||||
double SpawnRate = 1;
|
||||
int ParticlesPerTick = 1;
|
||||
//TODO: Refactor. Have cooldown instead of this
|
||||
double TimeSinceLastSpawn = 100;
|
||||
int MaxCount = 0;
|
||||
float EmittingAngle = 0.f;
|
||||
float Spread = 0.f;
|
||||
float Speed = 2.f;
|
||||
double LifeTime = 100;
|
||||
|
||||
//System variables
|
||||
float GravityScale = 1.0f;
|
||||
|
||||
@@ -9,13 +9,15 @@ namespace CollisionLayer
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
Pad = 1 << 0,
|
||||
Ball = 1 << 1,
|
||||
Brick = 1 << 2,
|
||||
Water = 1 << 3,
|
||||
PowerUp = 1 << 4,
|
||||
Other = 1 << 5,
|
||||
Wall = 1 << 6
|
||||
Pad = 1 << 0,
|
||||
Ball = 1 << 1,
|
||||
Brick = 1 << 2,
|
||||
Water = 1 << 3,
|
||||
PowerUp = 1 << 4,
|
||||
Other = 1 << 5,
|
||||
Wall = 1 << 6,
|
||||
LifeBuoy = 1 << 7,
|
||||
Projectile = 1 << 8
|
||||
};
|
||||
}
|
||||
|
||||
@@ -39,20 +41,21 @@ enum Type
|
||||
|
||||
bool Calculate = false;
|
||||
float GravityScale = 0.f;
|
||||
float Density = 20.f;
|
||||
|
||||
|
||||
CollisionLayer::Type Category = CollisionLayer::Type::Other;
|
||||
CollisionLayer::Type Mask = static_cast<CollisionLayer::Type>(
|
||||
CollisionLayer::Pad
|
||||
| CollisionLayer::Ball
|
||||
| CollisionLayer::Brick
|
||||
| CollisionLayer::Water
|
||||
| CollisionLayer::PowerUp
|
||||
| CollisionLayer::Wall
|
||||
| CollisionLayer::Other
|
||||
);
|
||||
};
|
||||
|
||||
CollisionLayer::Type Mask = static_cast<CollisionLayer::Type>(
|
||||
CollisionLayer::Pad
|
||||
| CollisionLayer::Ball
|
||||
| CollisionLayer::Brick
|
||||
| CollisionLayer::Water
|
||||
| CollisionLayer::PowerUp
|
||||
| CollisionLayer::Wall
|
||||
| CollisionLayer::LifeBuoy
|
||||
| CollisionLayer::Other
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ struct Contact : Event
|
||||
{
|
||||
EntityID Entity1;
|
||||
EntityID Entity2;
|
||||
glm::vec2 IntersectionPoint;
|
||||
glm::vec2 Normal;
|
||||
glm::vec2 SignificantNormal;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
#ifndef EVENTS_ECREATEPARTICLESEQUENCE_H__
|
||||
#define EVENTS_ECREATEPARTICLESEQUENCE_H__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Physics/CParticle.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct CreateParticleSequence : public Event
|
||||
{
|
||||
//Emitter
|
||||
double EmitterLifeTime = 100;
|
||||
glm::vec3 Position = glm::vec3(0);
|
||||
float GravityScale = 0.f;
|
||||
float SpawnRate = 1.f;
|
||||
int NumberOfTicks = 100;
|
||||
float Speed = 1.f;
|
||||
int ParticlesPerTick = 1.f;
|
||||
float Spread = 1.f;
|
||||
float EmittingAngle = 0.f;
|
||||
float MaxCount = 0;
|
||||
glm::vec4 Color = glm::vec4(0);
|
||||
EntityID parent = 0;
|
||||
|
||||
//Particle
|
||||
std::string SpriteFile = "";
|
||||
double ParticleLifeTime = 3.f;
|
||||
ParticleFlags::Type Flags = static_cast<ParticleFlags::Type>(ParticleFlags::Powder | ParticleFlags::ParticleContactFilter | ParticleFlags::FixtureContactFilter);
|
||||
float Radius = 1.f;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define DAYDREAM_PHYSICSSYSTEM_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <random>
|
||||
|
||||
#include <Box2D/Box2D.h>
|
||||
|
||||
@@ -9,27 +10,35 @@
|
||||
#include "Core/World.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Core/CTemplate.h"
|
||||
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CRectangleShape.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/CWaterVolume.h"
|
||||
#include "Core/CTransform.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "CRectangleShape.h"
|
||||
#include "Physics/CPhysics.h"
|
||||
#include "Physics/EContact.h"
|
||||
#include "Physics/ESetImpulse.h"
|
||||
#include "Physics/CParticle.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
#include "Physics/CCircleShape.h"
|
||||
#include "Physics/CParticleEmitter.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBall.h"
|
||||
|
||||
#include "Transform/TransformSystem.h"
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Core/CTemplate.h"
|
||||
#include "Transform/TransformSystem.h"
|
||||
|
||||
#include "CRectangleShape.h"
|
||||
|
||||
#include "Game/EStageCleared.h"
|
||||
#include "Game/EPause.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CBall.h"
|
||||
|
||||
#include "Rendering/CSprite.h"
|
||||
#include "Rendering/CModel.h"
|
||||
|
||||
|
||||
namespace dd
|
||||
{
|
||||
@@ -40,6 +49,7 @@ namespace dd
|
||||
class PhysicsSystem : public System
|
||||
{
|
||||
friend class ContractListener;
|
||||
friend class DestructionListener;
|
||||
|
||||
public:
|
||||
PhysicsSystem(World* world, std::shared_ptr<dd::EventBroker> eventBroker)
|
||||
@@ -47,6 +57,9 @@ namespace dd
|
||||
|
||||
~PhysicsSystem();
|
||||
|
||||
EventRelay<PhysicsSystem, Events::CreateParticleSequence> m_ECreateParticleSequence;
|
||||
bool CreateParticleSequence(const Events::CreateParticleSequence &event);
|
||||
|
||||
void RegisterComponents(ComponentFactory* cf) override;
|
||||
void Initialize() override;
|
||||
void Update(double dt) override;
|
||||
@@ -62,6 +75,8 @@ namespace dd
|
||||
b2Vec2 Point;
|
||||
};
|
||||
bool m_Pause = false;
|
||||
|
||||
std::mt19937 gen;
|
||||
|
||||
|
||||
b2Vec2 m_Gravity = b2Vec2(0.f, -9.82f);
|
||||
@@ -71,9 +86,11 @@ namespace dd
|
||||
int m_VelocityIterations = 6;
|
||||
int m_PositionIterations = 2;
|
||||
|
||||
std::vector<b2ParticleSystem*> m_ParticleSystem;
|
||||
b2ParticleSystem* m_WaterParticleSystem;
|
||||
std::vector<b2ParticleGroup*> t_ParticleGroup;
|
||||
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID> m_WaterParticleHandleToEntities;
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*> m_EntitiesToWaterParticleHandle;
|
||||
std::vector<std::unordered_map<EntityID, const b2ParticleHandle*>> m_EntitiesToParticleHandle;
|
||||
std::vector<std::unordered_map<const b2ParticleHandle*, EntityID>> m_ParticleHandleToEntities;
|
||||
std::unordered_map<EntityID, b2Body*> m_EntitiesToBodies;
|
||||
@@ -87,7 +104,7 @@ namespace dd
|
||||
void InitializeWater();
|
||||
void CreateParticleGroup(EntityID entity);
|
||||
|
||||
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale);
|
||||
b2ParticleSystem* CreateParticleSystem(float radius, float gravityScale, int maxCount);
|
||||
void CreateParticleEmitter(EntityID entity);
|
||||
void UpdateParticleEmitters(double dt); //TODO: Remove them and particles if needed.
|
||||
|
||||
@@ -95,36 +112,95 @@ namespace dd
|
||||
bool SetImpulse(const Events::SetImpulse &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Pause> m_EPause;
|
||||
bool OnPause(const dd::Events::Pause &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::StageCleared> m_EStageCleared;
|
||||
bool OnStageCleared(const dd::Events::StageCleared &event);
|
||||
dd::EventRelay<PhysicsSystem, dd::Events::Contact> m_EContact;
|
||||
bool OnContact(const dd::Events::Contact &event);
|
||||
bool m_Travelling = false;
|
||||
float m_DistanceTravelled = 0;
|
||||
|
||||
//TODO: Fill struct with info needed.
|
||||
struct ParticleEmitter
|
||||
{
|
||||
std::vector<b2ParticleSystem*> System;
|
||||
std::vector<EntityID> Emitter;
|
||||
std::vector<EntityID> Template;
|
||||
};
|
||||
ParticleEmitter m_ParticleEmitters;
|
||||
struct EmitterHandler //TODO CHANGE NAMES
|
||||
{
|
||||
std::vector<b2ParticleSystem*> ParticleSystem;
|
||||
std::vector<EntityID> ParticleEmitter;
|
||||
std::vector<EntityID> ParticleTemplate;
|
||||
};
|
||||
EmitterHandler m_ParticleEmitters;
|
||||
|
||||
std::list<Impulse> m_Impulses;
|
||||
|
||||
|
||||
class DestructionListener : public b2DestructionListener
|
||||
{
|
||||
public:
|
||||
DestructionListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
void SayGoodbye(b2Joint*) {LOG_INFO("joint körs");};
|
||||
void SayGoodbye(b2Fixture*) {/*LOG_INFO("Fixture körs");*/};
|
||||
|
||||
void SayGoodbye(b2ParticleSystem* particleSystem, int32 index) override
|
||||
{
|
||||
LOG_INFO("Particle ded");
|
||||
|
||||
|
||||
const b2ParticleHandle* handle = particleSystem->GetParticleHandleFromIndex(index);
|
||||
for (int i = 0; i < m_PhysicsSystem->m_ParticleEmitters.ParticleSystem.size(); i++) {
|
||||
if(m_PhysicsSystem->m_ParticleEmitters.ParticleSystem[i] == particleSystem) {
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID>::iterator it = m_PhysicsSystem->m_ParticleHandleToEntities[i].find(handle);
|
||||
if(it != m_PhysicsSystem->m_ParticleHandleToEntities[i].end()) {
|
||||
EntityID id = it->second;
|
||||
m_PhysicsSystem->m_World->RemoveEntity(id);
|
||||
m_PhysicsSystem->m_ParticleHandleToEntities[i].erase(it);
|
||||
LOG_INFO("Removing from list");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
class ParticleContactDisabler : public b2ContactFilter
|
||||
{
|
||||
public:
|
||||
ParticleContactDisabler() { };
|
||||
|
||||
//Particles to particles
|
||||
virtual bool ShouldCollide(b2ParticleSystem *particleSystem, int32 particleIndexA, int32 particleIndexB)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
virtual bool ShouldCollide(b2Fixture* fixture, b2ParticleSystem* particleSystem, int32 particleIndex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
class ContactListener : public b2ContactListener
|
||||
{
|
||||
public:
|
||||
ContactListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
void BeginContact(b2Contact* contact);
|
||||
void EndContact(b2Contact* contact);
|
||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
|
||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
|
||||
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
class ContactListener : public b2ContactListener
|
||||
{
|
||||
public:
|
||||
ContactListener(PhysicsSystem* physicsSystem)
|
||||
: m_PhysicsSystem(physicsSystem) { }
|
||||
|
||||
ContactListener* m_ContactListener;
|
||||
void BeginContact(b2Contact* contact);
|
||||
void EndContact(b2Contact* contact);
|
||||
void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
|
||||
void PostSolve(b2Contact* contact, const b2ContactImpulse* impulse);
|
||||
|
||||
private:
|
||||
PhysicsSystem* m_PhysicsSystem;
|
||||
};
|
||||
|
||||
DestructionListener* m_DestructionListener;
|
||||
ParticleContactDisabler* m_ParticleContactDisabler;
|
||||
ContactListener* m_ContactListener;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Game/CBall.h"
|
||||
#include "Game/CBrick.h"
|
||||
#include "Game/CPad.h"
|
||||
#include "Physics/ECreateParticleSequence.h"
|
||||
|
||||
namespace dd
|
||||
{
|
||||
|
||||
@@ -358,12 +358,10 @@ void dd::Renderer::DrawForward(RenderQueue &objects, RenderQueue &lights)
|
||||
{
|
||||
// Forward-render semi-transparent objects on top of the current framebuffer
|
||||
glDisable(GL_CULL_FACE);
|
||||
glCullFace(GL_BACK);
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
//glBlendEquationSeparate(GL_FUNC_ADD, GL_FUNC_ADD);
|
||||
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_FbDeferred3);
|
||||
// glClearColor(1, 0.9, 0.8f, 1);
|
||||
@@ -444,7 +442,6 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(viewMatrix));
|
||||
glUniform4fv(glGetUniformLocation(shaderProgramHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
|
||||
@@ -30,6 +30,7 @@ uniform vec3 LightPosition;
|
||||
uniform float LightRadius;
|
||||
uniform vec3 LightSpecular;
|
||||
uniform vec3 LightDiffuse;
|
||||
uniform vec4 Color;
|
||||
|
||||
in VertexData
|
||||
{
|
||||
@@ -86,5 +87,5 @@ void main()
|
||||
vec4 La = vec4(0.3, 0.3, 0.3, 1.0);
|
||||
vec4 light = phong(Input.Position, normalize(normal), specularTexel.rgb, specularTexel.a);
|
||||
//frag_Diffuse = light;
|
||||
frag_Diffuse = diffuseTexel;
|
||||
frag_Diffuse = diffuseTexel * Color;
|
||||
}
|
||||
@@ -18,7 +18,11 @@ void dd::Systems::BallSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBallLost, &BallSystem::OnMultiBallLost);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EResetBall, &BallSystem::OnResetBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EMultiBall, &BallSystem::OnMultiBall);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStickyPad, &BallSystem::OnStickyPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &BallSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlasterOver, &BallSystem::OnInkBlasterOver);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &BallSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
|
||||
|
||||
//OctoBall
|
||||
{
|
||||
@@ -33,15 +37,14 @@ void dd::Systems::BallSystem::Initialize()
|
||||
circleShape->Radius = 0.4f;
|
||||
std::shared_ptr<Components::Ball> ball = m_World->AddComponent<Components::Ball>(ent);
|
||||
ball->Speed = 5.f;
|
||||
ball->Waiting = true;
|
||||
std::shared_ptr<Components::Physics> physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
physics->Category = CollisionLayer::Type::Ball;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||
physics->Calculate = true;
|
||||
|
||||
//auto plight = m_World->AddComponent<Components::PointLight>(ent);
|
||||
//plight->Radius = 2.f;
|
||||
transform->Sticky = true;
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
@@ -60,11 +63,17 @@ void dd::Systems::BallSystem::Initialize()
|
||||
|
||||
void dd::Systems::BallSystem::Update(double dt)
|
||||
{
|
||||
if (Lives() < 0)
|
||||
if (Lives() == 0)
|
||||
{
|
||||
SetLives(3);
|
||||
Events::GameOver e;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
Events::Pause p;
|
||||
p.Type = "All";
|
||||
EventBroker->Publish(p);
|
||||
|
||||
//TODO: Make this not so ugly
|
||||
SetLives(-1);
|
||||
}
|
||||
ResolveContacts();
|
||||
}
|
||||
@@ -100,14 +109,38 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
if (ballComponent != nullptr) {
|
||||
if (ReplaceBall()) {
|
||||
SetReplaceBall(false);
|
||||
if (ReplaceBall()) {
|
||||
SetReplaceBall(false);
|
||||
m_Waiting = true;
|
||||
ballComponent->Waiting = true;
|
||||
}
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Position = glm::vec3(0.0f, 0.26f, -10.f);
|
||||
transform->Velocity = glm::vec3(0.0f, -ballComponent->Speed, 0.f);
|
||||
if (ballComponent->Waiting) {
|
||||
if (!m_Waiting) {
|
||||
ballComponent->Waiting = false;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::normalize(glm::vec3(0.5f, 1, 0.f)) * ballComponent->Speed;
|
||||
} else if (!ballComponent->Sticky) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
transform->Position = glm::vec3(0.0f, -3.f, -10.f);
|
||||
transform->Orientation = glm::quat();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (ballComponent->Sticky) {
|
||||
if (!m_Waiting)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Velocity = ballComponent->SavedSpeed;
|
||||
m_StickyCounter--;
|
||||
if (m_StickyCounter > 0) {
|
||||
m_Sticky = true;
|
||||
}
|
||||
ballComponent->Sticky = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (glm::abs(transformBall->Velocity.y) < 2) {
|
||||
if (transformBall->Velocity.y > 0) {
|
||||
@@ -116,7 +149,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
transformBall->Velocity.y = -2;
|
||||
}
|
||||
}
|
||||
if (transformBall->Position.y < -EdgeY() - 4) {
|
||||
if (transformBall->Position.y < -EdgeY() - 4 || transformBall->Position.y > EdgeY() + 4) {
|
||||
if (MultiBalls() != 0) {
|
||||
m_World->RemoveEntity(entity);
|
||||
Events::MultiBallLost e;
|
||||
@@ -224,44 +257,64 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
//TODO: Add support for power-up collisions
|
||||
}
|
||||
|
||||
auto brick = m_World->GetComponent<Components::Brick>(otherEntitiy);
|
||||
if (brick != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
auto physics = m_World->GetComponent<Components::Physics>(otherEntitiy);
|
||||
auto rectangle = m_World->GetComponent<Components::RectangleShape>(otherEntitiy);
|
||||
int hey = 5;
|
||||
}
|
||||
|
||||
//if this is a brick thats dead do not collide :)
|
||||
|
||||
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(ballEntity);
|
||||
glm::vec2 ballVelocity = glm::vec2(ballTransform->Velocity.x, ballTransform->Velocity.y);
|
||||
|
||||
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad"){
|
||||
|
||||
if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Pad") {
|
||||
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
|
||||
Events::HitPad e;
|
||||
e.Ball = ballEntity;
|
||||
e.Pad = otherEntitiy;
|
||||
EventBroker->Publish(e);
|
||||
// Events::HitLag el;
|
||||
// el.Time = 0.1f;
|
||||
//el.Type = "All";
|
||||
// EventBroker->Publish(el);
|
||||
|
||||
auto padTransform = m_World->GetComponent<Components::Transform>(otherEntitiy);
|
||||
float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier();
|
||||
|
||||
|
||||
float x = (ballTransform->Position.x - padTransform->Position.x) * XMovementMultiplier();
|
||||
float y = glm::cos((abs(x) / (1.6f)) * glm::pi<float>() / 2.f) + 1.f;
|
||||
|
||||
ballComponent->Combo = 0;
|
||||
|
||||
if (m_InkBlaster) {
|
||||
if (!m_InkAttached) {
|
||||
m_InkAttached = true;
|
||||
m_Waiting = true;
|
||||
m_BlockedWaiting = true;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->StickyPlacement = glm::vec3(0, 0.5f, 0);
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity = glm::vec3(0.f, 0.f, 0.f);
|
||||
}
|
||||
} else if (m_Sticky) {
|
||||
m_Sticky = false;
|
||||
m_Waiting = true;
|
||||
ballComponent->Sticky = true;
|
||||
ballComponent->StickyPlacement = ballTransform->Position - padTransform->Position;
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(x, y, 0.f)) * ballComponent->Speed;
|
||||
ballTransform->Velocity *= -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
ballTransform->Velocity = glm::normalize(glm::vec3(x, y ,0.f)) * ballComponent->Speed;
|
||||
ballComponent->Combo = 0;
|
||||
Events::ComboEvent ec;
|
||||
ec.Combo = ballComponent->Combo;
|
||||
ec.Ball = ballEntity;
|
||||
EventBroker->Publish(ec);
|
||||
//std::cout << "Combo: " << ballComponent->Combo << std::endl;
|
||||
}
|
||||
else {
|
||||
} // Lifebuoy should always reflect the ball upwards
|
||||
else if (m_World->GetProperty<std::string>(otherEntitiy, "Name") == "Lifebuoy"){
|
||||
ballTransform->Velocity = glm::vec3(ballTransform->Velocity.x, abs(ballTransform->Velocity.y), ballTransform->Velocity.z);
|
||||
Events::LifebuoyHit e;
|
||||
e.Lifebuoy = otherEntitiy;
|
||||
EventBroker->Publish(e);
|
||||
} else {
|
||||
auto it = m_Contacts.find(ballEntity);
|
||||
if (it == m_Contacts.end()) {
|
||||
std::list<glm::vec2> normalList;
|
||||
@@ -272,9 +325,6 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
|
||||
normalList.push_back(event.Normal);
|
||||
m_Contacts[ballEntity] = normalList;
|
||||
}
|
||||
|
||||
//glm::vec2 reflectedVelocity = glm::reflect(ballVelocity, event.Normal);
|
||||
//ballTransform->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -285,23 +335,18 @@ void dd::Systems::BallSystem::ResolveContacts()
|
||||
{
|
||||
|
||||
for (auto c : m_Contacts) {
|
||||
int count = 0;
|
||||
EntityID entity = c.first;
|
||||
std::list<glm::vec2> contactNormals = c.second;
|
||||
glm::vec2 finalNormal = glm::vec2(0.f);
|
||||
for (auto it = contactNormals.begin(); it != contactNormals.end(); it++) {
|
||||
finalNormal = finalNormal + (*it);
|
||||
count++;
|
||||
}
|
||||
finalNormal = glm::normalize(finalNormal);
|
||||
|
||||
if (count > 1) {
|
||||
LOG_INFO("MultiCollision %i", count);
|
||||
}
|
||||
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
glm::vec2 velocity = glm::vec2(transform->Velocity.x, transform->Velocity.y);
|
||||
glm::vec2 reflectedVelocity = glm::reflect(velocity, finalNormal);
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(entity);
|
||||
reflectedVelocity = glm::normalize(reflectedVelocity) * ballComponent->Speed;
|
||||
transform->Velocity = glm::vec3(reflectedVelocity, 0.f);
|
||||
|
||||
}
|
||||
@@ -324,6 +369,7 @@ void dd::Systems::BallSystem::CreateLife(int number)
|
||||
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(life);
|
||||
transform->Position = glm::vec3(-1.5f + number * 0.15f, -2.f, -5.f);
|
||||
transform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
transform->Sticky = true;
|
||||
|
||||
std::shared_ptr<Components::Life> lifeNr = m_World->AddComponent<Components::Life>(life);
|
||||
lifeNr->Number = number;
|
||||
@@ -367,8 +413,10 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
|
||||
auto transform2 = m_World->GetComponent<Components::Transform>(ent2);
|
||||
auto ball1 = m_World->GetComponent<Components::Ball>(ent1);
|
||||
auto ball2 = m_World->GetComponent<Components::Ball>(ent2);
|
||||
ball1->Waiting = false;
|
||||
ball2->Waiting = false;
|
||||
auto padTransform = event.padTransform;
|
||||
float x1 = padTransform->Position.x - 2, x2 = padTransform->Position.x + 2;
|
||||
float x1 = padTransform->Position.x/* - 2*/, x2 = padTransform->Position.x/* + 2*/;
|
||||
if (x1 < -m_EdgeX) {
|
||||
x1 = m_EdgeX - 0.2;
|
||||
}
|
||||
@@ -386,3 +434,39 @@ bool dd::Systems::BallSystem::OnMultiBall(const dd::Events::MultiBall &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnStickyPad(const dd::Events::StickyPad &event)
|
||||
{
|
||||
m_Sticky = true;
|
||||
m_StickyCounter = 5;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||
{
|
||||
m_InkBlaster = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnInkBlasterOver(const dd::Events::InkBlasterOver &event)
|
||||
{
|
||||
auto ballComponent = m_World->GetComponent<Components::Ball>(event.Ball);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(event.Ball);
|
||||
|
||||
m_InkBlaster = false;
|
||||
m_InkAttached = false;
|
||||
m_BlockedWaiting = false;
|
||||
m_Sticky = true;
|
||||
ballComponent->SavedSpeed = glm::normalize(glm::vec3(0.f, 1.f, 0.f)) * ballComponent->Speed;
|
||||
m_Waiting = false;
|
||||
transform->Velocity = glm::normalize(glm::vec3(0.f, 1, 0.f)) * ballComponent->Speed;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::BallSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
if (!m_BlockedWaiting) {
|
||||
m_Waiting = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,13 @@ void dd::Systems::LevelSystem::Initialize()
|
||||
cRec->Dimensions = glm::vec2(0.9f, 0.35f);
|
||||
std::shared_ptr<Components::Physics> cPhys = m_World->AddComponent<Components::Physics>(m_BrickTemplate);
|
||||
std::shared_ptr<Components::Template> cTemplate = m_World->AddComponent<Components::Template>(m_BrickTemplate);
|
||||
cPhys->CollisionType = CollisionType::Type::Dynamic;
|
||||
cPhys->CollisionType = CollisionType::Type::Static;
|
||||
cPhys->GravityScale = 0.f;
|
||||
cPhys->Category = CollisionLayer::Type::Brick;
|
||||
cPhys->Mask = CollisionLayer::Type::Ball;
|
||||
cPhys->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Ball | CollisionLayer::Type::Projectile | CollisionLayer::Type::Wall | CollisionLayer::LifeBuoy);
|
||||
transform->Sticky = false;
|
||||
|
||||
model->ModelFile = "Models/Brick/TurquoiseBrick.obj";
|
||||
model->ModelFile = "Models/Brick/WhiteBrick.obj";
|
||||
transform->Position = glm::vec3(50, 50, -10);
|
||||
|
||||
//sound
|
||||
@@ -48,7 +49,7 @@ void dd::Systems::LevelSystem::Update(double dt)
|
||||
{
|
||||
if (!m_Initialized) {
|
||||
GetNextLevel();
|
||||
CreateLevel();
|
||||
CreateLevel(0);
|
||||
m_Initialized = true;
|
||||
}
|
||||
}
|
||||
@@ -61,16 +62,38 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
// Check the background.
|
||||
auto model = m_World->GetComponent<Components::Model>(entity);
|
||||
if (model != nullptr) {
|
||||
if (model->ModelFile == "Models/Test/halfpipe/Halfpipe.obj") {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y <= -34.6) {
|
||||
transform->Position.y = 34.6;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto brick = m_World->GetComponent<Components::Brick>(entity);
|
||||
if (brick != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
//Removes bricks that falls out of the stage.
|
||||
if (transform->Position.y < -10) {
|
||||
if (brick->Type == MultiBallBrick) {
|
||||
if (transform->Position.y < -10) {
|
||||
if (brick->Type == StandardBrick) {
|
||||
} else if (brick->Type == MultiBallBrick) {
|
||||
Events::MultiBall e;
|
||||
e.padTransform = transform;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
} else if (brick->Type == LifebuoyBrick) {
|
||||
Events::Lifebuoy e;
|
||||
e.Transform = transform;
|
||||
EventBroker->Publish(e);
|
||||
} else if (brick->Type == StickyBrick) {
|
||||
Events::StickyPad e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (brick->Type == InkBlasterBrick) {
|
||||
Events::InkBlaster e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
m_LooseBricks--;
|
||||
m_World->RemoveEntity(entity);
|
||||
}
|
||||
@@ -81,6 +104,8 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
|
||||
if (NumberOfBricks() <= 0 && m_LooseBricks <= 0 && !Restarting()) {
|
||||
if (MultiBalls() <= 0 && PowerUps() <= 0) {
|
||||
Events::StageCleared ec;
|
||||
ec.ClearedStage = m_CurrentLevel;
|
||||
ec.StageCluster = m_CurrentCluster;
|
||||
EventBroker->Publish(ec);
|
||||
} else {
|
||||
if (ball != nullptr && MultiBalls() > 0) {
|
||||
@@ -125,7 +150,7 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
||||
for (int i = 0; i < rows; i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, num, 1);
|
||||
CreateBrick(i, j, spacesBetweenBricks, spaceToEdge, 0, num, 1, glm::vec4(0, 0, 0, 0));
|
||||
}
|
||||
if (num == 1)
|
||||
num = Lines();
|
||||
@@ -136,7 +161,7 @@ void dd::Systems::LevelSystem::CreateBasicLevel(int rows, int lines, glm::vec2 s
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateLevel()
|
||||
void dd::Systems::LevelSystem::CreateLevel(int aboveBasicLevel)
|
||||
{
|
||||
std::cout << "Loading level: " << m_CurrentLevel << std::endl;
|
||||
SetNumberOfBricks(Rows() * Lines());
|
||||
@@ -146,7 +171,7 @@ void dd::Systems::LevelSystem::CreateLevel()
|
||||
for (int i = 0; i < Rows(); i++) {
|
||||
num--;
|
||||
for (int j = 0; j < Lines(); j++) {
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), num, m_Bricks[getter]);
|
||||
CreateBrick(i, j, SpaceBetweenBricks(), SpaceToEdge(), aboveBasicLevel, num, m_Bricks[getter], m_Colors[getter]);
|
||||
getter++;
|
||||
}
|
||||
if (num == 1) {
|
||||
@@ -157,7 +182,7 @@ void dd::Systems::LevelSystem::CreateLevel()
|
||||
SetRestarting(false);
|
||||
}
|
||||
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int num, int typeInt)
|
||||
void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBetweenBricks, float spaceToEdge, int aboveLevel, int num, int typeInt, glm::vec4 colorVec)
|
||||
{
|
||||
if (typeInt == EmptyBrickSpace) {
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
@@ -167,17 +192,27 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
|
||||
m_World->RemoveComponent<Components::Template>(brick);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(brick);
|
||||
auto cBrick = m_World->GetComponent<Components::Brick>(brick);
|
||||
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
if (typeInt == StandardBrick) {
|
||||
model->Color = colorVec;
|
||||
} else if (typeInt == MultiBallBrick) {
|
||||
cBrick->Type = MultiBallBrick;
|
||||
std::shared_ptr<Components::PowerUpBrick> cPow = m_World->AddComponent<Components::PowerUpBrick>(brick);
|
||||
auto model = m_World->GetComponent<Components::Model>(brick);
|
||||
model->ModelFile = "Models/Brick/IceBrick.obj";
|
||||
}
|
||||
} else if (typeInt == LifebuoyBrick) {
|
||||
cBrick->Type = LifebuoyBrick;
|
||||
model->ModelFile = "Models/Brick/LifeBuoyBrick.obj";
|
||||
} else if (typeInt == StickyBrick) {
|
||||
cBrick->Type = StickyBrick;
|
||||
model->ModelFile = "Models/Brick/StickyBrick.obj";
|
||||
} else if (typeInt == InkBlasterBrick) {
|
||||
cBrick->Type = InkBlasterBrick;
|
||||
model->Color = glm::vec4(0.1f, 0.1f, 0.1f, 1.0f);
|
||||
}
|
||||
|
||||
|
||||
float x = line * spacesBetweenBricks.x;
|
||||
float y = row * spacesBetweenBricks.y;
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y , -10.f);
|
||||
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
|
||||
cBrick->Score = 10 * num;
|
||||
return;
|
||||
}
|
||||
@@ -191,6 +226,7 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
EntityID entityBrick;
|
||||
EntityID entityBall;
|
||||
EntityID entityShot = 0;
|
||||
auto ball = m_World->GetComponent<Components::Ball>(event.Entity2);
|
||||
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
|
||||
if (brick != nullptr) {
|
||||
@@ -210,7 +246,17 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
if (ball != nullptr) {
|
||||
entityBall = event.Entity1;
|
||||
} else {
|
||||
return false;
|
||||
auto shot = m_World->GetComponent<Components::Projectile>(event.Entity1);
|
||||
if (shot != nullptr) {
|
||||
entityShot = event.Entity1;
|
||||
} else {
|
||||
shot = m_World->GetComponent<Components::Projectile>(event.Entity2);
|
||||
if (shot != nullptr) {
|
||||
entityShot = event.Entity2;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,13 +265,54 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
return false;
|
||||
}
|
||||
|
||||
/*auto power = m_World->GetComponent<Components::PowerUpBrick>(entityBrick);
|
||||
if (power != nullptr && NumberOfBricks() > 1) {
|
||||
Events::CreatePowerUp e;
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
e.Position = transform->Position;
|
||||
EventBroker->Publish(e);
|
||||
}*/
|
||||
if (entityShot != 0) {
|
||||
// For when a brick gets shot.
|
||||
brick->Removed = true;
|
||||
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
physicsComponent->GravityScale = 1.f;
|
||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||
|
||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
auto transformComponentShot = m_World->GetComponent<Components::Transform>(entityShot);
|
||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
||||
|
||||
Events::SetImpulse e;
|
||||
e.Entity = entityBrick;
|
||||
|
||||
glm::vec2 point = glm::vec2(transformComponentBrick->Position.x + ((transformComponentShot->Position.x - transformComponentBrick->Position.x) / 4),
|
||||
transformComponentBrick->Position.y + ((transformComponentShot->Position.y - transformComponentBrick->Position.y) / 4));
|
||||
|
||||
e.Impulse = glm::normalize(point)*5.f;
|
||||
e.Point = point;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
|
||||
SetNumberOfBricks(NumberOfBricks() - 1);
|
||||
Events::ScoreEvent es;
|
||||
es.Score = brick->Score;
|
||||
EventBroker->Publish(es);
|
||||
|
||||
m_World->RemoveEntity(entityShot);
|
||||
|
||||
Events::CreateParticleSequence ep;
|
||||
ep.parent = entityBrick;
|
||||
ep.EmitterLifeTime = 1.f;
|
||||
ep.ParticleLifeTime = 1.5f;
|
||||
ep.ParticlesPerTick = 1;
|
||||
ep.SpawnRate = 0.2;
|
||||
ep.EmittingAngle = glm::half_pi<float>();
|
||||
ep.Spread = 1.5f;
|
||||
ep.Position = transformComponentBrick->Position;
|
||||
ep.Radius = 0.05;
|
||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
||||
ep.Speed = 50;
|
||||
EventBroker->Publish(ep);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Restarting() && !brick->Removed) {
|
||||
brick->Removed = true;
|
||||
@@ -239,11 +326,13 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
auto ballTransform = m_World->GetComponent<Components::Transform>(entityBall);
|
||||
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(entityBrick);
|
||||
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
|
||||
physicsComponent->GravityScale = 1.f;
|
||||
physicsComponent->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Water | CollisionLayer::Wall);
|
||||
|
||||
auto transformComponentBrick = m_World->GetComponent<Components::Transform>(entityBrick);
|
||||
auto transformComponentBall = m_World->GetComponent<Components::Transform>(entityBall);
|
||||
auto brickModel = m_World->GetComponent<Components::Model>(entityBrick);
|
||||
|
||||
Events::SetImpulse e;
|
||||
e.Entity = entityBrick;
|
||||
@@ -262,6 +351,21 @@ bool dd::Systems::LevelSystem::OnContact(const dd::Events::Contact &event)
|
||||
es.Score = brick->Score * ball->Combo;
|
||||
EventBroker->Publish(es);
|
||||
|
||||
Events::CreateParticleSequence ep;
|
||||
ep.parent = entityBrick;
|
||||
ep.EmitterLifeTime = 1.f;
|
||||
ep.ParticleLifeTime = 1.5f;
|
||||
ep.ParticlesPerTick = 1;
|
||||
ep.SpawnRate = 0.2;
|
||||
ep.EmittingAngle = glm::half_pi<float>();
|
||||
ep.Spread = 1.5f;
|
||||
ep.Position = transformComponentBrick->Position;
|
||||
ep.Radius = 0.05;
|
||||
ep.SpriteFile = "Textures/Particles/FadeBall.png";
|
||||
ep.Color = brickModel->Color + glm::vec4(0.3f);
|
||||
ep.Speed = 50;
|
||||
EventBroker->Publish(ep);
|
||||
|
||||
//std::cout << "Combo: " << ball->Combo << std::endl;
|
||||
//std::cout << NumberOfBricks() << std::endl;
|
||||
//std::cout << "Brick Score: " << brick->Score << std::endl;
|
||||
@@ -304,6 +408,7 @@ bool dd::Systems::LevelSystem::OnCreatePowerUp(const dd::Events::CreatePowerUp &
|
||||
cPhys->CollisionType = CollisionType::Type::Dynamic;
|
||||
cPhys->Category = CollisionLayer::Type::PowerUp;
|
||||
cPhys->Mask = CollisionLayer::Type::Pad;
|
||||
transform->Sticky = false;
|
||||
|
||||
std::shared_ptr<Components::PowerUp> cPow = m_World->AddComponent<Components::PowerUp>(powerUp);
|
||||
|
||||
@@ -337,8 +442,16 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
m_CurrentLevel++;
|
||||
if (m_CurrentLevel < 6) {
|
||||
GetNextLevel();
|
||||
CreateLevel();
|
||||
}
|
||||
CreateLevel(12);
|
||||
} else {
|
||||
// Win
|
||||
Events::ClusterClear e;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
Events::Pause p;
|
||||
p.Type = "All";
|
||||
EventBroker->Publish(p);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -346,10 +459,51 @@ bool dd::Systems::LevelSystem::OnStageCleared(const dd::Events::StageCleared &ev
|
||||
void dd::Systems::LevelSystem::GetNextLevel()
|
||||
{
|
||||
std::array<int, 42> level;
|
||||
// 0 is empty space.
|
||||
std::array<glm::vec4, 42> color;
|
||||
// Level array indicates type of brick.
|
||||
// 0 is empty space.
|
||||
// 1 is standard brick.
|
||||
// 2 is multiball brick.
|
||||
if (m_CurrentCluster == 1) {
|
||||
// 3 is lifebuoy brick.
|
||||
// 4 is sticky brick.
|
||||
// 5 is ink blaster brick.
|
||||
|
||||
// wolor array determines the color of standard bricks.
|
||||
// w is white.
|
||||
// r is red.
|
||||
// g is green.
|
||||
// b is blue.
|
||||
// y is yellow.
|
||||
// c is cyan.
|
||||
// m is magenta.
|
||||
// d is dark.
|
||||
// Feel free to make your own.
|
||||
glm::vec4 w = glm::vec4(1, 1, 1, 0);
|
||||
glm::vec4 r = glm::vec4(1, 0, 0, 0);
|
||||
glm::vec4 g = glm::vec4(0, 1, 0, 0);
|
||||
glm::vec4 b = glm::vec4(0, 0, 1, 0);
|
||||
glm::vec4 y = glm::vec4(1, 1, 0, 0);
|
||||
glm::vec4 c = glm::vec4(0, 1, 1, 0);
|
||||
glm::vec4 m = glm::vec4(1, 0, 1, 0);
|
||||
glm::vec4 d = glm::vec4(0, 0, 0, 0);
|
||||
|
||||
//glm::vec4 p4 = glm::vec4(asd.f / 255.f, asd.f / 255.f, sad.f / 255.f, 1.f);
|
||||
glm::vec4 br = glm::vec4(143.f / 255.f, 98.f / 255.f, 0.f / 255.f, 1.f);
|
||||
|
||||
glm::vec4 lb1 = glm::vec4(115.f / 255.f, 232.f / 255.f, 236.f / 255.f, 1.f);
|
||||
glm::vec4 lb2 = glm::vec4(107.f / 255.f, 214.f / 255.f, 218.f / 255.f, 1.f);
|
||||
glm::vec4 lb3 = glm::vec4(91.f / 255.f, 183.f / 255.f, 186.f / 255.f, 1.f);
|
||||
glm::vec4 lb4 = glm::vec4(70.f / 255.f, 153.f / 255.f, 156.f / 255.f, 1.f);
|
||||
|
||||
glm::vec4 p1 = glm::vec4(255.f / 255.f, 184.f / 255.f, 254.f / 255.f, 1.f);
|
||||
glm::vec4 p2 = glm::vec4(255.f / 255.f, 81.f / 255.f, 253.f / 255.f, 1.f);
|
||||
glm::vec4 p3 = glm::vec4(189.f / 255.f, 0.f / 255.f, 187.f / 255.f, 1.f);
|
||||
glm::vec4 p4 = glm::vec4(125.f / 255.f, 0.f / 255.f, 147.f / 255.f, 1.f);
|
||||
|
||||
|
||||
|
||||
|
||||
if (m_CurrentCluster == 0) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -358,6 +512,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 0,
|
||||
@@ -366,6 +527,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 1,
|
||||
@@ -374,6 +542,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -382,6 +557,13 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
@@ -390,54 +572,97 @@ void dd::Systems::LevelSystem::GetNextLevel()
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 1};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, w, w, w, w, w, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 2) {
|
||||
} else if (m_CurrentCluster == 1) {
|
||||
if (m_CurrentLevel == 1) {
|
||||
level =
|
||||
{1, 1, 0, 1, 0, 1, 1,
|
||||
{0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 2, 1, 2, 1,
|
||||
1, 1, 0, 1, 0, 1, 1,
|
||||
1, 0, 0, 1, 0, 0, 1};
|
||||
1, 0, 1, 2, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0,
|
||||
1, 0, 1, 0, 1, 0, 1,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
color =
|
||||
{w, w, w, w, w, w, w,
|
||||
lb4, lb4, lb4, lb4, lb4, lb4, lb4,
|
||||
lb3, lb3, lb3, lb3, lb3, lb3, lb3,
|
||||
lb2, lb2, lb2, lb2, lb2, lb2, lb2,
|
||||
lb1, lb1, lb1, lb1, lb1, lb1, lb1,
|
||||
w, w, w, w, w, w, w};
|
||||
} else if (m_CurrentLevel == 2) {
|
||||
level =
|
||||
{1, 0, 0, 0, 0, 0, 1,
|
||||
0, 1, 0, 0, 0, 1, 0,
|
||||
0, 0, 2, 2, 2, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0};
|
||||
{0, 0, 1, 0, 1, 0, 0,
|
||||
0, 1, 0, 1, 0, 1, 0,
|
||||
0, 0, 1, 1, 1, 0, 0,
|
||||
0, 0, 0, 3, 0, 0, 0,
|
||||
1, 1, 1, 0, 1, 1, 1,
|
||||
1, 0, 0, 0, 0, 0, 1};
|
||||
color =
|
||||
{w, w, r, w, r, w, w,
|
||||
w, w, w, r, w, w, w,
|
||||
w, w, r, w, r, w, w,
|
||||
w, w, w, w, w, w, w,
|
||||
w, r, w, w, w, r, w,
|
||||
r, w, w, w, w, w, r};
|
||||
} else if (m_CurrentLevel == 3) {
|
||||
level =
|
||||
{2, 0, 0, 0, 0, 0, 2,
|
||||
0, 1, 0, 0, 0, 1, 0,
|
||||
1, 2, 1, 1, 1, 2, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 1, 1, 1, 0, 1};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
{0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 1, 1, 1, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 0,
|
||||
1, 1, 1, 4, 1, 1, 1,
|
||||
0, 0, 0, 1, 0, 0, 0,
|
||||
0, 0, 1, 1, 1, 0, 0};
|
||||
color =
|
||||
{g, g, g, g, g, g, g,
|
||||
g, g, g, g, g, g, g,
|
||||
g, g, g, g, g, g, g,
|
||||
g, g, g, w, g, g, g,
|
||||
w, w, w, br, w, w, w,
|
||||
w, w, br, br, br, w, w};
|
||||
} else if (m_CurrentLevel == 4) {
|
||||
level =
|
||||
{1, 2, 1, 1, 1, 2, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 2, 1, 1, 1, 2, 1,
|
||||
1, 0, 1, 1, 1, 0, 1,
|
||||
1, 0, 0, 0, 0, 0, 1,
|
||||
0, 1, 1, 0, 1, 1, 0};
|
||||
{0, 0, 1, 0, 1, 0, 0,
|
||||
0, 1, 1, 1, 1, 1, 0,
|
||||
1, 1, 1, 1, 1, 1, 1,
|
||||
0, 1, 1, 1, 1, 1, 0,
|
||||
0, 0, 1, 5, 1, 0, 0,
|
||||
0, 0, 0, 1, 0, 0, 0};
|
||||
color =
|
||||
{w, w, p1, w, p1, w, w,
|
||||
w, p2, p3, p2, p3, p2, w,
|
||||
p1, p2, p3, p4, p3, p2, p1,
|
||||
w, p1, p2, p3, p2, p1, w,
|
||||
w, w, p1, w, p1, w, w,
|
||||
w, w, w, p1, w, w, w};
|
||||
} else if (m_CurrentLevel == 5) {
|
||||
level =
|
||||
{1, 0, 1, 0, 1, 0, 1,
|
||||
{0, 1, 0, 0, 0, 1, 0,
|
||||
1, 4, 1, 1, 1, 3, 1,
|
||||
0, 1, 0, 1, 0, 1, 0,
|
||||
2, 0, 1, 0, 1, 0, 2,
|
||||
0, 1, 0, 2, 0, 1, 0,
|
||||
1, 0, 1, 0, 1, 0, 1,
|
||||
0, 1, 0, 1, 0, 1, 0};
|
||||
0, 1, 0, 1, 0, 1, 0,
|
||||
1, 5, 1, 1, 1, 2, 1,
|
||||
0, 1, 0, 0, 0, 1, 0};
|
||||
color =
|
||||
{w, p3, w, w, w, r, w,
|
||||
p2, w, p1, g, w, w, w,
|
||||
w, p4, w, g, w, r, w,
|
||||
w, br, w, g, w, lb1, w,
|
||||
y, w, y, g, b, w, b,
|
||||
w, br, w, w, w, lb1, w};
|
||||
}
|
||||
} else if (m_CurrentCluster == 3) {
|
||||
|
||||
}
|
||||
|
||||
std::copy(std::begin(level), std::end(level), std::begin(m_Bricks));
|
||||
std::copy(std::begin(level), std::end(level), std::begin(m_Bricks));
|
||||
std::copy(std::begin(color), std::end(color), std::begin(m_Colors));
|
||||
}
|
||||
|
||||
bool dd::Systems::LevelSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/LifebuoySystem.h"
|
||||
|
||||
|
||||
void dd::Systems::LifebuoySystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &LifebuoySystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &LifebuoySystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifebuoy, &LifebuoySystem::OnLifebuoy);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ELifebuoyHit, &LifebuoySystem::OnLifebuoyHit);
|
||||
|
||||
//Lifebuoy
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Lifebuoy");
|
||||
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(50.f, -4.8f, -10.f);
|
||||
auto rectangleShape = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
auto lifebuoyTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
rectangleShape->Dimensions = glm::vec2(0.9f, 0.19f);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Static;
|
||||
physics->Category = CollisionLayer::LifeBuoy;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::Brick | CollisionLayer::LifeBuoy | CollisionLayer::Pad | CollisionLayer::Water);
|
||||
physics->Density = 1.0f;
|
||||
physics->GravityScale = 1;
|
||||
ctransform->Sticky = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Lifebuoy/Lifebuoy1.obj";
|
||||
auto lifebuoy = m_World->AddComponent<Components::Lifebuoy>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_Template = ent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::LifebuoySystem::Update(double dt)
|
||||
{
|
||||
for (auto it = m_Lifebuoys.begin(); it != m_Lifebuoys.end();) {
|
||||
|
||||
auto transformComponent = m_World->GetComponent<Components::Transform>(it->Entity);
|
||||
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(it->Entity);
|
||||
|
||||
if (transformComponent->Position.y < m_DownEdge) {
|
||||
m_World->RemoveEntity(it->Entity);
|
||||
m_Lifebuoys.erase(it++);
|
||||
}
|
||||
else {
|
||||
|
||||
if (transformComponent->Position.x > m_RightEdge) {
|
||||
transformComponent->Position = glm::vec3(m_LeftEdge + 0.1f, transformComponent->Position.y, transformComponent->Position.z);
|
||||
} else if (transformComponent->Position.x < m_LeftEdge) {
|
||||
transformComponent->Position = glm::vec3(m_RightEdge - 0.1f, transformComponent->Position.y, transformComponent->Position.z);
|
||||
}
|
||||
|
||||
if (lifebuoyComponent->Hits <= 0) {
|
||||
auto physicsComponent = m_World->GetComponent<Components::Physics>(it->Entity);
|
||||
physicsComponent->Mask = CollisionLayer::Type::LifeBuoy;
|
||||
physicsComponent->GravityScale = 10.f;
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(it->Entity);
|
||||
modelComponent->Color = glm::vec4(0.5f, 0.5f, 0.5f, 0.f);
|
||||
}
|
||||
|
||||
if (transformComponent->Position.y < m_DownLimit && lifebuoyComponent->Hits > 0) {
|
||||
transformComponent->Position.y = m_DownLimit;
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::LifebuoySystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "LifebuoySystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnLifebuoy(const dd::Events::Lifebuoy &event)
|
||||
{
|
||||
auto ent = m_World->CloneEntity(m_Template);
|
||||
m_World->SetProperty(ent, "Name", "Lifebuoy");
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
auto physics = m_World->GetComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
transform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
transform->Velocity = glm::vec3(20.f, 3.f, 0.f);
|
||||
LifebuoyInfo info;
|
||||
info.Entity = ent;
|
||||
m_Lifebuoys.push_back(info);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::LifebuoySystem::OnLifebuoyHit(const dd::Events::LifebuoyHit &event)
|
||||
{
|
||||
auto lifebuoyComponent = m_World->GetComponent<Components::Lifebuoy>(event.Lifebuoy);
|
||||
lifebuoyComponent->Hits -= 1;
|
||||
auto modelComponent = m_World->GetComponent<Components::Model>(event.Lifebuoy);
|
||||
modelComponent->ModelFile = "Models/Lifebuoy/Lifebuoy" + std::to_string(5 - lifebuoyComponent->Hits) + ".obj";
|
||||
return true;
|
||||
}
|
||||
@@ -28,21 +28,23 @@ void dd::Systems::PadSystem::Initialize()
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContactPowerUp, &PadSystem::OnContactPowerUp);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PadSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PadSystem::OnPause);
|
||||
//EVENT_SUBSCRIBE_MEMBER(m_EBindKey, &PadSystem::OnBindKey);
|
||||
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Pad");
|
||||
auto ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
ctransform->Position = glm::vec3(0.f, -3.5f, -10.f);
|
||||
ctransform->Position = glm::vec3(0.f, -4.8f, -10.f);
|
||||
auto rectangleShape = m_World->AddComponent<Components::RectangleShape>(ent);
|
||||
rectangleShape->Dimensions = glm::vec2(1.f, 0.5f);
|
||||
rectangleShape->Dimensions = glm::vec2(1.f, 0.1f);
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
physics->CollisionType = CollisionType::Type::Kinematic;
|
||||
physics->Category = CollisionLayer::Type::Pad;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::PowerUp);
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Ball | CollisionLayer::PowerUp | CollisionLayer::LifeBuoy);
|
||||
physics->Calculate = true;
|
||||
ctransform->Sticky = true;
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Submarine2.obj";
|
||||
cModel->ModelFile = "Models/Ship/Ship.obj";
|
||||
|
||||
auto pad = m_World->AddComponent<Components::Pad>(ent);
|
||||
m_World->CommitEntity(ent);
|
||||
@@ -55,6 +57,15 @@ void dd::Systems::PadSystem::UpdateEntity(double dt, EntityID entity, EntityID p
|
||||
{
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
auto ball = m_World->GetComponent<Components::Ball>(entity);
|
||||
if (ball != nullptr) {
|
||||
if (ball->Sticky) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
transform->Position = Transform()->Position;
|
||||
transform->Position += ball->StickyPlacement;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void dd::Systems::PadSystem::Update(double dt)
|
||||
@@ -123,8 +134,7 @@ bool dd::Systems::PadSystem::OnPause(const dd::Events::Pause &event)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
{
|
||||
bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event) {
|
||||
int val = event.KeyCode;
|
||||
if (val == GLFW_KEY_UP) {
|
||||
//std::cout << "Up!" << std::endl;
|
||||
@@ -154,6 +164,13 @@ bool dd::Systems::PadSystem::OnKeyDown(const dd::Events::KeyDown &event)
|
||||
e.Time = 0.2;
|
||||
e.Type = "All";
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_S) {
|
||||
Events::StageCleared e;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_SPACE) {
|
||||
Events::ActionButton e;
|
||||
e.Position = Transform()->Position;
|
||||
EventBroker->Publish(e);
|
||||
} else if (val == GLFW_KEY_D) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// Created by Adniklastrator on 2015-10-08.
|
||||
//
|
||||
|
||||
|
||||
#include "PrecompiledHeader.h"
|
||||
#include "Game/ProjectileSystem.h"
|
||||
|
||||
|
||||
void dd::Systems::ProjectileSystem::Initialize()
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &ProjectileSystem::OnContact);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &ProjectileSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInkBlaster, &ProjectileSystem::OnInkBlaster);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EHitPad, &ProjectileSystem::OnHitPad);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &ProjectileSystem::OnActionButton);
|
||||
|
||||
//Ink Blast
|
||||
{
|
||||
auto ent = m_World->CreateEntity();
|
||||
m_World->SetProperty(ent, "Name", "Projectile");
|
||||
std::shared_ptr<Components::Transform> ctransform = m_World->AddComponent<Components::Transform>(ent);
|
||||
|
||||
auto circleShape = m_World->AddComponent<Components::CircleShape>(ent);
|
||||
auto inkBlastTemplate = m_World->AddComponent<Components::Template>(ent);
|
||||
circleShape->Radius = 0.1f;
|
||||
auto physics = m_World->AddComponent<Components::Physics>(ent);
|
||||
physics->CollisionType = CollisionType::Type::Dynamic;
|
||||
physics->Category = CollisionLayer::Type::Projectile;
|
||||
physics->Mask = static_cast<CollisionLayer::Type>(CollisionLayer::Type::Pad | CollisionLayer::Type::Brick | CollisionLayer::Type::Wall);
|
||||
physics->Calculate = true;
|
||||
ctransform->Sticky = true;
|
||||
ctransform->Position = glm::vec3(0.f, 0.f, -10.f);
|
||||
ctransform->Scale = glm::vec3(0.1f, 0.1f, 0.1f);
|
||||
auto cModel = m_World->AddComponent<Components::Model>(ent);
|
||||
cModel->ModelFile = "Models/Test/Ball/Sid.obj";
|
||||
auto projectile = m_World->AddComponent<Components::Projectile>(ent);
|
||||
|
||||
m_World->CommitEntity(ent);
|
||||
|
||||
m_InkBlastTemplate = ent;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::Update(double dt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void dd::Systems::ProjectileSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
if (IsPaused()) {
|
||||
return;
|
||||
}
|
||||
auto templateCheck = m_World->GetComponent<Components::Template>(entity);
|
||||
if (templateCheck != nullptr){ return; }
|
||||
|
||||
auto shot = m_World->GetComponent<Components::Projectile>(entity);
|
||||
if (shot != nullptr) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform->Position.y > 8) {
|
||||
m_World->RemoveEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnPause(const dd::Events::Pause &event)
|
||||
{
|
||||
if (event.Type != "ProjectileSystem" && event.Type != "All") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IsPaused()) {
|
||||
SetPause(false);
|
||||
} else {
|
||||
SetPause(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnInkBlaster(const dd::Events::InkBlaster &event)
|
||||
{
|
||||
m_InkBlaster = true;
|
||||
m_Shots = 5;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnHitPad(const dd::Events::HitPad &event)
|
||||
{
|
||||
if (m_InkBlaster) {
|
||||
m_SquidLoaded = true;
|
||||
m_AttachedSquid = event.Ball;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool dd::Systems::ProjectileSystem::OnActionButton(const dd::Events::ActionButton &event)
|
||||
{
|
||||
if (m_InkBlaster && m_SquidLoaded) {
|
||||
auto ent = m_World->CloneEntity(m_InkBlastTemplate);
|
||||
m_World->RemoveComponent<Components::Template>(ent);
|
||||
auto transform = m_World->GetComponent<Components::Transform>(ent);
|
||||
transform->Position = event.Position;
|
||||
transform->Velocity = glm::vec3(0, 5, 0);
|
||||
m_Shots--;
|
||||
if (m_Shots <= 0) {
|
||||
auto ball = m_World->GetComponent<Components::Ball>(m_AttachedSquid);
|
||||
m_InkBlaster = false;
|
||||
m_SquidLoaded = false;
|
||||
ball->InkBlaster = false;
|
||||
ball->Sticky = false;
|
||||
ball->Waiting = true;
|
||||
|
||||
{
|
||||
Events::InkBlasterOver e;
|
||||
e.Ball = m_AttachedSquid;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
{
|
||||
Events::ActionButton e;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -12,8 +12,11 @@ void dd::Systems::PhysicsSystem::ContactListener::BeginContact(b2Contact* contac
|
||||
e.Entity2 = m_PhysicsSystem->m_BodiesToEntities[contact->GetFixtureB()->GetBody()];
|
||||
e.Normal = glm::normalize(glm::vec2(contact->GetManifold()->localNormal.x, contact->GetManifold()->localNormal.y));
|
||||
e.SignificantNormal = glm::normalize((glm::abs(e.Normal.x) > glm::abs(e.Normal.y)) ? glm::vec2(e.Normal.x, 0) : glm::vec2(0, e.Normal.y));
|
||||
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
//contact->GetManifold()->points
|
||||
b2Vec2 pos = worldManifold.points[0];
|
||||
glm::vec2 glmPos = glm::vec2(pos.x, pos.y);
|
||||
e.IntersectionPoint = glmPos;
|
||||
m_PhysicsSystem->EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::ContactListener::EndContact(b2Contact* contact)
|
||||
@@ -29,10 +32,17 @@ void dd::Systems::PhysicsSystem::ContactListener::PreSolve(b2Contact* contact, c
|
||||
auto physicsComponentA = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityA);
|
||||
auto physicsComponentB = m_PhysicsSystem->m_World->GetComponent<Components::Physics>(entityB);
|
||||
|
||||
|
||||
std::string propertyA = m_PhysicsSystem->m_World->GetProperty<std::string>(entityA, "Name");
|
||||
std::string propertyB = m_PhysicsSystem->m_World->GetProperty<std::string>(entityB, "Name");
|
||||
|
||||
if (physicsComponentA != nullptr && physicsComponentB != nullptr) {
|
||||
if (physicsComponentA->Calculate || physicsComponentB->Calculate) {
|
||||
// Turn of collisions
|
||||
contact->SetEnabled(false);
|
||||
if ((propertyA != "Lifebuoy" && propertyB != "Pad") || (propertyA != "Pad" && propertyB != "Lifebuoy")) {
|
||||
contact->SetEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,35 @@ void dd::Systems::PhysicsSystem::RegisterComponents(ComponentFactory* cf)
|
||||
|
||||
void dd::Systems::PhysicsSystem::Initialize()
|
||||
{
|
||||
std::random_device rd;
|
||||
gen = std::mt19937(rd());
|
||||
m_DestructionListener = new DestructionListener(this);
|
||||
m_ContactListener = new ContactListener(this);
|
||||
m_PhysicsWorld = new b2World(m_Gravity);
|
||||
m_ParticleContactDisabler = new ParticleContactDisabler();
|
||||
m_PhysicsWorld->SetContactListener(m_ContactListener);
|
||||
m_PhysicsWorld->SetContactFilter(m_ParticleContactDisabler);
|
||||
m_PhysicsWorld->SetDestructionListener(m_DestructionListener);
|
||||
|
||||
InitializeWater();
|
||||
EVENT_SUBSCRIBE_MEMBER(m_SetImpulse, &PhysicsSystem::SetImpulse);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPause, &PhysicsSystem::OnPause);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EStageCleared, &PhysicsSystem::OnStageCleared);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECreateParticleSequence, &PhysicsSystem::CreateParticleSequence);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EContact, &PhysicsSystem::OnContact);
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::InitializeWater()
|
||||
{
|
||||
float radius = 0.13f;
|
||||
float gravityScale = 1.0f;
|
||||
CreateParticleSystem(radius, gravityScale);
|
||||
|
||||
b2ParticleSystemDef m_ParticleSystemDef;
|
||||
m_ParticleSystemDef.radius = radius;
|
||||
m_ParticleSystemDef.gravityScale = gravityScale;
|
||||
m_ParticleSystemDef.density = 4.f;
|
||||
|
||||
m_WaterParticleSystem = m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef);
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::SetImpulse(const Events::SetImpulse &event)
|
||||
@@ -89,6 +105,16 @@ void dd::Systems::PhysicsSystem::SyncEntitiesWithBodies()
|
||||
filter.categoryBits = physicsComponent->Category;
|
||||
filter.maskBits = physicsComponent->Mask;
|
||||
body->GetFixtureList()->SetFilterData(filter);
|
||||
|
||||
if (physicsComponent->CollisionType == CollisionType::Type::Static) {
|
||||
body->SetType(b2_staticBody);
|
||||
}
|
||||
else if (physicsComponent->CollisionType == CollisionType::Type::Dynamic) {
|
||||
body->SetType(b2_dynamicBody);
|
||||
}
|
||||
else if (physicsComponent->CollisionType == CollisionType::Type::Kinematic) {
|
||||
body->SetType(b2_dynamicBody);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -141,10 +167,18 @@ void dd::Systems::PhysicsSystem::SyncBodiesWithEntities()
|
||||
|
||||
void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
{
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
if (m_Pause) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_Travelling) {
|
||||
if (m_DistanceTravelled > 12.f) {
|
||||
m_DistanceTravelled = 0;
|
||||
m_Travelling = false;
|
||||
}
|
||||
|
||||
m_DistanceTravelled += 6.0f * dt;
|
||||
}
|
||||
m_Accumulator += dt;
|
||||
|
||||
while(m_Accumulator >= m_TimeStep)
|
||||
@@ -166,9 +200,34 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
SyncBodiesWithEntities();
|
||||
|
||||
|
||||
//water
|
||||
b2Vec2 *positionBuffer = m_WaterParticleSystem->GetPositionBuffer();
|
||||
for (auto i : m_EntitiesToWaterParticleHandle){
|
||||
EntityID entity = i.first;
|
||||
const b2ParticleHandle *particleH = i.second;
|
||||
|
||||
|
||||
b2Vec2 positionB2 = positionBuffer[particleH->GetIndex()];
|
||||
glm::vec2 position = glm::vec2(positionB2.x, positionB2.y);
|
||||
|
||||
EntityID entityParent = m_World->GetEntityParent(entity);
|
||||
glm::vec3 parentTransform = glm::vec3(0.f);
|
||||
if(entityParent) {
|
||||
auto tp = m_World->GetComponent<Components::Transform>(entityParent);
|
||||
parentTransform = tp->Position;
|
||||
}
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
transform->Position = glm::vec3(position.x - parentTransform.x, position.y - parentTransform.y, 0);
|
||||
}
|
||||
|
||||
//Normal particles
|
||||
for ( int e = 0; e < m_EntitiesToParticleHandle.size(); e++) {
|
||||
b2Vec2 *positionBuffer = m_ParticleSystem[e]->GetPositionBuffer();
|
||||
for (auto i : m_EntitiesToParticleHandle[e]) {
|
||||
b2Vec2 *positionBuffer = m_ParticleEmitters.ParticleSystem[e]->GetPositionBuffer();
|
||||
if(!positionBuffer) {
|
||||
break;
|
||||
}
|
||||
for (auto i : m_EntitiesToParticleHandle[e]){
|
||||
EntityID entity = i.first;
|
||||
const b2ParticleHandle *particleH = i.second;
|
||||
|
||||
@@ -177,14 +236,13 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
|
||||
EntityID entityParent = m_World->GetEntityParent(entity);
|
||||
glm::vec3 parentTransform = glm::vec3(0.f);
|
||||
if (entityParent) {
|
||||
if(entityParent) {
|
||||
auto tp = m_World->GetComponent<Components::Transform>(entityParent);
|
||||
parentTransform = tp->Position;
|
||||
}
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
|
||||
transform->Position = glm::vec3(position.x, position.y, -10) - parentTransform;
|
||||
|
||||
transform->Position = glm::vec3(position.x, position.y, transform->Position.z);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +251,55 @@ void dd::Systems::PhysicsSystem::Update(double dt)
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, EntityID parent)
|
||||
{
|
||||
{
|
||||
if (m_Travelling) {
|
||||
auto transform = m_World->GetComponent<Components::Transform>(entity);
|
||||
if (transform != nullptr) {
|
||||
if (!transform->Sticky) {
|
||||
transform->Position.y -= 6.0f * dt;
|
||||
}
|
||||
} else {
|
||||
transform->Position.y -= 6.0f * dt;
|
||||
}
|
||||
}
|
||||
auto particle = m_World->GetComponent<Components::Particle>(entity);
|
||||
auto pTemplate = m_World->GetComponent<Components::Template>(entity);
|
||||
|
||||
|
||||
|
||||
if (particle && !pTemplate) {
|
||||
particle->LifeTime -= dt;
|
||||
if (particle->LifeTime <= 0) {
|
||||
for (int i = 0; i < m_EntitiesToParticleHandle.size(); i++) {
|
||||
const b2ParticleHandle* handle = m_EntitiesToParticleHandle[i][entity];
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*>::iterator iter1;
|
||||
std::unordered_map<const b2ParticleHandle*,EntityID>::iterator iter2;
|
||||
iter1 = m_EntitiesToParticleHandle[i].find(entity);
|
||||
iter2 = m_ParticleHandleToEntities[i].find(handle);
|
||||
if (iter1 != m_EntitiesToParticleHandle[i].end()) {
|
||||
m_EntitiesToParticleHandle[i].erase(iter1);
|
||||
}
|
||||
if (iter2 != m_ParticleHandleToEntities[i].end()) {
|
||||
m_ParticleHandleToEntities[i].erase(iter2);
|
||||
}
|
||||
m_World->RemoveEntity(entity);
|
||||
}
|
||||
}
|
||||
auto sprite = m_World->GetComponent<Components::Sprite>(entity);
|
||||
sprite->Color.w = particle->LifeTime;
|
||||
}
|
||||
|
||||
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(entity);
|
||||
if (emitter) {
|
||||
EntityID emitterParent = emitter->Parent;
|
||||
if (emitterParent != 0) {
|
||||
auto emitterTransform = m_World->GetComponent<Components::Transform>(entity);
|
||||
auto parentTransform = m_World->GetComponent<Components::Transform>(emitterParent);
|
||||
if (emitterTransform && parentTransform) {
|
||||
emitterTransform->Position = parentTransform->Position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnPause(const dd::Events::Pause &event)
|
||||
@@ -243,23 +348,22 @@ void dd::Systems::PhysicsSystem::OnEntityCommit(EntityID entity)
|
||||
|
||||
void dd::Systems::PhysicsSystem::OnEntityRemoved(EntityID entity)
|
||||
{
|
||||
/* auto physics = m_World->GetComponent<Components::Physics>(entity);
|
||||
if (physics == nullptr) {
|
||||
return;
|
||||
}*/
|
||||
|
||||
auto it = m_EntitiesToBodies.find(entity);
|
||||
if(it == m_EntitiesToBodies.end()) {
|
||||
LOG_ERROR("Trying to remove non-exsisting body, Entity: %i", entity);
|
||||
return;
|
||||
if(it != m_EntitiesToBodies.end()) {
|
||||
it->second->GetWorld()->DestroyBody(it->second);
|
||||
m_BodiesToEntities.erase(it->second);
|
||||
m_EntitiesToBodies.erase(entity);
|
||||
}
|
||||
|
||||
//It told me I was removing a lot of objects, and I didn't need that information, so I commented it out.
|
||||
//LOG_INFO("Removing entity %i", entity);
|
||||
it->second->GetWorld()->DestroyBody(it->second);
|
||||
m_BodiesToEntities.erase(it->second);
|
||||
m_EntitiesToBodies.erase(entity);
|
||||
//delete body;
|
||||
}
|
||||
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnStageCleared(const dd::Events::StageCleared &event)
|
||||
{
|
||||
if (event.ClearedStage < 5) {
|
||||
m_Travelling = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -316,7 +420,7 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
|
||||
|
||||
|
||||
fixtureDef.shape = pShape;
|
||||
fixtureDef.density = 10.f;
|
||||
fixtureDef.density = physicsComponent->Density;
|
||||
fixtureDef.restitution = 1.0f;
|
||||
fixtureDef.friction = 0.0f;
|
||||
body->CreateFixture(&fixtureDef);
|
||||
@@ -324,16 +428,12 @@ void dd::Systems::PhysicsSystem::CreateBody(EntityID entity)
|
||||
|
||||
delete pShape;
|
||||
|
||||
/* if(physicsComponent->Static) {
|
||||
body->SetType(b2BodyType::b2_staticBody);
|
||||
} else if (! physicsComponent->Static) {
|
||||
body->SetType(b2BodyType::b2_dynamicBody);
|
||||
}*/
|
||||
|
||||
body->SetGravityScale(physicsComponent->GravityScale);
|
||||
m_EntitiesToBodies.insert(std::make_pair(entity, body));
|
||||
m_BodiesToEntities.insert(std::make_pair(body, entity));
|
||||
}
|
||||
|
||||
|
||||
void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
{
|
||||
auto transform = m_World->GetComponent<Components::Transform>(e);
|
||||
@@ -349,19 +449,19 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
pd.shape = &shape;
|
||||
pd.flags = b2_tensileParticle;
|
||||
pd.position.Set(transform->Position.x, transform->Position.y);
|
||||
t_ParticleGroup.push_back(m_ParticleSystem[0]->CreateParticleGroup(pd));
|
||||
b2Vec2* t_ParticlePositions = m_ParticleSystem[0]->GetPositionBuffer();
|
||||
for(int i = 0; i < m_ParticleSystem[0]->GetParticleCount(); i++){
|
||||
t_ParticleGroup.push_back(m_WaterParticleSystem->CreateParticleGroup(pd));
|
||||
b2Vec2* t_ParticlePositions = m_WaterParticleSystem->GetPositionBuffer();
|
||||
for(int i = 0; i < m_WaterParticleSystem->GetParticleCount(); i++){
|
||||
{
|
||||
auto t_waterparticle = m_World->CreateEntity(e);
|
||||
auto transformChild = m_World->AddComponent<Components::Transform>(t_waterparticle);
|
||||
|
||||
transformChild->Position = glm::vec3(t_ParticlePositions[i].x - transform->Position.x, t_ParticlePositions[i].y - transform->Position.y, -9.5f);
|
||||
transformChild->Scale = glm::vec3(m_ParticleSystem[0]->GetRadius())/transform->Scale;
|
||||
transformChild->Scale = glm::vec3(m_WaterParticleSystem->GetRadius())/transform->Scale;
|
||||
m_World->CommitEntity(t_waterparticle);
|
||||
|
||||
m_EntitiesToParticleHandle[0].insert(std::make_pair(t_waterparticle, m_ParticleSystem[0]->GetParticleHandleFromIndex(i)));
|
||||
m_ParticleHandleToEntities[0].insert(std::make_pair( m_ParticleSystem[0]->GetParticleHandleFromIndex(i), t_waterparticle));
|
||||
m_EntitiesToWaterParticleHandle.insert(std::make_pair(t_waterparticle, m_WaterParticleSystem->GetParticleHandleFromIndex(i)));
|
||||
m_WaterParticleHandleToEntities.insert(std::make_pair(m_WaterParticleSystem->GetParticleHandleFromIndex(i), t_waterparticle));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -369,46 +469,166 @@ void dd::Systems::PhysicsSystem::CreateParticleGroup(EntityID e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void dd::Systems::PhysicsSystem::UpdateParticleEmitters(double dt)
|
||||
{
|
||||
for (int i = 0; i < m_ParticleEmitters.System.size(); i++) {
|
||||
auto e = m_ParticleEmitters.Emitter[i];
|
||||
auto pt = m_ParticleEmitters.Template[i];
|
||||
auto ps = m_ParticleEmitters.System[i];
|
||||
|
||||
|
||||
std::vector<EntityID> emittersToDelete;
|
||||
int pSizeTest = 0; //For debugging, delete this
|
||||
int psListSize = 0;
|
||||
for (int i = 0; i < m_ParticleEmitters.ParticleSystem.size(); i++) {
|
||||
auto e = m_ParticleEmitters.ParticleEmitter[i];
|
||||
auto pt = m_ParticleEmitters.ParticleTemplate[i];
|
||||
auto ps = m_ParticleEmitters.ParticleSystem[i];
|
||||
pSizeTest += ps->GetParticleCount();
|
||||
psListSize++;
|
||||
auto emitter = m_World->GetComponent<Components::ParticleEmitter>(e);
|
||||
auto particleTemplate = m_World->GetComponent<Components::Particle>(pt);
|
||||
emitter->TimeSinceLastSpawn += dt;
|
||||
if(emitter->TimeSinceLastSpawn < emitter->SpawnRate) {
|
||||
if(!emitter) {
|
||||
LOG_INFO("ParticleEmitter Component is nil");
|
||||
continue;
|
||||
}
|
||||
if(!particleTemplate) {
|
||||
LOG_INFO("ParticleTemplate Component is nil.");
|
||||
continue;
|
||||
}
|
||||
auto emitterTransform = m_World->GetComponent<Components::Transform>(e);
|
||||
emitterTransform->Orientation = glm::rotate(glm::quat(), 3.f, glm::vec3(0.f, 0.f, -1.f));
|
||||
|
||||
emitter->TimeSinceLastSpawn += dt;
|
||||
emitter->LifeTime -= dt;
|
||||
|
||||
if (emitter->LifeTime <= 0 || emitter->NumberOfTicks <= 0) {
|
||||
emittersToDelete.push_back(e);
|
||||
continue;
|
||||
}
|
||||
if(emitter->TimeSinceLastSpawn < emitter->SpawnRate || emitter->NumberOfTicks < 1) {
|
||||
continue;
|
||||
}
|
||||
emitter->NumberOfTicks--;
|
||||
emitter->TimeSinceLastSpawn -= emitter->SpawnRate;
|
||||
auto templateTransform = m_World->GetComponent<Components::Transform>(pt);
|
||||
|
||||
b2ParticleDef particleDef;
|
||||
particleDef.flags = particleTemplate->Flags;
|
||||
//particleDef.color TODO: Implement this if we want color mixing and shit.
|
||||
particleDef.lifetime = particleTemplate->LifeTime;
|
||||
particleDef.velocity = b2Vec2(templateTransform->Velocity.x, templateTransform->Velocity.y);
|
||||
particleDef.position = b2Vec2(templateTransform->Position.x, templateTransform->Position.y);
|
||||
for ( int j = 0; j < emitter->ParticlesPerTick; j++) {
|
||||
particleDef.flags = particleTemplate->Flags;
|
||||
//particleDef.color TODO: Implement this if we want color mixing and shit.
|
||||
particleDef.lifetime = particleTemplate->LifeTime;
|
||||
float eAngle = emitter->EmittingAngle;
|
||||
float halfSpread = emitter->Spread / 2;
|
||||
|
||||
auto particle = m_World->CloneEntity(pt, 0);
|
||||
m_World->RemoveComponent<Components::Template>(particle);
|
||||
std::uniform_real_distribution<float> dis(eAngle - halfSpread, eAngle + halfSpread);
|
||||
float pAngle = dis(gen);
|
||||
std::uniform_real_distribution<float> dis2(0.3, 1.5);
|
||||
float speedMultiplier = dis2(gen);
|
||||
glm::vec2 unitVec = glm::normalize(glm::vec2(glm::cos(pAngle), glm::sin(pAngle)));
|
||||
glm::vec2 vel = unitVec * emitter->Speed * (float)dt * speedMultiplier * 0.5f;
|
||||
particleDef.velocity = b2Vec2(vel.x, vel.y);
|
||||
particleDef.position = b2Vec2(emitterTransform->Position.x, emitterTransform->Position.y);
|
||||
|
||||
auto b2Particle = ps->CreateParticle(particleDef);
|
||||
auto b2ParticleHandle = ps->GetParticleHandleFromIndex(b2Particle);
|
||||
m_EntitiesToParticleHandle[i].insert(std::make_pair(particle, b2ParticleHandle));
|
||||
m_ParticleHandleToEntities[i].insert(std::make_pair(b2ParticleHandle, particle));
|
||||
|
||||
//TODO: Ta bort detta
|
||||
int particles = 0;
|
||||
for (auto i : m_EntitiesToParticleHandle)
|
||||
{
|
||||
particles += i.size();
|
||||
auto particle = m_World->CloneEntity(pt, 0);
|
||||
m_World->RemoveComponent<Components::Template>(particle);
|
||||
auto transform2 = m_World->GetComponent<Components::Transform>(particle);
|
||||
|
||||
std::uniform_real_distribution<float> dist(0, 1);
|
||||
float zDistribution = dist(gen);
|
||||
transform2->Position = glm::vec3(emitterTransform->Position.x, emitterTransform->Position.y, -9.5f + zDistribution);
|
||||
transform2->Scale = glm::vec3(particleTemplate->Radius * 2.f / speedMultiplier, particleTemplate->Radius * 2.f / speedMultiplier, 1);
|
||||
|
||||
|
||||
auto b2Particle = ps->CreateParticle(particleDef);
|
||||
|
||||
auto b2ParticleHandle = ps->GetParticleHandleFromIndex(b2Particle);
|
||||
m_EntitiesToParticleHandle[i].insert(std::make_pair(particle, b2ParticleHandle));
|
||||
m_ParticleHandleToEntities[i].insert(std::make_pair(b2ParticleHandle, particle));
|
||||
|
||||
|
||||
}
|
||||
LOG_INFO("--I have %i particles.", particles);
|
||||
|
||||
}
|
||||
// system("cls");
|
||||
// std::cout << "Particles living: " << pSizeTest << std::endl;
|
||||
// std::cout << "particle systems: " << psListSize << std::endl;
|
||||
// int entHandles = 0;
|
||||
// for (int i = 0; i < m_EntitiesToParticleHandle.size(); i++)
|
||||
// entHandles += m_EntitiesToParticleHandle[i].size();
|
||||
// std::cout << "Entities and handles: " << entHandles << std::endl;
|
||||
// LOG_INFO("Particles living: %i", pSizeTest);
|
||||
// LOG_INFO("Particle systems: %i", psListSize);
|
||||
// int entHandles = 0;
|
||||
// for (int i = 0; i < m_EntitiesToParticleHandle.size(); i++)
|
||||
// entHandles += m_EntitiesToParticleHandle[i].size();
|
||||
// LOG_INFO("Entities and handles: %i", entHandles);
|
||||
|
||||
|
||||
for (int i = 0; i < emittersToDelete.size(); i++)
|
||||
{
|
||||
EntityID ent = emittersToDelete[i];
|
||||
int key;
|
||||
for(key = 0; key < m_ParticleEmitters.ParticleEmitter.size(); key++) {
|
||||
if (m_ParticleEmitters.ParticleEmitter[key] == ent) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_ParticleEmitters.ParticleSystem[key]->GetParticleCount() == 0 && key <= m_ParticleEmitters.ParticleSystem.size()) {
|
||||
m_World->RemoveEntity(ent);
|
||||
m_PhysicsWorld->DestroyParticleSystem(m_ParticleEmitters.ParticleSystem[key]);
|
||||
m_ParticleEmitters.ParticleSystem.erase(m_ParticleEmitters.ParticleSystem.begin() + key);
|
||||
m_ParticleEmitters.ParticleEmitter.erase(m_ParticleEmitters.ParticleEmitter.begin() + key);
|
||||
m_ParticleEmitters.ParticleTemplate.erase(m_ParticleEmitters.ParticleTemplate.begin() + key);
|
||||
m_EntitiesToParticleHandle.erase(m_EntitiesToParticleHandle.begin() + key);
|
||||
m_ParticleHandleToEntities.erase(m_ParticleHandleToEntities.begin() + key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int stp = 0;
|
||||
for (auto ts : m_EntitiesToParticleHandle)
|
||||
{
|
||||
stp += ts.size();
|
||||
}
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::CreateParticleSequence(const Events::CreateParticleSequence &event)
|
||||
{
|
||||
//Creating Emitter
|
||||
EntityID emitter = m_World->CreateEntity();
|
||||
|
||||
auto emitterTransform = m_World->AddComponent<Components::Transform>(emitter);
|
||||
auto particleEmitter= m_World->AddComponent<Components::ParticleEmitter>(emitter);
|
||||
|
||||
if (event.parent != 0) {
|
||||
particleEmitter->Parent = event.parent;
|
||||
}
|
||||
|
||||
emitterTransform->Position = event.Position;
|
||||
particleEmitter->GravityScale = event.GravityScale;
|
||||
particleEmitter->SpawnRate = event.SpawnRate;
|
||||
particleEmitter->NumberOfTicks = event.NumberOfTicks;
|
||||
particleEmitter->Speed = event.Speed;
|
||||
particleEmitter->ParticlesPerTick = event.ParticlesPerTick;
|
||||
particleEmitter->Spread = event.Spread;
|
||||
particleEmitter->EmittingAngle = event.EmittingAngle;
|
||||
particleEmitter->LifeTime = event.EmitterLifeTime;
|
||||
|
||||
{
|
||||
//Creating Particle Template
|
||||
auto particle = m_World->CreateEntity(emitter);
|
||||
auto particleTransform = m_World->AddComponent<Components::Transform>(particle);
|
||||
auto sprite = m_World->AddComponent<Components::Sprite>(particle);
|
||||
auto particleComponent = m_World->AddComponent<Components::Particle>(particle);
|
||||
m_World->AddComponent<Components::Template>(particle);
|
||||
|
||||
particleTransform->Position = emitterTransform->Position;
|
||||
sprite->SpriteFile = event.SpriteFile;
|
||||
sprite->Color = event.Color;
|
||||
particleComponent->LifeTime = event.ParticleLifeTime;
|
||||
particleComponent->Flags = event.Flags;
|
||||
particleComponent->Radius = event.Radius;
|
||||
}
|
||||
m_World->CommitEntity(emitter);
|
||||
return true;
|
||||
}
|
||||
|
||||
void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
||||
@@ -426,14 +646,14 @@ void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
||||
auto particleTemplate = m_World->GetComponent<Components::Template>(c);
|
||||
if (!p) {
|
||||
continue;
|
||||
LOG_WARNING("--Emitter's Child is not a particle.");
|
||||
LOG_WARNING("ParticleEmitter's Child is not a particle.");
|
||||
}
|
||||
if(!particleTemplate) {
|
||||
LOG_ERROR("Emitter's particleChild is not a template.");
|
||||
LOG_ERROR("ParticleEmitter's particleChild is not a template.");
|
||||
continue;
|
||||
}
|
||||
if (pf != 0) {
|
||||
LOG_WARNING("Emitter has more than one child that is a particleTemplate, only the first one is used.");
|
||||
LOG_WARNING("ParticleEmitter has more than one child that is a particleTemplate, only the first one is used.");
|
||||
break;
|
||||
}
|
||||
childEntity = c;
|
||||
@@ -441,13 +661,14 @@ void dd::Systems::PhysicsSystem::CreateParticleEmitter(EntityID entity)
|
||||
pf++;
|
||||
}
|
||||
//TODO: Skicka med fler flaggor till particlesystemet;
|
||||
m_ParticleEmitters.System.push_back(CreateParticleSystem(particle->Radius, 0.f));
|
||||
m_ParticleEmitters.Emitter.push_back(entity);
|
||||
m_ParticleEmitters.Template.push_back(childEntity);
|
||||
|
||||
m_ParticleEmitters.ParticleSystem.push_back(CreateParticleSystem(particle->Radius, 0.f, 0));
|
||||
m_ParticleEmitters.ParticleEmitter.push_back(entity);
|
||||
m_ParticleEmitters.ParticleTemplate.push_back(childEntity);
|
||||
}
|
||||
|
||||
|
||||
b2ParticleSystem* dd::Systems::PhysicsSystem::CreateParticleSystem(float radius, float gravityScale)
|
||||
b2ParticleSystem* dd::Systems::PhysicsSystem::CreateParticleSystem(float radius, float gravityScale, int maxCount)
|
||||
{
|
||||
std::unordered_map<EntityID, const b2ParticleHandle*> m1;
|
||||
std::unordered_map<const b2ParticleHandle*, EntityID> m2;
|
||||
@@ -455,14 +676,48 @@ b2ParticleSystem* dd::Systems::PhysicsSystem::CreateParticleSystem(float radius,
|
||||
m_ParticleHandleToEntities.push_back(m2);
|
||||
|
||||
b2ParticleSystemDef m_ParticleSystemDef;
|
||||
m_ParticleSystemDef.maxCount = maxCount;
|
||||
m_ParticleSystemDef.radius = radius;
|
||||
m_ParticleSystemDef.gravityScale = gravityScale;
|
||||
m_ParticleSystemDef.destroyByAge = true;
|
||||
|
||||
m_ParticleSystem.push_back(m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef));
|
||||
|
||||
return m_ParticleSystem.back();
|
||||
return m_PhysicsWorld->CreateParticleSystem(&m_ParticleSystemDef);
|
||||
}
|
||||
|
||||
bool dd::Systems::PhysicsSystem::OnContact(const dd::Events::Contact &event)
|
||||
{
|
||||
//Check if it is a brick colliding
|
||||
auto brick = m_World->GetComponent<Components::Brick>(event.Entity1);
|
||||
Components::Model* model;
|
||||
|
||||
if (!brick) {
|
||||
brick = m_World->GetComponent<Components::Brick>(event.Entity2);
|
||||
if (!brick) {
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
model = m_World->GetComponent<Components::Model>(event.Entity2);
|
||||
}
|
||||
}
|
||||
else {
|
||||
model = m_World->GetComponent<Components::Model>(event.Entity1);
|
||||
}
|
||||
Events::CreateParticleSequence e;
|
||||
e.EmitterLifeTime = 4;
|
||||
//- glm::atan(event.Normal.x, event.Normal.y
|
||||
e.EmittingAngle = glm::half_pi<float>();
|
||||
e.Spread = 0.5f;
|
||||
e.NumberOfTicks = 1;
|
||||
e.ParticleLifeTime = 1.f;
|
||||
e.ParticlesPerTick = 15;
|
||||
e.Position = glm::vec3(event.IntersectionPoint.x, event.IntersectionPoint.y, -10);
|
||||
e.Radius = 0.2f;
|
||||
e.SpriteFile = "Textures/Particles/Cloud_Particle.png";
|
||||
e.Color = model->Color + glm::vec4(0.5f);
|
||||
e.Speed = 100;
|
||||
EventBroker->Publish(e);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
dd::Systems::PhysicsSystem::~PhysicsSystem()
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
dd::Systems::SoundSystem::~SoundSystem()
|
||||
{
|
||||
alcCloseDevice(m_Device);
|
||||
};
|
||||
}
|
||||
|
||||
void dd::Systems::SoundSystem::Initialize()
|
||||
{
|
||||
@@ -41,6 +41,8 @@ void dd::Systems::SoundSystem::Initialize()
|
||||
e.IsAmbient = true;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void dd::Systems::SoundSystem::Update(double dt)
|
||||
@@ -165,10 +167,14 @@ bool dd::Systems::SoundSystem::OnContact(const dd::Events::Contact &event)
|
||||
}
|
||||
|
||||
//Send play-sound event
|
||||
dd::Events::PlaySound e;
|
||||
e.FilePath = collisionSound->FilePath;
|
||||
e.IsAmbient = false;
|
||||
EventBroker->Publish(e);
|
||||
|
||||
{
|
||||
dd::Events::PlaySound e;
|
||||
e.FilePath = collisionSound->FilePath;
|
||||
e.IsAmbient = false;
|
||||
EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||