• Create Account

Posted 26 March 2012 - 11:15 PM

So i have been reading lazy foo's tuts and been playing around with SDL, i have created a little thing where if you click the dot should fly that way and be pulled down by gravity (it is really simple) the idea is kinda like angry birds very basic concept, however i keep getting werid results such as going really fast, shooting up and gravity breaking. So i was woundering is someone could have a look and help thanks i think its today with these parts,
void Dot::handle_input()
{
if(shoot == false)
{
if (event.type == SDL_MOUSEBUTTONDOWN)
{
if (event.button.button == SDL_BUTTON_LEFT)
{
int tempX,tempY;
tempX = event.button.x;
tempY = event.button.y;  //x,y
Gradient = (ceil(tempY - y) / (tempX - x));
xVel = 50;
shoot = true;

}
}
}
}

void Dot::handle_AI()
{
//Gravity
yVel = yVel + 1;
if((y >= SCREEN_HEIGHT) && (yVel >= 0))
{
yVel = 0;
}
}


if not this is everything http://pastebin.com/pfpd6LN5

Thanks for the help

### #1Rya729

Posted 26 March 2012 - 10:19 AM

So i have been reading lazy foo's tuts and been playing around with SDL, i have created a little thing where if you click the dot should fly that way and be pulled down by gravity (it is really simple) the idea is kinda like angry birds very basic concept, however i keep getting werid results such as going really fast, shooting up and gravity breaking. So i was woundering is someone could have a look and help thanks i think its today with these parts,
void Dot::handle_input()
{
if(shoot == false)
{
if (event.type == SDL_MOUSEBUTTONDOWN)
{
if (event.button.button == SDL_BUTTON_LEFT)
{
int tempX,tempY;
tempX = event.button.x;
tempY = event.button.y;  //x,y
Gradient = (ceil(tempY - y) / (tempX - x));
xVel = 50;
shoot = true;

}
}
}
}

void Dot::handle_AI()
{
//Gravity
yVel = yVel + 1;
if((y >= SCREEN_HEIGHT) && (yVel >= 0))
{
yVel = 0;
}
}


if not this is everything http://pastebin.com/pfpd6LN5

Thanks for the help

PARTNERS