-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrocket.h
More file actions
57 lines (41 loc) · 1.12 KB
/
rocket.h
File metadata and controls
57 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/**
rocket.h
Purpose: Rocket capable of learning through genetic algorithms.
@author Joshua Varga
@version 1.0
*/
#ifndef ROCKET_H
#define ROCKET_H
#define _USE_MATH_DEFINES
#include <math.h>
#include <random>
#include <iostream>
#include <SFML/Graphics.hpp>
class Rocket : public sf::Drawable
{
private:
sf::Texture texture;
sf::Sprite sprite;
sf::Vector2f position;
sf::Vector2f velocity;
sf::Vector2f acceleration;
double fitness;
std::vector<sf::Vector2f> dna;
bool crashed = false;
double round(double d);
double heading(sf::Vector2f vector);
double map(double x, double in_min, double in_max, double out_min, double out_max);
virtual void draw(sf::RenderTarget &target, sf::RenderStates states) const;
public:
Rocket(){};
Rocket(int stepLimit, sf::Texture &texture);
Rocket(std::vector<sf::Vector2f> newDna, sf::Texture &texture);
void applyForce(sf::Vector2f force);
void collision(sf::Sprite earth, sf::Sprite asteroid);
void calculateFitness(sf::Sprite asteroid);
double getFitness();
void setFitness(double newFitness);
std::vector<sf::Vector2f> getDna();
void update(int step);
};
#endif // ROCKET_H