This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
windowSize = boardSize * (tileSize + border) - border; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For x | |
// For y | |
currentTile.setPosition((tileSize + border) * y, (tileSize + border) * x); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto box_position{sf::Mouse::getPosition(window)}; | |
for (auto& component : {box_position.x, box_position.y}) | |
{ | |
while (component % tileSize) | |
--component; | |
} | |
box.setPosition(box_position); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf::Vector2f delta(sf::Vector2f(sf::Mouse::getPosition(window)) - player.getPosition()); | |
player.setRotation(atan(delta.y / delta.x) * 180 / PI); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See RotateToMouse.cpp for definition of delta | |
sf::Vector2f normalizedDelta(delta / hypot(delta.x, delta.y)); | |
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) | |
background.move(sf::Vector2f(-normalizedDelta.x, -normalizedDelta.y)); | |
if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) | |
background.move(sf::Vector2f(normalizedDelta.x, normalizedDelta.y)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sf::Event event; | |
while (window.pollEvent(event)) | |
{ | |
using k = sf::Keyboard; | |
using e = sf::Event; | |
auto kc = event.key.code; | |
auto et = event.type; | |
auto kp = e::KeyPressed; | |
//DIREKTER VERGLEICH///////////////////////////////////////////////// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics.hpp> | |
#include <stdio.h> | |
#include <set> | |
#include <vector> | |
#include <math.h> | |
#include <assert.h> | |
const sf::Vector2u window_size{1280, 720}; | |
sf::CircleShape player{20.f}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Most credit to @fallahn | |
#version 120 | |
uniform sampler2D tex1; | |
uniform sampler2D tex2; | |
uniform sampler2D maskTex; | |
void main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics.hpp> | |
// #define CATCH_CONFIG_MAIN | |
// #include <catch.hpp> | |
void draw_lines(const std::vector<sf::Vector2f>& vector, sf::RenderWindow& window, sf::Color color = sf::Color::White) | |
{ | |
for (auto it{vector.cbegin()}; it != vector.cend();) | |
{ | |
auto current_it{it}; | |
if (++it != vector.cend()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <SFML/Graphics.hpp> | |
#include <cassert> | |
#include <array> | |
#include <algorithm> | |
// #define CATCH_CONFIG_MAIN | |
// #include <catch.hpp> | |
void draw_lines(const std::vector<sf::Vector2f>& vector_, sf::RenderTarget& target_, sf::Color color_ = sf::Color::White) | |
{ | |
for (auto it{vector_.cbegin()}; it != vector_.cend();) |
OlderNewer