Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Pein95

Pages: [1]
1
General / Install in Linux
« on: December 14, 2013, 06:26:56 pm »
I try to install sfml in linux mint.
In the terminal I write this line:  sudo apt-get install libsfml-dev
After instalation I try to compile this code:

#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        window.draw(shape);
        window.display();
    }

    return 0;
}
 
g++ -o main.cpp
And after that I have this errors:
main.cpp: In function ‘int main()’:
main.cpp:6:5: error: ‘CircleShape’ is not a member of ‘sf’
main.cpp:6:21: error: expected ‘;’ before ‘shape’
main.cpp:7:5: error: ‘shape’ was not declared in this scope
main.cpp:9:19: error: ‘class sf::RenderWindow’ has no member named ‘isOpen’
main.cpp:12:23: error: ‘class sf::RenderWindow’ has no member named ‘pollEvent’
main.cpp:14:23: error: ‘class sf::Event’ has no member named ‘type’
main.cpp:15:24: error: ‘class sf::RenderWindow’ has no member named ‘close’
main.cpp:18:16: error: ‘class sf::RenderWindow’ has no member named ‘clear’
main.cpp:19:16: error: ‘class sf::RenderWindow’ has no member named ‘draw’
main.cpp:20:16: error: ‘class sf::RenderWindow’ has no member named ‘display’

How I can fix its?
Sorry for my English, it is not very good)

2
General / Some error
« on: September 05, 2013, 10:02:35 pm »
if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                {
                        sf::Vector2i MousePosition = sf::Mouse::getPosition(window);
                        for (int i=0; i<24; i++)
                        {
                                for (int j=0; j<24; j++)
                                {
                                       

                                        if((int)rect[i][j].getPosition().x < MousePosition.x&&
                                                (int)rect[i][j].getPosition().y < MousePosition.y &&
                                                (int)rect[i][j].getPosition().x + (int)rect[i][j].getGlobalBounds().width > MousePosition.x
                                                && (int)rect[i][j].getPosition().y + (int)rect[i][j].getGlobalBounds().height > MousePosition.y)
                                        {
                                                rect[i][j].setFillColor(sf::Color::Red);
                                                break;
                                        }
                                }
                        }
                       
                }

 
When I click on the some rect, I have error in this line:
if((int)rect[i][j].getPosition().x < MousePosition.x&&
                                                (int)rect[i][j].getPosition().y < MousePosition.y &&
                                                (int)rect[i][j].getPosition().x + (int)rect[i][j].getGlobalBounds().width > MousePosition.x
                                                && (int)rect[i][j].getPosition().y + (int)rect[i][j].getGlobalBounds().height > MousePosition.y)
 

Unhandled exception at 0x00F0F1C2 in Project2.exe: 0xC0000005: Access violation writing location 0x00180000.



3
General / Re: Unhandled exception at 0x77AB22C2 (ntdll.dll)
« on: August 30, 2013, 07:39:05 pm »
Thanks)

4
General / Unhandled exception at 0x77AB22C2 (ntdll.dll)
« on: August 30, 2013, 07:22:20 pm »
//Game.h
#pragma once
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>

class Game
{
public:
        static void Start();

private:
        static bool IsExiting();
        static void GameLoop();

        enum GameState {Uninitialized, ShowingSplash, Paused,
                ShowingMenu, Playing, Exiting};

        static GameState _gameState;
        static sf::RenderWindow _mainWindow;
};
 

#include "Game.h"


Game::GameState Game::_gameState = Uninitialized;
sf::RenderWindow Game::_mainWindow;


void Game::Start()
{
        if (_gameState != Uninitialized)
                return;

        _mainWindow.create(sf::VideoMode(1024, 768,32), "Pang!");
        _gameState = Game::Playing;

        while (!IsExiting())
        {
                GameLoop();
        }

        _mainWindow.close();
}


bool Game::IsExiting()
{
        if (_gameState == Game::Exiting)
                return true;
        else
                return false;
}

void Game::GameLoop()
{
        sf::Event currentEvent;
        while(_mainWindow.pollEvent(currentEvent))
        {
                switch (_gameState)
                {
                case Game::Playing:
                        {
                                _mainWindow.clear(sf::Color(255,0,0));
                                _mainWindow.display();

                                if(currentEvent.type == sf::Event::Closed)
                                {
                                        _gameState = Game::Exiting;
                                }
                                break;
                        }
                       
                       

                }
        }
}


 

I have error in this line: sf::RenderWindow Game::_mainWindow;.
How I can fix it?
Sorry for my English) it is not my native English)

Pages: [1]
anything