help with introduction to c++ part 8

62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 08, 2013 at 10:26

i am having trouble figuring out the second assignment for this week, i have been browsing devmaster, but didnt find anything. if anyone knows how to do this, please help.

here is the link to the assignment: http://devmaster.net/posts/2850/introduction-to-c-with-game-development-part-8-memory-addresses-and-pointers

8 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Oct 08, 2013 at 16:04

What specifically are you having trouble with? The second assignment has several parts.

62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 11:25

i am having trouble with loading the image, i can not even start with the rest without first having an image getting loaded. when i have the image loaded, i start on the next part of the assignment. i have already made an image to use.

62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 11:54

thanks for trying to help me out :)

62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 11:45

ok, i figured it out, i have to convert the image to a .tga file and then load it as a sprite for some reason, devmaster is placing my code weird, but you are probably able to make that out yourself

the code to load the image is:

Sprite TheSprite( new Surface("image name"), 1);
void Game::Tick( float a_DT )
{
	TheSprite.Draw( 0, 0, m_Screen);
}
62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 12:07

well, now i am stuck on the next part of the assignment

62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 14:10

i am now using this code:

Sprite theSprite (new Surface("image.jpg"),1);

int whiteX= 320;
int y = 1;

void Game::Tick( float a_DT )
{
	theSprite.Draw(0,0, m_Screen);
	Pixel* white = m_Screen->GetBuffer();
	white[whiteX + (640*y)] = 0x0000ff;
	if (white[whiteX + (640 * (y + 1))] == 0xff000000) y++;
	if (white[whiteX + (640 * (y + 1))] == 0xff000000)
	{
		if(y % 2 == 0) whiteX += 1;
		else whiteX -= 1;
	}
}
62729b540737c9893b8005b272fa96fa
0
Leaf 101 Oct 09, 2013 at 14:11

also, how do i add these grey code blocks i see on devmaster

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Oct 09, 2013 at 16:32

Code blocks can be created on the forum by indenting the code by four spaces or one tab (we use Markdown for formatting). I edited your previous posts to fix that.

So it sounds like you’ve got the basic idea. You just need to finish implementing the logic specified in the assignment. You also need to erase the previous white dot when you move it, and draw it in the new position.