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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#pragma once
#include <iostream>
#include <stdio.h>
#include <sfml/system.hpp>
#include <sfml/graphics.hpp>
#include <sfml/window.hpp>
#include <vector>
#include "line.h"
#include "bar.h"
using namespace sf;
using namespace std;
class ball
{
public:
ball(Texture&);
ball(Vector2f position, Vector2f speed, Texture& texture);
ball(RenderWindow&, Vector2f position, Vector2f speed, Texture& texture);
ball(RenderWindow&, Vector2f position, Vector2f speed, Texture& texture, Vector2f scale);
ball(Vector2f position, Vector2f speed, Texture& texture, Color);
~ball();
void buildMask();
void setPosition(Vector2f);
Vector2f getPosition();
void collisionManager(line aLine);
void collisionManager(ball&, ball&);
void collisionManager(bar&);
bool isOutOfBound();
void collideWithLine(Vertex&, Vertex&);
void collideWithLineTip(Vertex&, Vertex&);
bool canHitLine(Vertex&, Vertex&);
bool canCollideWithBar(bar&);
vector<Vertex> getPolygonPoints(bar&);
float distanceBetweenLineAndSprite(line aLine);
float distanceBetweenPointAndSprite(Vertex aPoint);
float distanceBetweenSpriteAndSprite(ball&, ball&);
float getTrueAngleLine(Vertex&, Vertex&);
float getTrueAngleSpeed();
float getReflectedAngle(float, float);
float calcNormalizedAngle(float);
float getRadius();
Sprite& getSprite();
Color& getColor();
Vector2f& getScale();
void gravityEffect();
void move();
void update();
protected:
RenderWindow& myWin;
Texture& myTexture;
Sprite mySprite;
Vector2f myPosition;
Vector2f mySize;
Vector2f myScale;
Vector2f mySpeed;
float myMass;
float kinEnergy;
vector<vector<bool>> myMask;
bool inCollision;
Color myColor;
Clock myClock;
bool hadCollision;
CircleShape myCircle;
float speedCorrection;
private:
};
|