lesson 9 homework, help
Posted: May 19th, 2012, 3:29 pm
hi chili,
I have problem with lesson 9 homework
the thing is that the square dosen't want to move
can you check my code?
game.cpp
#include "Game.h"
Game::Game( HWND hWnd,const KeyboardServer& kServer )
: gfx ( hWnd ),
kbd( kServer ),
boxX( 200 ),
boxY( 100 ),
boxHeight( 150 ),
boxWidth( 150 )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::ComposeFrame()
{
int y = boxY;
int x = boxX;
while( y < boxY + boxHeight )
{
for(x < boxX + boxWidth; x++ )
{
gfx.PutPixel( x,y,255,255,255 );
}
y++;
}
int speed = 5;
if(kbd.RightIsPressed())
{
x = x + speed;
}
if(kbd.LeftIsPressed())
{
x = x - speed;
}
if(kbd.DownIsPressed())
{
y = y + speed;
}
if(kbd.UpIsPressed())
{
y = y - speed;
}
}
game.h
#pragma once
#include "D3DGraphics.h"
#include "Keyboard.h"
class Game
{
public:
Game( HWND hWnd,const KeyboardServer& kServer );
void Go();
private:
void ComposeFrame();
/********************************/
/* User Functions */
// TODO: User functions go here
/********************************/
private:
D3DGraphics gfx;
KeyboardClient kbd;
/********************************/
/* User Variables */
int boxX;
int boxY;
int boxWidth;
int boxHeight;
/********************************/
};
can you tell me what thing I fucked up?
I have problem with lesson 9 homework
the thing is that the square dosen't want to move
can you check my code?
game.cpp
#include "Game.h"
Game::Game( HWND hWnd,const KeyboardServer& kServer )
: gfx ( hWnd ),
kbd( kServer ),
boxX( 200 ),
boxY( 100 ),
boxHeight( 150 ),
boxWidth( 150 )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::ComposeFrame()
{
int y = boxY;
int x = boxX;
while( y < boxY + boxHeight )
{
for(x < boxX + boxWidth; x++ )
{
gfx.PutPixel( x,y,255,255,255 );
}
y++;
}
int speed = 5;
if(kbd.RightIsPressed())
{
x = x + speed;
}
if(kbd.LeftIsPressed())
{
x = x - speed;
}
if(kbd.DownIsPressed())
{
y = y + speed;
}
if(kbd.UpIsPressed())
{
y = y - speed;
}
}
game.h
#pragma once
#include "D3DGraphics.h"
#include "Keyboard.h"
class Game
{
public:
Game( HWND hWnd,const KeyboardServer& kServer );
void Go();
private:
void ComposeFrame();
/********************************/
/* User Functions */
// TODO: User functions go here
/********************************/
private:
D3DGraphics gfx;
KeyboardClient kbd;
/********************************/
/* User Variables */
int boxX;
int boxY;
int boxWidth;
int boxHeight;
/********************************/
};
can you tell me what thing I fucked up?