# Rya729

Members

2

100 Neutral

• Rank
Newbie

• Location
England
1. ## Basic game phyics problem

Thanks for the input guys. However i have wrote this and i have a problem, so any help would be great. [code] #include <iostream> #define _USE_MATH_DEFINES #include <math.h> int main() { int x = 0; int y = 380; int clickX = 40; int clickY = 360; float angleRadians,angleDregees,maxVelocity; float xVel,yVel; int b; maxVelocity = 100; //The angle in radians angleRadians = atan((y-clickY)/(clickX-x)); //The angle in degrees angleDregees = (angleRadians * 180 / M_PI); //velocitys xVel = ceil(((90-angleDregees)/90)*maxVelocity); yVel = ceil((angleDregees/90)*maxVelocity); std::cout << "angle in radians :" << angleRadians << std::endl; std::cout << "angle in degees :" << angleDregees << std::endl; std::cout << "xVelocity :" << xVel << std::endl; std::cout << "yVelocity :" << yVel << std::endl; std::cin >> b; } [/code] It ethier gives me 100 xVel or 100 yVel or 50/50. When i change the values, thanks for any help
2. ## Basic game phyics problem

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, [code] void Dot::handle_input() { if(shoot == false) { if (event.type == SDL_MOUSEBUTTONDOWN) { if (event.button.button == SDL_BUTTON_LEFT) { int tempX,tempY; int Gradient; tempX = event.button.x; tempY = event.button.y; //x,y Gradient = (ceil(tempY - y) / (tempX - x)); xVel = 50; yVel = 50*Gradient; shoot = true; } } } } void Dot::handle_AI() { //Gravity yVel = yVel + 1; if((y >= SCREEN_HEIGHT) && (yVel >= 0)) { yVel = 0; } } [/code] if not this is everything [url="http://pastebin.com/pfpd6LN5"]http://pastebin.com/pfpd6LN5[/url] Thanks for the help