I keep getting the error missing: ';' before '.' Help

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
Craigspaz
Posts: 33
Joined: June 9th, 2012, 12:23 am

I keep getting the error missing: ';' before '.' Help

Post by Craigspaz » June 22nd, 2012, 8:59 pm

This part of the code is in game.h

Code: Select all

struct Fighter
	{
		int x;
		int y;
	};

This part of the code is in game.cpp

Code: Select all

void Game::UpdateGame()
{
	if( kbd.RightIsPressed() )
	{
		Fighter.x++;
	}

	if( kbd.LeftIsPressed() )
	{
		Fighter.x--;
	}

	if( kbd.UpIsPressed() )
	{
		Fighter.y++;
	}

	if( kbd.DownIsPressed() )
	{
		Fighter.y++;
	}
}
The error says syntax error missing : ';' before '.'

Does anybody know how to fix this?
CraigSpaz

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

Re: I keep getting the error missing: ';' before '.' Help

Post by chili » June 23rd, 2012, 1:11 am

Your problem probably lies elsewhere. Read the rules and post your solution folder. We will help you.
Chili

Craigspaz
Posts: 33
Joined: June 9th, 2012, 12:23 am

Re: I keep getting the error missing: ';' before '.' Help

Post by Craigspaz » June 23rd, 2012, 1:50 am

I attached my solution.
Attachments
MYGAME.zip
(653.47 KiB) Downloaded 156 times
CraigSpaz

User avatar
zentojamorn
Posts: 10
Joined: May 22nd, 2012, 4:22 am

Re: I keep getting the error missing: ';' before '.' Help

Post by zentojamorn » June 23rd, 2012, 3:45 am

Errors are from struct that you declared in Game.h.
You treat struct-name as variable.

You code should be like

Code: Select all

	
struct Character
	{
		int lookingup_x;
		int lookingupt_y;
		int lookingleft_x;
		int lookingleft_y;
		int lookingdown_x;
		int lookingdown_y;
		int lookingright_x;
		int lookingright_y;
	}Fighter,BlueEnemy,BlueRedWhiteEnemy,BlueRedWhiteBigEnemy,BlueYellowEnemy,BlueYellowRedEnemy,BossEnemy;
Download link below will help you understand more about struct.
Attachments
Test2.zip
Example of how to using Struct.
(714.96 KiB) Downloaded 127 times
Sorry for my poor english..

Craigspaz
Posts: 33
Joined: June 9th, 2012, 12:23 am

Re: I keep getting the error missing: ';' before '.' Help

Post by Craigspaz » June 23rd, 2012, 10:57 am

Thanks it helped a lot.
CraigSpaz

Post Reply