Who knows

This commit is contained in:
Benjamin Morgan 2025-09-26 09:26:47 -06:00
parent eaf5a55d18
commit 32e50969b4
45 changed files with 38346 additions and 38306 deletions

2
.gitignore vendored
View file

@ -1,2 +1,2 @@
.idea .idea
cmake-build-debug/ cmake-build-debug/

38
Beam.h
View file

@ -1,19 +1,19 @@
// //
// Created by Benjamin on 4/23/2021. // Created by Benjamin on 4/23/2021.
// //
#ifndef SFML_TEMPLATE_BEAM_H #ifndef SFML_TEMPLATE_BEAM_H
#define SFML_TEMPLATE_BEAM_H #define SFML_TEMPLATE_BEAM_H
class Beam : public Shootable { class Beam : public Shootable {
public: public:
Beam(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double damage, double _range) : Shootable(texture, rect, scale, rows, cols, xOffset, yOffset, frameDelay, damage) { Beam(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double damage, double _range) : Shootable(texture, rect, scale, rows, cols, xOffset, yOffset, frameDelay, damage) {
lifetime = 1; lifetime = 1;
range = _range; range = _range;
} }
}; };
#endif //SFML_TEMPLATE_BEAM_H #endif //SFML_TEMPLATE_BEAM_H

View file

@ -1,46 +1,46 @@
// //
// Created by Benjamin on 4/23/2021. // Created by Benjamin on 4/23/2021.
// //
#ifndef SFML_TEMPLATE_BEAMWEAPON_H #ifndef SFML_TEMPLATE_BEAMWEAPON_H
#define SFML_TEMPLATE_BEAMWEAPON_H #define SFML_TEMPLATE_BEAMWEAPON_H
#include <thread> #include <thread>
#include "Beam.h" #include "Beam.h"
class BeamWeapon : public Weapon { class BeamWeapon : public Weapon {
private: private:
int duration; int duration;
int framesShot = 0; int framesShot = 0;
public: public:
BeamWeapon(Beam _proj, const sf::SoundBuffer& buffer, float volume, double effectiveAngle, int _duration, int frameDelay) : Weapon(frameDelay, effectiveAngle, buffer, volume) { BeamWeapon(Beam _proj, const sf::SoundBuffer& buffer, float volume, double effectiveAngle, int _duration, int frameDelay) : Weapon(frameDelay, effectiveAngle, buffer, volume) {
projectile = std::move(_proj); projectile = std::move(_proj);
duration = _duration; duration = _duration;
} }
Shootable* shoot(const Ship* shooter) override { Shootable* shoot(const Ship* shooter) override {
framesShot++; framesShot++;
if (noise.getStatus() != sf::Sound::Playing) noise.play(); if (noise.getStatus() != sf::Sound::Playing) noise.play();
projectile.setShooter((GameSprite *) shooter); projectile.setShooter((GameSprite *) shooter);
sf::Vector2f adjusted(shooter->getXPos() + shooter->getLocalBounds().width/4 * shooter->getScale().x * cos(shooter->getDirection()*GameSprite::PI/180), shooter->getYPos() - shooter->getLocalBounds().width/4 * shooter->getScale().x * sin(shooter->getDirection()*GameSprite::PI/180)); sf::Vector2f adjusted(shooter->getXPos() + shooter->getLocalBounds().width/4 * shooter->getScale().x * cos(shooter->getDirection()*GameSprite::PI/180), shooter->getYPos() - shooter->getLocalBounds().width/4 * shooter->getScale().x * sin(shooter->getDirection()*GameSprite::PI/180));
double newWidth = shooter->getTarget() == nullptr ? projectile.getRange() : GameSprite::distance(adjusted, shooter->getTarget()->getPosition()); double newWidth = shooter->getTarget() == nullptr ? projectile.getRange() : GameSprite::distance(adjusted, shooter->getTarget()->getPosition());
projectile.setTextureRect(sf::IntRect(projectile.getTextureRect().left, projectile.getTextureRect().top, newWidth > projectile.getRange() ? projectile.getRange() * (1/projectile.getScale().x) : newWidth * (1/projectile.getScale().x), projectile.getTextureRect().height)); projectile.setTextureRect(sf::IntRect(projectile.getTextureRect().left, projectile.getTextureRect().top, newWidth > projectile.getRange() ? projectile.getRange() * (1/projectile.getScale().x) : newWidth * (1/projectile.getScale().x), projectile.getTextureRect().height));
projectile.setOrigin(0, projectile.getLocalBounds().height/2); projectile.setOrigin(0, projectile.getLocalBounds().height/2);
projectile.setPosition(adjusted); projectile.setPosition(adjusted);
projectile.setDirection(shooter->getTarget() == nullptr ? shooter->getDirection() : -GameSprite::getAimAngle(shooter->getTarget()->getPosition(), projectile.getPosition())); projectile.setDirection(shooter->getTarget() == nullptr ? shooter->getDirection() : -GameSprite::getAimAngle(shooter->getTarget()->getPosition(), projectile.getPosition()));
if (framesShot == duration) { if (framesShot == duration) {
framesShot = 0; framesShot = 0;
currentFrame = 0; currentFrame = 0;
noise.stop(); noise.stop();
} }
return new Shootable(projectile); return new Shootable(projectile);
} }
}; };
#endif //SFML_TEMPLATE_BEAMWEAPON_H #endif //SFML_TEMPLATE_BEAMWEAPON_H

View file

@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 14)
include_directories("D:/Program Files/mingw-w64/mingw64/x86_64-w64-mingw32/include") include_directories("D:/Program Files/mingw-w64/mingw64/x86_64-w64-mingw32/include")
add_executable(SFML_Template main.cpp Game.cpp Game.h GameSprite.cpp GameSprite.h Ship.cpp Ship.h System.cpp System.h Planet.cpp Planet.h Collision.cpp Collision.h Menu.cpp Menu.h GameSound.h) add_executable(SFML_Template main.cpp Game.cpp Game.h GameSprite.cpp GameSprite.h Ship.cpp Ship.h System.cpp System.h Planet.cpp Planet.h Collision.cpp Collision.h Menu.cpp Menu.h Rider.h)
target_link_directories(SFML_Template PUBLIC "D:/Program Files/mingw-w64/mingw64/x86_64-w64-mingw32/lib") target_link_directories(SFML_Template PUBLIC "D:/Program Files/mingw-w64/mingw64/x86_64-w64-mingw32/lib")

358
COMShip.h
View file

@ -1,179 +1,179 @@
// //
// Created by benmo on 3/26/2020. // Created by benmo on 3/26/2020.
// //
#ifndef SFML_TEMPLATE_COMSHIP_H #ifndef SFML_TEMPLATE_COMSHIP_H
#define SFML_TEMPLATE_COMSHIP_H #define SFML_TEMPLATE_COMSHIP_H
#include <random> #include <random>
#include <iostream> #include <iostream>
#include "System.h" #include "System.h"
#include "Ship.h" #include "Ship.h"
#include <float.h> #include <float.h>
class COMShip : public Ship { class COMShip : public Ship {
public: public:
enum Status { enum Status {
ROLL, MOVING, WARPING, ATTACKING ROLL, MOVING, WARPING, ATTACKING
}; };
private: private:
sf::Vector2f destination; sf::Vector2f destination;
int ticksSinceLast = 0, landing = -9999; int ticksSinceLast = 0, landing = -9999;
float targetVelo; float targetVelo;
std::string name; std::string name;
int playerReputation; int playerReputation;
Status status = ROLL; Status status = ROLL;
public: public:
COMShip(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float accelRate, float maxVelocity, float direction, float turnRate, int maxFuel, int maxHull, int cargo, int passengers, std::string _name, int playerRep) : Ship(texture, scale, xPos, yPos, velocity, maxVelocity, direction, turnRate, maxFuel, maxHull, cargo, passengers) { COMShip(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float accelRate, float maxVelocity, float direction, float turnRate, int maxFuel, int maxHull, int cargo, int passengers, std::string _name, int playerRep) : Ship(texture, scale, xPos, yPos, velocity, maxVelocity, direction, turnRate, maxFuel, maxHull, cargo, passengers) {
destination = sf::Vector2f(xPos + 1, yPos + 1); destination = sf::Vector2f(xPos + 1, yPos + 1);
spritePhysics.acceleration = accelRate; spritePhysics.acceleration = accelRate;
playerReputation = playerRep; playerReputation = playerRep;
name = std::move(_name); name = std::move(_name);
}; };
void shoot(std::vector<Shootable*> &shots) override { void shoot(std::vector<Shootable*> &shots) override {
for (Weapon *w : weapons) { for (Weapon *w : weapons) {
double angle = -getAimAngle(target->getPosition(), getPosition()); double angle = -getAimAngle(target->getPosition(), getPosition());
double leftEffectiveBorder = spritePhysics.direction + w->getEffectiveAngle()/2; double leftEffectiveBorder = spritePhysics.direction + w->getEffectiveAngle()/2;
double rightEffectiveBorder = spritePhysics.direction - w->getEffectiveAngle()/2; double rightEffectiveBorder = spritePhysics.direction - w->getEffectiveAngle()/2;
if (w->canShoot() && ( angle < leftEffectiveBorder && angle > rightEffectiveBorder) && distance(target->getPosition(), getPosition()) < w->getProjectile().getRange()) { if (w->canShoot() && ( angle < leftEffectiveBorder && angle > rightEffectiveBorder) && distance(target->getPosition(), getPosition()) < w->getProjectile().getRange()) {
shots.push_back(w->shoot(this)); shots.push_back(w->shoot(this));
} }
} }
} }
template< class RNG > template< class RNG >
Status pathfind(const sf::RenderWindow &window, RNG &gen, System *loc, Ship* player, std::vector<Shootable*> &projectiles) { Status pathfind(const sf::RenderWindow &window, RNG &gen, System *loc, Ship* player, std::vector<Shootable*> &projectiles) {
if (status != ATTACKING && isHostile()) { if (status != ATTACKING && isHostile()) {
setTarget(player); setTarget(player);
status = ATTACKING; status = ATTACKING;
} }
if (status == ROLL) { if (status == ROLL) {
rollPosition(window, gen); rollPosition(window, gen);
} }
if (status == ATTACKING) { if (status == ATTACKING) {
if (target != nullptr) { if (target != nullptr) {
dogFight(getShortestWeaponRange(), target, projectiles); dogFight(getShortestWeaponRange(), target, projectiles);
} else { } else {
status = MOVING; status = MOVING;
} }
} }
if (status == MOVING) { if (status == MOVING) {
approachTargetVelocity(); approachTargetVelocity();
turnTowardsTarget(); turnTowardsTarget();
ticksSinceLast++; ticksSinceLast++;
if (ticksSinceLast > 2000) std::cout << "likely loop" << std::endl; if (ticksSinceLast > 2000) std::cout << "likely loop" << std::endl;
if (distance(destination, getPosition()) > 4000) std::cout << "Out of bounds" << std::endl; if (distance(destination, getPosition()) > 4000) std::cout << "Out of bounds" << std::endl;
else if (distance(destination, getPosition()) <(180 * targetVelo) / (GameSprite::PI * getTurnRate()) * 1.1) else if (distance(destination, getPosition()) <(180 * targetVelo) / (GameSprite::PI * getTurnRate()) * 1.1)
status = ROLL; status = ROLL;
} }
return status; return status;
} }
void dogFight(double dist, Ship *target, std::vector<Shootable*> &projectiles) { void dogFight(double dist, Ship *target, std::vector<Shootable*> &projectiles) {
destination = target->getPosition(); destination = target->getPosition();
if (distance(getPosition(), target->getPosition()) > dist) targetVelo = spritePhysics.maxVelocity; if (distance(getPosition(), target->getPosition()) > dist) targetVelo = spritePhysics.maxVelocity;
else targetVelo = target->getVelocity(); else targetVelo = target->getVelocity();
turnTowardsTarget(); turnTowardsTarget();
approachTargetVelocity(); approachTargetVelocity();
shoot(projectiles); shoot(projectiles);
} }
double getShortestWeaponRange() { double getShortestWeaponRange() {
double smallest = DBL_MAX; double smallest = DBL_MAX;
for (Weapon *w : weapons) { for (Weapon *w : weapons) {
if (w->getProjectile().getRange() < smallest) { if (w->getProjectile().getRange() < smallest) {
smallest = w->getProjectile().getRange() == 0 ? smallest : w->getProjectile().getRange(); smallest = w->getProjectile().getRange() == 0 ? smallest : w->getProjectile().getRange();
} }
} }
return smallest == DBL_MAX ? -1 : smallest; return smallest == DBL_MAX ? -1 : smallest;
} }
void turnTowardsTarget() { void turnTowardsTarget() {
double targetAngle = -getAimAngle(destination, getPosition()); double targetAngle = -getAimAngle(destination, getPosition());
double changeAngle = abs(spritePhysics.direction - targetAngle); double changeAngle = abs(spritePhysics.direction - targetAngle);
if (changeAngle > 180) changeAngle = abs(changeAngle - 360); if (changeAngle > 180) changeAngle = abs(changeAngle - 360);
if (changeAngle > getTurnRate()) changeAngle = getTurnRate(); if (changeAngle > getTurnRate()) changeAngle = getTurnRate();
if (abs(spritePhysics.direction - targetAngle) <= 180) turn(spritePhysics.direction - targetAngle > 0 ? changeAngle : -changeAngle); if (abs(spritePhysics.direction - targetAngle) <= 180) turn(spritePhysics.direction - targetAngle > 0 ? changeAngle : -changeAngle);
else turn(spritePhysics.direction - targetAngle > 0 ? -changeAngle : changeAngle); else turn(spritePhysics.direction - targetAngle > 0 ? -changeAngle : changeAngle);
} }
void approachTargetVelocity() { void approachTargetVelocity() {
if (getVelocity() > targetVelo) accelerate( if (getVelocity() > targetVelo) accelerate(
abs(spritePhysics.velocity - targetVelo) > spritePhysics.acceleration ? -spritePhysics.acceleration : -abs( abs(spritePhysics.velocity - targetVelo) > spritePhysics.acceleration ? -spritePhysics.acceleration : -abs(
spritePhysics.velocity - targetVelo)); spritePhysics.velocity - targetVelo));
else if (getVelocity() < targetVelo) accelerate( else if (getVelocity() < targetVelo) accelerate(
abs(spritePhysics.velocity - targetVelo) > spritePhysics.acceleration ? spritePhysics.acceleration : abs( abs(spritePhysics.velocity - targetVelo) > spritePhysics.acceleration ? spritePhysics.acceleration : abs(
spritePhysics.velocity - targetVelo)); spritePhysics.velocity - targetVelo));
} }
template<class RNG> template<class RNG>
void rollPosition(const sf::RenderWindow &window, RNG &gen) { void rollPosition(const sf::RenderWindow &window, RNG &gen) {
std::uniform_int_distribution<int> roll; std::uniform_int_distribution<int> roll;
roll = std::uniform_int_distribution<int>(0, 100); roll = std::uniform_int_distribution<int>(0, 100);
if (roll(gen) == 50) { if (roll(gen) == 50) {
status = WARPING; status = WARPING;
return; return;
} }
else status = MOVING; else status = MOVING;
roll = std::uniform_int_distribution<int>(-1500, 1500); roll = std::uniform_int_distribution<int>(-1500, 1500);
do { do {
int randXPos = roll(gen); int randXPos = roll(gen);
int randYPos = roll(gen); int randYPos = roll(gen);
destination = sf::Vector2f((int) window.getSize().x / 2.0 + randXPos, destination = sf::Vector2f((int) window.getSize().x / 2.0 + randXPos,
(int) window.getSize().y / 2.0 + randYPos); (int) window.getSize().y / 2.0 + randYPos);
roll = std::uniform_int_distribution<int>(4, 6); roll = std::uniform_int_distribution<int>(4, 6);
targetVelo = spritePhysics.maxVelocity / roll(gen); targetVelo = spritePhysics.maxVelocity / roll(gen);
} while (distance(destination, getPosition()) < (180 * targetVelo) / (PI * getTurnRate()) * 1.1); } while (distance(destination, getPosition()) < (180 * targetVelo) / (PI * getTurnRate()) * 1.1);
ticksSinceLast = 0; ticksSinceLast = 0;
} }
int getPlayerRep() const { int getPlayerRep() const {
return playerReputation; return playerReputation;
} }
void setPlayerRep(int playerRep) { void setPlayerRep(int playerRep) {
playerReputation = playerRep; playerReputation = playerRep;
} }
bool isFriendly() const { bool isFriendly() const {
return playerReputation >= Game::FRIENDLY_LOW; return playerReputation >= Game::FRIENDLY_LOW;
} }
bool isNeutral() const { bool isNeutral() const {
return playerReputation >= Game::NUETRAL_LOW && playerReputation <= Game::NUETRAL_HIGH; return playerReputation >= Game::NUETRAL_LOW && playerReputation <= Game::NUETRAL_HIGH;
} }
bool isHostile() const { bool isHostile() const {
return playerReputation <= Game::HOSTILE_HIGH; return playerReputation <= Game::HOSTILE_HIGH;
} }
std::string getName() { std::string getName() {
return name; return name;
} }
}; };
#endif //SFML_TEMPLATE_COMSHIP_H #endif //SFML_TEMPLATE_COMSHIP_H

View file

@ -1,190 +1,191 @@
/* /*
* File: collision.cpp * File: collision.cpp
* Author: Nick (original version), ahnonay (SFML2 compatibility) * Author: Nick (original version), ahnonay (SFML2 compatibility), bmorgan1 (collsion point return)
*/ */
#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::Vector2f &point) {
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; point = sf::Vector2f(i, j);
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; {
if (!img.loadFromFile(Filename)) sf::Image img;
return false; if (!img.loadFromFile(Filename))
if (!LoadInto.loadFromImage(img)) return false;
return false; if (!LoadInto.loadFromImage(img))
return false;
Bitmasks.CreateMask(&LoadInto, img);
return true; Bitmasks.CreateMask(&LoadInto, img);
} return true;
}
sf::Vector2f GetSpriteCenter (const sf::Sprite& Object)
{ sf::Vector2f GetSpriteCenter (const sf::Sprite& Object)
sf::FloatRect AABB = Object.getGlobalBounds(); {
return sf::Vector2f (AABB.left+AABB.width/2.f, AABB.top+AABB.height/2.f); sf::FloatRect AABB = Object.getGlobalBounds();
} 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::Vector2f Scale = Object.getScale(); sf::IntRect OriginalSize = Object.getTextureRect();
return sf::Vector2f (OriginalSize.width*Scale.x, OriginalSize.height*Scale.y); sf::Vector2f Scale = Object.getScale();
} return sf::Vector2f (OriginalSize.width*Scale.x, OriginalSize.height*Scale.y);
}
bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
sf::Vector2f Obj1Size = GetSpriteSize(Object1); bool CircleTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
sf::Vector2f Obj2Size = GetSpriteSize(Object2); sf::Vector2f Obj1Size = GetSpriteSize(Object1);
float Radius1 = (Obj1Size.x + Obj1Size.y) / 4; sf::Vector2f Obj2Size = GetSpriteSize(Object2);
float Radius2 = (Obj2Size.x + Obj2Size.y) / 4; float Radius1 = (Obj1Size.x + Obj1Size.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: {
OrientedBoundingBox (const sf::Sprite& Object) // Calculate the four points of the OBB from a transformed (scaled, rotated...) sprite public:
{ OrientedBoundingBox (const sf::Sprite& Object) // Calculate the four points of the OBB from a transformed (scaled, rotated...) sprite
sf::Transform trans = Object.getTransform(); {
sf::IntRect local = Object.getTextureRect(); sf::Transform trans = Object.getTransform();
Points[0] = trans.transformPoint(0.f, 0.f); sf::IntRect local = Object.getTextureRect();
Points[1] = trans.transformPoint(local.width, 0.f); Points[0] = trans.transformPoint(0.f, 0.f);
Points[2] = trans.transformPoint(local.width, local.height); Points[1] = trans.transformPoint(local.width, 0.f);
Points[3] = trans.transformPoint(0.f, local.height); Points[2] = trans.transformPoint(local.width, 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); {
Max = Min; Min = (Points[0].x*Axis.x+Points[0].y*Axis.y);
for (int j = 1; j<4; j++) Max = Min;
{ 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)
Min=Projection; if (Projection<Min)
if (Projection>Max) Min=Projection;
Max=Projection; if (Projection>Max)
} Max=Projection;
} }
}; }
};
bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
OrientedBoundingBox OBB1 (Object1); bool BoundingBoxTest(const sf::Sprite& Object1, const sf::Sprite& Object2) {
OrientedBoundingBox OBB2 (Object2); OrientedBoundingBox OBB1 (Object1);
OrientedBoundingBox OBB2 (Object2);
// Create the four distinct axes that are perpendicular to the edges of the two rectangles
sf::Vector2f Axes[4] = { // Create the four distinct axes that are perpendicular to the edges of the two rectangles
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[0].x, sf::Vector2f Axes[4] = {
OBB1.Points[1].y-OBB1.Points[0].y), sf::Vector2f (OBB1.Points[1].x-OBB1.Points[0].x,
sf::Vector2f (OBB1.Points[1].x-OBB1.Points[2].x, OBB1.Points[1].y-OBB1.Points[0].y),
OBB1.Points[1].y-OBB1.Points[2].y), sf::Vector2f (OBB1.Points[1].x-OBB1.Points[2].x,
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[3].x, OBB1.Points[1].y-OBB1.Points[2].y),
OBB2.Points[0].y-OBB2.Points[3].y), sf::Vector2f (OBB2.Points[0].x-OBB2.Points[3].x,
sf::Vector2f (OBB2.Points[0].x-OBB2.Points[1].x, OBB2.Points[0].y-OBB2.Points[3].y),
OBB2.Points[0].y-OBB2.Points[1].y) sf::Vector2f (OBB2.Points[0].x-OBB2.Points[1].x,
}; 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 ...
OBB1.ProjectOntoAxis(Axes[i], MinOBB1, MaxOBB1); // ... project the points of both OBBs onto the axis ...
OBB2.ProjectOntoAxis(Axes[i], MinOBB2, MaxOBB2); OBB1.ProjectOntoAxis(Axes[i], MinOBB1, MaxOBB1);
OBB2.ProjectOntoAxis(Axes[i], MinOBB2, MaxOBB2);
// ... 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 // ... and check whether the outermost projected points of both OBBs overlap.
if (!((MinOBB2<=MaxOBB1)&&(MaxOBB2>=MinOBB1))) // If this is not the case, the Separating Axis Theorem states that there can be no collision between the rectangles
return false; if (!((MinOBB2<=MaxOBB1)&&(MaxOBB2>=MinOBB1)))
} return false;
return true; }
} return true;
}
} }

View file

@ -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), bmorgan1 (collsion point return)
* *
* 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, sf::Vector2f &point);
////// //////
/// 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

View file

@ -1,32 +1,32 @@
// //
// Created by benmo on 5/7/2020. // Created by benmo on 5/7/2020.
// //
#ifndef SFML_TEMPLATE_EXPLORE_H #ifndef SFML_TEMPLATE_EXPLORE_H
#define SFML_TEMPLATE_EXPLORE_H #define SFML_TEMPLATE_EXPLORE_H
#include <string> #include <string>
#include <utility> #include <utility>
class Explore { class Explore {
private: private:
std::string type, message; std::string type, message;
int moneyHigh, moneyLow, prestigeHigh, prestigeLow; int moneyHigh, moneyLow, prestigeHigh, prestigeLow;
public: public:
Explore(std::string _type, std::string msg, int _moneyLow = 0, int _moneyHigh = 0, int _prestigeLow = 0, int _prestigeHigh = 0) { Explore(std::string _type, std::string msg, int _moneyLow = 0, int _moneyHigh = 0, int _prestigeLow = 0, int _prestigeHigh = 0) {
message = std::move(msg); message = std::move(msg);
type = _type; type = _type;
moneyHigh = _moneyHigh; moneyHigh = _moneyHigh;
moneyLow = _moneyLow; moneyLow = _moneyLow;
prestigeHigh = _prestigeHigh; prestigeHigh = _prestigeHigh;
prestigeLow = _prestigeLow; prestigeLow = _prestigeLow;
} }
std::string getMessage() { std::string getMessage() {
return message; return message;
} }
}; };
#endif //SFML_TEMPLATE_EXPLORE_H #endif //SFML_TEMPLATE_EXPLORE_H

4401
Game.cpp

File diff suppressed because it is too large Load diff

132
Game.h
View file

@ -1,66 +1,66 @@
// //
// Created by benmo on 2/14/2020. // Created by benmo on 2/14/2020.
// //
#ifndef SFML_TEMPLATE_GAME_H #ifndef SFML_TEMPLATE_GAME_H
#define SFML_TEMPLATE_GAME_H #define SFML_TEMPLATE_GAME_H
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
#include "GameSprite.h" #include "GameSprite.h"
#include "Ship.h" #include "Ship.h"
class Game { class Game {
private: private:
void init(); void init();
bool playedBip = false, playedErr = false, soundOn = true, musicOn = true; bool playedBip = false, playedErr = false, soundOn = true, musicOn = true;
sf::SoundBuffer bip; sf::SoundBuffer bip;
sf::Sound bipSound; sf::Sound bipSound;
sf::SoundBuffer err; sf::SoundBuffer err;
sf::Sound errSound; sf::Sound errSound;
sf::Texture loadingBarEmpty; sf::Texture loadingBarEmpty;
sf::Texture loadingBarFull; sf::Texture loadingBarFull;
sf::Font oxan; sf::Font oxan;
std::vector<std::string> abstractNounNameComponents; std::vector<std::string> abstractNounNameComponents;
std::vector<std::string> adjectiveNameComponents; std::vector<std::string> adjectiveNameComponents;
std::vector<std::string> animalNameComponents; std::vector<std::string> animalNameComponents;
std::vector<std::string> standaloneNameNameComponents; std::vector<std::string> standaloneNameNameComponents;
std::vector<std::string> femaleNameNameComponents; std::vector<std::string> femaleNameNameComponents;
std::vector<std::string> femaleTitleNameComponents; std::vector<std::string> femaleTitleNameComponents;
std::vector<std::string> neutralTitleNameComponents; std::vector<std::string> neutralTitleNameComponents;
std::vector<std::string> maleNameNameComponents; std::vector<std::string> maleNameNameComponents;
std::vector<std::string> maleTitleNameComponents; std::vector<std::string> maleTitleNameComponents;
std::vector<std::string> nounNameComponents; std::vector<std::string> nounNameComponents;
std::vector<std::string> numberNameComponents; std::vector<std::string> numberNameComponents;
std::vector<std::string> craftNameNameComponents; std::vector<std::string> craftNameNameComponents;
//update total //update total
int totalTextures = 195; int totalTextures = 195;
int loadedTextures = 0; int loadedTextures = 0;
void playBip(); void playBip();
void playErr(); void playErr();
void readNameComponents(); void readNameComponents();
template<class RNG > template<class RNG >
std::string generateName(RNG &gen); std::string generateName(RNG &gen);
void updateLoader(sf::RenderWindow &window, const std::string& msg); void updateLoader(sf::RenderWindow &window, const std::string& msg);
public: public:
const static int FRIENDLY_LOW = 100, NUETRAL_HIGH = 99, NUETRAL_LOW = 0, HOSTILE_HIGH = -1; const static int FRIENDLY_LOW = 100, NUETRAL_HIGH = 99, NUETRAL_LOW = 0, HOSTILE_HIGH = -1;
Game(bool _soundOn, bool _musicOn) { Game(bool _soundOn, bool _musicOn) {
soundOn = _soundOn; soundOn = _soundOn;
musicOn = _musicOn; musicOn = _musicOn;
init(); init();
} }
}; };
#endif //SFML_TEMPLATE_GAME_H #endif //SFML_TEMPLATE_GAME_H

View file

@ -1,209 +1,209 @@
#include <iostream> #include <iostream>
#include "GameSprite.h" #include "GameSprite.h"
void GameSprite::init() { void GameSprite::init() {
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);
} }
GameSprite::GameSprite() : sf::Sprite() { GameSprite::GameSprite() : sf::Sprite() {
init(); init();
} }
GameSprite::GameSprite(const sf::Texture &texture) : sf::Sprite(texture) { GameSprite::GameSprite(const sf::Texture &texture) : sf::Sprite(texture) {
init(); init();
} }
GameSprite::GameSprite(const sf::Texture &texture, float scale) : sf::Sprite(texture) { GameSprite::GameSprite(const sf::Texture &texture, float scale) : sf::Sprite(texture) {
init(); init();
setScale(scale/100, scale/100); setScale(scale/100, scale/100);
} }
GameSprite::GameSprite(const sf::Texture &texture, const sf::IntRect &rectangle) : sf::Sprite(texture, rectangle) { GameSprite::GameSprite(const sf::Texture &texture, const sf::IntRect &rectangle) : sf::Sprite(texture, rectangle) {
init(); init();
} }
GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction) : sf::Sprite(texture) { GameSprite::GameSprite(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;
setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2); setOrigin(getGlobalBounds().width/2,getGlobalBounds().height/2);
setScale(scale/100, scale/100); setScale(scale/100, scale/100);
setPosition(spritePhysics.xPos,spritePhysics.yPos); setPosition(spritePhysics.xPos,spritePhysics.yPos);
setRotation(direction); setRotation(direction);
} }
GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction) : GameSprite(texture, scale, xPos, yPos, velocity, direction) { GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction) : GameSprite(texture, scale, xPos, yPos, velocity, direction) {
spritePhysics.maxVelocity = maxVelocity; spritePhysics.maxVelocity = maxVelocity;
} }
GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity) : GameSprite(texture, scale, xPos, yPos, velocity, maxVelocity, direction) { GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity) : GameSprite(texture, scale, xPos, yPos, velocity, maxVelocity, direction) {
spritePhysics.rotVelocity = rotVelocity; spritePhysics.rotVelocity = rotVelocity;
spritePhysics.maxRotVelocity = maxRotVelocity; spritePhysics.maxRotVelocity = maxRotVelocity;
} }
GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity) : GameSprite(texture, scale, xPos, yPos, velocity, maxVelocity, direction, rotVelocity, maxRotVelocity) { GameSprite::GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity) : GameSprite(texture, scale, xPos, yPos, velocity, maxVelocity, direction, rotVelocity, maxRotVelocity) {
spritePhysics.acceleration = acceleration; spritePhysics.acceleration = acceleration;
spritePhysics.rotAcceleration = rotAcceleration; spritePhysics.rotAcceleration = rotAcceleration;
} }
GameSprite::GameSprite(const sf::Texture &texture, const sf::IntRect &rect, int _rows, int _cols, int _xOffset, int _yOffset, int _frameDelay) : GameSprite(texture, rect) { GameSprite::GameSprite(const sf::Texture &texture, const sf::IntRect &rect, int _rows, int _cols, int _xOffset, int _yOffset, int _frameDelay) : GameSprite(texture, rect) {
rows = _rows; rows = _rows;
cols = _cols; cols = _cols;
xOffset = _xOffset; xOffset = _xOffset;
yOffset = _yOffset; yOffset = _yOffset;
frameDelay = _frameDelay; frameDelay = _frameDelay;
initRect = rect; initRect = rect;
isAnimated = true; isAnimated = true;
} }
void GameSprite::update() { void GameSprite::update() {
framesAlive++; framesAlive++;
if (isAnimated) updateAnimation(); if (isAnimated) updateAnimation();
calculateNewPosition(); calculateNewPosition();
calculateNewDirection(); calculateNewDirection();
setPosition(spritePhysics.xPos, spritePhysics.yPos); setPosition(spritePhysics.xPos, spritePhysics.yPos);
setRotation(-spritePhysics.direction); setRotation(-spritePhysics.direction);
} }
void GameSprite::nextTexture() { void GameSprite::nextTexture() {
currentCol++; currentCol++;
if (currentCol == cols) { if (currentCol == cols) {
currentCol = 0; currentCol = 0;
currentRow++; currentRow++;
if (currentRow == rows) { if (currentRow == rows) {
currentRow = 0; currentRow = 0;
} }
} }
sf::IntRect newRect(initRect.left + xOffset * currentCol, initRect.top + yOffset * currentRow, initRect.width, initRect.height); sf::IntRect newRect(initRect.left + xOffset * currentCol, initRect.top + yOffset * currentRow, initRect.width, initRect.height);
setTextureRect(newRect); setTextureRect(newRect);
} }
void GameSprite::updateAnimation(bool override) { void GameSprite::updateAnimation(bool override) {
currentFrame++; currentFrame++;
if (override) { if (override) {
nextTexture(); nextTexture();
currentFrame = 0; currentFrame = 0;
} else { } else {
if (currentFrame == frameDelay) { if (currentFrame == frameDelay) {
nextTexture(); nextTexture();
currentFrame = 0; currentFrame = 0;
} }
} }
} }
void GameSprite::calculateNewDirection() { void GameSprite::calculateNewDirection() {
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;
} }
void GameSprite::calculateNewPosition() { void GameSprite::calculateNewPosition() {
spritePhysics.xPos += cos(spritePhysics.direction * (PI / 180)) * spritePhysics.velocity; spritePhysics.xPos += cos(spritePhysics.direction * (PI / 180)) * spritePhysics.velocity;
spritePhysics.yPos += -(sin(spritePhysics.direction * (PI / 180)) * spritePhysics.velocity); spritePhysics.yPos += -(sin(spritePhysics.direction * (PI / 180)) * spritePhysics.velocity);
} }
void GameSprite::accelerate(float override, bool ignoreMax) { void GameSprite::accelerate(float override, bool ignoreMax) {
if (override != 0) spritePhysics.velocity += override; if (override != 0) spritePhysics.velocity += override;
else spritePhysics.velocity += spritePhysics.acceleration; else spritePhysics.velocity += spritePhysics.acceleration;
if (!ignoreMax && std::abs(spritePhysics.velocity) > spritePhysics.maxVelocity) spritePhysics.velocity = spritePhysics.velocity > 0 ? spritePhysics.maxVelocity : -spritePhysics.maxVelocity; if (!ignoreMax && std::abs(spritePhysics.velocity) > spritePhysics.maxVelocity) spritePhysics.velocity = spritePhysics.velocity > 0 ? spritePhysics.maxVelocity : -spritePhysics.maxVelocity;
} }
void GameSprite::rotAccel(float override, bool ignoreMax) { void GameSprite::rotAccel(float override, bool ignoreMax) {
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 GameSprite::turn(float degrees) { void GameSprite::turn(float degrees) {
spritePhysics.direction -= degrees; spritePhysics.direction -= degrees;
setRotation(-spritePhysics.direction); setRotation(-spritePhysics.direction);
} }
float GameSprite::getXPos() const { float GameSprite::getXPos() const {
return spritePhysics.xPos; return spritePhysics.xPos;
} }
float GameSprite::getYPos() const { float GameSprite::getYPos() const {
return spritePhysics.yPos; return spritePhysics.yPos;
} }
void GameSprite::setPosition(float xPos, float yPos) { void GameSprite::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 GameSprite::setPosition(const sf::Vector2f &vec) { void GameSprite::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 GameSprite::getDirection() const { float GameSprite::getDirection() const {
return spritePhysics.direction; return spritePhysics.direction;
} }
void GameSprite::setDirection(float angle) { void GameSprite::setDirection(float angle) {
spritePhysics.direction = angle; spritePhysics.direction = angle;
setRotation(-angle); setRotation(-angle);
} }
void GameSprite::setVelocity(float velo) { void GameSprite::setVelocity(float velo) {
spritePhysics.velocity = velo; spritePhysics.velocity = velo;
} }
float GameSprite::getVelocity() const { float GameSprite::getVelocity() const {
return spritePhysics.velocity; return spritePhysics.velocity;
} }
double GameSprite::getAimAngle(const Sprite& b, const Sprite& a) { double GameSprite::getAimAngle(const Sprite& b, const Sprite& a) {
return getAimAngle(b.getPosition(), a.getPosition()); return getAimAngle(b.getPosition(), a.getPosition());
} }
double GameSprite::getAimAngle(sf::Vector2f b, sf::Vector2f a) { double GameSprite::getAimAngle(sf::Vector2f b, sf::Vector2f a) {
double dx = b.x - a.x; double dx = b.x - a.x;
double dy = b.y - a.y; double dy = b.y - a.y;
double targetAngle = -((atan2(dy, dx)) * 180 / GameSprite::PI); double targetAngle = -((atan2(dy, dx)) * 180 / GameSprite::PI);
targetAngle = fmod(targetAngle, 360); targetAngle = fmod(targetAngle, 360);
if (targetAngle < 0) if (targetAngle < 0)
targetAngle += 360; targetAngle += 360;
return -targetAngle; return -targetAngle;
} }
int GameSprite::getFramesAlive() const { int GameSprite::getFramesAlive() const {
return framesAlive; return framesAlive;
} }
bool GameSprite::isPastLifetime() const { bool GameSprite::isPastLifetime() const {
return lifetime != INFINITE && framesAlive >= lifetime; return lifetime != INFINITE && framesAlive >= lifetime;
} }
int GameSprite::getLifetime() const { int GameSprite::getLifetime() const {
return lifetime; return lifetime;
} }

View file

@ -1,109 +1,109 @@
// //
// 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>
#ifndef INFINITE #ifndef INFINITE
#define INFINITE -1 #define INFINITE -1
#endif #endif
#ifdef VISIBLE #ifdef VISIBLE
#define VISIBLE -2 #define VISIBLE -2
#endif #endif
class GameSprite: public sf::Sprite{ class GameSprite: public sf::Sprite{
protected: protected:
struct Physics { struct Physics {
float velocity, direction, acceleration, maxVelocity; float velocity, direction, acceleration, maxVelocity;
float rotVelocity, rotAcceleration, maxRotVelocity; float rotVelocity, rotAcceleration, maxRotVelocity;
float xPos, yPos; float xPos, yPos;
}; };
Physics spritePhysics{}; Physics spritePhysics{};
bool isAnimated = false; bool isAnimated = false;
int currentFrame = 0, frameDelay = 0, currentRow = 0, currentCol = 0, rows, cols, xOffset, yOffset; int currentFrame = 0, frameDelay = 0, currentRow = 0, currentCol = 0, rows, cols, xOffset, yOffset;
sf::IntRect initRect; sf::IntRect initRect;
int lifetime = INFINITE; int lifetime = INFINITE;
int framesAlive = 0; int framesAlive = 0;
void nextTexture(); void nextTexture();
public: public:
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));
} }
/* /*
* Contructors * Contructors
*/ */
GameSprite(); GameSprite();
explicit GameSprite(const sf::Texture &texture); explicit GameSprite(const sf::Texture &texture);
GameSprite(const sf::Texture &texture, float scale); GameSprite(const sf::Texture &texture, float scale);
GameSprite(const sf::Texture &texture, const sf::IntRect &rectangle); GameSprite(const sf::Texture &texture, const sf::IntRect &rectangle);
GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction); GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float direction);
GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity); GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float rotVelocity, float maxRotVelocity);
GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity); GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float acceleration, float maxVelocity, float direction, float rotVelocity, float rotAcceleration, float maxRotVelocity);
GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction); GameSprite(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction);
GameSprite(const sf::Texture& texture, const sf::IntRect &rect, int _rows, int _cols, int _xOffset, int _yOffset, int frameDelay); GameSprite(const sf::Texture& texture, const sf::IntRect &rect, int _rows, int _cols, int _xOffset, int _yOffset, int frameDelay);
void init(); void init();
/** /**
* Updates sprite's position, direction, velocities, etc. every tick based on its Physics struct * Updates sprite's position, direction, velocities, etc. every tick based on its Physics struct
*/ */
void update(); virtual void update();
void updateAnimation(bool override = false); void updateAnimation(bool override = false);
/* /*
* Helper functions for update() * Helper functions for update()
*/ */
void calculateNewDirection(); void calculateNewDirection();
void calculateNewPosition(); void calculateNewPosition();
/** /**
* Accelerates ship by acceleration stat, can be overridden * Accelerates ship by acceleration stat, can be overridden
* @param override - Used to override acceleration stat default 0 * @param override - Used to override acceleration stat default 0
* @param ignoreMax - When false, maximum velocity will be honored when calculating new velocity default false * @param ignoreMax - When false, maximum velocity will be honored when calculating new velocity default false
*/ */
void accelerate(float override = 0, bool ignoreMax = false); void accelerate(float override = 0, bool ignoreMax = false);
/** /**
* Accelerates ship rotationally by rotational acceleration stat, can be overridden * Accelerates ship rotationally by rotational acceleration stat, can be overridden
* @param override - Used to override acceleration stat default 0 * @param override - Used to override acceleration stat default 0
* @param ignoreMax - When false, maximum rotational velocity will be honored when calculating new velocity default false * @param ignoreMax - When false, maximum rotational velocity will be honored when calculating new velocity default false
*/ */
void rotAccel(float override = 0, bool ignoreMax = false); void rotAccel(float override = 0, bool ignoreMax = false);
void turn(float degrees); void turn(float degrees);
float getXPos() const; float getXPos() const;
float getYPos() const; float getYPos() const;
void setPosition(float xPos, float yPos); void setPosition(float xPos, float yPos);
void setPosition(const sf::Vector2f &vec); void setPosition(const sf::Vector2f &vec);
float getDirection() const; float getDirection() const;
void setDirection(float angle); void setDirection(float angle);
void setVelocity(float velo); void setVelocity(float velo);
float getVelocity() const; float getVelocity() const;
static double getAimAngle(const Sprite& b, const Sprite& a); static double getAimAngle(const Sprite& b, const Sprite& a);
static double getAimAngle(sf::Vector2f b, sf::Vector2f a); static double getAimAngle(sf::Vector2f b, sf::Vector2f a);
int getFramesAlive() const; int getFramesAlive() const;
bool isPastLifetime() const; bool isPastLifetime() const;
int getLifetime() const; int getLifetime() const;
}; };
#endif //SFML_TEMPLATE_SPRITE_H #endif //SFML_TEMPLATE_SPRITE_H

1348
LICENSE

File diff suppressed because it is too large Load diff

898
Menu.cpp
View file

@ -1,450 +1,450 @@
// //
// Created by benmo on 2/20/2020. // Created by benmo on 2/20/2020.
// //
#include <iostream> #include <iostream>
#include <windows.h> #include <windows.h>
#include <shellapi.h> #include <shellapi.h>
#include <winuser.h> #include <winuser.h>
#include "Menu.h" #include "Menu.h"
#include "GameSprite.h" #include "GameSprite.h"
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include <SFML/Window.hpp> #include <SFML/Window.hpp>
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
int Menu::init() { int Menu::init() {
const int MENU = 0, CREDITS = 1; const int MENU = 0, CREDITS = 1;
int screen = MENU; int screen = MENU;
std::vector<GameSprite*> buttons; std::vector<GameSprite*> buttons;
std::vector<sf::Text*> text; std::vector<sf::Text*> text;
std::vector<sf::Text*> credits; std::vector<sf::Text*> credits;
std::vector<sf::Sprite*> creditsGUI; std::vector<sf::Sprite*> creditsGUI;
sf::RenderWindow window( sf::VideoMode(1240, 640), "Star Captain" ); sf::RenderWindow window( sf::VideoMode(1240, 640), "Star Captain" );
sf::View mainView; sf::View mainView;
mainView.setCenter(window.getSize().x/(float)2.0, window.getSize().y/(float)2.0); mainView.setCenter(window.getSize().x/(float)2.0, window.getSize().y/(float)2.0);
mainView.setSize(window.getSize().x, window.getSize().y); mainView.setSize(window.getSize().x, window.getSize().y);
window.setView(mainView); window.setView(mainView);
window.setPosition(sf::Vector2i(window.getPosition().x, window.getPosition().y - 20)); window.setPosition(sf::Vector2i(window.getPosition().x, window.getPosition().y - 20));
/************************************************* /*************************************************
* File Input && Processing * File Input && Processing
*************************************************/ *************************************************/
sf::Font sk; sf::Font sk;
sk.loadFromFile("./data/Fonts/Sk.ttf"); sk.loadFromFile("./data/Fonts/Sk.ttf");
sf::Font skME; sf::Font skME;
skME.loadFromFile("./data/Fonts/SKoME.ttf"); skME.loadFromFile("./data/Fonts/SKoME.ttf");
sf::Font xolo; sf::Font xolo;
xolo.loadFromFile("./data/Fonts/Xolonium-Bold.ttf"); xolo.loadFromFile("./data/Fonts/Xolonium-Bold.ttf");
sf::Font monkirta; sf::Font monkirta;
monkirta.loadFromFile("./data/Fonts/Monkirta Pursuit NC.ttf"); monkirta.loadFromFile("./data/Fonts/Monkirta Pursuit NC.ttf");
sf::Font oxan; sf::Font oxan;
oxan.loadFromFile("./data/Fonts/Oxanium-Light.ttf"); oxan.loadFromFile("./data/Fonts/Oxanium-Light.ttf");
sf::Texture back; sf::Texture back;
back.loadFromFile("./data/Gui/space.png"); back.loadFromFile("./data/Gui/space.png");
back.setRepeated(true); back.setRepeated(true);
sf::Texture button; sf::Texture button;
button.loadFromFile("./data/Gui/button.png"); button.loadFromFile("./data/Gui/button.png");
sf::Texture box; sf::Texture box;
box.loadFromFile("./data/Gui/window.png"); box.loadFromFile("./data/Gui/window.png");
sf::Texture boxSm; sf::Texture boxSm;
boxSm.loadFromFile("./data/Gui/windowSm.png"); boxSm.loadFromFile("./data/Gui/windowSm.png");
sf::Texture cloud; sf::Texture cloud;
cloud.loadFromFile("./data/Gui/cloud.png"); cloud.loadFromFile("./data/Gui/cloud.png");
sf::Texture leftArrow; sf::Texture leftArrow;
leftArrow.loadFromFile("./data/Gui/Backward_BTN.png"); leftArrow.loadFromFile("./data/Gui/Backward_BTN.png");
sf::Texture soundBTN; sf::Texture soundBTN;
soundBTN.loadFromFile("./data/Gui/Sound.png"); soundBTN.loadFromFile("./data/Gui/Sound.png");
sf::Texture musicBTN; sf::Texture musicBTN;
musicBTN.loadFromFile("./data/Gui/Music.png"); musicBTN.loadFromFile("./data/Gui/Music.png");
sf::Music menuLoop; sf::Music menuLoop;
menuLoop.openFromFile("./data/Sounds/Menu Loop.wav"); menuLoop.openFromFile("./data/Sounds/Menu Loop.wav");
menuLoop.setLoop(true); menuLoop.setLoop(true);
menuLoop.play(); menuLoop.play();
bip.loadFromFile("./data/Sounds/rollover.wav"); bip.loadFromFile("./data/Sounds/rollover.wav");
/************************************************* /*************************************************
* Object Initialization * Object Initialization
*************************************************/ *************************************************/
//Background pan sprite //Background pan sprite
sf::Sprite background(back); sf::Sprite background(back);
sf::FloatRect fBounds(mainView.getCenter().x, mainView.getCenter().y, background.getTexture()->getSize().x * 3, background.getTexture()->getSize().y * 3); sf::FloatRect fBounds(mainView.getCenter().x, mainView.getCenter().y, background.getTexture()->getSize().x * 3, background.getTexture()->getSize().y * 3);
sf::IntRect iBounds(fBounds); sf::IntRect iBounds(fBounds);
background.setTextureRect(iBounds); background.setTextureRect(iBounds);
background.setPosition(mainView.getCenter()); background.setPosition(mainView.getCenter());
background.setOrigin(iBounds.width/(float)2.0,iBounds.height/(float)2.0); background.setOrigin(iBounds.width/(float)2.0,iBounds.height/(float)2.0);
//Sound settings //Sound settings
GameSprite soundButton(soundBTN, 25, 35, 37, 0, 0); GameSprite soundButton(soundBTN, 25, 35, 37, 0, 0);
GameSprite musicButton(musicBTN, 25, soundButton.getXPos() + soundButton.getGlobalBounds().width, soundButton.getYPos(), 0, 0); GameSprite musicButton(musicBTN, 25, soundButton.getXPos() + soundButton.getGlobalBounds().width, soundButton.getYPos(), 0, 0);
//Title text //Title text
sf::Text title("Star Captain", skME, 90); sf::Text title("Star Captain", skME, 90);
title.setPosition(mainView.getCenter().x, mainView.getCenter().y - window.getSize().y / (float)3.0); title.setPosition(mainView.getCenter().x, mainView.getCenter().y - window.getSize().y / (float)3.0);
title.setFillColor(sf::Color::White); title.setFillColor(sf::Color::White);
title.setLetterSpacing(title.getLetterSpacing() + (float)0.5); title.setLetterSpacing(title.getLetterSpacing() + (float)0.5);
title.setOrigin(title.getGlobalBounds().width/(float)2.0, title.getGlobalBounds().height/(float)2.0); title.setOrigin(title.getGlobalBounds().width/(float)2.0, title.getGlobalBounds().height/(float)2.0);
//Start button & text //Start button & text
GameSprite startButton(button, 55); GameSprite startButton(button, 55);
startButton.setPosition(mainView.getCenter().x, mainView.getCenter().y - window.getSize().y / (float)12.0); startButton.setPosition(mainView.getCenter().x, mainView.getCenter().y - window.getSize().y / (float)12.0);
//default button color //default button color
sf::Color defButtonColor = startButton.getColor(); sf::Color defButtonColor = startButton.getColor();
sf::Text startText("Start", sk, 28); sf::Text startText("Start", sk, 28);
startText.setPosition(startButton.getPosition().x, startButton.getPosition().y - 7); startText.setPosition(startButton.getPosition().x, startButton.getPosition().y - 7);
startText.setFillColor(sf::Color(0,0,0,0)); startText.setFillColor(sf::Color(0,0,0,0));
startText.setOutlineColor(sf::Color::White); startText.setOutlineColor(sf::Color::White);
startText.setOutlineThickness(1); startText.setOutlineThickness(1);
startText.setLetterSpacing(startText.getLetterSpacing() + 1); startText.setLetterSpacing(startText.getLetterSpacing() + 1);
startText.setOrigin(startText.getLocalBounds().width/2, startText.getLocalBounds().height/2); startText.setOrigin(startText.getLocalBounds().width/2, startText.getLocalBounds().height/2);
//Credits button & text //Credits button & text
GameSprite creditsButton(button, 55); GameSprite creditsButton(button, 55);
creditsButton.setPosition(mainView.getCenter().x, mainView.getCenter().y); creditsButton.setPosition(mainView.getCenter().x, mainView.getCenter().y);
sf::Text creditsText("Credits", sk, 28); sf::Text creditsText("Credits", sk, 28);
creditsText.setPosition(creditsButton.getPosition().x, creditsButton.getPosition().y - 6); creditsText.setPosition(creditsButton.getPosition().x, creditsButton.getPosition().y - 6);
creditsText.setFillColor(sf::Color(0,0,0,0)); creditsText.setFillColor(sf::Color(0,0,0,0));
creditsText.setOutlineColor(sf::Color::White); creditsText.setOutlineColor(sf::Color::White);
creditsText.setOutlineThickness(1); creditsText.setOutlineThickness(1);
creditsText.setLetterSpacing(creditsText.getLetterSpacing() + 1); creditsText.setLetterSpacing(creditsText.getLetterSpacing() + 1);
creditsText.setOrigin(creditsText.getLocalBounds().width/2, creditsText.getLocalBounds().height/2); creditsText.setOrigin(creditsText.getLocalBounds().width/2, creditsText.getLocalBounds().height/2);
//Exit button & text //Exit button & text
GameSprite exitButton(button, 55); GameSprite exitButton(button, 55);
exitButton.setPosition(mainView.getCenter().x, mainView.getCenter().y + window.getSize().y / (float)12.0); exitButton.setPosition(mainView.getCenter().x, mainView.getCenter().y + window.getSize().y / (float)12.0);
sf::Text exitText("Exit", sk, 28); sf::Text exitText("Exit", sk, 28);
exitText.setPosition(mainView.getCenter().x, exitButton.getPosition().y - 6); exitText.setPosition(mainView.getCenter().x, exitButton.getPosition().y - 6);
exitText.setFillColor(sf::Color(0,0,0,0)); exitText.setFillColor(sf::Color(0,0,0,0));
exitText.setOutlineColor(sf::Color::White); exitText.setOutlineColor(sf::Color::White);
exitText.setOutlineThickness(1); exitText.setOutlineThickness(1);
exitText.setLetterSpacing(exitText.getLetterSpacing() + 1); exitText.setLetterSpacing(exitText.getLetterSpacing() + 1);
exitText.setOrigin(exitText.getLocalBounds().width/2, exitText.getLocalBounds().height/2); exitText.setOrigin(exitText.getLocalBounds().width/2, exitText.getLocalBounds().height/2);
buttons.push_back(&startButton); buttons.push_back(&startButton);
buttons.push_back(&creditsButton); buttons.push_back(&creditsButton);
buttons.push_back(&exitButton); buttons.push_back(&exitButton);
text.push_back(&startText); text.push_back(&startText);
text.push_back(&creditsText); text.push_back(&creditsText);
text.push_back(&exitText); text.push_back(&exitText);
//Credits //Credits
sf::Text creditsTitle("Credits + Resources", sk, 70); sf::Text creditsTitle("Credits + Resources", sk, 70);
creditsTitle.setPosition(mainView.getCenter().x, window.getSize().y / (float)14.0); creditsTitle.setPosition(mainView.getCenter().x, window.getSize().y / (float)14.0);
creditsTitle.setFillColor(sf::Color::White); creditsTitle.setFillColor(sf::Color::White);
creditsTitle.setOrigin(creditsTitle.getGlobalBounds().width/2, creditsTitle.getGlobalBounds().height/2); creditsTitle.setOrigin(creditsTitle.getGlobalBounds().width/2, creditsTitle.getGlobalBounds().height/2);
//Credits box //Credits box
sf::Text credsTitle("Credits", xolo, 28); sf::Text credsTitle("Credits", xolo, 28);
credsTitle.setOrigin(credsTitle.getGlobalBounds().width/2, credsTitle.getGlobalBounds().height/2); credsTitle.setOrigin(credsTitle.getGlobalBounds().width/2, credsTitle.getGlobalBounds().height/2);
credsTitle.setPosition(mainView.getSize().x/(float)5.1, mainView.getSize().y/2 + mainView.getSize().y/22); credsTitle.setPosition(mainView.getSize().x/(float)5.1, mainView.getSize().y/2 + mainView.getSize().y/22);
credsTitle.setFillColor(sf::Color::White); credsTitle.setFillColor(sf::Color::White);
sf::Text music("River Schreckengost - ", monkirta, 20); sf::Text music("River Schreckengost - ", monkirta, 20);
music.setOrigin(music.getGlobalBounds().width/2, music.getGlobalBounds().height/2); music.setOrigin(music.getGlobalBounds().width/2, music.getGlobalBounds().height/2);
music.setPosition(mainView.getSize().x/(float)5.8, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)8.5); music.setPosition(mainView.getSize().x/(float)5.8, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)8.5);
music.setFillColor(sf::Color::White); music.setFillColor(sf::Color::White);
sf::Text musicText("Music", oxan, 15); sf::Text musicText("Music", oxan, 15);
musicText.setPosition(mainView.getSize().x/(float)5.8 + music.getGlobalBounds().width/2, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)8.925); musicText.setPosition(mainView.getSize().x/(float)5.8 + music.getGlobalBounds().width/2, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)8.925);
musicText.setFillColor(sf::Color::White); musicText.setFillColor(sf::Color::White);
sf::Text musicLabel("Instagram - ", monkirta, 15); sf::Text musicLabel("Instagram - ", monkirta, 15);
musicLabel.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)7.3); musicLabel.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)7.3);
musicLabel.setFillColor(sf::Color::White); musicLabel.setFillColor(sf::Color::White);
sf::Text musicText0("@river.schreck", oxan, 12); sf::Text musicText0("@river.schreck", oxan, 12);
musicText0.setPosition(mainView.getSize().x/(float)11.5 + musicLabel.getGlobalBounds().width, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)7.15); musicText0.setPosition(mainView.getSize().x/(float)11.5 + musicLabel.getGlobalBounds().width, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)7.15);
musicText0.setFillColor(sf::Color::White); musicText0.setFillColor(sf::Color::White);
musicText0.setStyle(sf::Text::Style::Underlined); musicText0.setStyle(sf::Text::Style::Underlined);
sf::Text musicLabel0("SoundCloud - ", monkirta, 15); sf::Text musicLabel0("SoundCloud - ", monkirta, 15);
musicLabel0.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)6.1); musicLabel0.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)6.1);
musicLabel0.setFillColor(sf::Color::White); musicLabel0.setFillColor(sf::Color::White);
sf::Text musicText1("River Ethans", oxan, 12); sf::Text musicText1("River Ethans", oxan, 12);
musicText1.setPosition(mainView.getSize().x/(float)11.5 + musicLabel0.getGlobalBounds().width, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)5.95); musicText1.setPosition(mainView.getSize().x/(float)11.5 + musicLabel0.getGlobalBounds().width, mainView.getSize().y/(float)2 + mainView.getSize().y/(float)5.95);
musicText1.setFillColor(sf::Color::White); musicText1.setFillColor(sf::Color::White);
musicText1.setStyle(sf::Text::Style::Underlined); musicText1.setStyle(sf::Text::Style::Underlined);
//Resources Box //Resources Box
sf::Text resourcesTitle("Resources", xolo, 28); sf::Text resourcesTitle("Resources", xolo, 28);
resourcesTitle.setOrigin(resourcesTitle.getGlobalBounds().width/2, resourcesTitle.getGlobalBounds().height/2); resourcesTitle.setOrigin(resourcesTitle.getGlobalBounds().width/2, resourcesTitle.getGlobalBounds().height/2);
resourcesTitle.setPosition(mainView.getSize().x - mainView.getSize().x/(float)4.95, mainView.getSize().y/(float)4.8); resourcesTitle.setPosition(mainView.getSize().x - mainView.getSize().x/(float)4.95, mainView.getSize().y/(float)4.8);
resourcesTitle.setFillColor(sf::Color::White); resourcesTitle.setFillColor(sf::Color::White);
//Dev box //Dev box
sf::Text developerTitle("Developer: ", xolo, 25); sf::Text developerTitle("Developer: ", xolo, 25);
developerTitle.setPosition(mainView.getSize().x/13, mainView.getSize().y/(float)5.2); developerTitle.setPosition(mainView.getSize().x/13, mainView.getSize().y/(float)5.2);
developerTitle.setFillColor(sf::Color(0,0,0,0)); developerTitle.setFillColor(sf::Color(0,0,0,0));
developerTitle.setOutlineThickness(.8); developerTitle.setOutlineThickness(.8);
developerTitle.setOutlineColor(sf::Color::White); developerTitle.setOutlineColor(sf::Color::White);
sf::Text developer("Benjamin Morgan", monkirta, 20); sf::Text developer("Benjamin Morgan", monkirta, 20);
developer.setOrigin(developer.getGlobalBounds().width/2, developer.getGlobalBounds().height/2); developer.setOrigin(developer.getGlobalBounds().width/2, developer.getGlobalBounds().height/2);
developer.setPosition(mainView.getSize().x/(float)6.725, mainView.getSize().y/(float)3.95); developer.setPosition(mainView.getSize().x/(float)6.725, mainView.getSize().y/(float)3.95);
developer.setFillColor(sf::Color::White); developer.setFillColor(sf::Color::White);
sf::Text devLabel("Site - ", monkirta, 15); sf::Text devLabel("Site - ", monkirta, 15);
devLabel.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.65); devLabel.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.65);
devLabel.setFillColor(sf::Color::White); devLabel.setFillColor(sf::Color::White);
sf::Text devText("https://bmorgan01.github.io/Portfolio-Blog/", oxan, 12); sf::Text devText("https://bmorgan01.github.io/Portfolio-Blog/", oxan, 12);
devText.setPosition(mainView.getSize().x/(float)11.5 + devLabel.getGlobalBounds().width, mainView.getSize().y/(float)3.6); devText.setPosition(mainView.getSize().x/(float)11.5 + devLabel.getGlobalBounds().width, mainView.getSize().y/(float)3.6);
devText.setFillColor(sf::Color::White); devText.setFillColor(sf::Color::White);
devText.setStyle(sf::Text::Style::Underlined); devText.setStyle(sf::Text::Style::Underlined);
sf::Text devLabel0("Github - ", monkirta, 15); sf::Text devLabel0("Github - ", monkirta, 15);
devLabel0.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.35); devLabel0.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.35);
devLabel0.setFillColor(sf::Color::White); devLabel0.setFillColor(sf::Color::White);
sf::Text devText0("bMorgan01", oxan, 12); sf::Text devText0("bMorgan01", oxan, 12);
devText0.setPosition(mainView.getSize().x/(float)11.5 + devLabel0.getGlobalBounds().width, mainView.getSize().y/(float)3.3); devText0.setPosition(mainView.getSize().x/(float)11.5 + devLabel0.getGlobalBounds().width, mainView.getSize().y/(float)3.3);
devText0.setFillColor(sf::Color::White); devText0.setFillColor(sf::Color::White);
devText0.setStyle(sf::Text::Style::Underlined); devText0.setStyle(sf::Text::Style::Underlined);
sf::Text devLabel1("Email - ", monkirta, 15); sf::Text devLabel1("Email - ", monkirta, 15);
devLabel1.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.1); devLabel1.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)3.1);
devLabel1.setFillColor(sf::Color::White); devLabel1.setFillColor(sf::Color::White);
sf::Text devText1("ben.morgan5000@gmail.com", oxan, 12); sf::Text devText1("ben.morgan5000@gmail.com", oxan, 12);
devText1.setPosition(mainView.getSize().x/(float)11.5 + devLabel1.getGlobalBounds().width, mainView.getSize().y/(float)3.05); devText1.setPosition(mainView.getSize().x/(float)11.5 + devLabel1.getGlobalBounds().width, mainView.getSize().y/(float)3.05);
devText1.setFillColor(sf::Color::White); devText1.setFillColor(sf::Color::White);
sf::Text devLabel2("Repo - ", monkirta, 15); sf::Text devLabel2("Repo - ", monkirta, 15);
devLabel2.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2.87); devLabel2.setPosition(mainView.getSize().x/(float)11.5, mainView.getSize().y/(float)2.87);
devLabel2.setFillColor(sf::Color::White); devLabel2.setFillColor(sf::Color::White);
sf::Text devText2("https://github.com/bMorgan01/StarCap", oxan, 12); sf::Text devText2("https://github.com/bMorgan01/StarCap", oxan, 12);
devText2.setPosition(mainView.getSize().x/(float)11.5 + devLabel2.getGlobalBounds().width, mainView.getSize().y/(float)2.83); devText2.setPosition(mainView.getSize().x/(float)11.5 + devLabel2.getGlobalBounds().width, mainView.getSize().y/(float)2.83);
devText2.setFillColor(sf::Color::White); devText2.setFillColor(sf::Color::White);
devText2.setStyle(sf::Text::Style::Underlined); devText2.setStyle(sf::Text::Style::Underlined);
//Credits GUI //Credits GUI
sf::Sprite backButton(leftArrow); sf::Sprite backButton(leftArrow);
backButton.setScale(.3, .3); backButton.setScale(.3, .3);
backButton.setPosition(33, 100); backButton.setPosition(33, 100);
sf::Sprite textBox(box); sf::Sprite textBox(box);
textBox.setScale(.35, .35); textBox.setScale(.35, .35);
textBox.setPosition(mainView.getSize().x - mainView.getSize().x/3, mainView.getSize().y/(float)5.5); textBox.setPosition(mainView.getSize().x - mainView.getSize().x/3, mainView.getSize().y/(float)5.5);
sf::Sprite textBoxSm(boxSm); sf::Sprite textBoxSm(boxSm);
textBoxSm.setScale(.35, .35); textBoxSm.setScale(.35, .35);
textBoxSm.setPosition(mainView.getSize().x/15, mainView.getSize().y/2 + mainView.getSize().y/50); textBoxSm.setPosition(mainView.getSize().x/15, mainView.getSize().y/2 + mainView.getSize().y/50);
sf::Sprite devBox(cloud); sf::Sprite devBox(cloud);
devBox.setScale(.442, .442); devBox.setScale(.442, .442);
devBox.setPosition(mainView.getSize().x/15 - 2, mainView.getSize().y/(float)5.5); devBox.setPosition(mainView.getSize().x/15 - 2, mainView.getSize().y/(float)5.5);
sf::Sprite issueButton(button); sf::Sprite issueButton(button);
issueButton.setColor(sf::Color::Red); issueButton.setColor(sf::Color::Red);
issueButton.setScale(40.0/100.0, 40.0/100.0); issueButton.setScale(40.0/100.0, 40.0/100.0);
issueButton.setOrigin(issueButton.getGlobalBounds().width/2, issueButton.getGlobalBounds().height/2); issueButton.setOrigin(issueButton.getGlobalBounds().width/2, issueButton.getGlobalBounds().height/2);
issueButton.setPosition(mainView.getSize().x/(float)6.2, mainView.getSize().y/(float)2.52); issueButton.setPosition(mainView.getSize().x/(float)6.2, mainView.getSize().y/(float)2.52);
sf::Text issueText("Report Bug", sk, 16); sf::Text issueText("Report Bug", sk, 16);
issueText.setPosition(issueButton.getPosition().x - 21, issueButton.getPosition().y); issueText.setPosition(issueButton.getPosition().x - 21, issueButton.getPosition().y);
issueText.setFillColor(sf::Color(0,0,0,0)); issueText.setFillColor(sf::Color(0,0,0,0));
issueText.setFillColor(sf::Color::White); issueText.setFillColor(sf::Color::White);
credits.push_back(&creditsTitle); credits.push_back(&creditsTitle);
credits.push_back(&developerTitle); credits.push_back(&developerTitle);
credits.push_back(&credsTitle); credits.push_back(&credsTitle);
credits.push_back(&music); credits.push_back(&music);
credits.push_back(&musicText); credits.push_back(&musicText);
credits.push_back(&musicLabel); credits.push_back(&musicLabel);
credits.push_back(&musicText0); credits.push_back(&musicText0);
credits.push_back(&musicLabel0); credits.push_back(&musicLabel0);
credits.push_back(&musicText1); credits.push_back(&musicText1);
credits.push_back(&resourcesTitle); credits.push_back(&resourcesTitle);
credits.push_back(&developer); credits.push_back(&developer);
credits.push_back(&devLabel); credits.push_back(&devLabel);
credits.push_back(&devText); credits.push_back(&devText);
credits.push_back(&devLabel0); credits.push_back(&devLabel0);
credits.push_back(&devText0); credits.push_back(&devText0);
credits.push_back(&devLabel1); credits.push_back(&devLabel1);
credits.push_back(&devText1); credits.push_back(&devText1);
credits.push_back(&devLabel2); credits.push_back(&devLabel2);
credits.push_back(&devText2); credits.push_back(&devText2);
credits.push_back(&issueText); credits.push_back(&issueText);
creditsGUI.push_back(&backButton); creditsGUI.push_back(&backButton);
creditsGUI.push_back(&textBox); creditsGUI.push_back(&textBox);
creditsGUI.push_back(&textBoxSm); creditsGUI.push_back(&textBoxSm);
creditsGUI.push_back(&devBox); creditsGUI.push_back(&devBox);
creditsGUI.push_back(&issueButton); creditsGUI.push_back(&issueButton);
while( window.isOpen() ) { while( window.isOpen() ) {
/********************************************* /*********************************************
* Pre-draw ops here. * Pre-draw ops here.
*********************************************/ *********************************************/
/********************************************* /*********************************************
* Drawing goes here. * Drawing goes here.
*********************************************/ *********************************************/
window.clear( sf::Color::Black ); // clear the contents of the old frame window.clear( sf::Color::Black ); // clear the contents of the old frame
window.draw(background); window.draw(background);
switch(screen) { switch(screen) {
case MENU: case MENU:
/************** /**************
* Draw Menu * Draw Menu
**************/ **************/
backButton.setPosition(33, 100); backButton.setPosition(33, 100);
//Sound buttons //Sound buttons
window.draw(soundButton); window.draw(soundButton);
window.draw(musicButton); window.draw(musicButton);
//Title text //Title text
window.draw(title); window.draw(title);
for (int i = 0; i < buttons.size(); i++) { for (int i = 0; i < buttons.size(); i++) {
window.draw(*buttons[i]); window.draw(*buttons[i]);
window.draw(*text[i]); window.draw(*text[i]);
} }
break; break;
case CREDITS: case CREDITS:
/************** /**************
* Draw Credits * Draw Credits
**************/ **************/
backButton.setPosition(33, 27); backButton.setPosition(33, 27);
for (sf::Sprite *s : creditsGUI) { for (sf::Sprite *s : creditsGUI) {
window.draw(*s); window.draw(*s);
} }
for (sf::Text *t : credits) { for (sf::Text *t : credits) {
window.draw(*t); window.draw(*t);
} }
break; break;
} }
window.display(); // display the window window.display(); // display the window
sf::Event event{}; sf::Event event{};
while( window.pollEvent(event) ) { // ask the window if any events occurred while( window.pollEvent(event) ) { // ask the window if any events occurred
/********************************************* /*********************************************
* Event handling here. * Event handling here.
*********************************************/ *********************************************/
sf::Vector2i mousePos = sf::Mouse::getPosition( window ); sf::Vector2i mousePos = sf::Mouse::getPosition( window );
sf::Vector2f mousePosF( static_cast<float>( mousePos.x ), static_cast<float>( mousePos.y ) ); sf::Vector2f mousePosF( static_cast<float>( mousePos.x ), static_cast<float>( mousePos.y ) );
switch (event.type) { switch (event.type) {
case sf::Event::Closed: //user clicked X button case sf::Event::Closed: //user clicked X button
window.close(); window.close();
break; break;
case sf::Event::MouseButtonPressed: //User clicked mouse case sf::Event::MouseButtonPressed: //User clicked mouse
if (exitButton.getGlobalBounds().contains(mousePosF) && screen == MENU) { if (exitButton.getGlobalBounds().contains(mousePosF) && screen == MENU) {
playBip(); playBip();
return EXIT_FAILURE; return EXIT_FAILURE;
} else if (startButton.getGlobalBounds().contains(mousePosF) && screen == MENU) { } else if (startButton.getGlobalBounds().contains(mousePosF) && screen == MENU) {
playBip(); playBip();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} else if (creditsButton.getGlobalBounds().contains(mousePosF) && screen == MENU) { } else if (creditsButton.getGlobalBounds().contains(mousePosF) && screen == MENU) {
playBip(); playBip();
screen = CREDITS; screen = CREDITS;
} else if (issueButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (issueButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://github.com/bMorgan01/StarCap/issues", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://github.com/bMorgan01/StarCap/issues", nullptr, nullptr, SW_SHOWNORMAL);
} else if (devText.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (devText.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://bmorgan01.github.io/Portfolio-Blog/", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://bmorgan01.github.io/Portfolio-Blog/", nullptr, nullptr, SW_SHOWNORMAL);
} else if (devText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (devText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://github.com/bMorgan01", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://github.com/bMorgan01", nullptr, nullptr, SW_SHOWNORMAL);
} else if (devText2.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (devText2.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://github.com/bMorgan01/StarCap", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://github.com/bMorgan01/StarCap", nullptr, nullptr, SW_SHOWNORMAL);
} else if (musicText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (musicText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://www.instagram.com/river.schreck/", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://www.instagram.com/river.schreck/", nullptr, nullptr, SW_SHOWNORMAL);
} else if (musicText1.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (musicText1.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
ShellExecute(nullptr, "open", "https://soundcloud.com/riverethans", nullptr, nullptr, SW_SHOWNORMAL); ShellExecute(nullptr, "open", "https://soundcloud.com/riverethans", nullptr, nullptr, SW_SHOWNORMAL);
} else if (backButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) { } else if (backButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) {
playBip(); playBip();
screen = MENU; screen = MENU;
} else if (soundButton.getGlobalBounds().contains(mousePosF) && screen == MENU) { } else if (soundButton.getGlobalBounds().contains(mousePosF) && screen == MENU) {
soundOn = !soundOn; soundOn = !soundOn;
playBip(); playBip();
} else if (musicButton.getGlobalBounds().contains(mousePosF) && screen == MENU) { } else if (musicButton.getGlobalBounds().contains(mousePosF) && screen == MENU) {
playBip(); playBip();
musicOn = !musicOn; musicOn = !musicOn;
if (!musicOn) menuLoop.setVolume(0); if (!musicOn) menuLoop.setVolume(0);
else menuLoop.setVolume(100); else menuLoop.setVolume(100);
} }
break; break;
case sf::Event::MouseMoved: case sf::Event::MouseMoved:
if (exitButton.getGlobalBounds().contains(mousePosF) && screen == MENU) exitButton.setColor(sf::Color::Red); if (exitButton.getGlobalBounds().contains(mousePosF) && screen == MENU) exitButton.setColor(sf::Color::Red);
else if (startButton.getGlobalBounds().contains(mousePosF) && screen == MENU) startButton.setColor(sf::Color::Red); else if (startButton.getGlobalBounds().contains(mousePosF) && screen == MENU) startButton.setColor(sf::Color::Red);
else if (creditsButton.getGlobalBounds().contains(mousePosF) && screen == MENU) creditsButton.setColor(sf::Color::Red); else if (creditsButton.getGlobalBounds().contains(mousePosF) && screen == MENU) creditsButton.setColor(sf::Color::Red);
else if (issueButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) issueButton.setColor(sf::Color::Green); else if (issueButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) issueButton.setColor(sf::Color::Green);
else if (devText.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText.setFillColor(sf::Color::Red); else if (devText.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText.setFillColor(sf::Color::Red);
else if (devText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText0.setFillColor(sf::Color::Red); else if (devText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText0.setFillColor(sf::Color::Red);
else if (devText2.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText2.setFillColor(sf::Color::Red); else if (devText2.getGlobalBounds().contains(mousePosF) && screen == CREDITS) devText2.setFillColor(sf::Color::Red);
else if (musicText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) musicText0.setFillColor(sf::Color::Red); else if (musicText0.getGlobalBounds().contains(mousePosF) && screen == CREDITS) musicText0.setFillColor(sf::Color::Red);
else if (musicText1.getGlobalBounds().contains(mousePosF) && screen == CREDITS) musicText1.setFillColor(sf::Color::Red); else if (musicText1.getGlobalBounds().contains(mousePosF) && screen == CREDITS) musicText1.setFillColor(sf::Color::Red);
else if (backButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) backButton.setColor(sf::Color::Red); else if (backButton.getGlobalBounds().contains(mousePosF) && screen == CREDITS) backButton.setColor(sf::Color::Red);
else if (soundButton.getGlobalBounds().contains(mousePosF) && soundOn && screen == MENU) soundButton.setColor(sf::Color::Red); else if (soundButton.getGlobalBounds().contains(mousePosF) && soundOn && screen == MENU) soundButton.setColor(sf::Color::Red);
else if (musicButton.getGlobalBounds().contains(mousePosF) && musicOn && screen == MENU) musicButton.setColor(sf::Color::Red); else if (musicButton.getGlobalBounds().contains(mousePosF) && musicOn && screen == MENU) musicButton.setColor(sf::Color::Red);
else if (soundButton.getGlobalBounds().contains(mousePosF) && !soundOn && screen == MENU) soundButton.setColor(sf::Color::White); else if (soundButton.getGlobalBounds().contains(mousePosF) && !soundOn && screen == MENU) soundButton.setColor(sf::Color::White);
else if (musicButton.getGlobalBounds().contains(mousePosF) && !musicOn && screen == MENU) musicButton.setColor(sf::Color::White); else if (musicButton.getGlobalBounds().contains(mousePosF) && !musicOn && screen == MENU) musicButton.setColor(sf::Color::White);
break; break;
} }
if (!exitButton.getGlobalBounds().contains(mousePosF)) exitButton.setColor(defButtonColor); if (!exitButton.getGlobalBounds().contains(mousePosF)) exitButton.setColor(defButtonColor);
if (!startButton.getGlobalBounds().contains(mousePosF)) startButton.setColor(defButtonColor); if (!startButton.getGlobalBounds().contains(mousePosF)) startButton.setColor(defButtonColor);
if (!creditsButton.getGlobalBounds().contains(mousePosF)) creditsButton.setColor(defButtonColor); if (!creditsButton.getGlobalBounds().contains(mousePosF)) creditsButton.setColor(defButtonColor);
if (!issueButton.getGlobalBounds().contains(mousePosF)) issueButton.setColor(sf::Color::Red); if (!issueButton.getGlobalBounds().contains(mousePosF)) issueButton.setColor(sf::Color::Red);
if (!devText.getGlobalBounds().contains(mousePosF)) devText.setFillColor(sf::Color::White); if (!devText.getGlobalBounds().contains(mousePosF)) devText.setFillColor(sf::Color::White);
if (!devText0.getGlobalBounds().contains(mousePosF)) devText0.setFillColor(sf::Color::White); if (!devText0.getGlobalBounds().contains(mousePosF)) devText0.setFillColor(sf::Color::White);
if (!devText2.getGlobalBounds().contains(mousePosF)) devText2.setFillColor(sf::Color::White); if (!devText2.getGlobalBounds().contains(mousePosF)) devText2.setFillColor(sf::Color::White);
if (!musicText0.getGlobalBounds().contains(mousePosF)) musicText0.setFillColor(sf::Color::White); if (!musicText0.getGlobalBounds().contains(mousePosF)) musicText0.setFillColor(sf::Color::White);
if (!musicText1.getGlobalBounds().contains(mousePosF)) musicText1.setFillColor(sf::Color::White); if (!musicText1.getGlobalBounds().contains(mousePosF)) musicText1.setFillColor(sf::Color::White);
if (!backButton.getGlobalBounds().contains(mousePosF)) backButton.setColor(defButtonColor); if (!backButton.getGlobalBounds().contains(mousePosF)) backButton.setColor(defButtonColor);
if (!soundButton.getGlobalBounds().contains(mousePosF) && soundOn) soundButton.setColor(sf::Color::White); if (!soundButton.getGlobalBounds().contains(mousePosF) && soundOn) soundButton.setColor(sf::Color::White);
if (!musicButton.getGlobalBounds().contains(mousePosF) && musicOn) musicButton.setColor(sf::Color::White); if (!musicButton.getGlobalBounds().contains(mousePosF) && musicOn) musicButton.setColor(sf::Color::White);
if (!soundButton.getGlobalBounds().contains(mousePosF) && !soundOn) soundButton.setColor(sf::Color::Red); if (!soundButton.getGlobalBounds().contains(mousePosF) && !soundOn) soundButton.setColor(sf::Color::Red);
if (!musicButton.getGlobalBounds().contains(mousePosF) && !musicOn) musicButton.setColor(sf::Color::Red); if (!musicButton.getGlobalBounds().contains(mousePosF) && !musicOn) musicButton.setColor(sf::Color::Red);
} }
} }
return EXIT_FAILURE; return EXIT_FAILURE;
} }
void Menu::playBip() { void Menu::playBip() {
if (soundOn) { if (soundOn) {
bipSound.setBuffer(bip); bipSound.setBuffer(bip);
bipSound.setVolume(100); bipSound.setVolume(100);
bipSound.play(); bipSound.play();
} }
} }

56
Menu.h
View file

@ -1,28 +1,28 @@
// //
// Created by benmo on 2/20/2020. // Created by benmo on 2/20/2020.
// //
#ifndef SFML_TEMPLATE_MENU_H #ifndef SFML_TEMPLATE_MENU_H
#define SFML_TEMPLATE_MENU_H #define SFML_TEMPLATE_MENU_H
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
class Menu { class Menu {
public: public:
int result; int result;
bool soundOn = true, musicOn = true; bool soundOn = true, musicOn = true;
Menu() { Menu() {
result = init(); result = init();
} }
private: private:
sf::SoundBuffer bip; sf::SoundBuffer bip;
sf::Sound bipSound; sf::Sound bipSound;
bool playedBip = false; bool playedBip = false;
int init(); int init();
void playBip(); void playBip();
}; };
#endif //SFML_TEMPLATE_MENU_H #endif //SFML_TEMPLATE_MENU_H

View file

@ -1,28 +1,28 @@
#include "Planet.h" #include "Planet.h"
Planet::Planet(const sf::Texture &texture, float scale, float xPos, float yPos, float direction) : GameSprite(texture, scale, xPos, yPos, 0, direction) { Planet::Planet(const sf::Texture &texture, float scale, float xPos, float yPos, float direction) : GameSprite(texture, scale, xPos, yPos, 0, direction) {
landable = false; landable = false;
} }
Planet::Planet(const std::string& _name, const std::string& _desc, int landscape, const sf::Texture &texture, float scale, float xPos, float yPos, float direction) : GameSprite(texture, scale, xPos, yPos, 0, direction) { Planet::Planet(const std::string& _name, const std::string& _desc, int landscape, const sf::Texture &texture, float scale, float xPos, float yPos, float direction) : GameSprite(texture, scale, xPos, yPos, 0, direction) {
landable = true; landable = true;
name = _name; name = _name;
desc = _desc; desc = _desc;
image = landscape; image = landscape;
} }
bool Planet::isLandable() { bool Planet::isLandable() {
return landable; return landable;
} }
std::string Planet::getName() { std::string Planet::getName() {
return name; return name;
} }
std::string Planet::getDesc() { std::string Planet::getDesc() {
return desc; return desc;
} }
int Planet::getImageNum() { int Planet::getImageNum() {
return image; return image;
} }

View file

@ -1,29 +1,29 @@
// //
// Created by benmo on 3/3/2020. // Created by benmo on 3/3/2020.
// //
#ifndef SFML_TEMPLATE_PLANET_H #ifndef SFML_TEMPLATE_PLANET_H
#define SFML_TEMPLATE_PLANET_H #define SFML_TEMPLATE_PLANET_H
#include "GameSprite.h" #include "GameSprite.h"
class Planet : public GameSprite { class Planet : public GameSprite {
private: private:
bool landable = true; bool landable = true;
std::string name; std::string name;
std::string desc; std::string desc;
int image; int image;
public: public:
Planet(const sf::Texture &texture, float scale, float xPos, float yPos, float direction); Planet(const sf::Texture &texture, float scale, float xPos, float yPos, float direction);
Planet(const std::string& _name, const std::string& _desc, int landscape, const sf::Texture &texture, float scale, float xPos, float yPos, float direction); Planet(const std::string& _name, const std::string& _desc, int landscape, const sf::Texture &texture, float scale, float xPos, float yPos, float direction);
bool isLandable(); bool isLandable();
std::string getName(); std::string getName();
std::string getDesc(); std::string getDesc();
int getImageNum(); int getImageNum();
}; };
#endif //SFML_TEMPLATE_PLANET_H #endif //SFML_TEMPLATE_PLANET_H

View file

@ -1,22 +1,22 @@
// //
// Created by Benjamin on 4/20/2021. // Created by Benjamin on 4/20/2021.
// //
#ifndef SFML_TEMPLATE_PROJECTILE_H #ifndef SFML_TEMPLATE_PROJECTILE_H
#define SFML_TEMPLATE_PROJECTILE_H #define SFML_TEMPLATE_PROJECTILE_H
#include "Shootable.h" #include "Shootable.h"
class Projectile : public Shootable { class Projectile : public Shootable {
public: public:
Projectile() = default; Projectile() = default;
Projectile(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double velocity, double damage, double _range) : Shootable(texture, rect, scale, rows, cols, xOffset, yOffset, frameDelay, damage) { Projectile(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double velocity, double damage, double _range) : Shootable(texture, rect, scale, rows, cols, xOffset, yOffset, frameDelay, damage) {
setVelocity(velocity); setVelocity(velocity);
lifetime = _range/velocity; lifetime = _range/velocity;
range = _range; range = _range;
} }
}; };
#endif //SFML_TEMPLATE_PROJECTILE_H #endif //SFML_TEMPLATE_PROJECTILE_H

View file

@ -1,33 +1,33 @@
#include <utility> #include <utility>
// //
// Created by Benjamin on 4/20/2021. // Created by Benjamin on 4/20/2021.
// //
#ifndef SFML_TEMPLATE_PROJECTILEWEAPON_H #ifndef SFML_TEMPLATE_PROJECTILEWEAPON_H
#define SFML_TEMPLATE_PROJECTILEWEAPON_H #define SFML_TEMPLATE_PROJECTILEWEAPON_H
class ProjectileWeapon : public Weapon { class ProjectileWeapon : public Weapon {
public: public:
ProjectileWeapon(Projectile _proj, const sf::SoundBuffer& buffer, float volume, double effectiveAngle, int frameDelay) : Weapon(frameDelay, effectiveAngle, buffer, volume) { ProjectileWeapon(Projectile _proj, const sf::SoundBuffer& buffer, float volume, double effectiveAngle, int frameDelay) : Weapon(frameDelay, effectiveAngle, buffer, volume) {
projectile = std::move(_proj); projectile = std::move(_proj);
} }
Shootable* shoot(const Ship* shooter) override { Shootable* shoot(const Ship* shooter) override {
currentFrame = 0; currentFrame = 0;
noise.play(); noise.play();
projectile.setDirection(shooter->getDirection()); projectile.setDirection(shooter->getDirection());
projectile.setPosition(shooter->getXPos() + shooter->getLocalBounds().width/4 * shooter->getScale().x * cos(shooter->getDirection()*GameSprite::PI/180), shooter->getYPos() - shooter->getLocalBounds().width/4 * shooter->getScale().x * sin(shooter->getDirection()*GameSprite::PI/180)); projectile.setPosition(shooter->getXPos() + shooter->getLocalBounds().width/4 * shooter->getScale().x * cos(shooter->getDirection()*GameSprite::PI/180), shooter->getYPos() - shooter->getLocalBounds().width/4 * shooter->getScale().x * sin(shooter->getDirection()*GameSprite::PI/180));
projectile.setShooter((GameSprite *) shooter); projectile.setShooter((GameSprite *) shooter);
Shootable *copied = new Shootable(projectile); Shootable *copied = new Shootable(projectile);
return copied; return copied;
} }
}; };
#endif //SFML_TEMPLATE_PROJECTILEWEAPON_H #endif //SFML_TEMPLATE_PROJECTILEWEAPON_H

29
Rider.h Normal file
View file

@ -0,0 +1,29 @@
//
// Created by Benjamin on 4/29/2021.
//
#ifndef SFML_TEMPLATE_RIDER_H
#define SFML_TEMPLATE_RIDER_H
class Rider : public GameSprite {
private:
GameSprite *mount;
sf::Vector2f relativeLoc;
public:
Rider(const sf::Texture &texture, float scale, GameSprite *_mount, sf::Vector2f worldCoord) : GameSprite(texture, scale) {
mount = _mount;
relativeLoc = sf::Vector2f(worldCoord.x - mount->getPosition().x, worldCoord.y - mount->getPosition().y);
relativeLoc = mount->getInverseTransform().transformPoint(relativeLoc);
}
void update() override {
sf::Vector2f newLoc = mount->getTransform().transformPoint(relativeLoc);
setPosition(newLoc);
GameSprite::update();
}
};
#endif //SFML_TEMPLATE_RIDER_H

218
Ship.cpp
View file

@ -1,109 +1,109 @@
// //
// Created by benmo on 2/16/2020. // Created by benmo on 2/16/2020.
// //
#include "Ship.h" #include "Ship.h"
Ship::Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float turnSpeed, int maxFuel, int maxHull, int cargo, int passengers) : GameSprite(texture, scale, round(xPos), round(yPos), velocity, maxVelocity, direction) { Ship::Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float turnSpeed, int maxFuel, int maxHull, int cargo, int passengers) : GameSprite(texture, scale, round(xPos), round(yPos), velocity, maxVelocity, direction) {
turnRate = turnSpeed; turnRate = turnSpeed;
fullScale = scale; fullScale = scale;
fuelCap = maxFuel; fuelCap = maxFuel;
fuel = maxFuel; fuel = maxFuel;
hullCap = maxHull; hullCap = maxHull;
hull = hullCap; hull = hullCap;
cargoSpace = cargo; cargoSpace = cargo;
passengerSpace = passengers; passengerSpace = passengers;
target = nullptr; target = nullptr;
} }
void Ship::update() { void Ship::update() {
for (Weapon *w : weapons) { for (Weapon *w : weapons) {
w->recharge(); w->recharge();
} }
GameSprite::update(); GameSprite::update();
} }
void Ship::shoot(std::vector<Shootable*> &shots) { void Ship::shoot(std::vector<Shootable*> &shots) {
for (Weapon *w : weapons) { for (Weapon *w : weapons) {
if (w->canShoot()) { if (w->canShoot()) {
shots.push_back(w->shoot(this)); shots.push_back(w->shoot(this));
} }
} }
} }
float Ship::getTurnRate() const { float Ship::getTurnRate() const {
return turnRate; return turnRate;
} }
float Ship::getFullScale () const { float Ship::getFullScale () const {
return fullScale; return fullScale;
} }
int Ship::getFuelCap() const { int Ship::getFuelCap() const {
return fuelCap; return fuelCap;
} }
int Ship::getFuelRemaining() const { int Ship::getFuelRemaining() const {
return fuel; return fuel;
} }
void Ship::useFuel() { void Ship::useFuel() {
fuel--; fuel--;
} }
void Ship::setFuel(int _fuel) { void Ship::setFuel(int _fuel) {
fuel = _fuel; fuel = _fuel;
} }
int Ship::getHullCap() const { int Ship::getHullCap() const {
return hullCap; return hullCap;
} }
int Ship::getHullRemaining() const { int Ship::getHullRemaining() const {
return hull; return hull;
} }
void Ship::setHull(int _hull) { void Ship::setHull(int _hull) {
hull = _hull; hull = _hull;
} }
int Ship::getCargoSpace() const { int Ship::getCargoSpace() const {
return cargoSpace; return cargoSpace;
} }
int Ship::getUsedCargoSpace() const { int Ship::getUsedCargoSpace() const {
return cargoUsed; return cargoUsed;
} }
void Ship::setUsedCargoSpace(int _cargoUsed) { void Ship::setUsedCargoSpace(int _cargoUsed) {
cargoUsed = _cargoUsed; cargoUsed = _cargoUsed;
} }
int Ship::getPassengerSpace() const { int Ship::getPassengerSpace() const {
return passengerSpace; return passengerSpace;
} }
int Ship::getPassengersAboard() const { int Ship::getPassengersAboard() const {
return passengersOn; return passengersOn;
} }
void Ship::setPassengersAboard(int _passengersOn) { void Ship::setPassengersAboard(int _passengersOn) {
passengersOn = _passengersOn; passengersOn = _passengersOn;
} }
Ship * Ship::getTarget() const { Ship * Ship::getTarget() const {
return target; return target;
} }
void Ship::setTarget(Ship *_target) { void Ship::setTarget(Ship *_target) {
target = _target; target = _target;
} }
void Ship::addWeapon(Weapon *w) { void Ship::addWeapon(Weapon *w) {
weapons.push_back(w); weapons.push_back(w);
} }

114
Ship.h
View file

@ -1,57 +1,57 @@
// //
// Created by benmo on 2/16/2020. // Created by benmo on 2/16/2020.
// //
#ifndef SFML_TEMPLATE_SHIP_H #ifndef SFML_TEMPLATE_SHIP_H
#define SFML_TEMPLATE_SHIP_H #define SFML_TEMPLATE_SHIP_H
#include <vector> #include <vector>
#include <SFML/Graphics/Texture.hpp> #include <SFML/Graphics/Texture.hpp>
#include "GameSprite.h" #include "GameSprite.h"
#include "Weapon.h" #include "Weapon.h"
class Ship : public GameSprite { class Ship : public GameSprite {
protected: protected:
float fullScale, turnRate; float fullScale, turnRate;
int fuelCap, fuel, hullCap, hull, cargoSpace, cargoUsed = 0, passengerSpace, passengersOn = 0; int fuelCap, fuel, hullCap, hull, cargoSpace, cargoUsed = 0, passengerSpace, passengersOn = 0;
std::vector<Weapon*> weapons; std::vector<Weapon*> weapons;
Ship *target; Ship *target;
public: public:
Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float turnSpeed, int maxFuel, int maxHull, int cargo, int passengers); Ship(const sf::Texture &texture, float scale, float xPos, float yPos, float velocity, float maxVelocity, float direction, float turnSpeed, int maxFuel, int maxHull, int cargo, int passengers);
void update(); void update();
virtual void shoot(std::vector<Shootable*> &projectiles); virtual void shoot(std::vector<Shootable*> &projectiles);
float getTurnRate() const; float getTurnRate() const;
float getFullScale () const; float getFullScale () const;
int getFuelCap() const; int getFuelCap() const;
int getFuelRemaining() const; int getFuelRemaining() const;
void useFuel(); void useFuel();
void setFuel(int); void setFuel(int);
int getHullCap() const; int getHullCap() const;
int getHullRemaining() const; int getHullRemaining() const;
void setHull(int _hull); void setHull(int _hull);
int getCargoSpace() const; int getCargoSpace() const;
int getUsedCargoSpace() const; int getUsedCargoSpace() const;
void setUsedCargoSpace(int _cargoUsed); void setUsedCargoSpace(int _cargoUsed);
int getPassengerSpace() const; int getPassengerSpace() const;
int getPassengersAboard() const; int getPassengersAboard() const;
void setPassengersAboard(int _passengersOn); void setPassengersAboard(int _passengersOn);
Ship * getTarget() const; Ship * getTarget() const;
void setTarget(Ship *_target); void setTarget(Ship *_target);
void addWeapon(Weapon *w); void addWeapon(Weapon *w);
}; };
#endif //SFML_TEMPLATE_SHIP_H #endif //SFML_TEMPLATE_SHIP_H

View file

@ -1,47 +1,47 @@
// //
// Created by Benjamin on 4/20/2021. // Created by Benjamin on 4/20/2021.
// //
#ifndef SFML_TEMPLATE_SHOOTABLE_H #ifndef SFML_TEMPLATE_SHOOTABLE_H
#define SFML_TEMPLATE_SHOOTABLE_H #define SFML_TEMPLATE_SHOOTABLE_H
#include "GameSprite.h" #include "GameSprite.h"
#include "Ship.h" #include "Ship.h"
class Ship; class Ship;
class Shootable : public GameSprite { class Shootable : public GameSprite {
protected: protected:
double damage; double damage;
double range = 0; double range = 0;
Ship *shooter; Ship *shooter;
protected: protected:
Shootable(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double _damage) : GameSprite(texture, rect, rows, cols, xOffset, yOffset, frameDelay) { Shootable(const sf::Texture& texture, const sf::IntRect &rect, double scale, int rows, int cols, int xOffset, int yOffset, int frameDelay, double _damage) : GameSprite(texture, rect, rows, cols, xOffset, yOffset, frameDelay) {
damage = _damage; damage = _damage;
setScale(scale/100, scale/100); setScale(scale/100, scale/100);
} }
public: public:
Shootable() = default; Shootable() = default;
void setShooter(GameSprite* _shooter) { void setShooter(GameSprite* _shooter) {
shooter = reinterpret_cast<Ship *>(_shooter); shooter = reinterpret_cast<Ship *>(_shooter);
} }
Ship* getShooter() { Ship* getShooter() {
return shooter; return shooter;
} }
double getDamage() const { double getDamage() const {
return damage; return damage;
} }
double getRange() const { double getRange() const {
return range; return range;
} }
}; };
#endif //SFML_TEMPLATE_SHOOTABLE_H #endif //SFML_TEMPLATE_SHOOTABLE_H

View file

@ -1,94 +1,94 @@
#include "System.h" #include "System.h"
System::System(std::string _name) { System::System(std::string _name) {
name = std::move(_name); name = std::move(_name);
} }
sf::Sprite* System::getSystemCenter() { sf::Sprite* System::getSystemCenter() {
return planets[1]; return planets[1];
} }
void System::addPlanet(Planet *p) { void System::addPlanet(Planet *p) {
planets.push_back(p); planets.push_back(p);
if (p->isLandable()) landable = true; if (p->isLandable()) landable = true;
} }
void System::setRelativeMapPos(const sf::Vector2f &pos) { void System::setRelativeMapPos(const sf::Vector2f &pos) {
mapPos = pos; mapPos = pos;
} }
sf::Vector2f System::getRelativeMapPos() { sf::Vector2f System::getRelativeMapPos() {
return mapPos; return mapPos;
} }
void System::makeVisited() { void System::makeVisited() {
visited = true; visited = true;
} }
bool System::isVisited() const { bool System::isVisited() const {
return visited; return visited;
} }
std::string System::getName() { std::string System::getName() {
return name; return name;
} }
void System::setGovName(std::string gov) { void System::setGovName(std::string gov) {
govName = std::move(gov); govName = std::move(gov);
} }
std::string System::getGovName() { std::string System::getGovName() {
return govName; return govName;
} }
void System::setSysRep(int _rep) { void System::setSysRep(int _rep) {
rep = _rep; rep = _rep;
} }
int System::getSysRep() const { int System::getSysRep() const {
return rep; return rep;
} }
void System::setPop(int _pop) { void System::setPop(int _pop) {
pop = _pop; pop = _pop;
} }
int System::getPop() const { int System::getPop() const {
return pop; return pop;
} }
void System::setStren(int _stren) { void System::setStren(int _stren) {
stren = _stren; stren = _stren;
} }
int System::getStren() const { int System::getStren() const {
return stren; return stren;
} }
bool System::isLandable() const { bool System::isLandable() const {
return landable; return landable;
} }
const std::vector<Planet *> &System::getPlanets() const { const std::vector<Planet *> &System::getPlanets() const {
return planets; return planets;
} }
void System::setPlanets(const std::vector<Planet *> &planetList) { void System::setPlanets(const std::vector<Planet *> &planetList) {
System::planets = planetList; System::planets = planetList;
} }
std::vector<Task *> &System::getTasks(){ std::vector<Task *> &System::getTasks(){
return tasks; return tasks;
} }
const std::vector<int> &System::getExits() const { const std::vector<int> &System::getExits() const {
return exits; return exits;
} }
void System::addExit(int exit) { void System::addExit(int exit) {
exits.push_back(exit); exits.push_back(exit);
} }
void System::addTask(Task *task) { void System::addTask(Task *task) {
tasks.push_back(task); tasks.push_back(task);
} }

140
System.h
View file

@ -1,70 +1,70 @@
// //
// Created by benmo on 2/24/2020. // Created by benmo on 2/24/2020.
// //
#ifndef SFML_TEMPLATE_SYSTEM_H #ifndef SFML_TEMPLATE_SYSTEM_H
#define SFML_TEMPLATE_SYSTEM_H #define SFML_TEMPLATE_SYSTEM_H
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <string> #include <string>
#include "Planet.h" #include "Planet.h"
#include "Task.h" #include "Task.h"
class System { class System {
private: private:
std::string name; std::string name;
std::string govName; std::string govName;
sf::Vector2f mapPos; sf::Vector2f mapPos;
bool visited = false; bool visited = false;
bool landable = false; bool landable = false;
int rep = 5; int rep = 5;
int pop = 0; int pop = 0;
int stren = 0; int stren = 0;
std::vector<Planet*> planets; std::vector<Planet*> planets;
std::vector<Task*> tasks; std::vector<Task*> tasks;
std::vector<int> exits; std::vector<int> exits;
public: public:
explicit System(std::string _name); explicit System(std::string _name);
sf::Sprite* getSystemCenter(); sf::Sprite* getSystemCenter();
void addPlanet(Planet *p); void addPlanet(Planet *p);
void setRelativeMapPos(const sf::Vector2f &pos); void setRelativeMapPos(const sf::Vector2f &pos);
sf::Vector2f getRelativeMapPos(); sf::Vector2f getRelativeMapPos();
void makeVisited(); void makeVisited();
bool isVisited() const; bool isVisited() const;
std::string getName(); std::string getName();
void setGovName(std::string gov); void setGovName(std::string gov);
std::string getGovName(); std::string getGovName();
void setSysRep(int _rep); void setSysRep(int _rep);
int getSysRep() const; int getSysRep() const;
void setPop(int _pop); void setPop(int _pop);
int getPop() const; int getPop() const;
void setStren(int _stren); void setStren(int _stren);
int getStren() const; int getStren() const;
bool isLandable() const; bool isLandable() const;
const std::vector<Planet *> &getPlanets() const; const std::vector<Planet *> &getPlanets() const;
void setPlanets(const std::vector<Planet *> &planetList); void setPlanets(const std::vector<Planet *> &planetList);
std::vector<Task *> &getTasks(); std::vector<Task *> &getTasks();
void addTask(Task* task); void addTask(Task* task);
const std::vector<int> &getExits() const; const std::vector<int> &getExits() const;
void addExit(int exit); void addExit(int exit);
}; };
#endif //SFML_TEMPLATE_SYSTEM_H #endif //SFML_TEMPLATE_SYSTEM_H

110
Task.h
View file

@ -1,55 +1,55 @@
// //
// Created by benmo on 3/19/2020. // Created by benmo on 3/19/2020.
// //
#ifndef SFML_TEMPLATE_TASK_H #ifndef SFML_TEMPLATE_TASK_H
#define SFML_TEMPLATE_TASK_H #define SFML_TEMPLATE_TASK_H
#include <string> #include <string>
#include "Planet.h" #include "Planet.h"
class System; class System;
class Task { class Task {
private: private:
std::string name, desc; std::string name, desc;
int type, size, reward; int type, size, reward;
System *sysLoc; System *sysLoc;
Planet *loc; Planet *loc;
public: public:
static const int DELIVERY = 0, TAXI = 1; static const int DELIVERY = 0, TAXI = 1;
Task(int _type, const std::string& _name, const std::string& _desc, System *_sysLoc, Planet *_loc, int _reward, int _size) { Task(int _type, const std::string& _name, const std::string& _desc, System *_sysLoc, Planet *_loc, int _reward, int _size) {
type = _type; type = _type;
name = _name; name = _name;
desc = _desc; desc = _desc;
reward = _reward; reward = _reward;
size = _size; size = _size;
sysLoc = _sysLoc; sysLoc = _sysLoc;
loc = _loc; loc = _loc;
} }
int getType() const { int getType() const {
return type; return type;
} }
int getReward() const { int getReward() const {
return reward; return reward;
} }
int getSize() const { int getSize() const {
return size; return size;
} }
System* getSystem() { System* getSystem() {
return sysLoc; return sysLoc;
} }
Planet* getPlanet() { Planet* getPlanet() {
return loc; return loc;
} }
}; };
#endif //SFML_TEMPLATE_TASK_H #endif //SFML_TEMPLATE_TASK_H

116
Weapon.h
View file

@ -1,58 +1,58 @@
// //
// Created by Benjamin on 4/20/2021. // Created by Benjamin on 4/20/2021.
// //
#ifndef SFML_TEMPLATE_WEAPON_H #ifndef SFML_TEMPLATE_WEAPON_H
#define SFML_TEMPLATE_WEAPON_H #define SFML_TEMPLATE_WEAPON_H
#include "Projectile.h" #include "Projectile.h"
#include "GameSprite.h" #include "GameSprite.h"
#include <SFML/Audio.hpp> #include <SFML/Audio.hpp>
#include <iostream> #include <iostream>
class Weapon { class Weapon {
protected: protected:
int frameDelay, currentFrame; int frameDelay, currentFrame;
Shootable projectile; Shootable projectile;
sf::Sound noise; sf::Sound noise;
double effectiveAngle; double effectiveAngle;
Weapon() { Weapon() {
frameDelay = 0; frameDelay = 0;
currentFrame = 0; currentFrame = 0;
projectile = Shootable(); projectile = Shootable();
}; };
explicit Weapon(int _frameDelay, double _effectiveAngle, const sf::SoundBuffer& _buffer, float volume) : Weapon() { explicit Weapon(int _frameDelay, double _effectiveAngle, const sf::SoundBuffer& _buffer, float volume) : Weapon() {
effectiveAngle = _effectiveAngle; effectiveAngle = _effectiveAngle;
frameDelay = _frameDelay; frameDelay = _frameDelay;
noise.setBuffer(_buffer); noise.setBuffer(_buffer);
noise.setVolume(volume); noise.setVolume(volume);
} }
public: public:
virtual Shootable* shoot(const Ship* shooter) { virtual Shootable* shoot(const Ship* shooter) {
return new Shootable(projectile); return new Shootable(projectile);
} }
void recharge() { void recharge() {
if (currentFrame < frameDelay) { if (currentFrame < frameDelay) {
currentFrame++; currentFrame++;
} }
} }
bool canShoot() const { bool canShoot() const {
return currentFrame == frameDelay; return currentFrame == frameDelay;
} }
Shootable& getProjectile() { Shootable& getProjectile() {
return projectile; return projectile;
} }
double getEffectiveAngle() const { double getEffectiveAngle() const {
return effectiveAngle; return effectiveAngle;
} }
}; };
#endif //SFML_TEMPLATE_WEAPON_H #endif //SFML_TEMPLATE_WEAPON_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View file

@ -1,101 +1,101 @@
Jade Jade
Rain Rain
Dominion Dominion
Leviathan Leviathan
Salvation Salvation
Fate Fate
Change Change
Sorrow Sorrow
Glass Glass
Crystal Crystal
Heaven Heaven
Sand Sand
Moonlight Moonlight
Dawn Dawn
Dusk Dusk
Mystery Mystery
Magic Magic
Fire Fire
Ice Ice
Water Water
Starlight Starlight
Lightning Lightning
Thunder Thunder
Steel Steel
Glory Glory
Stone Stone
Bravery Bravery
Poetry Poetry
Promise Promise
Beauty Beauty
Mirth Mirth
Olympus Olympus
Light Light
Charity Charity
Mercy Mercy
Hope Hope
Virtue Virtue
Fortitude Fortitude
Enlightenment Enlightenment
Might Might
Destiny Destiny
Grass Grass
Clarity Clarity
Serenity Serenity
Tranquility Tranquility
Paradise Paradise
Contentment Contentment
Strength Strength
Power Power
Salt Salt
Atlantis Atlantis
Herring Herring
Doubt Doubt
Flint Flint
Spring Spring
Summer Summer
Autumn Autumn
Winter Winter
Snow Snow
Time Time
Space Space
Paper Paper
Rice Rice
Wheat Wheat
Bread Bread
Cheddar Cheddar
Motion Motion
Ash Ash
Sagebrush Sagebrush
Lead Lead
Tin Tin
Copper Copper
Bronze Bronze
Brass Brass
Silver Silver
Gold Gold
Cloth Cloth
Junk Junk
Logic Logic
Silence Silence
Wine Wine
Money Money
Slate Slate
Graphite Graphite
Cobalt Cobalt
Platinum Platinum
Wood Wood
Ore Ore
Grain Grain
Fission Fission
Fusion Fusion
Life Life
Hair Hair
Smoke Smoke
Essence Essence
Clay Clay
Myth Myth
Victory Victory
Defiance Defiance
Borneo Borneo
Grace Grace

View file

@ -1,298 +1,298 @@
Abundant Abundant
Accurate Accurate
Addicted Addicted
Adorable Adorable
Adventurous Adventurous
Afraid Afraid
Aggressive Aggressive
Alcoholic Alcoholic
Alert Alert
Aloof Aloof
Ambitious Ambitious
Ancient Ancient
Angry Angry
Animated Animated
Annoying Annoying
Anxious Anxious
Arrogant Arrogant
Ashamed Ashamed
Attractive Attractive
Auspicious Auspicious
Awesome Awesome
Awful Awful
Abactinal Abactinal
Abandoned Abandoned
Abashed Abashed
Abatable Abatable
Abatic Abatic
Abaxial Abaxial
Abbatial Abbatial
Abbreviated Abbreviated
Abducent Abducent
Abducting Abducting
Aberrant Aberrant
Abeyant Abeyant
Abhorrent Abhorrent
Abiding Abiding
Abient Abient
Bad Bad
Bashful Bashful
Beautiful Beautiful
Belligerent Belligerent
Beneficial Beneficial
Best Best
Big Big
Bitter Bitter
Bizarre Bizarre
Black Black
Blue Blue
Boring Boring
Brainy Brainy
Bright Bright
Broad Broad
Broken Broken
Busy Busy
Barren Barren
Barricaded Barricaded
Barytic Barytic
Basal Basal
Basaltic Basaltic
Baseborn Baseborn
Based Based
Baseless Baseless
Basic Basic
Bathyal Bathyal
Battleful Battleful
Battlemented Battlemented
Batty Batty
Batwing Batwing
Bias Bias
Calm Calm
Capable Capable
Careful Careful
Careless Careless
Caring Caring
Cautious Cautious
Charming Charming
Cheap Cheap
Cheerful Cheerful
Chubby Chubby
Clean Clean
Clever Clever
Clumsy Clumsy
Cold Cold
Colorful Colorful
Comfortable Comfortable
Concerned Concerned
Confused Confused
Crowded Crowded
Cruel Cruel
Curious Curious
Curly Curly
Cute Cute
Damaged Damaged
Dangerous Dangerous
Dark Dark
Deep Deep
Defective Defective
Delicate Delicate
Delicious Delicious
Depressed Depressed
Determined Determined
Different Different
Dirty Dirty
Disgusting Disgusting
Dry Dry
Dusty Dusty
Daft Daft
Daily Daily
Dainty Dainty
Damn Damn
Damning Damning
Damp Damp
Dampish Dampish
Darkling Darkling
Darned Darned
Dauntless Dauntless
Daylong Daylong
Early Early
Educated Educated
Efficient Efficient
Elderly Elderly
Elegant Elegant
Embarrassed Embarrassed
Empty Empty
Encouraging Encouraging
Enthusiastic Enthusiastic
Excellent Excellent
Exciting Exciting
Expensive Expensive
Fabulous Fabulous
Fair Fair
Faithful Faithful
Famous Famous
Fancy Fancy
Fantastic Fantastic
Fast Fast
Fearful Fearful
Fearless Fearless
Fertile Fertile
Filthy Filthy
Foolish Foolish
Forgetful Forgetful
Friendly Friendly
Funny Funny
Gentle Gentle
Glamorous Glamorous
Glorious Glorious
Gorgeous Gorgeous
Graceful Graceful
Grateful Grateful
Great Great
Greedy Greedy
Green Green
Handsome Handsome
Happy Happy
Harsh Harsh
Healthy Healthy
Heavy Heavy
Helpful Helpful
Hilarious Hilarious
Historical Historical
Horrible Horrible
Hot Hot
Huge Huge
Humorous Humorous
Hungry Hungry
Ignorant Ignorant
Illegal Illegal
Imaginary Imaginary
Impolite Impolite
Important Important
Impossible Impossible
Innocent Innocent
Intelligent Intelligent
Interesting Interesting
Jealous Jealous
Jolly Jolly
Juicy Juicy
Juvenile Juvenile
Kind Kind
Large Large
Legal Legal
Light Light
Literate Literate
Little Little
Lively Lively
Lonely Lonely
Loud Loud
Lovely Lovely
Lucky Lucky
Macho Macho
Magical Magical
Magnificent Magnificent
Massive Massive
Mature Mature
Mean Mean
Messy Messy
Modern Modern
Narrow Narrow
Nasty Nasty
Naughty Naughty
Nervous Nervous
New New
Noisy Noisy
Nutritious Nutritious
Obedient Obedient
Obese Obese
Obnoxious Obnoxious
Old Old
Overconfident Overconfident
Peaceful Peaceful
Pink Pink
Polite Polite
Poor Poor
Powerful Powerful
Precious Precious
Pretty Pretty
Proud Proud
Quick Quick
Quiet Quiet
Rapid Rapid
Rare Rare
Red Red
Remarkable Remarkable
Responsible Responsible
Rich Rich
Romantic Romantic
Royal Royal
Rude Rude
Scintillating Scintillating
Secretive Secretive
Selfish Selfish
Serious Serious
Sharp Sharp
Shiny Shiny
Shocking Shocking
Short Short
Shy Shy
Silly Silly
Sincere Sincere
Skinny Skinny
Slim Slim
Slow Slow
Small Small
Soft Soft
Spicy Spicy
Spiritual Spiritual
Splendid Splendid
Strong Strong
Successful Successful
Sweet Sweet
Talented Talented
Tall Tall
Tense Tense
Terrible Terrible
Terrific Terrific
Thick Thick
Thin Thin
Tiny Tiny
Tactful Tactful
Tailor-made Tailor-made
Take-charge Take-charge
Tangible Tangible
Tasteful Tasteful
Tasty Tasty
Teachable Teachable
Teeming Teeming
Tempean Tempean
Temperate Temperate
Tenable Tenable
Tenacious Tenacious
Tender Tender
Tender-hearted Tender-hearted
Terrific Terrific
Testimonial Testimonial
Thankful Thankful
Thankworthy Thankworthy
Therapeutic Therapeutic
Thorough Thorough
Thoughtful Thoughtful
Ugly Ugly
Unique Unique
Untidy Untidy
Upset Upset
Victorious Victorious
Violent Violent
Vulgar Vulgar
Warm Warm
Weak Weak
Wealthy Wealthy
Wide Wide
Wise Wise
Witty Witty
Wonderful Wonderful
Worried Worried
Young Young
Youthful Youthful
Zealous Zealous

View file

@ -1,143 +1,143 @@
Aardvark Aardvark
Alligator Alligator
Alpaca Alpaca
Anaconda Anaconda
Ant Ant
Antelope Antelope
Ape Ape
Aphid Aphid
Armadillo Armadillo
Asp Asp
Ass Ass
Baboon Baboon
Badger Badger
Bald Eagle Bald Eagle
Barracuda Barracuda
Bass Bass
Basset Hound Basset Hound
Bat Bat
Bear Bear
Beaver Beaver
Bedbug Bedbug
Bee Bee
Beetle Beetle
Bird Bird
Bison Bison
Bobcat Bobcat
Buffalo Buffalo
Butterfly Butterfly
Buzzard Buzzard
Camel Camel
Caribou Caribou
Carp Carp
Cat Cat
Caterpillar Caterpillar
Catfish Catfish
Cheetah Cheetah
Chicken Chicken
Chimpanzee Chimpanzee
Chipmunk Chipmunk
Cobra Cobra
Cod Cod
Condor Condor
Cougar Cougar
Cow Cow
Coyote Coyote
Crab Crab
Crane Crane
Cricket Cricket
Crocodile Crocodile
Crow Crow
Cuckoo Cuckoo
Deer Deer
Dinosaur Dinosaur
Dog Dog
Dolphin Dolphin
Donkey Donkey
Dove Dove
Dragonfly Dragonfly
Duck Duck
Eagle Eagle
Eel Eel
Elephant Elephant
Emu Emu
Falcon Falcon
Ferret Ferret
Finch Finch
Fish Fish
Flamingo Flamingo
Flea Flea
Fly Fly
Fox Fox
Frog Frog
Goat Goat
Goose Goose
Gopher Gopher
Gorilla Gorilla
Grasshopper Grasshopper
Hamster Hamster
Hare Hare
Hawk Hawk
Hippopotamus Hippopotamus
Horse Horse
Hummingbird Hummingbird
Humpback Whale Humpback Whale
Husky Husky
Iguana Iguana
Impala Impala
Kangaroo Kangaroo
Ladybug Ladybug
Leopard Leopard
Lion Lion
Lizard Lizard
Llama Llama
Lobster Lobster
Mongoose Mongoose
Monitor lizard Monitor lizard
Monkey Monkey
Moose Moose
Mosquito Mosquito
Moth Moth
Mountain goat Mountain goat
Mouse Mouse
Mule Mule
Octopus Octopus
Orca Orca
Ostrich Ostrich
Otter Otter
Owl Owl
Ox Ox
Oyster Oyster
Panda Panda
Panther Panther
Parrot Parrot
Peacock Peacock
Pelican Pelican
Penguin Penguin
Perch Perch
Pheasant Pheasant
Pig Pig
Pigeon Pigeon
Polar bear Polar bear
Porcupine Porcupine
Quail Quail
Rabbit Rabbit
Raccoon Raccoon
Rat Rat
Rattlesnake Rattlesnake
Raven Raven
Rooster Rooster
Sea lion Sea lion
Sheep Sheep
Shrew Shrew
Skunk Skunk
Snail Snail
Snake Snake
Spider Spider
Spider Spider
Tiger Tiger
Walrus Walrus
Whale Whale
Whale Whale
Wolf Wolf
Zebra Zebra

View file

@ -1,490 +1,490 @@
Horizon Horizon
Enterprise Enterprise
Rabbit Rabbit
Napoleon Napoleon
Khagan Khagan
Yokozuna Yokozuna
Ozeki Ozeki
Black Bear Black Bear
Indefatigable Indefatigable
Dauntless Dauntless
Nautilus Nautilus
Dolphin Dolphin
Humboldt Humboldt
Eagle Eagle
Slipstream Slipstream
Stargazer Stargazer
Venture Venture
Union Union
Sunrise Sunrise
Laotzu Laotzu
Mencius Mencius
Hawk Hawk
Confucius Confucius
Megalith Megalith
Istanbul Istanbul
Constantinople Constantinople
Winchester Winchester
Magellan Magellan
Constellation Constellation
Orion Orion
Oracle Oracle
Promised Land Promised Land
Garden of Eden Garden of Eden
George Washington George Washington
Odysseus Odysseus
Poseidon Poseidon
Sinbad Sinbad
Falling Snow Falling Snow
Quetzal Quetzal
Quetzlcoatl Quetzlcoatl
Icebreaker Icebreaker
Gorgon Gorgon
Winston Churchill Winston Churchill
Saint Felix Saint Felix
Orca Orca
Snowy Owl Snowy Owl
Bombay Bombay
Arethusa Arethusa
Crown Point Crown Point
Botany Bay Botany Bay
Medway Medway
Allure Allure
Bazinje Bazinje
Nomad Nomad
Redoubtable Redoubtable
Primarch Primarch
Great Egret Great Egret
Jeanne d'Arc Jeanne d'Arc
Geronimo Geronimo
Sitting Bull Sitting Bull
Pocahontas Pocahontas
Crazy Horse Crazy Horse
Toreador Toreador
Chelmsford Chelmsford
Argo Argo
Golden Fleece Golden Fleece
Pequod Pequod
Beagle Beagle
Santa Maria Santa Maria
Bismark Bismark
Golden Hind Golden Hind
Mayflower Mayflower
Monitor Monitor
Merrimack Merrimack
Potemkin Potemkin
Yamato Yamato
Fujiyama Fujiyama
Pretoria Pretoria
Xiao Yi Xiao Yi
Lou Chuan Lou Chuan
Zheng He Zheng He
Baychimo Baychimo
Constitution Constitution
Excelsior Excelsior
Renaissance Renaissance
Yellowstone Yellowstone
Jim Jones Jim Jones
John Henry John Henry
Paul Bunyan Paul Bunyan
Robin Hood Robin Hood
Annie Oakley Annie Oakley
Emiliano Zapata Emiliano Zapata
North Star North Star
Wanderer Wanderer
Tears in Rain Tears in Rain
Happy Returns Happy Returns
No Gods, No Masters No Gods, No Masters
Majestic Majestic
Santa Fe Santa Fe
Hunk of Junk Hunk of Junk
Bucket of Bolts Bucket of Bolts
Slag Heap Slag Heap
Flying Junkyard Flying Junkyard
Hammerhead Hammerhead
Heliopolis Heliopolis
Cornwall Cornwall
Chichen Itza Chichen Itza
Small Potatoes Small Potatoes
Simon Bolivar Simon Bolivar
Spartacus Spartacus
Harriet Tubman Harriet Tubman
Stonewall Jackson Stonewall Jackson
Shaka Zulu Shaka Zulu
Silk Road Silk Road
Good Egg Good Egg
Terrible Swift Sword Terrible Swift Sword
Loaves and Fishes Loaves and Fishes
Hero of Old Hero of Old
Ties That Bind Ties That Bind
A Quiet Truth A Quiet Truth
Fantastic Planet Fantastic Planet
Observer Observer
Times of Woe Times of Woe
Henry Ford Henry Ford
Charles de Gaulle Charles de Gaulle
Circe Circe
Amelia Earhart Amelia Earhart
Charles Lindbergh Charles Lindbergh
Roald Dahl Roald Dahl
Larry the Ship Larry the Ship
Jim Bowie Jim Bowie
Pax Republica Pax Republica
Riga Riga
Yerevan Yerevan
Brasilia Brasilia
Cape Town Cape Town
Borealis Borealis
Narcissus Narcissus
Tea Clipper Tea Clipper
Close-Hauled Close-Hauled
Windjammer Windjammer
Windstar Windstar
Potosi Potosi
Minotaur Minotaur
Ouroboros Ouroboros
Tiamat Tiamat
Artemis Artemis
Annabel Lee Annabel Lee
Old Ironsides Old Ironsides
Spice of Life Spice of Life
Purifying Gaze Purifying Gaze
Chateau Gaillard Chateau Gaillard
Sacramento Sacramento
Labnathia Labnathia
Brick by Brick Brick by Brick
Murano Murano
Johannesburg Johannesburg
Stapleton Stapleton
Righteous Righteous
Venerable Venerable
Mjolnir Mjolnir
Starscreamer Starscreamer
Barrabas Barrabas
Musashi Musashi
Misaka Misaka
Belo Horizonte Belo Horizonte
Visby Visby
Pyotr Velikiy Pyotr Velikiy
Invincible Invincible
Renowned Renowned
Courageous Courageous
Indomitable Indomitable
Endurance Endurance
Avenger Avenger
Unrivaled Unrivaled
Retribution Retribution
Allegiance Allegiance
One Hand Clapping One Hand Clapping
Washed Away Washed Away
Cash is King Cash is King
Equality Equality
Equanimity Equanimity
Eudamonia Eudamonia
Independence Independence
Interdependence Interdependence
Mutuality Mutuality
Proteus Proteus
William Rockefeller William Rockefeller
Lewis and Clark Lewis and Clark
Leif Erikson Leif Erikson
Marco Polo Marco Polo
Zheng He Zheng He
Vasco de Gama Vasco de Gama
Amerigo Vespucci Amerigo Vespucci
Jacques Cartier Jacques Cartier
James Cook James Cook
Horatio Hornblower Horatio Hornblower
Thorstein Veblen Thorstein Veblen
Karl Marx Karl Marx
John Maynard Keynes John Maynard Keynes
Milton Friedman Milton Friedman
Missouri Missouri
Montana Montana
Essex Essex
Karaboudjan Karaboudjan
Immer Essen Immer Essen
Scotia Scotia
Sherwood Sherwood
Thunderfish Thunderfish
Venture Venture
Arabella Arabella
Baalbek Baalbek
Barracuda Barracuda
Bellipotent Bellipotent
Calypso Calypso
Forrestal Forrestal
Compass Rose Compass Rose
Covenant Covenant
Dazzler Dazzler
Fenton Fenton
Keeling Keeling
Marie Celeste Marie Celeste
Hodgson Hodgson
Okinawa Okinawa
Orcus Orcus
Pharaoh Pharaoh
Pyramus Pyramus
Reluctant Reluctant
Saltash Saltash
Sturgeon Sturgeon
Swordfish Swordfish
Seaview Seaview
Starview Starview
Umbriago Umbriago
Valparaiso Valparaiso
Kandahar Kandahar
Colonia Colonia
Shenandoah Shenandoah
Destiny Destiny
Rockingham Rockingham
Atropos Atropos
Hotspur Hotspur
Speedwell Speedwell
Sutherland Sutherland
Magicienne Magicienne
Papillion Papillion
Vestal Vestal
Remembrance Remembrance
Ark Ark
Sardine Sardine
Pinafore Pinafore
Minnow Minnow
Skydiver Skydiver
Vondel Vondel
Elisabeth Dane Elisabeth Dane
Valkyrie Valkyrie
Geofon Geofon
Beowulf Beowulf
Nunki Nunki
Mercury Mercury
Venus Venus
Mars Mars
Jupiter Jupiter
Saturn Saturn
Uranus Uranus
Neptune Neptune
Pluto Pluto
Aquarius Aquarius
Pisces Pisces
Aries Aries
Taurus Taurus
Gemini Gemini
Leo Leo
Virgo Virgo
Libra Libra
Scorpio Scorpio
Sagittarius Sagittarius
Capricorn Capricorn
Karkinos Karkinos
Krios Krios
Tavros Tavros
Didimoi Didimoi
Leon Leon
Parthenos Parthenos
Zygos Zygos
Skorpios Skorpios
Toksotis Toksotis
Aigokeros Aigokeros
Ydrohoos Ydrohoos
Ihtheis Ihtheis
Ophiuchus Ophiuchus
Saman Kunan Saman Kunan
Wat Phra Kaew Wat Phra Kaew
Hakuho Hakuho
Tochinoshin Tochinoshin
Frida Kahlo Frida Kahlo
Garcia Marquez Garcia Marquez
Carrack Carrack
Lizard Lizard
Jack Tar Jack Tar
Landsman Landsman
Marlinspike Marlinspike
Sultana Sultana
Maidstone Maidstone
Gibraltar Gibraltar
Donegal Donegal
Preble Preble
Chesapeake Chesapeake
Tripoli Tripoli
Mastico Mastico
Syracuse Syracuse
Argus Argus
Syren Syren
Malaga Malaga
Leopard Leopard
Aeolus Aeolus
Africa Africa
Belvidera Belvidera
Guerriere Guerriere
Bonne Citoyenne Bonne Citoyenne
Java Java
Bainbridge Bainbridge
Pictou Pictou
Marblehead Marblehead
Cocteau Cocteau
Guinea Guinea
Puna Puna
Turon Turon
Singapore Singapore
Savannah Savannah
Gambrill Gambrill
Cuyler Cuyler
Dewey Dewey
Bodger Bodger
Anzio Anzio
Ardent Ardent
Choson Choson
Coronado Coronado
Berwick Berwick
Firebolt Firebolt
Kersarge Kersarge
Laboon Laboon
Manzanita Manzanita
Momsen Momsen
Somerset Somerset
Tortuga Tortuga
Colossus Colossus
Benavidez Benavidez
Brittin Brittin
Charlton Charlton
Eagleview Eagleview
Guadalupe Guadalupe
Alvaro de Bazan Alvaro de Bazan
La Loba La Loba
Swiftsure Swiftsure
Laramie Laramie
Pecos Pecos
Taos Taos
Souverain Souverain
Almaak Almaak
Chakra Chakra
Kalvari Kalvari
Shisumar Shisumar
Kolkata Kolkata
Rajput Rajput
Vympel Vympel
Shivalik Shivalik
Talwar Talwar
Godavari Godavari
Shardul Shardul
Magar Magar
Kamorta Kamorta
Kora Kora
Khukri Khukri
Abhay Abhay
Saryu Saryu
Sukanya Sukanya
Tinkat Tinkat
Shalki Shalki
Chennai Chennai
Mysore Mysore
Ranvir Ranvir
Tabar Tabar
Tarkash Tarkash
Galerna Galerna
Mistral Mistral
Castilla Castilla
Lezo Lezo
Serviola Serviola
Canabrava Canabrava
Toralla Toralla
Aresa Aresa
Alboran Alboran
Centinela Centinela
Patino Patino
Elcano Elcano
Toulon Toulon
Richelieu Richelieu
Dunquerque Dunquerque
Mers-el-Kebir Mers-el-Kebir
Rubis Rubis
Forbin Forbin
Cassard Cassard
Aquitaine Aquitaine
Auvergne Auvergne
Blaison Blaison
Belleisle Belleisle
Tonnant Tonnant
Bellerophon Bellerophon
Mont Blanc Mont Blanc
Pluton Pluton
Hortense Hortense
Shohei Maru Shohei Maru
Asahi Maru Asahi Maru
Choyo Choyo
Kaiten Kaiten
Mikaho Mikaho
Moshun Moshun
Ryoju Ryoju
Kongo Kongo
Tsukushi Tsukushi
Katsuragi Katsuragi
Akagi Akagi
Kotetsu Kotetsu
Fuso Fuso
Yashima Yashima
Mishima Mishima
Okinoshima Okinoshima
Satsuma Satsuma
Katori Katori
Kirishima Kirishima
Nagato Nagato
Matsushima Matsushima
Yoshino Yoshino
Kasagi Kasagi
Takasago Takasago
Chikuma Chikuma
Tenryu Tenryu
Kuma Kuma
Sendai Sendai
Soryu Soryu
Izumo Izumo
Hyuga Hyuga
Osumi Osumi
Kunisaki Kunisaki
Hatakaze Hatakaze
Scheherazade Scheherazade
Gormand Gormand
Firstborn Firstborn
Adir Adir
Zumwalt Zumwalt
Throckmorton Throckmorton
Normandy Normandy
Magna Carta Magna Carta
Casablanca Casablanca
Message in a Bottle Message in a Bottle
Monkey Business Monkey Business
Dorngas Dorngas
Soyuz Soyuz
Gorshkov Gorshkov
Zereguchniy Zereguchniy
Arthur Foss Arthur Foss
Chidiock Tichborne Chidiock Tichborne
Vera Hugh Vera Hugh
Challenger Challenger
Columbia Columbia
Endeavor Endeavor
Discovery Discovery
Babcock Babcock
Wilcox Wilcox
Burke Burke
Fletcher Fletcher
Garfish Garfish
Hornet Hornet
Nitro Nitro
Patoka Patoka
Powhatan Powhatan
Salamonie Salamonie
Sassacus Sassacus
Yorktown Yorktown
Deep-Sea Baby Deep-Sea Baby
Steady Progress Steady Progress
Barnacle Barnacle
Humpback Humpback
In the Reeds In the Reeds
Northwest Passage Northwest Passage
Yuri Gagarin Yuri Gagarin
Buzz Aldrin Buzz Aldrin
Neil Armstrong Neil Armstrong
Sally Ride Sally Ride

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
Duchess Duchess
Empress Empress
Lady Lady
Mistress Mistress
Princess Princess
Queen Queen

View file

@ -1,6 +1,6 @@
Admiral Admiral
Captain Captain
Champion Champion
Commodore Commodore
Saint Saint
Sovereign Sovereign

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
Alderman Alderman
Baron Baron
Duke Duke
Emperor Emperor
King King
Lord Lord
Master Master
Prince Prince

View file

@ -1,201 +1,201 @@
Star Star
Sun Sun
Sky Sky
Moon Moon
Nova Nova
Corona Corona
Photon Photon
Aurora Aurora
Void Void
Shockwave Shockwave
Cloud Cloud
Nebula Nebula
Quasar Quasar
Pulsar Pulsar
Horizon Horizon
Zenith Zenith
Comet Comet
Flare Flare
Energy Energy
Galaxy Galaxy
Ring Ring
Blade Blade
Sword Sword
Light Light
Flash Flash
Dance Dance
Flood Flood
Bounty Bounty
Castle Castle
Temple Temple
Spirit Spirit
Trail Trail
Flight Flight
Heart Heart
Pennant Pennant
Harvest Harvest
Nymph Nymph
Mermaid Mermaid
Siren Siren
Anchor Anchor
Hammerhead Hammerhead
Lion Lion
Lioness Lioness
Eagle Eagle
Silhouette Silhouette
Guardian Guardian
God God
Tower Tower
Pillar Pillar
Hero Hero
Quest Quest
Journey Journey
Matrix Matrix
Palace Palace
Pyramid Pyramid
Goblet Goblet
Sunset Sunset
Sunrise Sunrise
Fish Fish
Symbol Symbol
Mark Mark
Realm Realm
Tree Tree
Crossing Crossing
Shadow Shadow
Swan Swan
Forge Forge
Banner Banner
Voyage Voyage
Rose Rose
Song Song
Raven Raven
Point Point
Mountain Mountain
Island Island
Forest Forest
Carnation Carnation
Gaze Gaze
Ship Ship
Cave Cave
Phoenix Phoenix
Soul Soul
Teacup Teacup
Muse Muse
Chest Chest
Courser Courser
Katana Katana
God God
Goddess Goddess
Hoard Hoard
Jumper Jumper
Rider Rider
Chaser Chaser
Dancer Dancer
Seeker Seeker
Explorer Explorer
Lover Lover
Hunter Hunter
Beater Beater
Racer Racer
Piercer Piercer
Charger Charger
Speeder Speeder
Falcon Falcon
Paladin Paladin
Cavalier Cavalier
Spear Spear
Surfer Surfer
Strider Strider
Genie Genie
Caravan Caravan
Dreamer Dreamer
Folly Folly
Money Pit Money Pit
Beauty Beauty
Mule Mule
Work Horse Work Horse
Moneymaker Moneymaker
Starship Starship
Hauler Hauler
Beater Beater
Fortune Fortune
Dream Dream
Pride Pride
Gamble Gamble
Downfall Downfall
Regret Regret
Savior Savior
Miracle Miracle
Last Chance Last Chance
Last Stand Last Stand
Adventure Adventure
Jewel Jewel
Surprise Surprise
Cutter Cutter
Cruiser Cruiser
Spice Spice
Canyon Canyon
Tiger Tiger
Start Start
Angel Angel
Son Son
Boy Boy
Daughter Daughter
Girl Girl
Arrow Arrow
Bolt Bolt
Scholar Scholar
Home Home
Namer Namer
Sting Sting
Apprentice Apprentice
Walrus Walrus
Schooner Schooner
Pony Pony
Stick Stick
Wallet Wallet
Cone Cone
Carnival Carnival
Crossing Crossing
Chapel Chapel
Echo Echo
Name Name
Bear Bear
Storm Storm
Bucket Bucket
Bilge Bilge
Wheel Wheel
Wizard Wizard
Wall Wall
Unicorn Unicorn
Gem Gem
Oath Oath
Ghost Ghost
Engine Engine
Scallop Scallop
Kiwi Kiwi
Gambit Gambit
Pearl Pearl
Day Day
Maid Maid
Mare Mare
Citadel Citadel
Dart Dart
Giant Giant
Pioneer Pioneer
Freehold Freehold
Sentry Sentry
Sentinel Sentinel
Zephyr Zephyr
Terminus Terminus
Pinecone Pinecone
Sickle Sickle
Ladybug Ladybug
Enchantress Enchantress
Pilgrim Pilgrim
Alligator Alligator
Legend Legend
Cutter Cutter
Dune Dune
Obelisk Obelisk

View file

@ -1,13 +1,13 @@
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
II II
III III
IIII IIII

View file

@ -1,54 +1,54 @@
Alan Bean Alan Bean
Albert Einstein Albert Einstein
Ascension Ascension
Atlantis Atlantis
Aurora Aurora
Buran Buran
Calypso Calypso
Cargo Dragon Cargo Dragon
Challenger Challenger
Columbia Columbia
Deke Slayton Deke Slayton
Discovery Discovery
Dragon Capsule Dragon Capsule
Eagle Eagle
Edorado Amaldi Edorado Amaldi
Endeavour Endeavour
Enterprise Enterprise
Faith Faith
First Step First Step
Freedom Freedom
Friendship Friendship
Genesis Genesis
Georges Lemaître Georges Lemaître
Gumdrop Gumdrop
H. G. Wells H. G. Wells
Inspire Inspire
Johannes Kepler Johannes Kepler
John Glenn John Glenn
John Young John Young
Jules Verne Jules Verne
Kosmos Kosmos
Kounotori Kounotori
Liberty Bell Liberty Bell
Lunar Gateway Lunar Gateway
Mir Mir
Molly Brown Molly Brown
Odyssey Odyssey
Resilience Resilience
Robert H. Lawrence Robert H. Lawrence
Roger Chaffee Roger Chaffee
Salyut Salyut
Sigma Sigma
Skylab Skylab
Starhopper Starhopper
Tenacity Tenacity
Unity Unity
Yankee Clipper Yankee Clipper
Zarya Zarya
Zvezda Zvezda
Akatsuki Akatsuki
Hubble Hubble
Sputnik Sputnik
Starman Starman
Voyager Voyager

View file

@ -1,77 +1,77 @@
Syntron Syntron
The Commonwealth The Commonwealth
4 3200 4 3200
6 75 2.5 0.5 0 6 75 2.5 0.5 0
7 30 0.5 0.5 0 Eorus 0 7 30 0.5 0.5 0 Eorus 0
0 10 0.7 0.2 0 0 10 0.7 0.2 0
Exits 1 2 5 6 Exits 1 2 5 6
0.5 0.5 0.5 0.5
-- --
Tartus 3 Tartus 3
The Commonwealth The Commonwealth
3 2900 3 2900
2 70 1.5 -1.3 0 2 70 1.5 -1.3 0
31 25 0.5 0.5 0 Talypso 1 31 25 0.5 0.5 0 Talypso 1
Exits 0 4 6 Exits 0 4 6
0.52 0.48 0.52 0.48
-- --
Nebulous Nebulous
Worlds' Republic Worlds' Republic
7 5100 7 5100
24 110 2.3 0.9 0 24 110 2.3 0.9 0
9 60 0.5 0.5 0 Morgana 3 9 60 0.5 0.5 0 Morgana 3
Exits 0 5 Exits 0 5
0.46 0.55 0.46 0.55
-- --
Cayrel Cayrel
Syndicate Syndicate
8 3300 8 3300
4 90 -1.3 -1.65 0 4 90 -1.3 -1.65 0
25 100 0.5 0.5 0 25 100 0.5 0.5 0
Exits 4 Exits 4
0.6 0.420 0.6 0.420
-- --
Tterrag Prime Tterrag Prime
Syndicate Syndicate
16 7400 16 7400
17 87 2.2 -1.5 0 17 87 2.2 -1.5 0
65 94 0.5 0.5 0 65 94 0.5 0.5 0
62 10 0.7 0.8 160 62 10 0.7 0.8 160
6 7 0.3 0.25 -60 6 7 0.3 0.25 -60
Exits 1 3 6 Exits 1 3 6
0.55 0.5 0.55 0.5
-- --
Ceherus Ceherus
The Commonwealth The Commonwealth
12 6000 12 6000
5 65 1.7 2.5 0 5 65 1.7 2.5 0
48 70 0.5 0.5 0 Darya 2 48 70 0.5 0.5 0 Darya 2
Exits 0 2 Exits 0 2
0.48 0.6 0.48 0.6
-- --
Rich 4rD Rich 4rD
The Commonwealth The Commonwealth
3 2100 3 2100
30 125 -2.7 0.5 0 30 125 -2.7 0.5 0
39 70 0.5 0.5 0 39 70 0.5 0.5 0
Exits 0 4 1 Exits 0 4 1
0.525 0.55 0.525 0.55
-- --
Cootlo Cootlo
The Matriarchy The Matriarchy
3 3000 3 3000
2 75 0.05 0.05 0 2 75 0.05 0.05 0
16 75 0.5 0.5 0 16 75 0.5 0.5 0
Exits 8 Exits 8
0.2 0.3 0.2 0.3
-- --
Jon Mk2 Jon Mk2
The Matriarchy The Matriarchy
3 3000 3 3000
2 75 0.05 0.05 0 2 75 0.05 0.05 0
24 60 0.5 0.5 0 24 60 0.5 0.5 0
50 42 0.05 0.01 0 50 42 0.05 0.01 0
58 10 0.15 0.05 0 58 10 0.15 0.05 0
Exits 7 Exits 7
0.25 0.32 0.25 0.32
-- --

View file

@ -1,18 +1,18 @@
Planets Set (1.0) Planets Set (1.0)
Created and Distributed by Wisedawn (https://wisedawn.itch.io/) Created and Distributed by Wisedawn (https://wisedawn.itch.io/)
Creation Date: 10/04/2019 Creation Date: 10/04/2019
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
License: (Creative Commons Zero, CC0) License: (Creative Commons Zero, CC0)
http://creativecommons.org/publicdomain/zero/1.0/ http://creativecommons.org/publicdomain/zero/1.0/
This content is free to use in personal, educational and commercial projects. This content is free to use in personal, educational and commercial projects.
Support us by crediting Wisedawn (this is not mandatory). Support us by crediting Wisedawn (this is not mandatory).
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
Follow on Twitter for updates: Follow on Twitter for updates:
https://twitter.com/wisedawndev https://twitter.com/wisedawndev

View file

@ -1,34 +1,34 @@
/* /*
* 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
*/ */

View file

@ -1,19 +1,19 @@
#include <iostream> // for standard input/output #include <iostream> // for standard input/output
using namespace std; // using the standard namespace using namespace std; // using the standard namespace
#include "Game.h" #include "Game.h"
#include "Menu.h" #include "Menu.h"
int main() { int main() {
// display "Hello, World!" -- this still appears in our Run terminal as before // display "Hello, World!" -- this still appears in our Run terminal as before
cout << "Hello, World!" << endl; cout << "Hello, World!" << endl;
int result = EXIT_SUCCESS; int result = EXIT_SUCCESS;
while (result == EXIT_SUCCESS) { while (result == EXIT_SUCCESS) {
Menu m; Menu m;
result = m.result; result = m.result;
if (result == EXIT_SUCCESS) Game g(m.soundOn, m.musicOn); if (result == EXIT_SUCCESS) Game g(m.soundOn, m.musicOn);
} }
return EXIT_SUCCESS; // report our program exited successfully return EXIT_SUCCESS; // report our program exited successfully
} }

View file

@ -1,22 +1,25 @@
Resources: Resources:
---------- ----------
Planets: https://wisedawn.itch.io/20-cc0-planets Planets: https://wisedawn.itch.io/20-cc0-planets
https://v-ktor.itch.io/planet-sprites https://v-ktor.itch.io/planet-sprites
https://v-ktor.itch.io/star-sprites https://v-ktor.itch.io/star-sprites
Font: https://rphstudio.itch.io/space-font Font: https://rphstudio.itch.io/space-font
Ships: http://millionthvector.blogspot.com/p/free-sprites.html Ships: http://millionthvector.blogspot.com/p/free-sprites.html
http://millionthvector.blogspot.com/p/free-sprites_12.html http://millionthvector.blogspot.com/p/free-sprites_12.html
Gui: https://craftpix.net/freebies/free-space-shooter-game-gui/ Gui: https://craftpix.net/freebies/free-space-shooter-game-gui/
Images: https://commons.wikimedia.org/wiki/File:Dunajec_Gorge_-_Limestone_Rocks_2.jpg Images: https://commons.wikimedia.org/wiki/File:Dunajec_Gorge_-_Limestone_Rocks_2.jpg
https://unsplash.com/photos/8AwXs7GKzCk https://unsplash.com/photos/8AwXs7GKzCk
Sounds: https://freesound.org/people/PhreaKsAccount/sounds/46492/ Sounds: https://freesound.org/people/PhreaKsAccount/sounds/46492/
https://freesound.org/people/NenadSimic/sounds/268108/ https://freesound.org/people/NenadSimic/sounds/268108/
https://freesound.org/people/plasterbrain/sounds/423166/ https://freesound.org/people/plasterbrain/sounds/423166/
https://freesound.org/people/chipfork71/sounds/72239/
Ship Name Components: https://github.com/endless-sky/endless-sky/blob/master/data/human/names.txt
Ship Name Components: https://github.com/endless-sky/endless-sky/blob/master/data/human/names.txt
Explosions: https://www.deviantart.com/joesalotofthings/art/Explosion-w-Smoke-Earth-Magic-Special-Effect-869413004