Pounding head against wall.

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Pounding head against wall.

Post by thetoddfather » October 24th, 2012, 2:44 am

Grrr, second time writing this, accidentally refreshed.

Ok, I am rewriting the 'ScoreBoard' function in a new project. Got it implimented so it creates, opens, writes, edits, reads the file flawlessly.

So I began trying to add features to have the program read the file and print results to a highscore screen in the program.

So I created a function somewhat similar to this one (I have tried about twenty different ways):

Code: Select all

void PrintBoard()
{
	char buffer[64];
	sprintf(buffer,"Score: %d ",score );
	gfx.DrawString(buffer,x,y,&fixedSys,D3DCOLOR_XRGB(255,0,0));
	if(nextScore)
	{
	     nextScore->PrintBoard();
	}
				
}
However, as you may already be getting, I am getting all kinds of scope related, undefined and static related errors depending on how I try to impliment it. If I add this directly to the class it cannot recognize gfx and I get some illegal call to a non-static member from what I remember. If I define it in Game.cpp it's pretty much the same thing, or 'Game::gfx' : is not a type name, static, or enumerator.

I think I am missing something simple here to solve these issues, but for some reason it's not clicking. Can someone take a minute to explain how I should be creating/calling this function? There is something about this scope/static/who has access to what that is not quite registering in my brain.

Thanks!

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Pounding head against wall.

Post by thetoddfather » October 24th, 2012, 4:20 am

Did it!!

Few more hours of pouring over it and hitting the forums and I got it lol.
Don't think I need any help now. I'll post again if I do.

Thanks

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Pounding head against wall.

Post by chili » October 24th, 2012, 2:52 pm

Okay brah, glad you could figure it out on your own. Feel free to ask if you get stuck later. :)

P.S. What part of Canada are you from toddfather? I come from the homicide capital of Canada myself. ;)
Chili

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Pounding head against wall.

Post by thetoddfather » October 24th, 2012, 4:22 pm

Ya, I got it all working nicely. Saves, writes, reads and now prints to screen. Many of the concepts that have been eluding me, like when to pass a pointer to a function and how to use a pointer in a function etc, etc, etc... suddenly became clear. "Breakdown, breakthrough", what movie? So, I passed the functions pointers to gfx and font into the functions and the final working code looks like this:

Code: Select all

void Game::ScoreBoard::Score::PrintBoard(D3DGraphics* gfx, Font* fixedSys)
{
	if(scoreIndex <= 10)
	{
		if(scoreIndex <= 10)
		{
			char buffer[64];
			if(scoreIndex != 10)
			{
				sprintf(buffer," %d. %d",scoreIndex,score );
			}
			else
			{
				sprintf(buffer,"%d. %d",scoreIndex,score );
			}
		   gfx->DrawString(buffer,335,110+scoreYOff,fixedSys,D3DCOLOR_XRGB(255,0,0));
		}
	}
	if(nextScore)
	{
		scoreIndex++;
		scoreYOff += 25;
		nextScore->PrintBoard(gfx,fixedSys);
	}
	
}

void Game::ScoreBoard::PrintFirst(D3DGraphics* gfx, Font* fixedSys)
{
	if (firstScore)
	{
		scoreIndex = 0;
		if(scoreIndex < 10)
		{
			scoreIndex++;
		}
		scoreYOff = 0;
		firstScore->PrintBoard(gfx,fixedSys);
	}
}
Took many hours bashing my head against the desk for this to click for me. I was currently on Intermed 7, just at the point where we added full keyboard functionality. I am just watching the rest of 7 now, probably would have helped me a lot to complete this, but the struggle and experience was probably better for learning anyway. Thanks again.

I live in Vancouver my fellow Canadian friend. Born and raised in Langley, just outside of Van. I have family in Ottawa. Not much work there other than Gov, is that what led you to move to Japan? Have a few friends that moved there. You go there for programming related work/school? How many years you been there? You like it better there? Can pm me if you don't want your life story on the forums lol.

User avatar
Asimov
Posts: 814
Joined: May 19th, 2012, 11:38 pm

Re: Pounding head against wall.

Post by Asimov » October 24th, 2012, 9:18 pm

Hi TodFather,

Nice work getting your score to work.
I also save my highscores, but I have encoded mine. The one thing I won't share is my encoding algorithm as I developed it two years ago, and it is pretty hot heh heh.

Anyway here is my save dat file from my game. See if you can crack the code heh heh.
************************************************
***** Missile Command By Thomas R.Williams *****
************************************************
9KNGJuXfZrTUOXwXRwtNq2jwDGUJIwP6O12T
1MEDvDmeQHZBbDjeQHsQIqaAIMdPJ3KNGB7Z
1MUBBJCoIPP5bDYQNWIcIBfLOMWvZPGSGB7P
cHaBYPJbpuVGG6YGGKPdUQXEGJeUZYbHLB7V
7F1BLLfVYJZELoGAUlATIDIoXJJPIQOEEM2Z
GKYHpkNTDIJNRGKRROZW8Ov1ABfZPbORO8DJ
OKhHMMXV5FBMLdnAKIVc4nOJKJJcPCOEEFMB
Took me a while to implement it in the game though.
----> Asimov
"You know no matter how much I think I have learnt. I always end up hitting brick walls"
http://www.asimoventerprises.co.uk

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Pounding head against wall.

Post by thetoddfather » October 24th, 2012, 11:01 pm

That looks pretty complex. I think the most I'll ever do is maybe the binary method. Who knows? Depends how serious into this I get. I don't think I'll be cracking that any time soon lol.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: Pounding head against wall.

Post by chili » October 27th, 2012, 4:17 am

thetoddfather wrote: I live in Vancouver my fellow Canadian friend. Born and raised in Langley, just outside of Van. I have family in Ottawa. Not much work there other than Gov, is that what led you to move to Japan? Have a few friends that moved there. You go there for programming related work/school? How many years you been there? You like it better there? Can pm me if you don't want your life story on the forums lol.
I said the homicide capital, which I believe is still Winnipeg. :lol:

I moved to Japan mostly because I enjoy the language and because it's an interesting place to live. What I do here has little and less to do with programming I'm afraid. Maybe that's one of the reasons why I have this little project on YouTube. :)
Chili

User avatar
thetoddfather
Posts: 338
Joined: October 1st, 2012, 9:53 pm
Location: Canada

Re: Pounding head against wall.

Post by thetoddfather » October 27th, 2012, 5:52 pm

Ohhh, missed that little tidbit there haha. Apparently I need to be working on reading comprehension instead of my programming...

I thought I read somewhere Prince George waas, but maybe it was a different stat, like homicide per x number of peeps.

You enjoy the language? I don't believe I have ever heard anyone say quite such a thing.

"Oh hey Bill, I hear you're moving to Zambia? What's in Zambia?"
"Well John, I've gone through the process of moving from Canada to Zambia primarily because I enjoy their indigenous language."

Your an interesting chap, Chili, I'll give you that. Perhaps you should have been a linguistic Anthropologist...

I'll give you the interesting place to live thing. And I've been to Winnipeg, don't think I could live there but it's nice. Windy as all hell. Pretty sure many areas of Japan qualify for the 'more interesting place to live.' Their culture has to be the most interesting and often most bizaar. But I'd love to go. Do you speak/write/read well?

Post Reply