def diferent

This commit is contained in:
serk 2017-01-21 17:58:55 +01:00
parent bdc23b64e4
commit 8276d66807
5 changed files with 22 additions and 18 deletions

View file

@ -5,19 +5,23 @@ float rand(vec2 n) {
return fract(sin(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);
}
float line(float p, float x, float glow) {
if (abs(p - x) < 0.025) return 1.;
float line(float p, float x, float glow, float thick) {
if (abs(p - x) < thick) return 1.;
return 1. - pow(abs(p - x), glow);
}
float line2(float p, float x, float glow) {
return 1. - pow(abs(p - x), glow);
}
float grid(vec2 uv) {
float glow = 0.05;
float c = line(uv.x, 0.25, glow) + line(uv.x, 0.75, glow)
+ line(uv.x, 0.5, glow)
+ line(uv.x, 0.0, glow) + line(uv.x, 1.0, glow)
+ line(uv.y, 0.25, glow) + line(uv.y, 0.75, glow)
+ line(uv.y, 0.5, glow)
+ line(uv.y, 0.0, glow) + line(uv.y, 1.0, glow);
float c = line(uv.x, 0.25, glow, 0.025) + line(uv.x, 0.75, glow, 0.025)
+ line(uv.x, 0.5, glow, 0.025)
+ line(uv.x, 0.0, glow, 0.025) + line(uv.x, 1.0, glow, 0.025)
+ line(uv.y, 0.25, glow, 0.025) + line(uv.y, 0.75, glow, 0.025)
+ line(uv.y, 0.5, glow, 0.025)
+ line(uv.y, 0.0, glow, 0.025) + line(uv.y, 1.0, glow, 0.025);
return c;
}
@ -34,5 +38,6 @@ void main(void) {
else uv.y -= abs(time * 0.1);
vec4 color = vec4(255, 120, 153, 255) / 255.;
vec4 colorB = vec4(255,255,255,255)/ 255.;
gl_FragColor = (grid(fract(uv))) * color;
}

View file

@ -51,7 +51,7 @@ void Combat::draw(sf::RenderWindow *window) {
void Combat::updateEvents(sf::Event e) {
if (playerOneTurn) {
bool aux = player->event(e);
bool aux = player->event(e, !attacking);
if (!aux) { //end of player one ritm
if (!attacking) {
if(!player->hitBy(enemy->getAttack())) {
@ -63,7 +63,7 @@ void Combat::updateEvents(sf::Event e) {
}
}
else if (!ia) {
bool aux = !enemy->event(e);
bool aux = !enemy->event(e, !attacking);
enemyManager(aux); //end of player two not ia ritm
}
}

View file

@ -25,10 +25,10 @@ void Compas::add() {
void Compas::end() {
if (isPress) {
isPress = false;
std::cout << "end" << std::endl;
for (int i = 0; i < notes.size(); ++i) {
std::cout << notes[i] << std::endl;
}
// std::cout << "end" << std::endl;
// for (int i = 0; i < notes.size(); ++i) {
// std::cout << notes[i] << std::endl;
// }
}
}

View file

@ -21,7 +21,7 @@ bool Player::updateLogic(float deltaTime, sf::RenderWindow *window) {
return false;
}
bool Player::event(sf::Event e) {
bool Player::event(sf::Event e, bool def) {
switch(e.type) {
case (sf::Event::KeyPressed):
if(e.key.code == sf::Keyboard::C) {
@ -35,9 +35,8 @@ bool Player::event(sf::Event e) {
}
else {
compas.end();
error = true; //weird?
error = true;
if (animate != PlayerState::inMidle) animate = PlayerState::hurt;
}
}
break;

View file

@ -8,7 +8,7 @@ class Player : public Actor {
public:
Player();
Player(int num);
bool event(sf::Event e) final override;
bool event(sf::Event e, bool def) final override;
protected:
bool updateLogic(float deltaTime, sf::RenderWindow *window);