Need help with the 'Introduction to C++ with Game Development: Part 2' assignment

2b4c1c6a13566456f07e2d1ea837ef28
0
mrhelloworld 101 Dec 17, 2012 at 12:17

Hi,

I just started following the ‘Introduction to C++ with Game Development’ series of articles. Got stuck very soon though. Because English is not my mother tongue so I have some difficulties understanding some parts. In the assignment of part 2 you have to draw ‘IGAD’ on an 8x8 grid. Did that, using straight lines only. Well, kind of. I only got ‘IGA’ on my sheet. :P Here is what I drew on paper:

http://imageshack.us/photo/my-images/811/20121217131005.jpg/

Anyway, following the article, I thought I should have something like this (only for ‘I’):

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
m_Screen->Clear( 0 );
m_Screen->Print( "I", 2, 2, 0xffffff );
m_Screen->Line( 2, 9, 66, 9, 0xffffff );
m_Surface->Line( 60, 80, 60, 560, 0xffffff );
}

4 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 17, 2012 at 18:04

So, what is your actual question?

2b4c1c6a13566456f07e2d1ea837ef28
0
mrhelloworld 101 Dec 19, 2012 at 10:49

@Reedbeta

So, what is your actual question?

The code I wrote to draw ‘IGA’ is not correct. And I would not know how to write the right code. So I am kinda stuck.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Dec 19, 2012 at 18:24

It looks like you’re on the right track. I don’t think the Print() call belongs there as you’re supposed to draw it using lines only. You’ve got the m_Surface->Line() call for the ‘I’ there; now you just need to add additional lines for the ‘G’ and ‘A’. Just keep going.

2b4c1c6a13566456f07e2d1ea837ef28
0
mrhelloworld 101 Dec 22, 2012 at 19:48

@Reedbeta

It looks like you’re on the right track. I don’t think the Print() call belongs there as you’re supposed to draw it using lines only. You’ve got the m_Surface->Line() call for the ‘I’ there; now you just need to add additional lines for the ‘G’ and ‘A’. Just keep going.

That is very logical, thank you.

The thing is that it brings another issue op for me. The code I have right now (following your advise) is this (only drawing one line, the ‘I’):

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
    m_Screen->Clear( 0 );
    m_Screen->Line( 2, 9, 66, 9, 0xffffff );
    m_Surface->Line( 60, 80, 60, 560, 0xffffff );
}

That gives me the same errors (error C2065: ‘m_Surface’ : undeclared identifier and error C2227: left of ‘->Line’ must point to class/struct/union/generic type) though and nothing is drawn.

I do notice though that “ m_Screen->Line( 2, 9, 66, 9, 0xffffff );” does draw a horizontal line, so I tried that for drawing the ‘I’, so:

#include "string.h"
#include "surface.h"
#include "stdlib.h"
#include "template.h"
#include "game.h"
using namespace Tmpl8;
void Game::Init()
{

}
void Game::Tick( float a_DT )
{
    m_Screen->Clear( 0 );
    m_Screen->Line( 60, 80, 60, 560, 0xffffff );
}

That does not give me any errors, but draws an empty window?