Program
A program is set of instruction given by user to computer to perform a specific task.computer program, in depth intend or else process in lieu of solving a riddle by means of a computer; supplementary specifically, an unambiguous, well thought-out string of computational advice indispensable near attain such a solution.
Program Body
#include "MainWindow.h"
#include "Game.h"
Game::Game( MainWindow& wnd )
:
wnd( wnd ),
gfx( wnd )
{
}
void Game::Go()
{
gfx.BeginFrame();
UpdateModel();
ComposeFrame();
gfx.EndFrame();
}
void Game::UpdateModel()
{
x = x + vx;
y = y + vy;
if (wnd.kbd.KeyIsPressed(VK_UP)) {
if (iup) {
}
else {
vy = vy - 1;
iup = true;
}
}
else {
iup = false;
} if (wnd.kbd.KeyIsPressed(VK_DOWN)) {
if (idown) {
}
else {
vy = vy + 1;
idown = true;
}
} else{
idown = false;
}
if (wnd.kbd.KeyIsPressed(VK_LEFT)) {
if (ileft) {
}
else {
vx = vx - 1;
ileft = true;
}
}
else {
ileft = false;
}
if (wnd.kbd.KeyIsPressed(VK_RIGHT)) {
if (iright) {
}
else {
vx = vx + 1;
iright = true;
}
}
else {
iright = false;
}
shift = wnd.kbd.KeyIsPressed(VK_SHIFT);
};
void Game::ComposeFrame()
{
if (shift) {
gfx.PutPixel(x, y, 400, 0, color);
gfx.PutPixel(x + 1, y, 400, 0, color);
gfx.PutPixel(x + 2, y, 400, 0, color);
gfx.PutPixel(x + 8, y, 0, 400, color);
gfx.PutPixel(x + 9, y, 400, 0, color);
gfx.PutPixel(x + 10, y, 400, 0, color);
gfx.PutPixel(x - 3, y, 400, 0, color);
gfx.PutPixel(x - 3, y - 5, 400, 0, color);
gfx.PutPixel(x - 3, y - 5, 400, 0, color);
gfx.PutPixel(x, y, 0, 400, color);
gfx.PutPixel(x, y + 9, 400, 0, color);
gfx.PutPixel(x, y + 10, 400, 0, color);
}else{
gfx.PutPixel(x, y, color, 500, 0);
gfx.PutPixel(x + 1, y, color, 500, 0);
gfx.PutPixel(x + 2, y, color, 500, 0);
gfx.PutPixel(x + 3, y, color, 500, 0);
gfx.PutPixel(x, y + 1, color, 500, 0);
gfx.PutPixel(x, y + 2, color, 500, 0);
gfx.PutPixel(x, y + 3, color, 500, 0);
gfx.PutPixel(x, y, color, 500, 0);
gfx.PutPixel(x + 1, y + 1, color, 500, 0);
gfx.PutPixel(x + 2, y + 2, color, 500, 0);
gfx.PutPixel(x + 3, y + 3, color, 500, 0);
gfx.PutPixel(x + 4, y + 4, color, 500, 0);
gfx.PutPixel(x + 4, y + 1, color, 500, 0);
gfx.PutPixel(x + 3, y + 2, color, 500, 0);
gfx.PutPixel(x + 2, y + 3, color, 500, 0);
}
};