Something’s coming
I've basically dropped most of my attention on the game and begun working on a new project (as well as continuing the Django tutorials). As hinted before, the new project is in c++, along with my painfully welcoming experience to it. So far I haven't progressed much, but here's a mind-map of my next software-to-be.
![]()
I'd have to claim its probably my largest project to-date. The chart is pretty much self-explanatory of what's to become of it. Although I need some better name for it
C++ at its Finest
Recently, I've been programming in c++ for my next project. It's my first major project using c++ and I'm going through the usual stumbles with programming with a relatively unfamiliar language (and all its quirks). Several things bother me as modestly perplexing:
- How the JAM build system can build my code just fine, while SCons fails to link it due to some cryptic vtables errors.
- const-correctness
- function pointers and the limitations of them with member functions
- Cryptic linker errors when virtual functions aren't defined (and errors in general while we're at it).
However what has absolutely knocked me off my feet is seemingly C++ ignoring polymorphism. It's best explained with the code I currently have:
class baseWindow : public IWindow {
public:
void create(WNDPROC winProc, HINSTANCE hInst, int cmdshow);
cairo_surface_t* surface() const;
cairo_t* context() const;
//void resize(int, int){InvalidateRect(_hwnd, NULL, true);}
void show();
void quit();
char const* title() const;
char const* id() const;
point const* size() const;
LRESULT process_messages(HWND, UINT, WPARAM, LPARAM);
protected:
WNDCLASS _class;
HWND _hwnd;
char const* _title;
char const* _className;
int _cmdShow;
bool _bQuit;
PAINTSTRUCT _paintstruct;
HDC _hdc;
point* _size;
cairo_surface_t* _surface;
cairo_t* _context;
baseWindow(char const* title, char const* className) :
_title(title), _className(className), _bQuit(false),
_surface(NULL), _size(NULL)
{}
~baseWindow(){}
void _paint();
void lresize(int x, int y);
};
The code above is the base class (IWindow is simply an interface class). As you may have noticed, it utilizes the Windows API and cairo. However I also define another class:
class window : public baseWindow {
public:
window(char const* title, char const* className) : baseWindow(title, className){}
VSHAPE const* shapes() const{return &_shapes;}
VWIDGET const* widgets() const{return &_widgets;}
void paint();
void resize(int x, int y);
void draw(const point& p);
void drawShapes(const point& p);
void drawWidgets(const point& p);
point const* padding() const{return &_padding;}
void padding(int x, int y){_padding.set(x, y);}
void padding(const point& p){_padding = p;}
point offset() const{
point p(size()->x + padding()->x,
size()->y + padding()->y);
return p;
}
VSHAPE _shapes;
VWIDGET _widgets;
protected:
point _padding;
};
Now assuming all the methods are implemented the paint method will get called when the window is resized. However, when I perform something like this:
window w("Hello", "HelloClass");
program* p = program::instance();
solidSource s(0, 0, 0);
line l(0, 0, 100, 100, 5);
l.stroke(&s);
w._shapes.push_back(&l);
p->add(&w);
p->msgloop();
The window class constructor is called, but all the other member functions are controlled by the baseWindow class and none of the overridden window class member functions are fired. Strange indeed.
The game is progressing slowly
Unfortunately, while the game coding process is mostly complet, the game art and levels are definitely lacking (both in quality and quantity). Oh well, it was a nice semester long project. Next time I need to find better groupmates to work with.