my code is not really working (no errors, but the rectangle is not shown).
I have 3 classes: CFramework, CRectangle, CGame.
Whats wrong/missing?
My CFramework class initiates SDL and sets the video mode etc.
CRectangle.hpp:
#ifndef RECTANGLE_HPP
#define RECTANGLE_HPP
#include "Framework.hpp"
class CRectangle
{
public:
CRectangle ();
void createRectangle (int x, int y, int width, int height, int r, int g, int b);
private:
SDL_Surface *m_pScreen; // Pointer at the screen of CFramework
SDL_Rect m_Rect;
};
#endif
CRectangle.cpp:
#include "Rectangle.hpp"
// Konstruktor
//
// Aufgabe: Zeiger auf Screen holen
//
CRectangle::CRectangle ()
{
// Zeiger auf Screen holen
m_pScreen = g_pFramework->GetScreen ();
} // Konstruktor
// createRectangle
//
// Aufgabe: Viereck erstellen
//
void CRectangle::createRectangle (int x, int y, int width, int height, int r, int g, int b)
{
m_Rect.x = x;
m_Rect.y = y;
m_Rect.w = width;
m_Rect.h = height;
SDL_FillRect(m_pScreen, &m_Rect, SDL_MapRGB(m_pScreen->format, r, g, b));
} // createRectangle
CGame.cpp:
... // just the important stuff
m_pRectangleMenu = new CRectangle;
m_pRectangleMenu->createRectangle(100,100,400,400,233,34,34);
...
Well since you didn’t include an “SDL_Flip(screen_variable)”…maybe that’s your problem. If not, you should post up unto the SDL_Flip().
Reagan