diff --git a/CMakeLists.txt b/CMakeLists.txt index 763064ac..f43e51f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ set(SOURCES sources/Models/GameState.hpp sources/Runner/Runner.cpp sources/Runner/Runner.hpp + sources/Map/Map.cpp + sources/Map/Map.hpp sources/Component/Position/PositionComponent.cpp sources/Component/Position/PositionComponent.hpp sources/Component/Movable/MovableComponent.cpp diff --git a/assets/wall/breakable_wall.mtl b/assets/wall/breakable_wall.mtl index 7925a729..86d5a0cf 100644 --- a/assets/wall/breakable_wall.mtl +++ b/assets/wall/breakable_wall.mtl @@ -1,12 +1,54 @@ -# Blender MTL File: 'None' -# Material Count: 1 - -newmtl Cube.001 -Ns 225.000000 -Ka 1.000000 1.000000 1.000000 -Kd 0.800000 0.800000 0.800000 -Ks 0.500000 0.500000 0.500000 -Ke 0.000000 0.000000 0.000000 -Ni 1.450000 -d 1.000000 -illum 2 +# Blender v2.92.0 OBJ File: '' +# www.blender.org +mtllib breakable_wall.mtl +o cube +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 1.000000 +vt 1.000000 1.000000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.000000 1.000000 +vt 0.333333 1.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 0.000000 +vt 1.000000 0.000000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.666666 0.500000 +vt 0.666666 1.000000 +vt 0.333333 0.000000 +vt 0.666666 0.000000 +vt 0.333333 0.500000 +vt 0.666666 0.500000 +vn 0.0000 -0.0000 1.0000 +vn 0.0000 1.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn 0.0000 -1.0000 -0.0000 +vn 1.0000 0.0000 0.0000 +vn -1.0000 0.0000 0.0000 +usemtl cube +s 1 +f 1/1/1 2/2/1 3/3/1 +f 3/3/1 2/2/1 4/4/1 +f 3/5/2 4/6/2 5/7/2 +f 5/7/2 4/6/2 6/8/2 +f 5/9/3 6/10/3 7/11/3 +f 7/11/3 6/10/3 8/12/3 +f 7/13/4 8/14/4 1/15/4 +f 1/15/4 8/14/4 2/16/4 +f 2/17/5 8/12/5 4/18/5 +f 4/18/5 8/12/5 6/10/5 +f 7/19/6 1/20/6 5/21/6 +f 5/21/6 1/20/6 3/22/6 diff --git a/assets/wall/breakable_wall.obj b/assets/wall/breakable_wall.obj index 320cb55e..144c9997 100644 --- a/assets/wall/breakable_wall.obj +++ b/assets/wall/breakable_wall.obj @@ -1,338 +1,61 @@ -# Blender v2.92.0 OBJ File: '' -# www.blender.org -mtllib breakable_wall.mtl -o Cube.002 -v 0.404250 -0.428000 -0.404250 -v 0.404250 -0.428000 0.404250 -v -0.404250 -0.428000 0.404250 -v -0.404250 -0.428000 -0.404250 -v -0.404250 0.436000 0.404250 -v 0.404250 0.436000 0.404250 -v 0.404250 0.436000 -0.404250 -v -0.404250 0.436000 -0.404250 -v 0.432000 0.408250 -0.404250 -v 0.432000 0.408250 0.404250 -v 0.432000 -0.400250 0.404250 -v 0.432000 -0.400250 -0.404250 -v 0.404250 -0.500000 -0.404250 -v -0.404250 -0.500000 -0.404250 -v -0.404250 -0.500000 -0.504000 -v 0.404250 -0.500000 -0.504000 -v -0.404250 -0.500000 0.404250 -v 0.404250 -0.500000 0.404250 -v 0.404250 -0.500000 0.504000 -v -0.404250 -0.500000 0.504000 -v -0.404250 0.508000 -0.404250 -v 0.404250 0.508000 -0.404250 -v 0.404250 0.508000 -0.504000 -v -0.404250 0.508000 -0.504000 -v 0.404250 0.508000 0.404250 -v -0.404250 0.508000 0.404250 -v -0.404250 0.508000 0.504000 -v 0.404250 0.508000 0.504000 -v 0.504000 0.408250 -0.404250 -v 0.504000 -0.400250 -0.404250 -v 0.504000 -0.400250 -0.504000 -v 0.504000 0.408250 -0.504000 -v 0.504000 -0.400250 0.404250 -v 0.504000 0.408250 0.404250 -v 0.504000 0.408250 0.504000 -v 0.504000 -0.400250 0.504000 -v -0.504000 0.408250 0.404250 -v -0.504000 -0.400250 0.404250 -v -0.504000 -0.400250 0.504000 -v -0.504000 0.408250 0.504000 -v -0.504000 -0.400250 -0.404250 -v -0.504000 0.408250 -0.404250 -v -0.504000 0.408250 -0.504000 -v -0.504000 -0.400250 -0.504000 -v 0.404250 0.408250 0.504000 -v -0.404250 0.408250 0.504000 -v -0.404250 -0.400250 0.504000 -v 0.404250 -0.400250 0.504000 -v 0.504000 0.508000 -0.404250 -v 0.504000 0.508000 0.404250 -v 0.504000 -0.500000 0.404250 -v 0.504000 -0.500000 -0.404250 -v 0.404250 0.408250 -0.504000 -v -0.404250 0.408250 -0.504000 -v -0.404250 -0.400250 -0.504000 -v 0.404250 -0.400250 -0.504000 -v -0.504000 0.508000 -0.404250 -v -0.504000 0.508000 0.404250 -v -0.504000 -0.500000 0.404250 -v -0.504000 -0.500000 -0.404250 -v 0.504000 0.508000 -0.504000 -v 0.504000 -0.500000 -0.504000 -v 0.504000 -0.500000 0.504000 -v 0.504000 0.508000 0.504000 -v -0.504000 0.508000 0.504000 -v -0.504000 -0.500000 0.504000 -v -0.504000 -0.500000 -0.504000 -v -0.504000 0.508000 -0.504000 -v -0.404250 0.408250 0.432000 -v 0.404250 0.408250 0.432000 -v -0.404250 -0.400250 0.432000 -v 0.404250 -0.400250 0.432000 -v 0.404250 0.408250 -0.432000 -v -0.404250 0.408250 -0.432000 -v 0.404250 -0.400250 -0.432000 -v -0.404250 -0.400250 -0.432000 -v -0.432000 0.408250 0.404250 -v -0.432000 -0.400250 0.404250 -v -0.432000 0.408250 -0.404250 -v -0.432000 -0.400250 -0.404250 -vt 0.287300 0.056300 -vt 0.287300 0.282400 -vt 0.061200 0.282400 -vt 0.061200 0.056300 -vt 0.621800 0.620900 -vt 0.395400 0.620900 -vt 0.395400 0.394400 -vt 0.621800 0.394400 -vt 0.299200 0.394400 -vt 0.299200 0.620900 -vt 0.072700 0.620900 -vt 0.072700 0.394400 -vt 0.287300 0.036100 -vt 0.061200 0.036100 -vt 0.061200 0.008200 -vt 0.287300 0.008200 -vt 0.061200 0.302500 -vt 0.287300 0.302500 -vt 0.287300 0.330400 -vt 0.061200 0.330400 -vt 0.621800 0.374200 -vt 0.395400 0.374200 -vt 0.395400 0.346300 -vt 0.621800 0.346300 -vt 0.395400 0.641000 -vt 0.621800 0.641000 -vt 0.621800 0.669000 -vt 0.395400 0.669000 -vt 0.299200 0.374200 -vt 0.072700 0.374200 -vt 0.072700 0.346300 -vt 0.299200 0.346300 -vt 0.072700 0.641000 -vt 0.299200 0.641000 -vt 0.299200 0.669000 -vt 0.072700 0.669000 -vt 0.718100 0.641000 -vt 0.944500 0.641000 -vt 0.944500 0.669000 -vt 0.718100 0.669000 -vt 0.944500 0.374200 -vt 0.718100 0.374200 -vt 0.718100 0.346300 -vt 0.944500 0.346300 -vt 0.395400 0.696900 -vt 0.621800 0.696900 -vt 0.621800 0.963700 -vt 0.621800 0.991700 -vt 0.395400 0.991700 -vt 0.395400 0.963700 -vt 0.347300 0.394400 -vt 0.347300 0.620900 -vt 0.319300 0.620900 -vt 0.319300 0.394400 -vt 0.052500 0.394400 -vt 0.052500 0.620900 -vt 0.024600 0.620600 -vt 0.024600 0.394300 -vt 0.395400 0.318300 -vt 0.621800 0.318300 -vt 0.621800 0.051500 -vt 0.395400 0.051500 -vt 0.395400 0.023600 -vt 0.621800 0.023600 -vt 0.670000 0.394400 -vt 0.697900 0.394400 -vt 0.697900 0.620900 -vt 0.670000 0.620900 -vt 0.992600 0.620900 -vt 0.964700 0.620900 -vt 0.964700 0.394400 -vt 0.992600 0.394400 -vt 0.319300 0.366500 -vt 0.347300 0.366500 -vt 0.052500 0.366500 -vt 0.024600 0.366500 -vt 0.052500 0.648800 -vt 0.024600 0.648800 -vt 0.319300 0.648800 -vt 0.347300 0.648800 -vt 0.697900 0.648800 -vt 0.670000 0.648800 -vt 0.964700 0.648800 -vt 0.992600 0.648800 -vt 0.964700 0.366500 -vt 0.992600 0.366500 -vt 0.697900 0.366500 -vt 0.670000 0.366500 -vt 0.335400 0.282600 -vt 0.307500 0.282400 -vt 0.307500 0.056300 -vt 0.335400 0.056300 -vt 0.013200 0.282400 -vt 0.013200 0.056300 -vt 0.041100 0.056300 -vt 0.041100 0.282400 -vt 0.642000 0.620900 -vt 0.642000 0.394400 -vt 0.375200 0.394400 -vt 0.375200 0.620900 -vt 0.670000 0.717100 -vt 0.670000 0.943500 -vt 0.642000 0.943500 -vt 0.642000 0.717100 -vt 0.347300 0.717100 -vt 0.375200 0.717100 -vt 0.375200 0.943500 -vt 0.347300 0.943500 -vt 0.347300 0.298200 -vt 0.347300 0.071700 -vt 0.375200 0.071700 -vt 0.375200 0.298200 -vt 0.670000 0.071700 -vt 0.670000 0.298200 -vt 0.642000 0.298200 -vt 0.642000 0.071700 -vt 0.315200 0.008200 -vt 0.315200 0.036100 -vt 0.033300 0.008200 -vt 0.033300 0.036100 -vt 0.033300 0.302500 -vt 0.033300 0.330400 -vt 0.315200 0.302500 -vt 0.315200 0.330400 -vt 0.649800 0.374200 -vt 0.649800 0.346300 -vt 0.367400 0.374200 -vt 0.367400 0.346300 -vt 0.367400 0.669000 -vt 0.367400 0.641000 -vt 0.649800 0.669000 -vt 0.649800 0.641000 -vt 0.649800 0.696900 -vt 0.367400 0.696900 -vt 0.367400 0.991700 -vt 0.367400 0.963700 -vt 0.649800 0.963700 -vt 0.649800 0.991700 -vt 0.367400 0.318300 -vt 0.649800 0.318300 -vt 0.649800 0.023600 -vt 0.649800 0.051500 -vt 0.367400 0.051500 -vt 0.367400 0.023600 -vt 0.621800 0.717100 -vt 0.395400 0.717100 -vt 0.621800 0.943500 -vt 0.395400 0.943500 -vt 0.395400 0.298200 -vt 0.621800 0.298200 -vt 0.395400 0.071700 -vt 0.621800 0.071700 -vt 0.718100 0.620900 -vt 0.944500 0.620900 -vt 0.718100 0.394400 -vt 0.944500 0.394400 -vn 0.0000 -1.0000 -0.0000 -vn 0.0000 1.0000 0.0000 -vn 1.0000 0.0000 0.0000 -vn -1.0000 0.0000 0.0000 -vn 0.0000 0.0000 1.0000 -vn 0.0000 0.0000 -1.0000 -vn -0.7071 0.0000 0.7071 -vn 0.7071 0.0000 0.7071 -vn -0.7071 0.0000 -0.7071 -vn 0.7071 0.0000 -0.7071 -vn 0.7071 -0.7071 0.0000 -vn -0.7071 -0.7071 0.0000 -vn 0.7071 0.7071 0.0000 -vn -0.7071 0.7071 0.0000 -vn 0.0000 -0.7071 0.7071 -vn 0.0000 0.7071 0.7071 -vn 0.0000 -0.7071 -0.7071 -vn 0.0000 0.7071 -0.7071 -usemtl Cube.001 +# floor.obj +# + +mtllib floor.mtl +o floor + +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 + +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.666666 0.000000 +vt 1.000000 0.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.000000 1.000000 +vt 0.333333 1.000000 +vt 0.666666 1.000000 +vt 1.000000 1.000000 + +vn 0.000000 0.000000 1.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 -1.000000 0.000000 +vn 1.000000 0.000000 0.000000 +vn -1.000000 0.000000 0.000000 + +g floor +usemtl floor +# Back s 1 -f 1/1/1 2/2/1 3/3/1 4/4/1 -f 5/5/2 6/6/2 7/7/2 8/8/2 -f 9/9/3 10/10/3 11/11/3 12/12/3 -f 13/13/1 14/14/1 15/15/1 16/16/1 -f 17/17/1 18/18/1 19/19/1 20/20/1 -f 21/21/2 22/22/2 23/23/2 24/24/2 -f 25/25/2 26/26/2 27/27/2 28/28/2 -f 29/29/3 30/30/3 31/31/3 32/32/3 -f 33/33/3 34/34/3 35/35/3 36/36/3 -f 37/37/4 38/38/4 39/39/4 40/40/4 -f 41/41/4 42/42/4 43/43/4 44/44/4 -f 45/45/5 28/28/5 27/27/5 46/46/5 -f 47/47/5 20/48/5 19/49/5 48/50/5 -f 49/51/3 50/52/3 34/53/3 29/54/3 -f 30/55/3 33/56/3 51/57/3 52/58/3 -f 53/59/6 54/60/6 24/24/6 23/23/6 -f 55/61/6 56/62/6 16/63/6 15/64/6 -f 57/65/4 42/66/4 37/67/4 58/68/4 -f 59/69/4 38/70/4 41/71/4 60/72/4 -f 29/54/3 32/73/3 61/74/3 49/51/3 -f 31/75/3 30/55/3 52/58/3 62/76/3 -f 33/56/3 36/77/3 63/78/3 51/57/3 -f 35/79/3 34/53/3 50/52/3 64/80/3 -f 37/67/4 40/81/4 65/82/4 58/68/4 -f 39/83/4 38/70/4 59/69/4 66/84/4 -f 41/71/4 44/85/4 67/86/4 60/72/4 -f 43/87/4 42/66/4 57/65/4 68/88/4 -f 51/89/1 18/90/1 13/91/1 52/92/1 -f 59/93/1 60/94/1 14/95/1 17/96/1 -f 57/65/2 58/68/2 26/97/2 21/98/2 -f 50/52/2 49/51/2 22/99/2 25/100/2 -f 40/101/5 39/102/5 47/103/5 46/104/5 -f 35/105/5 45/106/5 48/107/5 36/108/5 -f 32/109/6 31/110/6 56/111/6 53/112/6 -f 44/113/6 43/114/6 54/115/6 55/116/6 -f 16/16/1 62/117/1 52/118/1 13/13/1 -f 67/119/1 15/15/1 14/14/1 60/120/1 -f 59/121/1 17/17/1 20/20/1 66/122/1 -f 18/18/1 51/123/1 63/124/1 19/19/1 -f 57/125/2 21/21/2 24/24/2 68/126/2 -f 22/22/2 49/127/2 61/128/2 23/23/2 -f 28/28/2 64/129/2 50/130/2 25/25/2 -f 65/131/2 27/27/2 26/26/2 58/132/2 -f 65/131/5 40/133/5 46/46/5 27/27/5 -f 45/45/5 35/134/5 64/129/5 28/28/5 -f 19/49/5 63/135/5 36/136/5 48/50/5 -f 39/137/5 66/138/5 20/48/5 47/47/5 -f 53/59/6 23/23/6 61/128/6 32/139/6 -f 43/140/6 68/126/6 24/24/6 54/60/6 -f 67/141/6 44/142/6 55/61/6 15/64/6 -f 16/63/6 56/62/6 31/143/6 62/144/6 -f 13/13/7 1/1/7 4/4/8 14/14/8 -f 18/90/9 2/2/9 1/1/7 13/91/7 -f 17/17/10 3/3/10 2/2/9 18/18/9 -f 14/95/8 4/4/8 3/3/10 17/96/10 -f 21/21/8 8/8/8 7/7/7 22/22/7 -f 26/97/10 5/5/10 8/8/8 21/98/8 -f 25/25/9 6/6/9 5/5/10 26/26/10 -f 22/99/7 7/7/7 6/6/9 25/100/9 -f 46/46/11 69/145/11 70/146/12 45/45/12 -f 47/103/13 71/147/13 69/145/11 46/104/11 -f 48/50/14 72/148/14 71/147/13 47/47/13 -f 45/106/12 70/146/12 72/148/14 48/107/14 -f 29/29/15 9/9/15 12/12/16 30/30/16 -f 34/53/17 10/10/17 9/9/15 29/54/15 -f 33/33/18 11/11/18 10/10/17 34/34/17 -f 30/55/16 12/12/16 11/11/18 33/56/18 -f 53/59/12 73/149/12 74/150/11 54/60/11 -f 56/111/14 75/151/14 73/149/12 53/112/12 -f 55/61/13 76/152/13 75/151/14 56/62/14 -f 54/115/11 74/150/11 76/152/13 55/116/13 -f 37/37/17 77/153/17 78/154/18 38/38/18 -f 42/66/15 79/155/15 77/153/17 37/67/17 -f 41/41/16 80/156/16 79/155/15 42/42/15 -f 38/70/18 78/154/18 80/156/16 41/71/16 -f 76/152/6 74/150/6 73/149/6 75/151/6 -f 78/154/4 77/153/4 79/155/4 80/156/4 -f 72/148/5 70/146/5 69/145/5 71/147/5 +f 1/1/1 2/4/1 3/9/1 +f 3/9/1 2/4/1 4/12/1 +# Top +s 2 +f 3/1/2 4/4/2 5/9/2 +f 5/9/2 4/4/2 6/12/2 +# Front +s 3 +f 5/1/3 6/4/3 7/9/3 +f 7/9/3 6/4/3 8/12/3 +# Bottom +s 4 +f 7/1/4 8/4/4 1/9/4 +f 1/9/4 8/4/4 2/12/4 +# Right +s 5 +f 2/1/5 8/4/5 4/9/5 +f 4/9/5 8/4/5 6/12/5 +# Left +s 6 +f 7/1/6 1/4/6 5/9/6 +f 5/9/6 1/4/6 3/12/6 \ No newline at end of file diff --git a/assets/wall/breakable_wall.png b/assets/wall/breakable_wall.png index bdbc5fda..8e18cca8 100644 Binary files a/assets/wall/breakable_wall.png and b/assets/wall/breakable_wall.png differ diff --git a/assets/wall/floor.mtl b/assets/wall/floor.mtl new file mode 100644 index 00000000..7925a729 --- /dev/null +++ b/assets/wall/floor.mtl @@ -0,0 +1,12 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl Cube.001 +Ns 225.000000 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 diff --git a/assets/wall/floor.obj b/assets/wall/floor.obj new file mode 100644 index 00000000..144c9997 --- /dev/null +++ b/assets/wall/floor.obj @@ -0,0 +1,61 @@ +# floor.obj +# + +mtllib floor.mtl +o floor + +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 + +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.666666 0.000000 +vt 1.000000 0.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.000000 1.000000 +vt 0.333333 1.000000 +vt 0.666666 1.000000 +vt 1.000000 1.000000 + +vn 0.000000 0.000000 1.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 -1.000000 0.000000 +vn 1.000000 0.000000 0.000000 +vn -1.000000 0.000000 0.000000 + +g floor +usemtl floor +# Back +s 1 +f 1/1/1 2/4/1 3/9/1 +f 3/9/1 2/4/1 4/12/1 +# Top +s 2 +f 3/1/2 4/4/2 5/9/2 +f 5/9/2 4/4/2 6/12/2 +# Front +s 3 +f 5/1/3 6/4/3 7/9/3 +f 7/9/3 6/4/3 8/12/3 +# Bottom +s 4 +f 7/1/4 8/4/4 1/9/4 +f 1/9/4 8/4/4 2/12/4 +# Right +s 5 +f 2/1/5 8/4/5 4/9/5 +f 4/9/5 8/4/5 6/12/5 +# Left +s 6 +f 7/1/6 1/4/6 5/9/6 +f 5/9/6 1/4/6 3/12/6 \ No newline at end of file diff --git a/assets/wall/floor.png b/assets/wall/floor.png new file mode 100644 index 00000000..74624ea9 Binary files /dev/null and b/assets/wall/floor.png differ diff --git a/assets/wall/hole.mtl b/assets/wall/hole.mtl new file mode 100644 index 00000000..7925a729 --- /dev/null +++ b/assets/wall/hole.mtl @@ -0,0 +1,12 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl Cube.001 +Ns 225.000000 +Ka 1.000000 1.000000 1.000000 +Kd 0.800000 0.800000 0.800000 +Ks 0.500000 0.500000 0.500000 +Ke 0.000000 0.000000 0.000000 +Ni 1.450000 +d 1.000000 +illum 2 diff --git a/assets/wall/hole.obj b/assets/wall/hole.obj new file mode 100644 index 00000000..519fef7e --- /dev/null +++ b/assets/wall/hole.obj @@ -0,0 +1,61 @@ +# hole.obj +# + +mtllib hole.mtl +o hole + +v -0.500000 -0.500000 0.500000 +v 0.500000 -0.500000 0.500000 +v -0.500000 0.500000 0.500000 +v 0.500000 0.500000 0.500000 +v -0.500000 0.500000 -0.500000 +v 0.500000 0.500000 -0.500000 +v -0.500000 -0.500000 -0.500000 +v 0.500000 -0.500000 -0.500000 + +vt 0.000000 0.000000 +vt 0.333333 0.000000 +vt 0.666666 0.000000 +vt 1.000000 0.000000 +vt 0.000000 0.500000 +vt 0.333333 0.500000 +vt 0.666666 0.500000 +vt 1.000000 0.500000 +vt 0.000000 1.000000 +vt 0.333333 1.000000 +vt 0.666666 1.000000 +vt 1.000000 1.000000 + +vn 0.000000 0.000000 1.000000 +vn 0.000000 1.000000 0.000000 +vn 0.000000 0.000000 -1.000000 +vn 0.000000 -1.000000 0.000000 +vn 1.000000 0.000000 0.000000 +vn -1.000000 0.000000 0.000000 + +g floor +usemtl floor +# Back +s 1 +f 1/1/1 2/4/1 3/9/1 +f 3/9/1 2/4/1 4/12/1 +# Top +s 2 +f 3/1/2 4/4/2 5/9/2 +f 5/9/2 4/4/2 6/12/2 +# Front +s 3 +f 5/1/3 6/4/3 7/9/3 +f 7/9/3 6/4/3 8/12/3 +# Bottom +s 4 +f 7/1/4 8/4/4 1/9/4 +f 1/9/4 8/4/4 2/12/4 +# Right +s 5 +f 2/1/5 8/4/5 4/9/5 +f 4/9/5 8/4/5 6/12/5 +# Left +s 6 +f 7/1/6 1/4/6 5/9/6 +f 5/9/6 1/4/6 3/12/6 \ No newline at end of file diff --git a/assets/wall/hole.png b/assets/wall/hole.png new file mode 100644 index 00000000..fe9ee288 Binary files /dev/null and b/assets/wall/hole.png differ diff --git a/lib/Ray/sources/Model/Model.cpp b/lib/Ray/sources/Model/Model.cpp index 92bf427c..aab5fdc6 100644 --- a/lib/Ray/sources/Model/Model.cpp +++ b/lib/Ray/sources/Model/Model.cpp @@ -16,10 +16,10 @@ namespace RAY::Drawables::Drawables3D { Model::Model(const std::string &filename, std::optional> texture, + const RAY::Vector3 &scale, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, - float rotationAngle, - const RAY::Vector3 &scale) + float rotationAngle) : ADrawable3D(position, WHITE), _model(_modelsCache.fetch(filename)), _rotationAxis(rotationAxis), diff --git a/lib/Ray/sources/Model/Model.hpp b/lib/Ray/sources/Model/Model.hpp index 8ab6a6e4..7a7e3fdf 100644 --- a/lib/Ray/sources/Model/Model.hpp +++ b/lib/Ray/sources/Model/Model.hpp @@ -27,10 +27,10 @@ namespace RAY::Drawables::Drawables3D { //! @param filePath: path to file to load Model(const std::string &filePath, std::optional> texture = std::nullopt, + const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1), const RAY::Vector3 &position = {0, 0, 0}, const RAY::Vector3 &rotationAxis = RAY::Vector3(0, 1, 0), - float rotationAngle = 0, - const RAY::Vector3 &scale = RAY::Vector3(1, 1, 1)); + float rotationAngle = 0); //! @brief Create an model, loading a file //! @param mesh: mesh to load diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp new file mode 100644 index 00000000..c90609f4 --- /dev/null +++ b/sources/Map/Map.cpp @@ -0,0 +1,238 @@ +// +// Created by Tom Augier on 5/26/21. +// Edited by Benjamin Henry on 5/26/21. +// + +#include "Map.hpp" + +namespace RAY3D = RAY::Drawables::Drawables3D; + +namespace BBM +{ + void MapGenerator::generateUnbreakableBlock(int width, int height, std::shared_ptr scene) + { + std::string unbreakableObj = "assets/wall/unbreakable_wall.obj"; + std::string unbreakablePnj = "assets/wall/unbreakable_wall.png"; + + for (int i = 0; i < width + 1; i++) { + for (int j = 0; j < height + 1; j++) { + if (!(i % 2) && !(j % 2)) { + scene->addEntity("Unbreakable Wall") + .addComponent(Vector3f(i, 0, j)) + //.addComponent(1) + .addComponent>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj)); + } + } + } + } + + void MapGenerator::generateWall(int width, int height, std::shared_ptr scene) + { + std::string unbreakableObj = "assets/wall/unbreakable_wall.obj"; + std::string unbreakablePnj = "assets/wall/unbreakable_wall.png"; + + scene->addEntity("Bottom Wall") + .addComponent(Vector3f((width + 1) / 2, 0, -1)) + //.addComponent(1) + .addComponent>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); + scene->addEntity("Upper Wall") + .addComponent(Vector3f((width + 1) / 2, 0, height + 1)) + //.addComponent(1) + .addComponent>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(width + 3, 1, 1)); + scene->addEntity("Left Wall") + .addComponent(Vector3f(width + 1, 0, (height + 1) / 2)) + //.addComponent(1) + .addComponent>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 3)); + scene->addEntity("Right Wall") + .addComponent(Vector3f(-1, 0, (height + 1) / 2)) + //.addComponent(1) + .addComponent>(unbreakableObj, std::make_pair(MAP_DIFFUSE, unbreakablePnj), RAY::Vector3(1, 1, height + 3)); + } + + void MapGenerator::generateFloor(int width, int height, std::shared_ptr scene) + { + scene->addEntity("Floor") + .addComponent(Vector3f(width / 2, -1, height / 2)) + //.addComponent(1) + .addComponent>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png"), RAY::Vector3(width + 2, 0, height + 2)); + } + + void MapGenerator::createElement(Vector3f coords, std::shared_ptr scene, BlockType blockType) + { + std::map elements = { + {BREAKABLE, &createBreakable}, + {UNBREAKABLE, &createUnbreakable}, + {HOLE, &createHole}, + {FLOOR, &createFloor}, + /* {BUMPER, &createBumper}, + {STAIRS, &createStairs} */ + }; + + try { + auto element = elements.at(blockType); + element(coords, scene); + } catch (std::exception const &err) { + return; + } + } + + void MapGenerator::createBreakable(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Breakable Block") + .addComponent(coords) + .addComponent(1) + //.addComponent(1) + .addComponent>("assets/wall/breakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/breakable_wall.png")); + } + + void MapGenerator::createFloor(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Floor") + .addComponent(Vector3f(coords)) + //.addComponent(1) + .addComponent>("assets/wall/floor.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/floor.png")); + } + + void MapGenerator::createUnbreakable(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Unbreakable Block") + .addComponent(coords) + //.addComponent(1) + .addComponent>("assets/wall/unbreakable_wall.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/unbreakable_wall.png")); + } + + void MapGenerator::createHole(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Hole Block") + .addComponent(Vector3f(coords.x, coords.y - 1, coords.z)) + .addComponent>("assets/wall/hole.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/hole.png")); + /* .addComponent([](const WAL::Entity &entity, WAL::Entity &other) { + if (other.hasComponent()) { + auto &health = other.getComponent(); + health.takeDmg(health.getHealthPoint()); + } + }); */ + } + + void MapGenerator::createBumper(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Bumper Block") + .addComponent(Vector3f(coords.x, coords.y - 1, coords.z)) + .addComponent>("assets/wall/bumper_block.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/bumper_block.png")); + /* .addComponent([](const WAL::Entity &entity, WAL::Entity &other) { + if (other.hasComponent()) { + auto &movable = other.getComponent(); + movable.addForce(Vector3f(0, 5, 0)); + } + } */ + } + + void MapGenerator::createStairs(Vector3f coords, std::shared_ptr scene) + { + scene->addEntity("Stairs Block") + .addComponent(coords) + //.addComponent(1) + .addComponent>("assets/wall/stairs_block.obj", std::make_pair(MAP_DIFFUSE, "assets/wall/stairs_block.png")); + } + + bool MapGenerator::isCloseToBlockType(std::map, BlockType> map, int x, int y, int z, BlockType blockType) + { + return (map[std::make_tuple(x - 1, y, z)] == blockType || + map[std::make_tuple(x + 1, y, z)] == blockType || + map[std::make_tuple(x, y, z + 1)] == blockType || + map[std::make_tuple(x, y, z - 1)] == blockType); + } + + MapGenerator::BlockType MapGenerator::getRandomBlockType() + { + double rnd = static_cast(std::rand())/RAND_MAX; + + if (rnd > 0.95) + return HOLE; + if (rnd > 0.10) + return BREAKABLE; + return NOTHING; + } + + MapGenerator::MapBlock MapGenerator::createHeight(MapBlock map, int width, int height) + { + double rnd = static_cast(std::rand())/RAND_MAX; + + if (rnd > 0.60) { + for (int i = 0; i < width; i++) { + map[std::make_tuple(i, 1, height)] = map[std::make_tuple(i, 0, height)]; + map[std::make_tuple(i, 0, height)] = FLOOR; + } + for (int j = 0; j < height; j++) { + map[std::make_tuple(width, 1, j)] = map[std::make_tuple(width, 0, j)]; + map[std::make_tuple(width, 0, j)] = FLOOR; + } + } + if (rnd > 0.30) { + for (int i = width - width/4; i < width + width/4 + 1; i++) { + for (int j = height - height/4; j < height + height/4 + 1; j++) { + map[std::make_tuple(i, 1, j)] = map[std::make_tuple(i, 0, j)]; + map[std::make_tuple(i, 0, j)] = FLOOR; + } + } + } + return map; + } + + MapGenerator::MapBlock MapGenerator::createSpawner(MapBlock map, int width, int height) + { + map[std::make_tuple(0, 0, 0)] = SPAWNER; + map[std::make_tuple(width, 0, 0)] = SPAWNER; + map[std::make_tuple(0, 0, height)] = SPAWNER; + map[std::make_tuple(width, 0, height)] = SPAWNER; + + return map; + } + + MapGenerator::MapBlock MapGenerator::createMap(int width, int height) + { + MapBlock map; + + width = width % 2 ? width + 1 : width; + height = height % 2 ? height + 1 : height; + for (int i = 0; i < width; i++) { + for (int j = 0; j < height; j++) + map[std::make_tuple(i, 0, j)] = NOTHING; + } + map = createSpawner(map, width, height); + for (int i = 0; i < width + 1; i++) { + for (int j = 0; j < height + 1; j++) { + if (map[std::make_tuple(i, 0, j)] == SPAWNER) + continue; + if (isCloseToBlockType(map, i , 0, j, SPAWNER)) + map[std::make_tuple(i, 0, j)] = NOTHING; + else + map[std::make_tuple(i, 0, j)] = getRandomBlockType(); + if (map[std::make_tuple(i, 0, j)] == UNBREAKABLE && isCloseToBlockType(map, i, 0, j, UNBREAKABLE)) + map[std::make_tuple(i, 0, j)] = BREAKABLE; + } + } + for (int i = 0; i < width + 1; i++) { + for (int j = 0; j < height + 1; j++) { + if (!((i + 1) % 2) && !((j + 1) % 2)) + map[std::make_tuple(i, 0, j)] = UNBREAKABLE; + } + } + map = createHeight(map, width, height); + return (map); + } + + void MapGenerator::loadMap(int width, int height, std::map, + BlockType> map, std::shared_ptr scene) + { + generateWall(width, height, scene); + generateFloor(width, height, scene); + for (int x = 0; x < width + 1; x++) { + for (int z = 0; z < height + 1; z++) { + for (int y = 0; y < 1 + 1; y++) + createElement(Vector3f(x, y, z), scene, map[std::make_tuple(x, y, z)]); + } + } + } + +} // namespace BBM \ No newline at end of file diff --git a/sources/Map/Map.hpp b/sources/Map/Map.hpp new file mode 100644 index 00000000..962ce7ce --- /dev/null +++ b/sources/Map/Map.hpp @@ -0,0 +1,137 @@ +// +// Created by Tom Augier on 5/26/21. +// Edited by Benjamin Henry on 5/26/21. +// + + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include "Component/Renderer/Drawable3DComponent.hpp" +#include "System/Renderer/Renderer3DSystem.hpp" +#include "Scene/Scene.hpp" +#include "Model/Model.hpp" +#include "Component/Component.hpp" +#include "Component/Position/PositionComponent.hpp" +#include "Component/Health/HealthComponent.hpp" +#include "Component/Movable/MovableComponent.hpp" + +namespace BBM +{ + + class MapGenerator + { + private: + //! @brief Enum of the block available. + enum BlockType { + NOTHING, + BREAKABLE, + HOLE, + FLOOR, + BUMPER, + STAIRS, + SPAWNER, + UNBREAKABLE + }; + + using MapElem = std::function scene)>; + using MapBlock = std::map, BlockType>; + + //! @brief Generate random block type + static BlockType getRandomBlockType(); + + //! @param map ASCII map + //! @param x x index on the block + //! @param z z index on the block + //! @param blockType blockType to compare with position + static bool isCloseToBlockType(std::map, BlockType> map, int x, int y, int z, BlockType blockType); + + //! @param width Width of the map + //! @param height Height of the map + //! @param scene Scene where the map is instanced + //! @brief Generate the unbreakable block of the map + static void generateUnbreakableBlock(int width, int height, std::shared_ptr scene); + + //! @param width Width of the map + //! @param height Height of the map + //! @param scene Scene where the map is instanced + //! @brief Generate the wall of the map + static void generateWall(int width, int height, std::shared_ptr scene); + + //! @param width Width of the map + //! @param height Height of the map + //! @param scene Scene where the map is instanced + //! @brief Generate the floor of the map + static void generateFloor(int width, int height, std::shared_ptr scene); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create element of the map + static void createElement(Vector3f coords, std::shared_ptr scene, BlockType blockType); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create breakable of the map + static void createBreakable(Vector3f coords, std::shared_ptr scene); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create unbreakable of the map + static void createUnbreakable(Vector3f coords, std::shared_ptr scene); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create hole of the map + static void createHole(Vector3f coords, std::shared_ptr scene); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create bumper of the map + static void createBumper(Vector3f coords, std::shared_ptr scene); + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create bumper of the map + static void createFloor(Vector3f coords, std::shared_ptr scene); + + + //! @param coords coords of the element + //! @param scene Scene where the map is instanced + //! @brief Create stair of the map + static void createStairs(Vector3f coords, std::shared_ptr scene); + + //! @param map Map to load with block declared inside + //! @param width Width of the map + //! @param height Height of the map + //! @brief Generate map of block to be loaded + static MapBlock createSpawner(MapBlock map, int width, int height); + + //! @param map Map to load with block declared inside + //! @param width Width of the map + //! @param height Height of the map + //! @brief Generate height for the map + static MapBlock createHeight(MapBlock map, int width, int height); + + + public: + + //! @param width Width of the map + //! @param height Height of the map + //! @brief Generate map of block to be loaded + static MapBlock createMap(int width, int height); + + //! @param width Width of the map + //! @param height Height of the map + //! @param map Map to load with block declared inside + //! @param scene Scene where the map is instanced + //! @brief Generate the map + static void loadMap(int width, int height, MapBlock map, std::shared_ptr scene); + + }; +} // namespace BBM \ No newline at end of file diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 9e527fcb..d2a1adc9 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -22,6 +22,7 @@ #include "Component/Renderer/CameraComponent.hpp" #include "Runner.hpp" #include "Models/GameState.hpp" +#include "Map/Map.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; namespace RAY3D = RAY::Drawables::Drawables3D; @@ -74,8 +75,10 @@ namespace BBM .addComponent() .addComponent(); scene->addEntity("camera") - .addComponent(0, 20, -5) - .addComponent(); + .addComponent(8, 20, 7) + .addComponent(Vector3f(8, 0, 8)); + std::srand(std::time(NULL)); + MapGenerator::loadMap(16, 16, MapGenerator::createMap(16, 16), scene); return scene; } diff --git a/sources/main.cpp b/sources/main.cpp index 43dccd7d..cb4a0269 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -22,8 +22,10 @@ #include "Drawables/3D/Sphere.hpp" #include "Model/Model.hpp" #include "Model/ModelAnimations.hpp" -#include "System/Renderer/Renderer3DSystem.hpp" -#include "System/Renderer/Renderer2DSystem.hpp" +#include +#include +#include +#include #include "Component/Renderer/Drawable3DComponent.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" #include "System/Renderer/RenderScreenSystem.hpp" @@ -45,8 +47,11 @@ std::string get_full_path(const std::string &color) return path; } - - +int demo(void) +{ + + return (0); +} void usage(const std::string &bin) { @@ -62,6 +67,6 @@ int main(int argc, char **argv) usage(argv[0]); return 1; } -// return demo(); + //return demo(); return BBM::run(); }