Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML/Graphics.hpp>
- #include <iostream>
- using namespace sf;
- class MainRoom{
- public:
- int heightR = 550;
- int widthR = 550;
- int x,y;
- };
- class Person:public MainRoom{
- public:
- int w = 30,h = 4;
- int movePerson(short range);
- };
- int Person::movePerson(short range) {
- if(Keyboard::isKeyPressed((Keyboard::A))){
- }else if(Keyboard::isKeyPressed(((Keyboard::D)))){
- }else if(Keyboard::isKeyPressed(((Keyboard::S)))){
- }else if(Keyboard::isKeyPressed(((Keyboard::W)))){
- }
- }
- int main()
- {
- //rooom
- MainRoom rm;
- RectangleShape room(Vector2f(rm.widthR, rm.heightR));
- room.setFillColor(Color::Blue);
- //hero
- RenderWindow window(VideoMode(600, 600), "SFML works!");
- Person pr;
- CircleShape main_hero(pr.w, pr.h);
- main_hero.setFillColor(Color::Yellow);
- while (window.isOpen())
- {
- main_hero.move(pr.movePerson(10), 0);
- main_hero.getPosition();
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == Event::Closed)
- window.close();
- }
- window.clear(Color::Black);
- window.draw(room);
- window.draw(main_hero);
- window.display();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement