Sign in to follow this  
  • entries
    90
  • comments
    59
  • views
    42089

Mouse DrIvEn CrAzY!

Sign in to follow this  
diablo_tk

75 views

Click here to download a NEW demo (.zip ~1.3mb)



Well as promised, I work mainly on Phill the Hungry Sheep today.

A few changes are:
* It's a mouse driven as I wanted it to be.
* Theres no pause when you get caught - this is in anticipation of music.

So to make things mouse driven I had to make buttons. I was thinking of making them objects and part of a more defined gui system - but for now it's a simple function (laugh if you must):

bool UI::OK(float x, float y)
{
if (PointInRect(Point2D(CInput::MouseX(), CInput::MouseY()), Rect(x, y, 64, 38)))
{
if (CInput::MouseDown(MOUSE_LEFT))
{
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("button-ok"), x, y, 1, true);
}
else
{
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("button-ok"), x, y, 0, true);
}

if (CInput::MousePressed(MOUSE_LEFT))
{
return true;
}
}
else
{
CGraphics::DrawImage((CImage*)CResourceManager::GetResource("button-ok"), x, y, 0, true);
}

return false;
}






(FYI I going to be getting rid of the C for Class).

So thats a simple hack.

I also added a new function to my graphics module which lets me draw a framed window from any given image.

void COpenGLGraphicsInterface::DrawImageFrame(CImage *image, float x, float y, float width, float height, float frameWidth, float frameHeight, bool noTransform)
{
float i, j;

i = j = 0.0f;

for (i = frameWidth; i < width - frameWidth * 1; i += frameWidth)
{
for (j = frameHeight; j < height - frameHeight * 1; j += frameHeight)
{
this->DrawImageWindow(image, x + i, y + j, frameWidth, frameHeight, frameWidth * 1, frameHeight * 1, frameWidth, frameHeight, noTransform);
}
}

for (i = frameWidth; i < width - frameWidth * 1; i += frameWidth)
{
this->DrawImageWindow(image, x + i, y, frameWidth, frameHeight, frameWidth * 1, 0, frameWidth, frameHeight, noTransform);
this->DrawImageWindow(image, x + i, y + (height - frameHeight), frameWidth, frameHeight, frameWidth * 1, frameHeight * 2, frameWidth, frameHeight, noTransform);
}

for (i = frameHeight; i < height - frameHeight * 1; i += frameHeight)
{
this->DrawImageWindow(image, x, y + i, frameWidth, frameHeight, 0, frameHeight * 1, frameWidth, frameHeight, noTransform);
this->DrawImageWindow(image, x + (width - frameWidth), y + i, frameWidth, frameHeight, frameWidth * 2, frameHeight * 1, frameWidth, frameHeight, noTransform);
}

this->DrawImageWindow(image, x, y, frameWidth, frameHeight, 0, 0, frameWidth, frameHeight, noTransform);
this->DrawImageWindow(image, x + (width - frameWidth), y, frameWidth, frameHeight, frameWidth * 2, 0, frameWidth, frameHeight, noTransform);
this->DrawImageWindow(image, x, y + (height - frameHeight), frameWidth, frameHeight, 0, frameHeight * 2, frameWidth, frameHeight, noTransform);
this->DrawImageWindow(image, x + (width - frameWidth), y + (height - frameHeight), frameWidth, frameHeight, frameWidth * 2, frameHeight * 2, frameWidth, frameHeight, noTransform);
}








Well thats about that for now.

FYI, my highest score is 5600, however giles got 7200 so, um, yea.

Simpsons
This is what I look like as a simpson in case you wanted to know:


Click here to download a NEW demo (.zip ~1.3mb)



Comments welcome.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now