Compare commits
1 commit
| Author | SHA1 | Date | |
|---|---|---|---|
| f43544d15d |
19 changed files with 2379 additions and 2063 deletions
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -1,5 +1,5 @@
|
||||||
.idea/
|
.idea/
|
||||||
bin/
|
bin/
|
||||||
cmake-build-debug/
|
cmake-build-debug/
|
||||||
include/
|
include/
|
||||||
lib/
|
lib/
|
||||||
70
Asteroid.h
70
Asteroid.h
|
|
@ -1,35 +1,35 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 9/28/2020.
|
// Created by benmo on 9/28/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_ASTEROID_H
|
#ifndef SFML_TEMPLATE_ASTEROID_H
|
||||||
#define SFML_TEMPLATE_ASTEROID_H
|
#define SFML_TEMPLATE_ASTEROID_H
|
||||||
|
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
|
|
||||||
class Asteroid : public Entity {
|
class Asteroid : public Entity {
|
||||||
public:
|
public:
|
||||||
Asteroid(int health, int points, const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Entity(health, points, texture, scale, xPos, yPos, velocity, direction) {
|
Asteroid(int health, int points, const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Entity(health, points, texture, scale, xPos, yPos, velocity, direction) {
|
||||||
size = health;
|
size = health;
|
||||||
type = "asteroid";
|
type = "asteroid";
|
||||||
}
|
}
|
||||||
|
|
||||||
int getSize() const {
|
int getSize() const {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hit(vector<MySprite> &animations, Sound &sound, Texture &explosion, default_random_engine &gen) {
|
void hit(vector<MySprite> &animations, Sound &sound, Texture &explosion, default_random_engine &gen) {
|
||||||
uniform_int_distribution<int> angle(0, 359);
|
uniform_int_distribution<int> angle(0, 359);
|
||||||
animations.emplace_back(explosion, getSize()*65, getXPos(), getYPos(), 0, angle(gen));
|
animations.emplace_back(explosion, getSize()*65, getXPos(), getYPos(), 0, angle(gen));
|
||||||
animations[animations.size() - 1].makeAnimated(5, 5, 0.01,23);
|
animations[animations.size() - 1].makeAnimated(5, 5, 0.01,23);
|
||||||
|
|
||||||
sound.setVolume(100.0/((4-size)/1.5));
|
sound.setVolume(100.0/(4-size));
|
||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_ASTEROID_H
|
#endif //SFML_TEMPLATE_ASTEROID_H
|
||||||
|
|
|
||||||
378
Collision.cpp
378
Collision.cpp
|
|
@ -1,190 +1,190 @@
|
||||||
/*
|
/*
|
||||||
* File: collision.cpp
|
* File: collision.cpp
|
||||||
* Author: Nick (original version), ahnonay (SFML2 compatibility)
|
* Author: Nick (original version), ahnonay (SFML2 compatibility)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
|
|
||||||
namespace Collision
|
namespace Collision
|
||||||
{
|
{
|
||||||
class BitmaskManager
|
class BitmaskManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~BitmaskManager() {
|
~BitmaskManager() {
|
||||||
std::map<const sf::Texture*, sf::Uint8*>::const_iterator end = Bitmasks.end();
|
std::map<const sf::Texture*, sf::Uint8*>::const_iterator end = Bitmasks.end();
|
||||||
for (std::map<const sf::Texture*, sf::Uint8*>::const_iterator iter = Bitmasks.begin(); iter!=end; iter++)
|
for (std::map<const sf::Texture*, sf::Uint8*>::const_iterator iter = Bitmasks.begin(); iter!=end; iter++)
|
||||||
delete [] iter->second;
|
delete [] iter->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Uint8 GetPixel (const sf::Uint8* mask, const sf::Texture* tex, unsigned int x, unsigned int y) {
|
sf::Uint8 GetPixel (const sf::Uint8* mask, const sf::Texture* tex, unsigned int x, unsigned int y) {
|
||||||
if (x>tex->getSize().x||y>tex->getSize().y)
|
if (x>tex->getSize().x||y>tex->getSize().y)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return mask[x+y*tex->getSize().x];
|
return mask[x+y*tex->getSize().x];
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Uint8* GetMask (const sf::Texture* tex) {
|
sf::Uint8* GetMask (const sf::Texture* tex) {
|
||||||
sf::Uint8* mask;
|
sf::Uint8* mask;
|
||||||
std::map<const sf::Texture*, sf::Uint8*>::iterator pair = Bitmasks.find(tex);
|
std::map<const sf::Texture*, sf::Uint8*>::iterator pair = Bitmasks.find(tex);
|
||||||
if (pair==Bitmasks.end())
|
if (pair==Bitmasks.end())
|
||||||
{
|
{
|
||||||
sf::Image img = tex->copyToImage();
|
sf::Image img = tex->copyToImage();
|
||||||
mask = CreateMask (tex, img);
|
mask = CreateMask (tex, img);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mask = pair->second;
|
mask = pair->second;
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Uint8* CreateMask (const sf::Texture* tex, const sf::Image& img) {
|
sf::Uint8* CreateMask (const sf::Texture* tex, const sf::Image& img) {
|
||||||
sf::Uint8* mask = new sf::Uint8[tex->getSize().y*tex->getSize().x];
|
sf::Uint8* mask = new sf::Uint8[tex->getSize().y*tex->getSize().x];
|
||||||
|
|
||||||
for (unsigned int y = 0; y<tex->getSize().y; y++)
|
for (unsigned int y = 0; y<tex->getSize().y; y++)
|
||||||
{
|
{
|
||||||
for (unsigned int x = 0; x<tex->getSize().x; x++)
|
for (unsigned int x = 0; x<tex->getSize().x; x++)
|
||||||
mask[x+y*tex->getSize().x] = img.getPixel(x,y).a;
|
mask[x+y*tex->getSize().x] = img.getPixel(x,y).a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmasks.insert(std::pair<const sf::Texture*, sf::Uint8*>(tex,mask));
|
Bitmasks.insert(std::pair<const sf::Texture*, sf::Uint8*>(tex,mask));
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
std::map<const sf::Texture*, sf::Uint8*> Bitmasks;
|
std::map<const sf::Texture*, sf::Uint8*> Bitmasks;
|
||||||
};
|
};
|
||||||
|
|
||||||
BitmaskManager Bitmasks;
|
BitmaskManager Bitmasks;
|
||||||
|
|
||||||
bool PixelPerfectTest(const sf::Sprite& Object1, const sf::Sprite& Object2, sf::Uint8 AlphaLimit) {
|
bool PixelPerfectTest(const sf::Sprite& Object1, const sf::Sprite& Object2, sf::Uint8 AlphaLimit) {
|
||||||
sf::FloatRect Intersection;
|
sf::FloatRect Intersection;
|
||||||
if (Object1.getGlobalBounds().intersects(Object2.getGlobalBounds(), Intersection)) {
|
if (Object1.getGlobalBounds().intersects(Object2.getGlobalBounds(), Intersection)) {
|
||||||
sf::IntRect O1SubRect = Object1.getTextureRect();
|
sf::IntRect O1SubRect = Object1.getTextureRect();
|
||||||
sf::IntRect O2SubRect = Object2.getTextureRect();
|
sf::IntRect O2SubRect = Object2.getTextureRect();
|
||||||
|
|
||||||
sf::Uint8* mask1 = Bitmasks.GetMask(Object1.getTexture());
|
sf::Uint8* mask1 = Bitmasks.GetMask(Object1.getTexture());
|
||||||
sf::Uint8* mask2 = Bitmasks.GetMask(Object2.getTexture());
|
sf::Uint8* mask2 = Bitmasks.GetMask(Object2.getTexture());
|
||||||
|
|
||||||
// Loop through our pixels
|
// Loop through our pixels
|
||||||
for (int i = Intersection.left; i < Intersection.left+Intersection.width; i++) {
|
for (int i = Intersection.left; i < Intersection.left+Intersection.width; i++) {
|
||||||
for (int j = Intersection.top; j < Intersection.top+Intersection.height; j++) {
|
for (int j = Intersection.top; j < Intersection.top+Intersection.height; j++) {
|
||||||
|
|
||||||
sf::Vector2f o1v = Object1.getInverseTransform().transformPoint(i, j);
|
sf::Vector2f o1v = Object1.getInverseTransform().transformPoint(i, j);
|
||||||
sf::Vector2f o2v = Object2.getInverseTransform().transformPoint(i, j);
|
sf::Vector2f o2v = Object2.getInverseTransform().transformPoint(i, j);
|
||||||
|
|
||||||
// Make sure pixels fall within the sprite's subrect
|
// Make sure pixels fall within the sprite's subrect
|
||||||
if (o1v.x > 0 && o1v.y > 0 && o2v.x > 0 && o2v.y > 0 &&
|
if (o1v.x > 0 && o1v.y > 0 && o2v.x > 0 && o2v.y > 0 &&
|
||||||
o1v.x < O1SubRect.width && o1v.y < O1SubRect.height &&
|
o1v.x < O1SubRect.width && o1v.y < O1SubRect.height &&
|
||||||
o2v.x < O2SubRect.width && o2v.y < O2SubRect.height) {
|
o2v.x < O2SubRect.width && o2v.y < O2SubRect.height) {
|
||||||
|
|
||||||
if (Bitmasks.GetPixel(mask1, Object1.getTexture(), (int)(o1v.x)+O1SubRect.left, (int)(o1v.y)+O1SubRect.top) > AlphaLimit &&
|
if (Bitmasks.GetPixel(mask1, Object1.getTexture(), (int)(o1v.x)+O1SubRect.left, (int)(o1v.y)+O1SubRect.top) > AlphaLimit &&
|
||||||
Bitmasks.GetPixel(mask2, Object2.getTexture(), (int)(o2v.x)+O2SubRect.left, (int)(o2v.y)+O2SubRect.top) > AlphaLimit)
|
Bitmasks.GetPixel(mask2, Object2.getTexture(), (int)(o2v.x)+O2SubRect.left, (int)(o2v.y)+O2SubRect.top) > AlphaLimit)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateTextureAndBitmask(sf::Texture &LoadInto, const std::string& Filename)
|
bool CreateTextureAndBitmask(sf::Texture &LoadInto, const std::string& Filename)
|
||||||
{
|
{
|
||||||
sf::Image img;
|
sf::Image img;
|
||||||
if (!img.loadFromFile(Filename))
|
if (!img.loadFromFile(Filename))
|
||||||
return false;
|
return false;
|
||||||
if (!LoadInto.loadFromImage(img))
|
if (!LoadInto.loadFromImage(img))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Bitmasks.CreateMask(&LoadInto, img);
|
Bitmasks.CreateMask(&LoadInto, img);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f GetSpriteCenter (const sf::Sprite& Object)
|
sf::Vector2f GetSpriteCenter (const sf::Sprite& Object)
|
||||||
{
|
{
|
||||||
sf::FloatRect AABB = Object.getGlobalBounds();
|
sf::FloatRect AABB = Object.getGlobalBounds();
|
||||||
return sf::Vector2f (AABB.left+AABB.width/2.f, AABB.top+AABB.height/2.f);
|
return sf::Vector2f (AABB.left+AABB.width/2.f, AABB.top+AABB.height/2.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f GetSpriteSize (const sf::Sprite& Object)
|
sf::Vector2f GetSpriteSize (const sf::Sprite& Object)
|
||||||
{
|
{
|
||||||
sf::IntRect OriginalSize = Object.getTextureRect();
|
sf::IntRect OriginalSize = Object.getTextureRect();
|
||||||
sf::Vector2f Scale = Object.getScale();
|
sf::Vector2f Scale = Object.getScale();
|
||||||
return sf::Vector2f (OriginalSize.width*Scale.x, OriginalSize.height*Scale.y);
|
return sf::Vector2f (OriginalSize.width*Scale.x, OriginalSize.height*Scale.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
|
bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
|
||||||
sf::Vector2f Obj1Size = GetSpriteSize(Object1);
|
sf::Vector2f Obj1Size = GetSpriteSize(Object1);
|
||||||
sf::Vector2f Obj2Size = GetSpriteSize(Object2);
|
sf::Vector2f Obj2Size = GetSpriteSize(Object2);
|
||||||
float Radius1 = (Obj1Size.x + Obj1Size.y) / 4;
|
float Radius1 = (Obj1Size.x + Obj1Size.y) / 4;
|
||||||
float Radius2 = (Obj2Size.x + Obj2Size.y) / 4;
|
float Radius2 = (Obj2Size.x + Obj2Size.y) / 4;
|
||||||
|
|
||||||
sf::Vector2f Distance = GetSpriteCenter(Object1)-GetSpriteCenter(Object2);
|
sf::Vector2f Distance = GetSpriteCenter(Object1)-GetSpriteCenter(Object2);
|
||||||
|
|
||||||
return (Distance.x * Distance.x + Distance.y * Distance.y <= (Radius1 + Radius2) * (Radius1 + Radius2));
|
return (Distance.x * Distance.x + Distance.y * Distance.y <= (Radius1 + Radius2) * (Radius1 + Radius2));
|
||||||
}
|
}
|
||||||
|
|
||||||
class OrientedBoundingBox // Used in the BoundingBoxTest
|
class OrientedBoundingBox // Used in the BoundingBoxTest
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OrientedBoundingBox (const sf::Sprite& Object) // Calculate the four points of the OBB from a transformed (scaled, rotated...) sprite
|
OrientedBoundingBox (const sf::Sprite& Object) // Calculate the four points of the OBB from a transformed (scaled, rotated...) sprite
|
||||||
{
|
{
|
||||||
sf::Transform trans = Object.getTransform();
|
sf::Transform trans = Object.getTransform();
|
||||||
sf::IntRect local = Object.getTextureRect();
|
sf::IntRect local = Object.getTextureRect();
|
||||||
Points[0] = trans.transformPoint(0.f, 0.f);
|
Points[0] = trans.transformPoint(0.f, 0.f);
|
||||||
Points[1] = trans.transformPoint(local.width, 0.f);
|
Points[1] = trans.transformPoint(local.width, 0.f);
|
||||||
Points[2] = trans.transformPoint(local.width, local.height);
|
Points[2] = trans.transformPoint(local.width, local.height);
|
||||||
Points[3] = trans.transformPoint(0.f, local.height);
|
Points[3] = trans.transformPoint(0.f, local.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
sf::Vector2f Points[4];
|
sf::Vector2f Points[4];
|
||||||
|
|
||||||
void ProjectOntoAxis (const sf::Vector2f& Axis, float& Min, float& Max) // Project all four points of the OBB onto the given axis and return the dotproducts of the two outermost points
|
void ProjectOntoAxis (const sf::Vector2f& Axis, float& Min, float& Max) // Project all four points of the OBB onto the given axis and return the dotproducts of the two outermost points
|
||||||
{
|
{
|
||||||
Min = (Points[0].x*Axis.x+Points[0].y*Axis.y);
|
Min = (Points[0].x*Axis.x+Points[0].y*Axis.y);
|
||||||
Max = Min;
|
Max = Min;
|
||||||
for (int j = 1; j<4; j++)
|
for (int j = 1; j<4; j++)
|
||||||
{
|
{
|
||||||
float Projection = (Points[j].x*Axis.x+Points[j].y*Axis.y);
|
float Projection = (Points[j].x*Axis.x+Points[j].y*Axis.y);
|
||||||
|
|
||||||
if (Projection<Min)
|
if (Projection<Min)
|
||||||
Min=Projection;
|
Min=Projection;
|
||||||
if (Projection>Max)
|
if (Projection>Max)
|
||||||
Max=Projection;
|
Max=Projection;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
|
bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
|
||||||
OrientedBoundingBox OBB1 (Object1);
|
OrientedBoundingBox OBB1 (Object1);
|
||||||
OrientedBoundingBox OBB2 (Object2);
|
OrientedBoundingBox OBB2 (Object2);
|
||||||
|
|
||||||
// Create the four distinct axes that are perpendicular to the edges of the two rectangles
|
// Create the four distinct axes that are perpendicular to the edges of the two rectangles
|
||||||
sf::Vector2f Axes[4] = {
|
sf::Vector2f Axes[4] = {
|
||||||
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[0].x,
|
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[0].x,
|
||||||
OBB1.Points[1].y-OBB1.Points[0].y),
|
OBB1.Points[1].y-OBB1.Points[0].y),
|
||||||
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[2].x,
|
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[2].x,
|
||||||
OBB1.Points[1].y-OBB1.Points[2].y),
|
OBB1.Points[1].y-OBB1.Points[2].y),
|
||||||
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[3].x,
|
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[3].x,
|
||||||
OBB2.Points[0].y-OBB2.Points[3].y),
|
OBB2.Points[0].y-OBB2.Points[3].y),
|
||||||
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[1].x,
|
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[1].x,
|
||||||
OBB2.Points[0].y-OBB2.Points[1].y)
|
OBB2.Points[0].y-OBB2.Points[1].y)
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int i = 0; i<4; i++) // For each axis...
|
for (int i = 0; i<4; i++) // For each axis...
|
||||||
{
|
{
|
||||||
float MinOBB1, MaxOBB1, MinOBB2, MaxOBB2;
|
float MinOBB1, MaxOBB1, MinOBB2, MaxOBB2;
|
||||||
|
|
||||||
// ... project the points of both OBBs onto the axis ...
|
// ... project the points of both OBBs onto the axis ...
|
||||||
OBB1.ProjectOntoAxis(Axes[i], MinOBB1, MaxOBB1);
|
OBB1.ProjectOntoAxis(Axes[i], MinOBB1, MaxOBB1);
|
||||||
OBB2.ProjectOntoAxis(Axes[i], MinOBB2, MaxOBB2);
|
OBB2.ProjectOntoAxis(Axes[i], MinOBB2, MaxOBB2);
|
||||||
|
|
||||||
// ... and check whether the outermost projected points of both OBBs overlap.
|
// ... and check whether the outermost projected points of both OBBs overlap.
|
||||||
// If this is not the case, the Separating Axis Theorem states that there can be no collision between the rectangles
|
// If this is not the case, the Separating Axis Theorem states that there can be no collision between the rectangles
|
||||||
if (!((MinOBB2<=MaxOBB1)&&(MaxOBB2>=MinOBB1)))
|
if (!((MinOBB2<=MaxOBB1)&&(MaxOBB2>=MinOBB1)))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
154
Collision.h
154
Collision.h
|
|
@ -1,77 +1,77 @@
|
||||||
/*
|
/*
|
||||||
* File: collision.h
|
* File: collision.h
|
||||||
* Authors: Nick Koirala (original version), ahnonay (SFML2 compatibility)
|
* Authors: Nick Koirala (original version), ahnonay (SFML2 compatibility)
|
||||||
*
|
*
|
||||||
* Collision Detection and handling class
|
* Collision Detection and handling class
|
||||||
* For SFML2.
|
* For SFML2.
|
||||||
|
|
||||||
Notice from the original version:
|
Notice from the original version:
|
||||||
|
|
||||||
(c) 2009 - LittleMonkey Ltd
|
(c) 2009 - LittleMonkey Ltd
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or
|
This software is provided 'as-is', without any express or
|
||||||
implied warranty. In no event will the authors be held
|
implied warranty. In no event will the authors be held
|
||||||
liable for any damages arising from the use of this software.
|
liable for any damages arising from the use of this software.
|
||||||
|
|
||||||
Permission is granted to anyone to use this software for any purpose,
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
including commercial applications, and to alter it and redistribute
|
including commercial applications, and to alter it and redistribute
|
||||||
it freely, subject to the following restrictions:
|
it freely, subject to the following restrictions:
|
||||||
|
|
||||||
1. The origin of this software must not be misrepresented;
|
1. The origin of this software must not be misrepresented;
|
||||||
you must not claim that you wrote the original software.
|
you must not claim that you wrote the original software.
|
||||||
If you use this software in a product, an acknowledgment
|
If you use this software in a product, an acknowledgment
|
||||||
in the product documentation would be appreciated but
|
in the product documentation would be appreciated but
|
||||||
is not required.
|
is not required.
|
||||||
|
|
||||||
2. Altered source versions must be plainly marked as such,
|
2. Altered source versions must be plainly marked as such,
|
||||||
and must not be misrepresented as being the original software.
|
and must not be misrepresented as being the original software.
|
||||||
|
|
||||||
3. This notice may not be removed or altered from any
|
3. This notice may not be removed or altered from any
|
||||||
source distribution.
|
source distribution.
|
||||||
|
|
||||||
*
|
*
|
||||||
* Created on 30 January 2009, 11:02
|
* Created on 30 January 2009, 11:02
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_COLLISION_H
|
#ifndef SFML_TEMPLATE_COLLISION_H
|
||||||
#define SFML_TEMPLATE_COLLISION_H
|
#define SFML_TEMPLATE_COLLISION_H
|
||||||
|
|
||||||
#include <SFML\Graphics.hpp>
|
#include <SFML\Graphics.hpp>
|
||||||
|
|
||||||
namespace Collision {
|
namespace Collision {
|
||||||
//////
|
//////
|
||||||
/// Test for a collision between two sprites by comparing the alpha values of overlapping pixels
|
/// Test for a collision between two sprites by comparing the alpha values of overlapping pixels
|
||||||
/// Supports scaling and rotation
|
/// Supports scaling and rotation
|
||||||
/// AlphaLimit: The threshold at which a pixel becomes "solid". If AlphaLimit is 127, a pixel with
|
/// AlphaLimit: The threshold at which a pixel becomes "solid". If AlphaLimit is 127, a pixel with
|
||||||
/// alpha value 128 will cause a collision and a pixel with alpha value 126 will not.
|
/// alpha value 128 will cause a collision and a pixel with alpha value 126 will not.
|
||||||
///
|
///
|
||||||
/// This functions creates bitmasks of the textures of the two sprites by
|
/// This functions creates bitmasks of the textures of the two sprites by
|
||||||
/// downloading the textures from the graphics card to memory -> SLOW!
|
/// downloading the textures from the graphics card to memory -> SLOW!
|
||||||
/// You can avoid this by using the "CreateTextureAndBitmask" function
|
/// You can avoid this by using the "CreateTextureAndBitmask" function
|
||||||
//////
|
//////
|
||||||
bool PixelPerfectTest(const sf::Sprite& Object1 ,const sf::Sprite& Object2, sf::Uint8 AlphaLimit = 0);
|
bool PixelPerfectTest(const sf::Sprite& Object1 ,const sf::Sprite& Object2, sf::Uint8 AlphaLimit = 0);
|
||||||
|
|
||||||
//////
|
//////
|
||||||
/// Replaces Texture::loadFromFile
|
/// Replaces Texture::loadFromFile
|
||||||
/// Load an imagefile into the given texture and create a bitmask for it
|
/// Load an imagefile into the given texture and create a bitmask for it
|
||||||
/// This is much faster than creating the bitmask for a texture on the first run of "PixelPerfectTest"
|
/// This is much faster than creating the bitmask for a texture on the first run of "PixelPerfectTest"
|
||||||
///
|
///
|
||||||
/// The function returns false if the file could not be opened for some reason
|
/// The function returns false if the file could not be opened for some reason
|
||||||
//////
|
//////
|
||||||
bool CreateTextureAndBitmask(sf::Texture &LoadInto, const std::string& Filename);
|
bool CreateTextureAndBitmask(sf::Texture &LoadInto, const std::string& Filename);
|
||||||
|
|
||||||
//////
|
//////
|
||||||
/// Test for collision using circle collision dection
|
/// Test for collision using circle collision dection
|
||||||
/// Radius is averaged from the dimensions of the sprite so
|
/// Radius is averaged from the dimensions of the sprite so
|
||||||
/// roughly circular objects will be much more accurate
|
/// roughly circular objects will be much more accurate
|
||||||
//////
|
//////
|
||||||
bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2);
|
bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2);
|
||||||
|
|
||||||
//////
|
//////
|
||||||
/// Test for bounding box collision using the Separating Axis Theorem
|
/// Test for bounding box collision using the Separating Axis Theorem
|
||||||
/// Supports scaling and rotation
|
/// Supports scaling and rotation
|
||||||
//////
|
//////
|
||||||
bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2);
|
bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_COLLISION_H
|
#endif //SFML_TEMPLATE_COLLISION_H
|
||||||
|
|
|
||||||
68
Entity.h
68
Entity.h
|
|
@ -1,34 +1,34 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 9/28/2020.
|
// Created by benmo on 9/28/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_ENTITY_H
|
#ifndef SFML_TEMPLATE_ENTITY_H
|
||||||
#define SFML_TEMPLATE_ENTITY_H
|
#define SFML_TEMPLATE_ENTITY_H
|
||||||
|
|
||||||
class Entity : public Mount {
|
class Entity : public Mount {
|
||||||
public:
|
public:
|
||||||
Entity(float health, int points, const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Mount(texture, scale, xPos, yPos, velocity, direction) {
|
Entity(float health, int points, const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Mount(texture, scale, xPos, yPos, velocity, direction) {
|
||||||
this->health = health;
|
this->health = health;
|
||||||
this->points = points;
|
this->points = points;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getHealth() const {
|
float getHealth() const {
|
||||||
return health;
|
return health;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setHealth(float health) {
|
void setHealth(float health) {
|
||||||
this->health = health;
|
this->health = health;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hit() {};
|
void hit() {};
|
||||||
|
|
||||||
int getPoints() const {
|
int getPoints() const {
|
||||||
return points;
|
return points;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
float health;
|
float health;
|
||||||
int points;
|
int points;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_ENTITY_H
|
#endif //SFML_TEMPLATE_ENTITY_H
|
||||||
|
|
|
||||||
6
Game.h
6
Game.h
|
|
@ -16,7 +16,7 @@ private:
|
||||||
sf::Texture loadingBarFull;
|
sf::Texture loadingBarFull;
|
||||||
|
|
||||||
//update total
|
//update total
|
||||||
int totalTextures = 53;
|
int totalTextures = 58;
|
||||||
int loadedTextures = 0;
|
int loadedTextures = 0;
|
||||||
|
|
||||||
sf::Font oxan;
|
sf::Font oxan;
|
||||||
|
|
@ -231,7 +231,7 @@ private:
|
||||||
pewBuff.loadFromFile("data\\Sounds\\pew.wav");
|
pewBuff.loadFromFile("data\\Sounds\\pew.wav");
|
||||||
updateLoader(window, "Loading sounds...");
|
updateLoader(window, "Loading sounds...");
|
||||||
pew.setBuffer(pewBuff);
|
pew.setBuffer(pewBuff);
|
||||||
pew.setVolume(25);
|
pew.setVolume(15);
|
||||||
|
|
||||||
Sound enemyBoom;
|
Sound enemyBoom;
|
||||||
SoundBuffer enemyBoomBuff;
|
SoundBuffer enemyBoomBuff;
|
||||||
|
|
@ -952,8 +952,6 @@ private:
|
||||||
int spaceBetween = 150 - widthEntryDate;
|
int spaceBetween = 150 - widthEntryDate;
|
||||||
int dateLoc = (window.getSize().x - (widthEntry + widthEntryDate + spaceBetween))/2;
|
int dateLoc = (window.getSize().x - (widthEntry + widthEntryDate + spaceBetween))/2;
|
||||||
|
|
||||||
cout << widthEntryDate << " " << widthEntry << " " << spaceBetween << endl;
|
|
||||||
|
|
||||||
highScoreEntriesDates[j].setPosition(dateLoc, window.getSize().y/1.8 + (25 * j));
|
highScoreEntriesDates[j].setPosition(dateLoc, window.getSize().y/1.8 + (25 * j));
|
||||||
highScoreEntries[j].setPosition(dateLoc + 150, window.getSize().y/1.8 + (25 * j));
|
highScoreEntries[j].setPosition(dateLoc + 150, window.getSize().y/1.8 + (25 * j));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
104
Mount.h
104
Mount.h
|
|
@ -1,52 +1,52 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 10/12/2020.
|
// Created by benmo on 10/12/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_MOUNT_H
|
#ifndef SFML_TEMPLATE_MOUNT_H
|
||||||
#define SFML_TEMPLATE_MOUNT_H
|
#define SFML_TEMPLATE_MOUNT_H
|
||||||
|
|
||||||
|
|
||||||
class Mount : public MySprite {
|
class Mount : public MySprite {
|
||||||
protected:
|
protected:
|
||||||
vector<Rider> riders;
|
vector<Rider> riders;
|
||||||
public:
|
public:
|
||||||
Mount(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : MySprite(texture, scale, xPos, yPos, velocity, direction) {}
|
Mount(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : MySprite(texture, scale, xPos, yPos, velocity, direction) {}
|
||||||
|
|
||||||
bool hasRider() {
|
bool hasRider() {
|
||||||
return !riders.empty();
|
return !riders.empty();
|
||||||
}
|
}
|
||||||
void update(RenderWindow* window = nullptr) {
|
void update(RenderWindow* window = nullptr) {
|
||||||
MySprite::update(window);
|
MySprite::update(window);
|
||||||
|
|
||||||
for (Rider &r : riders) {
|
for (Rider &r : riders) {
|
||||||
if (r.doesFollowPosition()) r.setPosition(getPosition());
|
if (r.doesFollowPosition()) r.setPosition(getPosition());
|
||||||
if (r.doesFollowDirection()) r.setDirection(getDirection());
|
if (r.doesFollowDirection()) r.setDirection(getDirection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRider(Rider &sprite, int index = -1) {
|
void addRider(Rider &sprite, int index = -1) {
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
riders.push_back(sprite);
|
riders.push_back(sprite);
|
||||||
riders[riders.size() - 1].setPosition(getPosition());
|
riders[riders.size() - 1].setPosition(getPosition());
|
||||||
} else {
|
} else {
|
||||||
riders.insert(riders.begin() + index, sprite);
|
riders.insert(riders.begin() + index, sprite);
|
||||||
riders[index].setPosition(getPosition());
|
riders[index].setPosition(getPosition());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeRider(int index = -1) {
|
void removeRider(int index = -1) {
|
||||||
if (index == -1) riders.pop_back();
|
if (index == -1) riders.pop_back();
|
||||||
else riders.erase(riders.begin() + index);
|
else riders.erase(riders.begin() + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Rider> getRiders() {
|
vector<Rider> getRiders() {
|
||||||
return riders;
|
return riders;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<Rider>* getRidersForEdit() {
|
vector<Rider>* getRidersForEdit() {
|
||||||
return &riders;
|
return &riders;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_MOUNT_H
|
#endif //SFML_TEMPLATE_MOUNT_H
|
||||||
|
|
|
||||||
634
MySprite.h
634
MySprite.h
|
|
@ -1,317 +1,317 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 2/14/2020.
|
// Created by benmo on 2/14/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_SPRITE_H
|
#ifndef SFML_TEMPLATE_SPRITE_H
|
||||||
#define SFML_TEMPLATE_SPRITE_H
|
#define SFML_TEMPLATE_SPRITE_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
using namespace sf;
|
using namespace sf;
|
||||||
|
|
||||||
class MySprite: public sf::Sprite{
|
class MySprite: public sf::Sprite{
|
||||||
protected:
|
protected:
|
||||||
struct Physics {
|
struct Physics {
|
||||||
float velocity, direction, acceleration, maxVelocity, minVelocity;
|
float velocity, direction, acceleration, maxVelocity, minVelocity;
|
||||||
float rotVelocity, rotAcceleration, maxRotVelocity;
|
float rotVelocity, rotAcceleration, maxRotVelocity;
|
||||||
float xPos, yPos;
|
float xPos, yPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Animation {
|
struct Animation {
|
||||||
float frameLength;
|
float frameLength;
|
||||||
unsigned int currframe = 0, columns, height, width, numFrames;
|
unsigned int currframe = 0, columns, height, width, numFrames;
|
||||||
Clock clock;
|
Clock clock;
|
||||||
bool isAnimated = false, isPlayed = false;
|
bool isAnimated = false, isPlayed = false;
|
||||||
IntRect textureRect;
|
IntRect textureRect;
|
||||||
};
|
};
|
||||||
|
|
||||||
Physics spritePhysics{};
|
Physics spritePhysics{};
|
||||||
|
|
||||||
Animation spriteAnimation{};
|
Animation spriteAnimation{};
|
||||||
|
|
||||||
bool toErase = false, circularHitbox = false;
|
bool toErase = false, circularHitbox = false;
|
||||||
|
|
||||||
string type = "Sprite";
|
string type = "Sprite";
|
||||||
public:
|
public:
|
||||||
enum EdgeBehavior {
|
enum EdgeBehavior {
|
||||||
IGNORE, LOOP, BOUNCE
|
IGNORE, LOOP, BOUNCE
|
||||||
};
|
};
|
||||||
|
|
||||||
EdgeBehavior edgeBehavior = IGNORE;
|
EdgeBehavior edgeBehavior = IGNORE;
|
||||||
|
|
||||||
constexpr static const double PI = 3.1415926;
|
constexpr static const double PI = 3.1415926;
|
||||||
|
|
||||||
static double distance(sf::Vector2f pos1, sf::Vector2f pos2) {
|
static double distance(sf::Vector2f pos1, sf::Vector2f pos2) {
|
||||||
return sqrt(pow(pos2.x - pos1.x, 2) + pow(pos2.y - pos1.y, 2));
|
return sqrt(pow(pos2.x - pos1.x, 2) + pow(pos2.y - pos1.y, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite() : sf::Sprite() {
|
MySprite() : sf::Sprite() {
|
||||||
spritePhysics.velocity = 0;
|
spritePhysics.velocity = 0;
|
||||||
spritePhysics.xPos = 0;
|
spritePhysics.xPos = 0;
|
||||||
spritePhysics.yPos = 0;
|
spritePhysics.yPos = 0;
|
||||||
spritePhysics.direction = 0;
|
spritePhysics.direction = 0;
|
||||||
|
|
||||||
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit MySprite(const sf::Texture &texture) : sf::Sprite(texture) {
|
explicit MySprite(const sf::Texture &texture) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = 0;
|
spritePhysics.velocity = 0;
|
||||||
spritePhysics.xPos = 0;
|
spritePhysics.xPos = 0;
|
||||||
spritePhysics.yPos = 0;
|
spritePhysics.yPos = 0;
|
||||||
spritePhysics.direction = 0;
|
spritePhysics.direction = 0;
|
||||||
|
|
||||||
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, float scale) : sf::Sprite(texture) {
|
MySprite(const sf::Texture &texture, float scale) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = 0;
|
spritePhysics.velocity = 0;
|
||||||
spritePhysics.xPos = 0;
|
spritePhysics.xPos = 0;
|
||||||
spritePhysics.yPos = 0;
|
spritePhysics.yPos = 0;
|
||||||
spritePhysics.direction = 0;
|
spritePhysics.direction = 0;
|
||||||
|
|
||||||
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
|
||||||
setScale(scale/100, scale/100);
|
setScale(scale/100, scale/100);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, const sf::IntRect &rectangle) : sf::Sprite(texture, rectangle) {
|
MySprite(const sf::Texture &texture, const sf::IntRect &rectangle) : sf::Sprite(texture, rectangle) {
|
||||||
spritePhysics.velocity = 0;
|
spritePhysics.velocity = 0;
|
||||||
spritePhysics.xPos = 0;
|
spritePhysics.xPos = 0;
|
||||||
spritePhysics.yPos = 0;
|
spritePhysics.yPos = 0;
|
||||||
spritePhysics.direction = 0;
|
spritePhysics.direction = 0;
|
||||||
|
|
||||||
setOrigin(rectangle.width/(float)2.0,rectangle.height/(float)2.0);
|
setOrigin(rectangle.width/(float)2.0,rectangle.height/(float)2.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : sf::Sprite(texture) {
|
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = velocity;
|
spritePhysics.velocity = velocity;
|
||||||
spritePhysics.xPos = xPos;
|
spritePhysics.xPos = xPos;
|
||||||
spritePhysics.yPos = yPos;
|
spritePhysics.yPos = yPos;
|
||||||
spritePhysics.direction = direction;
|
spritePhysics.direction = direction;
|
||||||
|
|
||||||
setScale(scale/100, scale/100);
|
setScale(scale/100, scale/100);
|
||||||
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
||||||
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
||||||
setRotation(direction);
|
setRotation(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity) : sf::Sprite(texture) {
|
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = velocity;
|
spritePhysics.velocity = velocity;
|
||||||
spritePhysics.xPos = xPos;
|
spritePhysics.xPos = xPos;
|
||||||
spritePhysics.yPos = yPos;
|
spritePhysics.yPos = yPos;
|
||||||
spritePhysics.direction = direction;
|
spritePhysics.direction = direction;
|
||||||
spritePhysics.rotVelocity = rotVelocity;
|
spritePhysics.rotVelocity = rotVelocity;
|
||||||
spritePhysics.maxVelocity = maxVelocity;
|
spritePhysics.maxVelocity = maxVelocity;
|
||||||
spritePhysics.maxRotVelocity = maxRotVelocity;
|
spritePhysics.maxRotVelocity = maxRotVelocity;
|
||||||
|
|
||||||
setScale(scale/100, scale/100);
|
setScale(scale/100, scale/100);
|
||||||
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
||||||
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
||||||
setRotation(direction);
|
setRotation(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity) : sf::Sprite(texture) {
|
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = velocity;
|
spritePhysics.velocity = velocity;
|
||||||
spritePhysics.xPos = xPos;
|
spritePhysics.xPos = xPos;
|
||||||
spritePhysics.yPos = yPos;
|
spritePhysics.yPos = yPos;
|
||||||
spritePhysics.direction = direction;
|
spritePhysics.direction = direction;
|
||||||
spritePhysics.rotVelocity = rotVelocity;
|
spritePhysics.rotVelocity = rotVelocity;
|
||||||
spritePhysics.maxVelocity = maxVelocity;
|
spritePhysics.maxVelocity = maxVelocity;
|
||||||
spritePhysics.maxRotVelocity = maxRotVelocity;
|
spritePhysics.maxRotVelocity = maxRotVelocity;
|
||||||
spritePhysics.acceleration = acceleration;
|
spritePhysics.acceleration = acceleration;
|
||||||
spritePhysics.rotAcceleration = rotAcceleration;
|
spritePhysics.rotAcceleration = rotAcceleration;
|
||||||
|
|
||||||
setScale(scale/100, scale/100);
|
setScale(scale/100, scale/100);
|
||||||
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
||||||
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
||||||
setRotation(direction);
|
setRotation(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction) : sf::Sprite(texture) {
|
MySprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction) : sf::Sprite(texture) {
|
||||||
spritePhysics.velocity = velocity;
|
spritePhysics.velocity = velocity;
|
||||||
spritePhysics.xPos = xPos;
|
spritePhysics.xPos = xPos;
|
||||||
spritePhysics.yPos = yPos;
|
spritePhysics.yPos = yPos;
|
||||||
spritePhysics.direction = direction;
|
spritePhysics.direction = direction;
|
||||||
spritePhysics.maxVelocity = maxVelocity;
|
spritePhysics.maxVelocity = maxVelocity;
|
||||||
|
|
||||||
setScale(scale/100, scale/100);
|
setScale(scale/100, scale/100);
|
||||||
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
setOrigin(getLocalBounds().width/2, getLocalBounds().height/2);
|
||||||
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
setPosition(spritePhysics.xPos,spritePhysics.yPos);
|
||||||
setRotation(direction);
|
setRotation(direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeAnimated(int rows, int columns, float length, int frames = 0) {
|
void makeAnimated(int rows, int columns, float length, int frames = 0) {
|
||||||
spriteAnimation.height = getTexture()->getSize().y/rows;
|
spriteAnimation.height = getTexture()->getSize().y/rows;
|
||||||
spriteAnimation.width = getTexture()->getSize().x/columns;
|
spriteAnimation.width = getTexture()->getSize().x/columns;
|
||||||
spriteAnimation.frameLength = length;
|
spriteAnimation.frameLength = length;
|
||||||
spriteAnimation.columns = columns;
|
spriteAnimation.columns = columns;
|
||||||
|
|
||||||
if (frames == 0) spriteAnimation.numFrames = rows*columns;
|
if (frames == 0) spriteAnimation.numFrames = rows*columns;
|
||||||
else spriteAnimation.numFrames = frames;
|
else spriteAnimation.numFrames = frames;
|
||||||
|
|
||||||
spriteAnimation.isAnimated = true;
|
spriteAnimation.isAnimated = true;
|
||||||
|
|
||||||
spriteAnimation.textureRect = IntRect(0, 0, spriteAnimation.width, spriteAnimation.height);
|
spriteAnimation.textureRect = IntRect(0, 0, spriteAnimation.width, spriteAnimation.height);
|
||||||
setTextureRect(spriteAnimation.textureRect);
|
setTextureRect(spriteAnimation.textureRect);
|
||||||
|
|
||||||
setOrigin(spriteAnimation.width/2.0, spriteAnimation.height/2.0);
|
setOrigin(spriteAnimation.width/2.0, spriteAnimation.height/2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void update(RenderWindow* window = nullptr) {
|
virtual void update(RenderWindow* window = nullptr) {
|
||||||
spritePhysics.xPos += cos(spritePhysics.direction * (PI/180.0)) * spritePhysics.velocity;
|
spritePhysics.xPos += cos(spritePhysics.direction * (PI/180.0)) * spritePhysics.velocity;
|
||||||
spritePhysics.yPos += -(sin(spritePhysics.direction * (PI/180.0)) * spritePhysics.velocity);
|
spritePhysics.yPos += -(sin(spritePhysics.direction * (PI/180.0)) * spritePhysics.velocity);
|
||||||
|
|
||||||
if (edgeBehavior == LOOP) {
|
if (edgeBehavior == LOOP) {
|
||||||
if (spritePhysics.xPos <= -getGlobalBounds().width)
|
if (spritePhysics.xPos <= -getGlobalBounds().width)
|
||||||
spritePhysics.xPos = window->getSize().x + getGlobalBounds().width;
|
spritePhysics.xPos = window->getSize().x + getGlobalBounds().width;
|
||||||
else if (spritePhysics.xPos >= window->getSize().x + getGlobalBounds().width)
|
else if (spritePhysics.xPos >= window->getSize().x + getGlobalBounds().width)
|
||||||
spritePhysics.xPos = -getGlobalBounds().width;
|
spritePhysics.xPos = -getGlobalBounds().width;
|
||||||
|
|
||||||
if (spritePhysics.yPos <= -getGlobalBounds().height)
|
if (spritePhysics.yPos <= -getGlobalBounds().height)
|
||||||
spritePhysics.yPos = window->getSize().y + getGlobalBounds().height;
|
spritePhysics.yPos = window->getSize().y + getGlobalBounds().height;
|
||||||
else if (spritePhysics.yPos >= window->getSize().y + getGlobalBounds().height)
|
else if (spritePhysics.yPos >= window->getSize().y + getGlobalBounds().height)
|
||||||
spritePhysics.yPos = -getGlobalBounds().height;
|
spritePhysics.yPos = -getGlobalBounds().height;
|
||||||
} else if (edgeBehavior == IGNORE) {
|
} else if (edgeBehavior == IGNORE) {
|
||||||
if (spritePhysics.xPos <= -getGlobalBounds().width ||
|
if (spritePhysics.xPos <= -getGlobalBounds().width ||
|
||||||
spritePhysics.xPos >= window->getSize().x + getGlobalBounds().width ||
|
spritePhysics.xPos >= window->getSize().x + getGlobalBounds().width ||
|
||||||
spritePhysics.yPos <= -getGlobalBounds().height ||
|
spritePhysics.yPos <= -getGlobalBounds().height ||
|
||||||
spritePhysics.yPos >= window->getSize().y + getGlobalBounds().height)
|
spritePhysics.yPos >= window->getSize().y + getGlobalBounds().height)
|
||||||
toErase = true;
|
toErase = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
spritePhysics.direction -= spritePhysics.rotVelocity;
|
spritePhysics.direction -= spritePhysics.rotVelocity;
|
||||||
spritePhysics.direction = fmod(spritePhysics.direction, 360);
|
spritePhysics.direction = fmod(spritePhysics.direction, 360);
|
||||||
if (spritePhysics.direction < 0)
|
if (spritePhysics.direction < 0)
|
||||||
spritePhysics.direction += 360;
|
spritePhysics.direction += 360;
|
||||||
|
|
||||||
if (spriteAnimation.isAnimated) {
|
if (spriteAnimation.isAnimated) {
|
||||||
if (spriteAnimation.clock.getElapsedTime().asSeconds() > spriteAnimation.frameLength) {
|
if (spriteAnimation.clock.getElapsedTime().asSeconds() > spriteAnimation.frameLength) {
|
||||||
spriteAnimation.currframe++;
|
spriteAnimation.currframe++;
|
||||||
if (spriteAnimation.currframe % spriteAnimation.columns == 0) {
|
if (spriteAnimation.currframe % spriteAnimation.columns == 0) {
|
||||||
spriteAnimation.textureRect.left = 0;
|
spriteAnimation.textureRect.left = 0;
|
||||||
spriteAnimation.textureRect.top += spriteAnimation.height;
|
spriteAnimation.textureRect.top += spriteAnimation.height;
|
||||||
} else
|
} else
|
||||||
spriteAnimation.textureRect.left += spriteAnimation.height;
|
spriteAnimation.textureRect.left += spriteAnimation.height;
|
||||||
|
|
||||||
setTextureRect(spriteAnimation.textureRect);
|
setTextureRect(spriteAnimation.textureRect);
|
||||||
spriteAnimation.clock.restart();
|
spriteAnimation.clock.restart();
|
||||||
|
|
||||||
if (spriteAnimation.currframe == spriteAnimation.numFrames) {
|
if (spriteAnimation.currframe == spriteAnimation.numFrames) {
|
||||||
spriteAnimation.isPlayed = true;
|
spriteAnimation.isPlayed = true;
|
||||||
spriteAnimation.currframe = 0;
|
spriteAnimation.currframe = 0;
|
||||||
|
|
||||||
spriteAnimation.textureRect.left = 0;
|
spriteAnimation.textureRect.left = 0;
|
||||||
spriteAnimation.textureRect.top = 0;
|
spriteAnimation.textureRect.top = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
spriteAnimation.clock.restart();
|
spriteAnimation.clock.restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setPosition(spritePhysics.xPos, spritePhysics.yPos);
|
setPosition(spritePhysics.xPos, spritePhysics.yPos);
|
||||||
setRotation(-spritePhysics.direction);
|
setRotation(-spritePhysics.direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
void accelerate(float override = 0, bool ignoreMax = false) {
|
void accelerate(float override = 0, bool ignoreMax = false) {
|
||||||
if (override != 0) spritePhysics.velocity += override;
|
if (override != 0) spritePhysics.velocity += override;
|
||||||
else spritePhysics.velocity += spritePhysics.acceleration;
|
else spritePhysics.velocity += spritePhysics.acceleration;
|
||||||
|
|
||||||
if (!ignoreMax && spritePhysics.velocity > spritePhysics.maxVelocity) spritePhysics.velocity = spritePhysics.maxVelocity;
|
if (!ignoreMax && spritePhysics.velocity > spritePhysics.maxVelocity) spritePhysics.velocity = spritePhysics.maxVelocity;
|
||||||
if (!ignoreMax && spritePhysics.velocity < spritePhysics.minVelocity) spritePhysics.velocity = spritePhysics.minVelocity;
|
if (!ignoreMax && spritePhysics.velocity < spritePhysics.minVelocity) spritePhysics.velocity = spritePhysics.minVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rotAccel(float override = 0, bool ignoreMax = false) {
|
void rotAccel(float override = 0, bool ignoreMax = false) {
|
||||||
if (override != 0) spritePhysics.rotVelocity += override;
|
if (override != 0) spritePhysics.rotVelocity += override;
|
||||||
else spritePhysics.rotVelocity += spritePhysics.rotAcceleration;
|
else spritePhysics.rotVelocity += spritePhysics.rotAcceleration;
|
||||||
|
|
||||||
if (!ignoreMax && spritePhysics.rotVelocity > spritePhysics.maxRotVelocity) spritePhysics.rotVelocity = spritePhysics.maxRotVelocity;
|
if (!ignoreMax && spritePhysics.rotVelocity > spritePhysics.maxRotVelocity) spritePhysics.rotVelocity = spritePhysics.maxRotVelocity;
|
||||||
else if (!ignoreMax && -spritePhysics.rotVelocity > spritePhysics.maxRotVelocity) spritePhysics.rotVelocity = -spritePhysics.maxRotVelocity;
|
else if (!ignoreMax && -spritePhysics.rotVelocity > spritePhysics.maxRotVelocity) spritePhysics.rotVelocity = -spritePhysics.maxRotVelocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
void turn(float degrees) {
|
void turn(float degrees) {
|
||||||
spritePhysics.direction -= degrees;
|
spritePhysics.direction -= degrees;
|
||||||
|
|
||||||
setRotation(-spritePhysics.direction);
|
setRotation(-spritePhysics.direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getXPos() {
|
float getXPos() {
|
||||||
return spritePhysics.xPos;
|
return spritePhysics.xPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getYPos() {
|
float getYPos() {
|
||||||
return spritePhysics.yPos;
|
return spritePhysics.yPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPosition(float xPos, float yPos) {
|
void setPosition(float xPos, float yPos) {
|
||||||
spritePhysics.xPos = xPos;
|
spritePhysics.xPos = xPos;
|
||||||
spritePhysics.yPos = yPos;
|
spritePhysics.yPos = yPos;
|
||||||
|
|
||||||
sf::Sprite::setPosition(sf::Vector2f(xPos, yPos));
|
sf::Sprite::setPosition(sf::Vector2f(xPos, yPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPosition(const sf::Vector2f &vec) {
|
void setPosition(const sf::Vector2f &vec) {
|
||||||
spritePhysics.xPos = vec.x;
|
spritePhysics.xPos = vec.x;
|
||||||
spritePhysics.yPos = vec.y;
|
spritePhysics.yPos = vec.y;
|
||||||
|
|
||||||
sf::Sprite::setPosition(vec);
|
sf::Sprite::setPosition(vec);
|
||||||
}
|
}
|
||||||
|
|
||||||
float getDirection() {
|
float getDirection() {
|
||||||
return spritePhysics.direction;
|
return spritePhysics.direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDirection(float angle) {
|
void setDirection(float angle) {
|
||||||
spritePhysics.direction = angle;
|
spritePhysics.direction = angle;
|
||||||
|
|
||||||
setRotation(-angle);
|
setRotation(-angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setVelocity(float velo) {
|
void setVelocity(float velo) {
|
||||||
spritePhysics.velocity = velo;
|
spritePhysics.velocity = velo;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getVelocity() {
|
float getVelocity() {
|
||||||
return spritePhysics.velocity;
|
return spritePhysics.velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
float getRotVelocity() {
|
float getRotVelocity() {
|
||||||
return spritePhysics.rotVelocity;
|
return spritePhysics.rotVelocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setMaxVelocity(float velo) {
|
void setMaxVelocity(float velo) {
|
||||||
spritePhysics.maxVelocity = velo;
|
spritePhysics.maxVelocity = velo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMinVelocity(float velo) {
|
void setMinVelocity(float velo) {
|
||||||
spritePhysics.minVelocity = velo;
|
spritePhysics.minVelocity = velo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setMaxRotVelocity(float velo) {
|
void setMaxRotVelocity(float velo) {
|
||||||
spritePhysics.maxRotVelocity = velo;
|
spritePhysics.maxRotVelocity = velo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEdgeBehavior(EdgeBehavior behavior) {
|
void setEdgeBehavior(EdgeBehavior behavior) {
|
||||||
edgeBehavior = behavior;
|
edgeBehavior = behavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool toBeErased() const {
|
bool toBeErased() const {
|
||||||
return toErase;
|
return toErase;
|
||||||
}
|
}
|
||||||
|
|
||||||
Animation getAnimation() {
|
Animation getAnimation() {
|
||||||
return spriteAnimation;
|
return spriteAnimation;
|
||||||
}
|
}
|
||||||
|
|
||||||
string getType() {
|
string getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setType(string type) {
|
void setType(string type) {
|
||||||
this->type = std::move(type);
|
this->type = std::move(type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_SPRITE_H
|
#endif //SFML_TEMPLATE_SPRITE_H
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
# Asteroids Clone
|
# Asteroids Clone
|
||||||
|
|
|
||||||
50
Rider.h
50
Rider.h
|
|
@ -1,25 +1,25 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 10/13/2020.
|
// Created by benmo on 10/13/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_RIDER_H
|
#ifndef SFML_TEMPLATE_RIDER_H
|
||||||
#define SFML_TEMPLATE_RIDER_H
|
#define SFML_TEMPLATE_RIDER_H
|
||||||
|
|
||||||
|
|
||||||
class Rider : public MySprite {
|
class Rider : public MySprite {
|
||||||
protected:
|
protected:
|
||||||
bool followsDirection = false, followsPosition = true;
|
bool followsDirection = false, followsPosition = true;
|
||||||
public:
|
public:
|
||||||
Rider(const sf::Texture &texture, float scale) : MySprite(texture, scale) {}
|
Rider(const sf::Texture &texture, float scale) : MySprite(texture, scale) {}
|
||||||
|
|
||||||
bool doesFollowDirection() const {
|
bool doesFollowDirection() const {
|
||||||
return followsDirection;
|
return followsDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doesFollowPosition() const {
|
bool doesFollowPosition() const {
|
||||||
return followsPosition;
|
return followsPosition;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_RIDER_H
|
#endif //SFML_TEMPLATE_RIDER_H
|
||||||
|
|
|
||||||
182
Ship.h
182
Ship.h
|
|
@ -1,91 +1,91 @@
|
||||||
//
|
//
|
||||||
// Created by benmo on 9/25/2020.
|
// Created by benmo on 9/25/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef SFML_TEMPLATE_SHIP_H
|
#ifndef SFML_TEMPLATE_SHIP_H
|
||||||
#define SFML_TEMPLATE_SHIP_H
|
#define SFML_TEMPLATE_SHIP_H
|
||||||
|
|
||||||
|
|
||||||
class Ship : public Mount {
|
class Ship : public Mount {
|
||||||
public:
|
public:
|
||||||
Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Mount(texture, scale, xPos, yPos, velocity, direction) {}
|
Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : Mount(texture, scale, xPos, yPos, velocity, direction) {}
|
||||||
|
|
||||||
void shoot(std::vector<MySprite> &projectiles, Sound &sound, sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) {
|
void shoot(std::vector<MySprite> &projectiles, Sound &sound, sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) {
|
||||||
projectiles.emplace_back(texture, scale, xPos, yPos, velocity, direction);
|
projectiles.emplace_back(texture, scale, xPos, yPos, velocity, direction);
|
||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hit(RenderWindow &window, vector<MySprite> &animations, Texture &explosionTexture, default_random_engine &gen) {
|
bool hit(RenderWindow &window, vector<MySprite> &animations, Texture &explosionTexture, default_random_engine &gen) {
|
||||||
uniform_int_distribution<int> angle(0, 359);
|
uniform_int_distribution<int> angle(0, 359);
|
||||||
animations.emplace_back(explosionTexture, 100, getXPos(), getYPos(), 0, angle(gen));
|
animations.emplace_back(explosionTexture, 100, getXPos(), getYPos(), 0, angle(gen));
|
||||||
animations[animations.size() - 1].makeAnimated(5, 5, 0.01,23);
|
animations[animations.size() - 1].makeAnimated(5, 5, 0.01,23);
|
||||||
|
|
||||||
setPosition(window.getSize().x/2, window.getSize().y/2);
|
setPosition(window.getSize().x/2, window.getSize().y/2);
|
||||||
setDirection(0);
|
setDirection(0);
|
||||||
setVelocity(0);
|
setVelocity(0);
|
||||||
lives--;
|
lives--;
|
||||||
|
|
||||||
return lives <= 0;
|
return lives <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void newLife(vector<MySprite> &lifeVec, Texture &life, RenderWindow &window, Sound &sound) {
|
void newLife(vector<MySprite> &lifeVec, Texture &life, RenderWindow &window, Sound &sound) {
|
||||||
setNumLivesAdded(getNumLivesAdded() + 1);
|
setNumLivesAdded(getNumLivesAdded() + 1);
|
||||||
setLives(getLives() + 1);
|
setLives(getLives() + 1);
|
||||||
lifeVec.emplace_back(life, 20,window.getSize().x - ((getLives() - 1) * 40 + 25), 25, 0,270);
|
lifeVec.emplace_back(life, 20,window.getSize().x - ((getLives() - 1) * 40 + 25), 25, 0,270);
|
||||||
sound.play();
|
sound.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
int getLives() const {
|
int getLives() const {
|
||||||
return lives;
|
return lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setLives(int lives) {
|
void setLives(int lives) {
|
||||||
this->lives = lives;
|
this->lives = lives;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setShield(bool shield, Texture* texture = nullptr, float scale = 0, Clock* timer = nullptr) {
|
void setShield(bool shield, Texture* texture = nullptr, float scale = 0, Clock* timer = nullptr) {
|
||||||
this->shield = shield;
|
this->shield = shield;
|
||||||
|
|
||||||
if (shield) {
|
if (shield) {
|
||||||
Rider temp(*texture, scale);
|
Rider temp(*texture, scale);
|
||||||
temp.setType("Shield");
|
temp.setType("Shield");
|
||||||
addRider(temp);
|
addRider(temp);
|
||||||
timer->restart();
|
timer->restart();
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < riders.size(); i++) {
|
for (int i = 0; i < riders.size(); i++) {
|
||||||
if (riders[i].getType() == "Shield") removeRider(i);
|
if (riders[i].getType() == "Shield") removeRider(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasShield() const {
|
bool hasShield() const {
|
||||||
return shield;
|
return shield;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getScore() const {
|
int getScore() const {
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScore(int score) {
|
void setScore(int score) {
|
||||||
this->score = score;
|
this->score = score;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNewLifeScore() const {
|
int getNewLifeScore() const {
|
||||||
return newLifeScore;
|
return newLifeScore;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNumLivesAdded() const {
|
int getNumLivesAdded() const {
|
||||||
return newLives;
|
return newLives;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNumLivesAdded(int numLives) {
|
void setNumLivesAdded(int numLives) {
|
||||||
newLives = numLives;
|
newLives = numLives;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
int lives = 3, score = 0, newLifeScore = 10000, newLives = 0;
|
int lives = 3, score = 0, newLifeScore = 10000, newLives = 0;
|
||||||
|
|
||||||
bool shield;
|
bool shield;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif //SFML_TEMPLATE_SHIP_H
|
#endif //SFML_TEMPLATE_SHIP_H
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
72
main.cpp
72
main.cpp
|
|
@ -1,37 +1,37 @@
|
||||||
#include <iostream> // for standard input/output
|
#include <iostream> // for standard input/output
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
using namespace std; // using the standard namespace
|
using namespace std; // using the standard namespace
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp> // include the SFML Graphics Library
|
#include <SFML/Graphics.hpp> // include the SFML Graphics Library
|
||||||
#include <SFML/Audio.hpp>
|
#include <SFML/Audio.hpp>
|
||||||
#include "Collision.h"
|
#include "Collision.h"
|
||||||
using namespace sf; // using the sf namespace
|
using namespace sf; // using the sf namespace
|
||||||
|
|
||||||
#include "MySprite.h"
|
#include "MySprite.h"
|
||||||
#include "Rider.h"
|
#include "Rider.h"
|
||||||
#include "Mount.h"
|
#include "Mount.h"
|
||||||
#include "Ship.h"
|
#include "Ship.h"
|
||||||
#include "Asteroid.h"
|
#include "Asteroid.h"
|
||||||
#include "Menu.h"
|
#include "Menu.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
bool play = true;
|
bool play = true;
|
||||||
Time mTime = Time::Zero;
|
Time mTime = Time::Zero;
|
||||||
int loop = 0;
|
int loop = 0;
|
||||||
|
|
||||||
while (play) {
|
while (play) {
|
||||||
Menu menu(loop, mTime);
|
Menu menu(loop, mTime);
|
||||||
if (menu.result == EXIT_SUCCESS) {
|
if (menu.result == EXIT_SUCCESS) {
|
||||||
Game game(menu.musicPicked, menu.mTime);
|
Game game(menu.musicPicked, menu.mTime);
|
||||||
if (game.result == 1) play = false;
|
if (game.result == 1) play = false;
|
||||||
|
|
||||||
loop = game.loop;
|
loop = game.loop;
|
||||||
mTime = game.mTime;
|
mTime = game.mTime;
|
||||||
}
|
}
|
||||||
else play = false;
|
else play = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
15
scores
15
scores
|
|
@ -1,5 +1,10 @@
|
||||||
19/10/2020 107800
|
19/10/2020 107800
|
||||||
19/10/2020 12100
|
19/10/2020 12100
|
||||||
19/10/2020 8700
|
19/10/2020 8700
|
||||||
19/10/2020 1300
|
21/10/2020 4900
|
||||||
19/10/2020 100
|
21/10/2020 2300
|
||||||
|
21/10/2020 2100
|
||||||
|
21/10/2020 1400
|
||||||
|
19/10/2020 1300
|
||||||
|
21/10/2020 800
|
||||||
|
21/10/2020 200
|
||||||
Loading…
Add table
Add a link
Reference in a new issue