I have made a button class if anyone want's to see:
#include "DarkGDK.h"
#include "gclass.h"
struct Color{
int r, g, b;
Color():r(0),g(0),b(0){}
Color(int rr, int gg, int bb):r(rr),g(gg),b(bb){}
};
template<typename T>
struct _Point{
T x, y;
_Point():x(0),y(0){}
_Point(T xx, T yy):x(xx),y(yy){}
bool operator==(_Point<T> a)
{return(a.x==x && a.y==y);}
bool operator!=(_Point<T> a)
{return!(a.x==x && a.y==y);}
_Point<T>* operator+=(_Point<T> a){
_Point<T>* p = this;
p->x += a.x;
p->y += a.y;
return p;
}
_Point<T>* operator-=(_Point<T> a){
_Point<T>* p = this;
p->x -= a.x;
p->y -= a.y;
return p;
}
_Point<T> operator+(_Point<T> a)
{return _Point<T>(a.x+x, a.y+y);}
_Point<T> operator-(_Point<T> a)
{return _Point<T>(a.x-x, a.y-y);}
};
typedef _Point<int> pointi;
struct ButtonFireWhenClicked{
int x, y, width, height;
int c_red, c_green, c_blue;
int c_red2, c_green2, c_blue2;
void(*this_func)(void);
void setFunction(void(*func)(void))
{this_func = func;}
void update(){
if (dbMouseX() > x && dbMouseX() < x+width &&
dbMouseY() > y && dbMouseY() < x+width){
if (dbMouseY() > y && dbMouseY() < y+height){
dbInk(dbRGB(c_red2, c_green2, c_blue2),
dbRGB(c_red2, c_green2, c_blue2));
dbBox(x, y, x+width, y+height);
if(dbMouseClick())
this_func();
}
}
else{
dbInk(dbRGB(c_red, c_green, c_blue),
dbRGB(c_red, c_green, c_blue));
dbBox(x, y, x+width, y+height);
}
}
ButtonFireWhenClicked(pointi pos, Color col1, Color col2, int w, int h)
:x(pos.x),y(pos.y),c_red(col1.r),c_green(col1.g),c_blue(col1.b),
c_red2(col2.r), c_green2(col2.g), c_blue2(col2.b), width(w), height(h)
{
dbInk(dbRGB(c_red, c_green, c_blue),dbRGB(c_red, c_green, c_blue));
dbBox(x, y, x+width, y+height);
}
};
What do you think? Give me feedback and be brutally honest
#ifdef __NEWBIE__
MakeAnAwesomeGame(lots of badies, lots of guns, lots of stuff to do, BIG level)
#endif