so what you're saying is reguardless if i make it true or false, wont matter if i have
also this is my code as of right now chili gave us homework which was too, make it so when the cursor collides with the other cursor it changes colors this is this code i have.
Code: Select all
void Game::Go()
{
gfx.BeginFrame();
UpdateModel();
ComposeFrame();
gfx.EndFrame();
}
void Game::UpdateModel()
{
if (x + 5 >= gfx.ScreenWidth)
{
x = gfx.ScreenWidth - 6;
vx = 0;
}
if (x - 5 < 0)
{
x = 5;
}
if (y + 5 >= gfx.ScreenHeight)
{
y = gfx.ScreenHeight - 6;
vy = 0;
}
if (y - 5 < 0)
{
y = 5;
}
if (wnd.kbd.KeyIsPressed(VK_UP))
{
if (inhibitUp)
{
}
else
{
vy = vy - 1;
inhibitUp = true;
}
}
else
{
inhibitUp = false;
}
if (wnd.kbd.KeyIsPressed(VK_DOWN))
{
if (inhibitDown)
{
}
else
{
vy = vy + 1;
inhibitDown = true;
}
}
else
{
inhibitDown = false;
}
if (wnd.kbd.KeyIsPressed(VK_LEFT))
{
if (inhibitLeft)
{
}
else
{
vx = vx - 1;
inhibitLeft = true;
}
}
else
{
inhibitLeft = false;
}
if (wnd.kbd.KeyIsPressed(VK_RIGHT))
{
if (inhibitRight)
{
}
else
{
vx = vx + 1;
inhibitRight = true;
}
}
else
{
inhibitRight = false;
}
x = x + vx;
y = y + vy;
controlIsPressed = wnd.kbd.KeyIsPressed(VK_CONTROL);
shapeIsChanged = wnd.kbd.KeyIsPressed(VK_SHIFT);
shapeIsChanged = false;
if (x < 200 || x > 300 )
{
shapeIsChanged = true;
}
}
void Game::ComposeFrame()
{
if(ExtraBox)
{
gb3 = 0;
gfx.PutPixel(5 + x2, y2, 255, gb2, gb3);
gfx.PutPixel(4 + x2, y2, 255, gb2, gb3);
gfx.PutPixel(3 + x2, y2, 255, gb2, gb3);
gfx.PutPixel(x2, 3 + y2, 255, gb2, gb3);
gfx.PutPixel(x2, 4 + y2, 255, gb2, gb3);
gfx.PutPixel(x2, 5 + y2, 255, gb2, gb3);
gfx.PutPixel(-5 + x2, y2, 255,gb2, gb3);
gfx.PutPixel(-4 + x2, y2, 255,gb2, gb3);
gfx.PutPixel(-3 + x2, y2, 255,gb2, gb3);
gfx.PutPixel(x2, -3 +y2, 255, gb2, gb3);
gfx.PutPixel(x2, -4 +y2, 255, gb2, gb3);
gfx.PutPixel(x2, -5 +y2, 255, gb2, gb3);
}
if (shapeIsChanged)
{
gfx.PutPixel(5 + x, y, 255, gb, gb);
gfx.PutPixel(5 + x,1 + y, 255, gb, gb);
gfx.PutPixel(5 + x,2 + y, 255, gb, gb);
gfx.PutPixel(4 + x,3 + y, 255, gb, gb);
gfx.PutPixel(3 + x,3 + y, 255, gb, gb);
gfx.PutPixel(2 + x,3 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, -0 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, -1 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, -2 + y, 255, gb, gb);
gfx.PutPixel(-4 + x,-3 + y, 255, gb, gb);
gfx.PutPixel(-3 + x,-3 + y, 255, gb, gb);
gfx.PutPixel(-2 + x,-3 + y, 255, gb, gb);
}
else
{
gfx.PutPixel(5 + x, y, 255, gb, gb);
gfx.PutPixel(4 + x, y, 255, gb, gb);
gfx.PutPixel(3 + x, y, 255, gb, gb);
gfx.PutPixel(x, 3 + y, 255, gb, gb);
gfx.PutPixel(x, 4 + y, 255, gb, gb);
gfx.PutPixel(x, 5 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, y, 255, gb, gb);
gfx.PutPixel(-4 + x, y, 255, gb, gb);
gfx.PutPixel(-3 + x, y, 255, gb, gb);
gfx.PutPixel(x, -3 + y, 255, gb, gb);
gfx.PutPixel(x, -4 + y, 255, gb, gb);
gfx.PutPixel(x, -5 + y, 255, gb, gb);
}
if (controlIsPressed)
{
gb = 0;
gfx.PutPixel(5 + x, y, 255, gb, gb);
gfx.PutPixel(4 + x, y, 255, gb, gb);
gfx.PutPixel(3 + x, y, 255, gb, gb);
gfx.PutPixel(x, 3 + y, 255, gb, gb);
gfx.PutPixel(x, 4 + y, 255, gb, gb);
gfx.PutPixel(x, 5 + y, 255, gb, gb);
gfx.PutPixel(-5 + x, y, 255, gb, gb);
gfx.PutPixel(-4 + x, y, 255, gb, gb);
gfx.PutPixel(-3 + x, y, 255, gb, gb);
gfx.PutPixel(x, -3 + y, 255, gb, gb);
gfx.PutPixel(x, -4 + y, 255, gb, gb);
gfx.PutPixel(x, -5 + y, 255, gb, gb);
}
}
in short i was able to get a box to appear i just didn't know how to make it "Collide" and i gave up and as soon i looked up the video chili freaking had bool colliding = false; or true; one of the two and i went OMG I KNEW IT! i was so mad that i gave up and looked cause i knew somehow i had to make it collide or write the code cause there was nothing