#ifndef BOARD_H
#define BOARD_H
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics.hpp>
#define numOfCellsH 4
#define numOfCellsW 4
#define cellHeight 128
#define cellWidth 128
#define margin 10
class board
{
public:
board(sf::RenderWindow* window);
~board();
void drawCellsBackground();
void drawBoard();
private:
sf::RenderWindow* mWindow;
sf::RectangleShape mBoardBox;
sf::RectangleShape mCellsBg;
};
gdb output :
Error in `/home/kachan/work/build-2048-Debug/2048': malloc(): smallbin double linked list corrupted: 0x00000000007b7180 ***
then i try
#ifndef BOARD_H
#define BOARD_H
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
#include <SFML/Graphics.hpp>
#define numOfCellsH 4
#define numOfCellsW 4
#define cellHeight 128
#define cellWidth 128
#define margin 10
class board
{
public:
board(sf::RenderWindow* window);
~board();
void drawCellsBackground();
void drawBoard();
private:
sf::RenderWindow* mWindow;
sf::RectangleShape mBoardBox;
// sf::RectangleShape mCellsBg;
};
and it works
program down before i init something, because
#include "board.h"
#include <SFML/Graphics/RenderWindow.hpp>
#include <SFML/Graphics/RectangleShape.hpp>
board::board(sf::RenderWindow *window)
{
mWindow = window;
// mBoardBox = new sf::RectangleShape;
mBoardBox.setSize(sf::Vector2f(((numOfCellsW+1) * margin) + (cellWidth * numOfCellsW),
((numOfCellsH+1) * margin) + (cellHeight * numOfCellsH)));
mBoardBox.setPosition(19, 160);
mBoardBox.setFillColor(sf::Color(187, 173, 160, 255));
// mCellsBg = new sf::RectangleShape;
// mCellsBg.setSize(sf::Vector2f(cellWidth, cellHeight));
// mCellsBg.setFillColor(sf::Color(205, 192, 180, 255));
}
board::~board()
{
}
void board::drawCellsBackground()
{
}
void board::drawBoard()
{
mWindow->draw(mBoardBox);
// mWindow->draw(mCellsBg);
}