Created
April 22, 2014 13:29
-
-
Save Mischa-Alff/11179303 to your computer and use it in GitHub Desktop.
autoBANNED.cpp
This file contains 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 <list> | |
#include <iostream> | |
#include <SFML/System.hpp> | |
#include <SFML/Window.hpp> | |
#include <SFML/Graphics.hpp> | |
int main() | |
{ | |
sf::RenderWindow window{{800, 600}, "AutoBANNED"}; | |
window.setFramerateLimit(60); | |
sf::Vector2f focal_point{window.getSize().x/2.f, 0}; | |
sf::VertexArray asphalt(sf::Triangles, 3); | |
asphalt[0] = {focal_point, sf::Color::Black}; | |
asphalt[1] = {sf::Vector2f{window.getSize().x/7.f*1.f, (float)window.getSize().y}, sf::Color::Black}; | |
asphalt[2] = {sf::Vector2f{window.getSize().x/7.f*6.f, (float)window.getSize().y}, sf::Color::Black}; | |
sf::VertexArray yellow_lines(sf::Triangles, 3); | |
yellow_lines[0] = {focal_point, sf::Color::Yellow}; | |
yellow_lines[1] = {sf::Vector2f{window.getSize().x/2.f-window.getSize().x/100, (float)window.getSize().y}, sf::Color::Yellow}; | |
yellow_lines[2] = {sf::Vector2f{window.getSize().x/2.f+window.getSize().x/100, (float)window.getSize().y}, sf::Color::Yellow}; | |
std::list<sf::RectangleShape> line_split{5}; | |
auto k = 0; | |
for(auto &i : line_split) | |
{ | |
i.setFillColor(sf::Color::Black); | |
i.setPosition({window.getSize().x/2.f-window.getSize().x/100.f, window.getSize().y/5.f*k++}); | |
i.setSize({window.getSize().x/50.f, 10.f*(window.getSize().y/(window.getSize().y-i.getPosition().y))}); | |
std::cout<<window.getSize().y/(window.getSize().y-i.getPosition().y)<<std::endl; | |
} | |
sf::VertexArray horizon(sf::Triangles, 12); | |
sf::Color horizon_color{125,125,125,255}; | |
sf::Color horizon_mid_color{125,125,125,255}; | |
sf::Color horizon_fade_color{125,125,125,0}; | |
float horizon_fade_top = window.getSize().y/2.f-window.getSize().y/6.f; | |
float horizon_fade_bottom = window.getSize().y/2.f-window.getSize().y/16.f; | |
horizon[0] = {{0.f, 0.f}, horizon_color}; | |
horizon[1] = {{0.f, horizon_fade_top}, horizon_mid_color}; | |
horizon[2] = {{(float)window.getSize().x, 0.f}, horizon_color}; | |
horizon[3] = {{(float)window.getSize().x, 0.f}, horizon_color}; | |
horizon[4] = {{0.f, horizon_fade_top}, horizon_mid_color}; | |
horizon[5] = {{(float)window.getSize().x, horizon_fade_top}, horizon_mid_color}; | |
horizon[6] = {{0.f,horizon_fade_top}, horizon_mid_color}; | |
horizon[7] = {{0.f,horizon_fade_bottom}, horizon_fade_color}; | |
horizon[8] = {{(float)window.getSize().x,horizon_fade_top}, horizon_mid_color}; | |
horizon[9] = {{(float)window.getSize().x,horizon_fade_top}, horizon_mid_color}; | |
horizon[10] = {{(float)window.getSize().x,horizon_fade_bottom}, horizon_fade_color}; | |
horizon[11] = {{0.f,horizon_fade_bottom}, horizon_fade_color}; | |
float velocity = 0.1f; | |
sf::Clock dt_timer; | |
dt_timer.restart(); | |
while(window.isOpen()) | |
{ | |
auto dt = dt_timer.restart().asMicroseconds()/1000.f; | |
sf::Event event; | |
while(window.pollEvent(event)) | |
{ | |
switch(event.type) | |
{ | |
case sf::Event::Closed: | |
window.close(); | |
break; | |
case sf::Event::KeyReleased: | |
switch(event.key.code) | |
{ | |
case sf::Keyboard::Equal: | |
velocity += 0.1f; | |
std::cout<<velocity<<std::endl; | |
break; | |
case sf::Keyboard::Dash: | |
velocity -= 0.1f; | |
std::cout<<velocity<<std::endl; | |
break; | |
default: | |
break; | |
} | |
default: | |
break; | |
} | |
} | |
window.clear(sf::Color::White); | |
window.draw(asphalt); | |
window.draw(yellow_lines); | |
for(auto &i : line_split) | |
{ | |
i.move(0.f, velocity*dt); | |
if(!window.getViewport(window.getDefaultView()).contains(static_cast<sf::Vector2i>(i.getPosition()))) | |
{ | |
i.setPosition({window.getSize().x/2.f-window.getSize().x/100.f, 0.f}); | |
} | |
i.setSize({window.getSize().x/50.f, 10.f*(window.getSize().y/(window.getSize().y-i.getPosition().y))}); | |
window.draw(i); | |
} | |
window.draw(horizon); | |
window.display(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This stuff is hax!