Page 1 of 1

lesson 9 homework, help

Posted: May 19th, 2012, 3:29 pm
by kacper130320
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?

Re: lesson 9 homework, help

Posted: May 19th, 2012, 3:50 pm
by chili
You're updating x and y when you should be updating boxX and boxY.

Re: lesson 9 homework, help

Posted: May 19th, 2012, 7:01 pm
by kacper130320
thx, and when I will finish waching your tutorials, than is it possible to use your framework for making 3d games or only 2d?

Re: lesson 9 homework, help

Posted: May 20th, 2012, 2:32 am
by chili
I will eventually be covering 3D graphics. Whether you will be able to make 3D games depends on you bro. ;)

Re: lesson 9 homework, help

Posted: May 20th, 2012, 12:09 pm
by kacper130320
ok thx,
so it's possible to make something similar game to minecraft using your framework
or do i have to use a different framework
and if you can make it than how long will it take about to make the basics of it?