-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCore.h
More file actions
36 lines (29 loc) · 898 Bytes
/
Core.h
File metadata and controls
36 lines (29 loc) · 898 Bytes
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
#pragma once
#include <SFML/Graphics.hpp>
#include <iostream>
#include "Node.h"
#include "Spring.h"
const double timestep = 5.0e-2;
const int ups = floor(1 / timestep);
const sf::Vector2f gravity = sf::Vector2f( 0.0f, -9.81f );
class Core
{
public:
Core(sf::RenderWindow& render_window) : window(render_window) {};
void run();
static const unsigned int rows = 10;
static const unsigned int cols = 20;
static void clamp(float& value, float min, float max);
static void clamp(sf::Vector2f& value, float min_mag, float max_mag);
static void setMag(sf::Vector2f& vector, float magnetude);
static float length(sf::Vector2f vector);
static float distance(sf::Vector2f pointA, sf::Vector2f pointB);
private:
sf::RenderWindow& window;
std::vector<Node> nodes;
std::vector<Spring> springs;
void setup();
void input();
void update();
void draw();
};