Click here to Skip to main content
15,884,298 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Please Upvote: C++/CLI: std::move causes std::unique_ptr parameter to be destructed before function call Pin
John Schroedl3-Jan-19 2:28
professionalJohn Schroedl3-Jan-19 2:28 
QuestionHow to catch exception caused by third party dll in c++? Pin
Sampath5797-Dec-18 0:22
Sampath5797-Dec-18 0:22 
AnswerRe: How to catch exception caused by third party dll in c++? Pin
Richard MacCutchan7-Dec-18 2:39
mveRichard MacCutchan7-Dec-18 2:39 
GeneralRe: How to catch exception caused by third party dll in c++? Pin
Sampath5797-Dec-18 2:58
Sampath5797-Dec-18 2:58 
GeneralRe: How to catch exception caused by third party dll in c++? Pin
Richard MacCutchan7-Dec-18 3:25
mveRichard MacCutchan7-Dec-18 3:25 
GeneralRe: How to catch exception caused by third party dll in c++? Pin
sameer.p.deshmukh9-Jan-19 1:02
sameer.p.deshmukh9-Jan-19 1:02 
QuestionHow to trace an unhandled exception in C++ using Visual Studio 2017 Pin
Dominick Marciano31-Oct-18 23:03
professionalDominick Marciano31-Oct-18 23:03 
AnswerRe: How to trace an unhandled exception in C++ using Visual Studio 2017 Pin
Richard MacCutchan31-Oct-18 23:55
mveRichard MacCutchan31-Oct-18 23:55 
GeneralRe: How to trace an unhandled exception in C++ using Visual Studio 2017 Pin
AndreyAksenov7-Dec-18 2:38
AndreyAksenov7-Dec-18 2:38 
GeneralRe: How to trace an unhandled exception in C++ using Visual Studio 2017 Pin
Richard MacCutchan7-Dec-18 3:22
mveRichard MacCutchan7-Dec-18 3:22 
AnswerRe: How to trace an unhandled exception in C++ using Visual Studio 2017 Pin
John Schroedl5-Nov-18 5:13
professionalJohn Schroedl5-Nov-18 5:13 
Questionmeaing of below code Pin
Member 139765087-Sep-18 22:01
Member 139765087-Sep-18 22:01 
AnswerRe: meaing of below code Pin
Richard MacCutchan7-Sep-18 22:32
mveRichard MacCutchan7-Sep-18 22:32 
AnswerRe: meaing of below code Pin
Victor Nijegorodov8-Sep-18 1:07
Victor Nijegorodov8-Sep-18 1:07 
Questionc++ sms send dll Pin
Member 139765087-Sep-18 1:07
Member 139765087-Sep-18 1:07 
AnswerRe: c++ sms send dll Pin
Richard MacCutchan7-Sep-18 2:38
mveRichard MacCutchan7-Sep-18 2:38 
AnswerRe: c++ sms send dll Pin
Victor Nijegorodov8-Sep-18 1:04
Victor Nijegorodov8-Sep-18 1:04 
AnswerRe: c++ sms send dll Pin
vidhya 360 com14-Oct-18 20:38
vidhya 360 com14-Oct-18 20:38 
QuestionSharpen filter of bmp image Pin
Jakub Bartczak27-Aug-18 21:21
Jakub Bartczak27-Aug-18 21:21 
AnswerRe: Sharpen filter of bmp image Pin
Jochen Arndt27-Aug-18 22:56
professionalJochen Arndt27-Aug-18 22:56 
Questionplease explain this lines of code Pin
Hiếu Ngô2-Aug-18 18:18
Hiếu Ngô2-Aug-18 18:18 
AnswerRe: please explain this lines of code Pin
Richard MacCutchan2-Aug-18 21:47
mveRichard MacCutchan2-Aug-18 21:47 
AnswerRe: please explain this lines of code Pin
Jochen Arndt2-Aug-18 22:29
professionalJochen Arndt2-Aug-18 22:29 
NewsC++/CLI support comes to ReSharper C++ Pin
John Schroedl23-Jul-18 6:22
professionalJohn Schroedl23-Jul-18 6:22 
QuestionTo find the angle of turn in a car racing game in C++/SFML Pin
Tarun Jha21-Jul-18 23:39
Tarun Jha21-Jul-18 23:39 
in the code below i would like to know how the logic of finding the angle at a turn works.

int main()
{
	RenderWindow app(VideoMode(640, 480), "Car Racing Game!");
	app.setFramerateLimit(60);

	Texture t1, t2;
	t1.loadFromFile("images/background.png");
	t2.loadFromFile("images/car.png");

	Sprite sBackground(t1), sCar(t2);
	sCar.setPosition(300, 300);
	sCar.setOrigin(22, 22);

	float x = 300, y = 300;
	float speed = 0, angle = 0;
	float maxSpeed = 12.0;
	float acc = 0.2, dec = 0.3;
	float turnSpeed = 0.08;

	while (app.isOpen())
	{
		Event event;
		while (app.pollEvent(event))
		{
			if (event.type == Event::Closed)
				app.close();
			if (Keyboard::isKeyPressed(Keyboard::Escape))
				app.close();
		}

		bool Up = false, Right = false, Down = false, Left = false;
		if (Keyboard::isKeyPressed(Keyboard::Up))		Up = true;
		if (Keyboard::isKeyPressed(Keyboard::Right))	Right = true;
		if (Keyboard::isKeyPressed(Keyboard::Down))		Down = true;
		if (Keyboard::isKeyPressed(Keyboard::Left))		Left = true;

		// Car Movements
		if (Up && speed < maxSpeed)
			if (speed < 0)	speed += dec;
			else speed += acc;

		if (Down && speed > -maxSpeed)
			if (speed > 0)	speed -= dec;
			else speed -= acc;

		if (!Up && !Down)
			if (speed - dec > 0)	speed -= dec;
			else if (speed + dec < 0)	speed += dec;
			else speed = 0;
                
                //--------- How this logic works ?
		if (Right && speed != 0)	angle += turnSpeed * speed / maxSpeed;
		if (Left && speed != 0)		angle -= turnSpeed * speed / maxSpeed;

		x += sin(angle) * speed ;
		y -= cos(angle) * speed ;
          
               //------------- //


		// Draw
		app.clear(Color::White);
		app.draw(sBackground);

		sCar.setPosition(x, y);
		sCar.setRotation(angle * 180 / 3.141592) ;
		sCar.setColor(Color::Red);
		app.draw(sCar);

		app.display();
	}
    return 0;
}


How the below logic works ?
Quote:
if (Right && speed != 0) angle += turnSpeed * speed / maxSpeed;
if (Left && speed != 0) angle -= turnSpeed * speed / maxSpeed;

x += sin(angle) * speed ;
y -= cos(angle) * speed ;


Thank you

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.