started the game
This commit is contained in:
parent
3334e64e5d
commit
0c1d8211f3
BIN
cascaydia.otf
Normal file
BIN
cascaydia.otf
Normal file
Binary file not shown.
60
main.cpp
Normal file
60
main.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#define DELAY 30000
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
int x = 0, y = 0;
|
||||
int max_x = 800, max_y = 600;
|
||||
int direction = 0;
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(max_x, max_y), "SFML Window");
|
||||
|
||||
sf::Font font;
|
||||
if (!font.loadFromFile("cascaydia.otf")) {
|
||||
std::cerr << "Failed to load font" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
sf::Text text("o", font, 24);
|
||||
text.setFillColor(sf::Color::White);
|
||||
|
||||
while (window.isOpen()) {
|
||||
sf::Event event;
|
||||
while (window.pollEvent(event)) {
|
||||
if (event.type == sf::Event::Closed) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up) && y > 0) {
|
||||
y--;
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down) && y < max_y - 1) {
|
||||
y++;
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left) && x > 0) {
|
||||
x--;
|
||||
}
|
||||
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right) && x < max_x - 1) {
|
||||
x++;
|
||||
}
|
||||
|
||||
// Clear the window
|
||||
window.clear();
|
||||
|
||||
// Set the position of the text
|
||||
text.setPosition(x, y);
|
||||
|
||||
// Draw the text on the window
|
||||
window.draw(text);
|
||||
|
||||
// Display everything that was drawn
|
||||
window.display();
|
||||
|
||||
sf::sleep(sf::microseconds(DELAY));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
0
racingcar.cpp
Normal file
0
racingcar.cpp
Normal file
Loading…
x
Reference in New Issue
Block a user