Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualDarkHorseKnight

Posted 07 April 2012 - 04:39 PM

fekoekfe

#23DarkHorseKnight

Posted 07 April 2012 - 04:36 PM

How can I functionize this code?


if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
SDL_GetMouseState(x,y);
if(x <= 100, y <= 100)
{
cout << "Hello World" << endl;
}

}

I tried doing it like so


[color=#000000][font=Georgia,]if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))[/font][/color]
[color=#000000][font=Georgia,]{[/font][/color]
[color=#000000][font=Georgia,]	SDL_GetMouseState(x,y);[/font][/color]
[color=#000000][font=Georgia,]	if(x &lt;= 100, y &lt;= 100)[/font][/color]
[color=#000000][font=Georgia,]	{[/font][/color]
[color=#000000][font=Georgia,]		cout &lt;&lt; "Hello World" &lt;&lt; endl;[/font][/color]
[color=#000000][font=Georgia,]	}[/font][/color]
[color=#000000][font=Georgia,]	[/font][/color]
[color=#000000][font=Georgia,]}
[/font][/color]

I tried doing it like so

[color=#000000][font=Georgia,]
[/font][/color]

[color=#000000][font=Georgia,]void mousecheck(int x, int y , int checktype)[/font][/color]
[color=#000000][font=Georgia,]{[/font][/color]
[color=#000000][font=Georgia,]	SDL_GetMouseState(&x,&y);[/font][/color]
[color=#000000][font=Georgia,]	[/font][/color]
[color=#000000][font=Georgia,]	int xm;[/font][/color]
[color=#000000][font=Georgia,]	int ym;[/font][/color]
[color=#000000][font=Georgia,]	[/font][/color]
[color=#000000][font=Georgia,]	if(checktype == 1)[/font][/color]
[color=#000000][font=Georgia,]	{[/font][/color]
[color=#000000][font=Georgia,]		if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))[/font][/color]
[color=#000000][font=Georgia,]		{[/font][/color]
[color=#000000][font=Georgia,]			[/font][/color]
[color=#000000][font=Georgia,]			if(xm &lt;= x, xy &lt;= y)[/font][/color]
[color=#000000][font=Georgia,]			{[/font][/color]
[color=#000000][font=Georgia,]				cout &lt;&lt; "Hello this worked" &lt;&lt; endl;[/font][/color]
[color=#000000][font=Georgia,]			}[/font][/color]
[color=#000000][font=Georgia,]			[/font][/color]
[color=#000000][font=Georgia,]		}[/font][/color]
[color=#000000][font=Georgia,]		[/font][/color]
[color=#000000][font=Georgia,]		if(checktype == 0)[/font][/color]
[color=#000000][font=Georgia,]		{[/font][/color]
[color=#000000][font=Georgia,]			[/font][/color]
[color=#000000][font=Georgia,]			if(event.type == SDL_MOUSEBUTTONUP && SDL_BUTTON(SDL_BUTTON_LEFT))[/font][/color]
[color=#000000][font=Georgia,]			{[/font][/color]
[color=#000000][font=Georgia,]				[/font][/color]
[color=#000000][font=Georgia,]				if(xm &lt;= x, xy &lt;= y)[/font][/color]
[color=#000000][font=Georgia,]				{[/font][/color]
[color=#000000][font=Georgia,]					cout &lt;&lt; "Hello this worked" &lt;&lt; endl;[/font][/color]
[color=#000000][font=Georgia,]				}[/font][/color]
[color=#000000][font=Georgia,]			}[/font][/color]
[color=#000000][font=Georgia,]			[/font][/color]
[color=#000000][font=Georgia,]		}[/font][/color]
[color=#000000][font=Georgia,]		//end of function[/font][/color]
[color=#000000][font=Georgia,]	}[/font][/color]


but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?

#22DarkHorseKnight

Posted 07 April 2012 - 04:34 PM

How can I functionize this code?


if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
SDL_GetMouseState(x,y);
if(x <= 100, y <= 100)
{
cout << "Hello World" << endl;
}

}

I tried doing it like so


void mousecheck(int x, int y , int checktype)
{
	 SDL_GetMouseState(&x,&y);

	 int xm;
	 int ym;

  if(checktype == 1)
{
  if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
  
  if(xm <= x, xy <= y)
{	  
   cout << "Hello this worked" << endl;
}

}

  if(checktype == 0)
{

  if(event.type == SDL_MOUSEBUTTONUP && SDL_BUTTON(SDL_BUTTON_LEFT))
{

  if(xm <= x, xy <= y)
{
	  cout << "Hello this worked" << endl;
}
		 }

	 }
//end of function
}


but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?

#21DarkHorseKnight

Posted 07 April 2012 - 04:34 PM

How can I functionize this code?


if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
SDL_GetMouseState(x,y);
if(x <= 100, y <= 100)
{
cout << "Hello World" << endl;
}

}

I tried doing it like so


void mousecheck(int x, int y , int checktype)
{
	 SDL_GetMouseState(&x,&y);

	 int xm;
	 int ym;

  if(checktype == 1)
{

  if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
  
  if(xm <= x, xy <= y)
{	  
   cout << "Hello this worked" << endl;
}

}

  if(checktype == 0)
{

  if(event.type == SDL_MOUSEBUTTONUP && SDL_BUTTON(SDL_BUTTON_LEFT))
{

  if(xm <= x, xy <= y)
{
	  cout << "Hello this worked" << endl;
}

		 }

	 }
//end of function
}


but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?

#20DarkHorseKnight

Posted 07 April 2012 - 04:34 PM

How can I functionize this code?


if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
SDL_GetMouseState(x,y);
if(x <= 100, y <= 100)
{
cout << "Hello World" << endl;
}

}

I tried doing it like so


void mousecheck(int x, int y , int checktype)
{
	 SDL_GetMouseState(&x,&y);

	 int xm;
	 int ym;

  if(checktype == 1)
{

  if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
  
  if(xm <= x, xy <= y)
{	  
   cout << "Hello this worked" << endl;
}

}

  if(checktype == 0)
{

  if(event.type == SDL_MOUSEBUTTONUP && SDL_BUTTON(SDL_BUTTON_LEFT))
{

  if(xm <= x, xy <= y)
{
	  cout << "Hello this worked" << endl;
}

		 }

	 }
//end of function
}


but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?

#19DarkHorseKnight

Posted 07 April 2012 - 04:34 PM

How can I functionize this code?


if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
SDL_GetMouseState(x,y);
if(x <= 100, y <= 100)
{
cout << "Hello World" << endl;
}

}

I tried doing it like so


void mousecheck(int x, int y , int checktype)
{
	 SDL_GetMouseState(&x,&y);

	 int xm;
	 int ym;

  if(checktype == 1)
{

  if(event.type == SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_BUTTON_LEFT))
{
  
if(xm <= x, xy <= y)
{	  
   cout << "Hello this worked" << endl;
}

}

if(checktype == 0)
{

  if(event.type == SDL_MOUSEBUTTONUP && SDL_BUTTON(SDL_BUTTON_LEFT))
{

  if(xm <= x, xy <= y)
{
	  cout << "Hello this worked" << endl;
}

		 }

	 }
//end of function
}


but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?

PARTNERS