Merge remote-tracking branch 'origin/master' into water

Conflicts:
	src/game/Physics/ContactListener.cpp
	src/game/Physics/PhysicsSystem.cpp
This commit is contained in:
Stiffly
2015-10-08 21:39:48 +02:00
25 changed files with 5314 additions and 94 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 120 B

+12
View File
@@ -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
+513
View File
@@ -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
+12
View File
@@ -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 LifebuoyTexture.png
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

+12
View File
@@ -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
File diff suppressed because it is too large Load Diff
Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

+9
View File
@@ -43,9 +43,11 @@
#include "Game/PadSystem.h"
#include "Game/CBall.h"
#include "Game/CPad.h"
#include "Game/CLifebuoy.h"
#include "Game/CBrick.h"
#include "Game/BallSystem.h"
#include "Game/HitLagSystem.h"
#include "Game/LifebuoySystem.h"
#include "Game/Bricks/CPowerUpBrick.h"
#include "Physics/PhysicsSystem.h"
@@ -110,6 +112,7 @@ 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::PowerUp>();
m_World->ComponentFactory.Register<Components::PowerUpBrick>();
@@ -126,6 +129,9 @@ 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::PhysicsSystem>(
[this]() { return new Systems::PhysicsSystem(m_World.get(), m_EventBroker); });
m_World->AddSystem<Systems::PhysicsSystem>();
@@ -181,6 +187,7 @@ public:
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);
@@ -261,6 +268,8 @@ 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);
}
+6
View File
@@ -21,11 +21,13 @@
#include "Game/EResetBall.h"
#include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h"
#include "Game/EStickyPad.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"
namespace dd
{
@@ -91,6 +93,8 @@ private:
bool m_ReplaceBall = false;
bool m_Pause = false;
bool m_Waiting = true;
bool m_Sticky = false;
int m_StickyCounter = 5;
EntityID m_LastCollision = 999999;
glm::vec3 m_SavedSpeed;
@@ -105,6 +109,7 @@ 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::Pause> m_EPause;
dd::EventRelay<BallSystem, dd::Events::Contact> m_Contact;
dd::EventRelay<BallSystem, dd::Events::ActionButton> m_EActionButton;
@@ -114,6 +119,7 @@ private:
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 OnPause(const dd::Events::Pause &event);
bool OnActionButton(const dd::Events::ActionButton &event);
};
+2
View File
@@ -20,6 +20,8 @@ struct Ball : Component
int Combo = 0;
bool Paused = false;
bool Waiting = true;
bool Sticky = false;
glm::vec3 StickyPlacement = glm::vec3(0, 0, 0);
glm::vec3 SavedSpeed = glm::vec3(0, 0, 0);
};
+25
View File
@@ -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
{
};
}
}
#endif //DAYDREAM_CLIFEBUOY_H
+25
View File
@@ -0,0 +1,25 @@
//
// Created by Adniklastrator on 2015-09-17.
//
#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
+25
View File
@@ -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
+6 -2
View File
@@ -22,13 +22,15 @@
#include "Game/EScoreEvent.h"
#include "Game/EComboEvent.h"
#include "Game/EHitPad.h"
#include "Game/ELifebuoy.h"
#include "Game/EStickyPad.h"
#include "Game/EMultiBall.h"
#include "Game/EMultiBallLost.h"
#include "Game/EPause.h"
#include "Game/EGameOver.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"
@@ -108,7 +110,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,6 +125,8 @@ private:
const int EmptyBrickSpace = 0;
const int StandardBrick = 1;
const int MultiBallBrick = 2;
const int LifebuoyBrick = 3;
const int StickyBrick = 4;
EntityID m_BrickTemplate;
+71
View File
@@ -0,0 +1,71 @@
//
// 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/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;
bool OnContact(const dd::Events::Contact &event);
bool OnPause(const dd::Events::Pause &event);
bool OnLifebuoy(const dd::Events::Lifebuoy &event);
struct LifeBuoyInfo
{
EntityID Entity;
float TimeToLive = 15.f;
};
float m_LeftEdge = -3.8f;
float m_RightEdge = 3.8f;
std::list<LifeBuoyInfo> m_LifeBuoys;
};
}
}
#endif //DAYDREAM_LIFEBUOYSYSTEM_H
+20 -18
View File
@@ -9,13 +9,14 @@ 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
};
}
@@ -39,20 +40,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
);
};
}
}
+1 -1
View File
@@ -117,7 +117,7 @@ namespace dd
dd::EventRelay<PhysicsSystem, dd::Events::Contact> m_EContact;
bool OnContact(const dd::Events::Contact &event);
bool m_Travelling = false;
float m_Timer = 0;
float m_DistanceTravelled = 0;
//TODO: Fill struct with info needed.
struct EmitterHandler //TODO CHANGE NAMES
+61 -37
View File
@@ -18,6 +18,7 @@ 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_EPause, &BallSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EActionButton, &BallSystem::OnActionButton);
@@ -39,7 +40,7 @@ void dd::Systems::BallSystem::Initialize()
std::shared_ptr<Components::Template> ballTemplate = m_World->AddComponent<Components::Template>(ent);
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;
transform->Sticky = true;
@@ -103,12 +104,27 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
if (templateCheck != nullptr){ return; }
if (ballComponent != nullptr) {
if (ReplaceBall()) {
SetReplaceBall(false);
m_Waiting = true;
ballComponent->Waiting = true;
}
if (ballComponent->Waiting) {
if (m_Waiting == false) {
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 {
transform->Velocity = glm::normalize(glm::vec3(-0.5f, 1, 0.f)) * ballComponent->Speed;
if (ballComponent->Sticky) {
transform->Velocity = ballComponent->SavedSpeed;
m_StickyCounter--;
std::cout << m_StickyCounter << std::endl;
if (m_StickyCounter > 0) {
m_Sticky = true;
}
ballComponent->Sticky = false;
}
} 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);
@@ -116,12 +132,7 @@ void dd::Systems::BallSystem::UpdateEntity(double dt, EntityID entity, EntityID
return;
}
}
if (ReplaceBall()) {
SetReplaceBall(false);
m_Waiting = true;
ballComponent->Waiting = true;
}
auto transformBall = m_World->GetComponent<Components::Transform>(entity);
if (glm::abs(transformBall->Velocity.y) < 2) {
if (transformBall->Velocity.y > 0) {
@@ -130,7 +141,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;
@@ -238,23 +249,16 @@ 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;
EventBroker->Publish(e);
// Events::HitLag el;
@@ -262,20 +266,34 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
//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_Sticky) {
m_Sticky = false;
m_Waiting = true;
ballComponent->Sticky = true;
ballComponent->Waiting = true;
ballComponent->StickyPlacement = padTransform->Position - ballTransform->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);
} else {
auto it = m_Contacts.find(ballEntity);
if (it == m_Contacts.end()) {
std::list<glm::vec2> normalList;
@@ -287,8 +305,12 @@ bool dd::Systems::BallSystem::Contact(const Events::Contact &event)
m_Contacts[ballEntity] = normalList;
}
//glm::vec2 reflectedVelocity = glm::reflect(ballVelocity, event.Normal);
//ballTransform->Velocity = glm::vec3(reflectedVelocity, 0.f);
auto brick = m_World->GetComponent<Components::Brick>(otherEntitiy);
if (brick != nullptr) {
auto physicsComponent = m_World->GetComponent<Components::Physics>(otherEntitiy);
physicsComponent->CollisionType = CollisionType::Type::Dynamic;
}
}
return true;
@@ -299,23 +321,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);
}
@@ -403,6 +420,13 @@ 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::OnActionButton(const dd::Events::ActionButton &event)
{
m_Waiting = false;
+29 -12
View File
@@ -27,13 +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::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
@@ -65,7 +65,7 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
// Check the background.
auto model = m_World->GetComponent<Components::Model>(entity);
if (model != nullptr) {
if (model->ModelFile == "Models/Test/halfpipe/Halfpipe.obj") {
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;
@@ -77,12 +77,20 @@ void dd::Systems::LevelSystem::UpdateEntity(double dt, EntityID entity, EntityID
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);
}
m_LooseBricks--;
m_World->RemoveEntity(entity);
}
@@ -185,10 +193,17 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
if (typeInt == StandardBrick) {
} 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;
auto model = m_World->GetComponent<Components::Model>(brick);
model->Color = glm::vec4(1.f, 0.f, 0.f, .0f);
} else if (typeInt == StickyBrick) {
cBrick->Type = StickyBrick;
auto model = m_World->GetComponent<Components::Model>(brick);
model->Color = glm::vec4(0.f, 0.f, 1.f, .0f);
}
float x = line * spacesBetweenBricks.x;
float y = row * spacesBetweenBricks.y;
transform->Position = glm::vec3(x - 3, 5 - spaceToEdge - y + aboveLevel, -10.f);
@@ -364,7 +379,9 @@ void dd::Systems::LevelSystem::GetNextLevel()
// 0 is empty space.
// 1 is standard brick.
// 2 is multiball brick.
if (m_CurrentCluster == 1) {
// 3 is lifebuoy brick.
// 4 is sticky brick.
if (m_CurrentCluster == 0) {
if (m_CurrentLevel == 1) {
level =
{0, 0, 0, 0, 0, 0, 0,
@@ -406,7 +423,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 1};
}
} else if (m_CurrentCluster == 2) {
} else if (m_CurrentCluster == 1) {
if (m_CurrentLevel == 1) {
level =
{1, 1, 0, 1, 0, 1, 1,
@@ -414,7 +431,7 @@ void dd::Systems::LevelSystem::GetNextLevel()
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};
4, 0, 0, 3, 0, 0, 1};
} else if (m_CurrentLevel == 2) {
level =
{1, 0, 0, 0, 0, 0, 1,
+111
View File
@@ -0,0 +1,111 @@
//
// 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);
//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/Lifebuoy.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();) {
it->TimeToLive -= dt;
if (it->TimeToLive < 0.f) {
m_World->RemoveEntity(it->Entity);
m_LifeBuoys.erase(it++);
}
else {
auto transformComponent = m_World->GetComponent<Components::Transform>(it->Entity);
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);
}
++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(event.Transform->Position.x, transform->Position.y + 2.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;
}
+19 -6
View File
@@ -34,17 +34,17 @@ void dd::Systems::PadSystem::Initialize()
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);
@@ -57,6 +57,16 @@ 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;
transform->Orientation = glm::quat();
}
}
}
void dd::Systems::PadSystem::Update(double dt)
@@ -155,7 +165,10 @@ 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_SPACE) {
} else if (val == GLFW_KEY_S) {
Events::StageCleared e;
EventBroker->Publish(e);
} else if (val == GLFW_KEY_SPACE) {
Events::ActionButton e;
EventBroker->Publish(e);
} else if (val == GLFW_KEY_D) {
+8 -1
View File
@@ -32,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);
}
}
}
+22 -17
View File
@@ -23,9 +23,9 @@ void dd::Systems::PhysicsSystem::Initialize()
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()
@@ -36,10 +36,9 @@ void dd::Systems::PhysicsSystem::InitializeWater()
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)
@@ -106,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);
}
}
}
}
@@ -163,11 +172,12 @@ void dd::Systems::PhysicsSystem::Update(double dt)
}
if (m_Travelling) {
m_Timer += dt;
if (m_Timer >= 2) {
m_Timer = 0;
if (m_DistanceTravelled > 12.f) {
m_DistanceTravelled = 0;
m_Travelling = false;
}
m_DistanceTravelled += 6.0f * dt;
}
m_Accumulator += dt;
@@ -245,12 +255,13 @@ void dd::Systems::PhysicsSystem::UpdateEntity(double dt, EntityID entity, Entity
if (m_Travelling) {
auto transform = m_World->GetComponent<Components::Transform>(entity);
if (transform != nullptr) {
if (transform->Sticky == true) {
return;
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);
@@ -398,7 +409,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);
@@ -406,12 +417,6 @@ 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));