Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <vector>
- #include <stdlib.h>
- #include <time.h>
- #include "ObiektGraficzny.h"
- #include "Ciastko.h"
- #include "Waz.h"
- using namespace std;
- using namespace sf;
- int main()
- {
- float x = 0.0;
- float y = 0.0;
- bool wynik;
- vector<Ciastko*> ciastka;
- Ciastko ciastko(30, 30, Color::Red, 7, 7);
- Ciastko ciastko2(50, 50, Color::Red, 6, 6);
- for (int i = 0; i < 9; i++)
- {
- x = rand() % 800 + 1;
- y = rand() % 600 + 1;
- ciastka.push_back(new Ciastko(50.0, 50.0, Color::Blue, x, y));
- }
- Waz waz(30.0, 30.0, Color::Green, 4.0, 4.0);
- waz.dodajOgon();
- sf::RenderWindow window(VideoMode(800,600),"Snake");
- sf::Event event;
- while (window.isOpen())
- {
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- {
- window.close();
- }
- }
- window.clear();
- if (Keyboard::isKeyPressed(Keyboard::Left))
- {
- waz.idzWezem("lewo");
- }
- if (Keyboard::isKeyPressed(Keyboard::Right))
- {
- waz.idzWezem("prawo");
- }
- if (Keyboard::isKeyPressed(Keyboard::Up))
- {
- waz.idzWezem("gora");
- }
- if (Keyboard::isKeyPressed(Keyboard::Down))
- {
- waz.idzWezem("dol");
- }
- waz.rysujWeza(window);
- ciastko.rysuj(window);
- wynik=waz.czyWazZjadlCiastko(ciastko);
- if (wynik == true)
- {
- ciastko.ustawKolor();
- ciastko.rysuj(window);
- }
- window.display();
- sf::sleep(sf::milliseconds(100));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement