I'm hoping that somebody can get some use out of it. Anyways the code is posted below.
(P.S. The code can be manipulated to draw any 4 sided shape, however it is set to a rectangle right now in the code below)
Here's the code that belongs in the Game.cpp file
Code: Select all
Game::Game( HWND hWnd,const KeyboardServer& kServer,const MouseServer& mServer )
: gfx( hWnd ),
audio( hWnd ),
kbd( kServer ),
mouse( mServer ),
x1( 400 ),
y1( 300 ),
x2( 450 ),
y2( 300 ),
x3( 450 ),
y3( 310 ),
x4( 400 ),
y4( 310 ),
r( 255 ),
g( 255 ),
b( 255 )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::ComposeFrame()
{
gfx.Draw4DShape(x1,y1,x2,y2,x3,y3,x4,y4,r,g,b);
}
Code: Select all
void Draw4SidedShape(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int r,int g,int b);
Code: Select all
void D3DGraphics::Draw4SidedShape(int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4,int r,int g,int b)
{
DrawLine(x1,y1,x2,y2,r,g,b);
DrawLine(x2,y2,x3,y3,r,g,b);
DrawLine(x3,y3,x4,y4,r,g,b);
DrawLine(x4,y4,x1,y1,r,g,b);
}