0
101 Feb 15, 2012 at 15:59

I’ve been following the tutorials and there weren’t any problems until part 9 and 12. I am still struggling with part 9, but
part 12 is something I think I am not able to solve. My code was this:

// Template, major revision 3
// IGAD/NHTV - Jacco Bikker - 2006-2009

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"

using namespace Tmpl8;

class Tank
{
public:
Tank()
{
x = 0;
y = 4 * 64;
rotation = 0;
}
void Move( Surface* a_Screen)
{
x++;
if ( x > ( 16 * 64 ) ) x = 0;
tank.Draw( x, y, a_Screen );
}
int x, y, rotation;
};

Tank mytank;

void Game::Init()
{

}

void Game::Tick( float a_DT )
{
mytank.Move( m_Screen );
}


The errors I got:
1>c:\-\part12\game.cpp(25) : error C2065: ‘tank’ : undeclared identifier
1>c:\-\part12\game.cpp(25) : error C2228: left of ‘.Draw’ must have class/struct/union

I thought it was weird, since this is exactly what was written in the tutorial. Luckily, I thought I understood the problem, so I
changed ‘tank.Draw’ to ‘Tank.Draw’. Unfortunately, this gave me these errors (both the same?):
1>c:\-\part12\game.cpp(25) : error C2143: syntax error : missing ‘;’ before ‘.’
1>c:\-\part12\game.cpp(25) : error C2143: syntax error : missing ‘;’ before ‘.’

This is where I got stuck..does anyone know how to solve this problem?

Rimevan

#### 2 Replies

0
101 Feb 15, 2012 at 23:19

I can’t find the source code for Part 12, but seeing the others, the “tank” from the line “tank.Draw( x, y, a_Screen );” is a Sprite object, not the Tank class’ instance. The Sprite object is the “image” what you draw to the screen. Don’t you miss a line like this “Sprite theSprite( new Surface(“assets/ctankbase.tga”), 16 );” somewhere?

0
101 Feb 16, 2012 at 14:18

@jari

I can’t find the source code for Part 12, but seeing the others, the “tank” from the line “tank.Draw( x, y, a_Screen );” is a Sprite object, not the Tank class’ instance. The Sprite object is the “image” what you draw to the screen. Don’t you miss a line like this “Sprite theSprite( new Surface(“assets/ctankbase.tga”), 16 );” somewhere?

Ah, that’s quite obvious=/ Thanks for the help, putting

Sprite tank( new Surface("assets/ctankbase.tga"), 16 );


just above the Tank class solved the problem.

Rimevan