lesson 9 homework, help

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
kacper130320
Posts: 50
Joined: May 19th, 2012, 3:00 pm

lesson 9 homework, help

Post by kacper130320 » 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?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: lesson 9 homework, help

Post by chili » May 19th, 2012, 3:50 pm

You're updating x and y when you should be updating boxX and boxY.
Chili

kacper130320
Posts: 50
Joined: May 19th, 2012, 3:00 pm

Re: lesson 9 homework, help

Post by kacper130320 » May 19th, 2012, 7:01 pm

thx, and when I will finish waching your tutorials, than is it possible to use your framework for making 3d games or only 2d?

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: lesson 9 homework, help

Post by chili » May 20th, 2012, 2:32 am

I will eventually be covering 3D graphics. Whether you will be able to make 3D games depends on you bro. ;)
Chili

kacper130320
Posts: 50
Joined: May 19th, 2012, 3:00 pm

Re: lesson 9 homework, help

Post by kacper130320 » May 20th, 2012, 12:09 pm

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?

Post Reply