#include <SFML/Graphics.hpp>
enum Znak
{
Yellow,
Red,
Empty
};
enum Ramka
{
Normal,
Highlight
};
class Board
{
public:
Board(sf::RenderWindow &App);
void draw();
void restart();
sf::Color bcolor;
sf::Color redColor;
private:
Znak tablica[5][5];
Ramka obramowanie[5][5];
sf::RenderWindow &mywindow;
sf::Color yellowColor;
sf::Color emptyColor;
sf::Color lineColor;
sf::Color highlightColor;
float radius;
float outline;
float spaceX,spaceY;
};
board.cpp
#include "module.h"
Board::Board(sf::RenderWindow &App) : mywindow(App)
{
bcolor = sf::Color::Color(0, 102, 153);
redColor = sf::Color::Color(214, 71, 0);
yellowColor = sf::Color::Color(235,235,0);
emptyColor = sf::Color::Color(224,224,224);
lineColor = sf::Color::Color(0, 51, 102);
highlightColor = sf::Color::Color(255, 153, 0);
radius = 60.0;
spaceY=radius/2.0;
outline=radius/15.0;
radius = radius - spaceY/2.0 - outline;
spaceX=radius/3.0;
restart();
}
void Board::restart()
{
for(int i=0;i<=5;i++)
for(int j=0;j<=5;j++)
{
tablica[i][j]=Empty;
obramowanie[i][j]=Normal;
}
}
void Board::draw()
{
sf::Color fillColor;
sf::CircleShape circle(radius,30);
circle.setOutlineColor(highlightColor);
circle.setFillColor(fillColor);
circle.setPosition(200, 200);
circle.setOutlineThickness(outline);
mywindow.draw(circle);
}
main.cpp
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>
#include "module.h"
int main()
{
// Create the main window
sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");
Board board(App);
// Start the game loop
while (App.isOpen())
{
// Process events
sf::Event event;
while (App.pollEvent(event))
{
// Close window : exit
if (event.type == sf::Event::Closed)
App.close();
}
// Clear screen
App.clear();
// Draw the sprite
board.draw();
// Update the window
App.display();
}
return EXIT_SUCCESS;
}
So the thing is, compiler passes it without any warning or error BUT the screen shows up and crashes insantly. I did tried to change the definition of Board::draw() to Board::draw(sf::RenderWindow &window) and then pass a reference to my App window, and use window.draw() in board.cpp and then Board.draw(App) in main.cpp but still it didn't work. My friend tried to make a friend method in class sf::RenderWindow::draw() but with no succes either. So my question is, what am I doing wrong? I am using VS 2010 on Win 7 64b.
Btw. I was using this tutorial:http://redkiing.word...i-introduction/
Regards, Chris.

New Topic/Question
Reply



MultiQuote





|