Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualXooch

Posted 26 April 2013 - 08:53 PM

Hey there,

 

I've rendered 4 zones which have an x,y,z coordinate and are all 100.0f by 100.0f and completely flat across the 'z' axis, resulting in this: 

gridfromabove.png

 

Now, I have a struct which holds the coordinates of a player in 3D space

struct PLAYER
{
      float x, y, z;
};
PLAYER Player

 

and I want to check if the player's coordinates are inside the more or less 2D grid, it doesn't need to check against the y axis as the player can not move up or down the y axis.

 

The problem is my CheckZone() function I am trying to create, so far it looks like this, but I'm struggling to work to this as I on a basic level for programming:

 

void Application::CheckZone()
{
	Player = {Player.x, Player.y, Player.y};

	float Section1[4][2] =
	{
		{0.0f, 0.0f},
		{0.0f, 80.f},
		{80.0f, 0.0f},
		{80.0f, 0.0f}
	};

	if(Player == Section1[][])
	{
		//Trigger element in Section1
	}

 

I'm getting "Error: expected an expression" from the 2 array boxes in the if statement, as well as the Player statement, I'm having trouble understanding some basic programming here, any help would be greatly appreciated 

 

 

EDIT: On closer inspection the title can be mis-leading, I'm not trying to check an object against an object, instead the coordinates for the grid which are decoupled from these arrays.


#1Xooch

Posted 26 April 2013 - 08:52 PM

Hey there,

 

I've rendered 4 zones which have an x,y,z coordinate and are all 100.0f by 100.0f and completely flat across the 'z' axis, resulting in this: 

gridfromabove.png

 

Now, I have a struct which holds the coordinates of a player in 3D space

struct PLAYER
{
      float x, y, z;
};
PLAYER Player

 

and I want to check if the player's coordinates are inside the more or less 2D grid, it doesn't need to check against the y axis as the player can not move up or down the y axis.

 

The problem is my CheckZone() function I am trying to create, so far it looks like this, but I'm struggling to work to this as I on a basic level for programming:

 

void Application::CheckZone()
{
	Player = {Player.x, Player.y, Player.y};

	float Section1[4][2] =
	{
		{0.0f, 0.0f},
		{0.0f, 80.f},
		{80.0f, 0.0f},
		{80.0f, 0.0f}
	};

	if(Player == Section1[][])
	{
		//Trigger element in Section1
	}

 

I'm getting "Error: expected an expression" from the 2 array boxes in the if statement, as well as the Player statement, I'm having trouble understanding some basic programming here, any help would be greatly appreciated 

 

 


PARTNERS