Show differencesHistory of post edits
#23DarkHorseKnight
Posted 07 April 2012 - 04:36 PM
How can I functionize this code?
I tried doing it like so
I tried doing it like so
[color=#000000][font=Georgia,]
but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?
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 <= 100, y <= 100)[/font][/color]
[color=#000000][font=Georgia,] {[/font][/color]
[color=#000000][font=Georgia,] cout << "Hello World" << 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 <= x, xy <= y)[/font][/color]
[color=#000000][font=Georgia,] {[/font][/color]
[color=#000000][font=Georgia,] cout << "Hello this worked" << 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 <= x, xy <= y)[/font][/color]
[color=#000000][font=Georgia,] {[/font][/color]
[color=#000000][font=Georgia,] cout << "Hello this worked" << 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?
I tried doing it like so
but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?
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?
I tried doing it like so
but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?
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?
I tried doing it like so
but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?
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?
I tried doing it like so
but that caused crashes for some reason ? probably because of memory but still has anyone got any ideas ?
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 ?