I am trying to make the character dissapear.

I am trying to make the 3D buzz game, but the eraseSprite function does not work as I want it to. I hoped it would go to the location of the sprite, but rather than that it reacts to my key presses. The reason I found out, was because my first move function messed up key input and sprite movement. That was fixed, but the erase (cout << ' ';) function still moves like the old sprite did.

key | sprite movement
-------------------
w | left
s | right
a | up
d | down

I have checked the erase function in DrawEngine.cpp and the erase function in sprite.cpp Is there another place where it can be located? I get no errors and it all works.

In sprite.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
bool Sprite::move(float x, float y)
{
	//erase sprite
    erase(pos.x, pos.y);


	pos.x += x;
	pos.y += y;

	facingDirection.x = x;
	facingDirection.y = y;

	//draw sprite
	draw(pos.x, pos.y);

	return true;
}


in DrawEngine.cpp
1
2
3
4
5
void DrawEngine::eraseSprite(int posx, int posy)
{
	gotoxy(posx, posy);
	cout << ' ';
}


If you want to see the gotoxy function:
1
2
3
4
5
6
7
8
9
10
11
12
void DrawEngine::gotoxy(int x, int y)
{
	HANDLE output_handle;
	COORD pos;

	pos.X = x;
	pos.Y = y;

	output_handle = GetStdHandle(STD_OUTPUT_HANDLE);
	
	SetConsoleCursorPosition(output_handle, pos);
}
Last edited on
Is there nor anyone who has done the tut?
Your description does not really outline your problem so it is very difficult to help you.
Instead of gotoxy and cout you can also use WriteConsoleOutputCharacter() ( http://msdn.microsoft.com/en-us/library/ms687410%28VS.85%29.aspx ).

Maybe you should try to output once another character than a space linke 'X'. That may help to fix your problem.
I agree. Perhaps your sprite's position has changed since you last couted it.
Topic archived. No new replies allowed.