I've tried and tried, but I can't fix some stuff to get the game working. I had a problem at around 25 minutes in the video, but I managed to fix that after a hour or 2. Now, I'm stuck at some stuff, because I just did what Chili did and it just don't freaking works!
Here's my game.cpp:
#include "Game.h"
Game( HWND hWnd,const KeyboardServer& kServer );
gfx ( hWnd ),
kbd( kServer )
faceX( 390 ),
faceY( 290 ),
poo1X( 100 ),
poo1Y( 100 ),
poo1IsEaten( false ),
poo2X( 650 ),
poo2Y( 200 ),
poo1IsEaten( false ),
poo3X( 300 ),
poo3Y( 510 ),
poo1IsEaten( false )
{}
void Game::Go()
{
gfx.BeginFrame();
ComposeFrame();
gfx.EndFrame();
}
void Game::DrawFace( int x,int y )
void Game::DrawPoo( int x, int y )
void Game::DrawGameOver( int x,int y )
void Game::ComposeFrame()
{
int speed;
speed = 3;
// adjust speed
if( kbd.EnterIsPressed() )
{
speed = 8;
}
if( kbd.SpaceIsPressed() )
{
speed = 1;
}
// move cursor
if( kbd.LeftIsPressed() )
{
faceX = faceX - speed;
}
if( kbd.RightIsPressed() )
{
faceX = faceX + speed;
}
if ( kbd.UpIsPressed() )
{
faceY = faceY - speed;
}
if( kbd.DownIsPressed() )
{
faceY = faceY + speed;
}
// clamp to window
if( faceX < 0 )
{
faceX = 0;
}
if( faceX + 20 > 799 )
{
faceX = 799 - 20;
}
if( faceY < 0 )
{
faceY = 0;
}
if( faceY + 20 > 599 )
{
faceY = 599 - 20;
}
if( !(poo1IsEaten && poo2IsEaten && poo3IsEaten ) )
{
if( !poo1IsEaten )
{
if( faceX + 20 > poo1X &&
faceX < poo1X + 24 &&
faceY + 20 > poo1Y &&
faceY < poo1Y + 24 )
{
poo1IsEaten = true;
}
DrawPoo( poo1X,poo1Y );
}
if( !poo2IsEaten )
{
if( faceX + 20 > poo2X &&
faceX < poo2X + 24 &&
faceY + 20 > poo2Y &&
faceY < poo2Y + 24 )
{
poo2IsEaten = true;
}
DrawPoo( poo2X,poo2Y );
}
if( !poo3IsEaten )
{
if( faceX + 20 > poo3X &&
faceX < poo3X + 24 &&
faceY + 20 > poo3Y &&
faceY < poo3Y + 24 )
{
poo3IsEaten = true;
}
DrawPoo( poo3X,poo3Y );
}
}
else
{
DrawGameOver( 375,275 );
}
DrawFace( faceX,faceY );
}
game.h:
Code: Select all
/******************************************************************************************
* Chili DirectX Framework Version 11.12.17 *
* Game.h *
* Copyright 2011 PlanetChili.net *
* *
* This file is part of The Chili DirectX Framework. *
* *
* The Chili DirectX Framework is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* The Chili DirectX Framework is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with The Chili DirectX Framework. If not, see <http://www.gnu.org/licenses/>. *
******************************************************************************************/
#pragma once
#include "D3DGraphics.h"
#include "Keyboard.h"
class Game
{
public:
Game( HWND hWnd,const KeyboardServer& kServer );
void Go();
private:
void ComposeFrame();
/********************************/
/* User Functions */
void DrawFace(int x,int y );
void DrawPoo(int x,int y );
void DrawGameOver(int x,int y );
/********************************/
private:
D3DGraphics gfx;
KeyboardClient kbd;
/********************************/
/* User Variables */
int faceX;
int faceY;
int poo1X;
int poo1Y;
bool Poo1IsEaten;
int poo2X;
int poo2Y;
bool Poo2IsEaten;
int poo3X;
int poo3Y;
bool Poo3IsEaten;
/********************************/
};
1>------ Build started: Project: Chili DirectX Framework, Configuration: Release Win32 ------
1>Build started 19-1-2012 20:40:51.
1>InitializeBuildStatus:
1> Touching "Release\Chili DirectX Framework.unsuccessfulbuild".
1>ClCompile:
1> Game.cpp
1>..\Assets\Game.cpp(23): error C2146: syntax error : missing ')' before identifier 'hWnd'
1>..\Assets\Game.cpp(23): error C2146: syntax error : missing ';' before identifier 'hWnd'
1>..\Assets\Game.cpp(23): error C2377: 'HWND' : redefinition; typedef cannot be overloaded with any other symbol
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\windef.h(208) : see declaration of 'HWND'
1>..\Assets\Game.cpp(23): error C2512: 'Game' : no appropriate default constructor available
1>..\Assets\Game.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(23): error C2143: syntax error : missing ';' before '&'
1>..\Assets\Game.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(23): warning C4228: nonstandard extension used : qualifiers after comma in declarator list are ignored
1>..\Assets\Game.cpp(23): error C2059: syntax error : ')'
1>..\Assets\Game.cpp(23): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(23): error C2530: 'kServer' : references must be initialized
1>..\Assets\Game.cpp(24): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(26): error C2146: syntax error : missing ';' before identifier 'faceX'
1>..\Assets\Game.cpp(26): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(27): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(29): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(30): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(31): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(32): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(33): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(33): error C2374: 'poo1IsEaten' : redefinition; multiple initialization
1> ..\Assets\Game.cpp(30) : see declaration of 'poo1IsEaten'
1>..\Assets\Game.cpp(34): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(35): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>..\Assets\Game.cpp(37): error C2448: 'poo1IsEaten' : function-style initializer appears to be a function definition
1>..\Assets\Game.cpp(2757): error C2065: 'poo2IsEaten' : undeclared identifier
1>..\Assets\Game.cpp(2757): error C2065: 'poo3IsEaten' : undeclared identifier
1>..\Assets\Game.cpp(2773): error C2065: 'poo2IsEaten' : undeclared identifier
1>..\Assets\Game.cpp(2780): error C2065: 'poo2IsEaten' : undeclared identifier
1>..\Assets\Game.cpp(2786): error C2065: 'poo3IsEaten' : undeclared identifier
1>..\Assets\Game.cpp(2793): error C2065: 'poo3IsEaten' : undeclared identifier
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.91
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
if you could only help a little bit to fix 1/60 errors I get, I would love to see what I did wrong.
Thanks