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

Managed C++/CLI

 
AnswerRe: To find the angle of turn in a car racing game in C++/SFML Pin
John Schroedl23-Jul-18 6:41
professionalJohn Schroedl23-Jul-18 6:41 
Consider the two chunks of code separately.

The first two lines are updating angle by a fraction of turnSpeed. If speed were == maxSpeed then speed/maxSpeed = 1. So angle += turnSpeed for a right-turn. turnSpeed = 0.08 so that's in Radians which is 4.58 degrees. This means if you're turning right or left at max speed, it'll add or remove 4.58 degrees each time through. If speed is less than the max, then the angle will change by a smaller amount (a fraction of .08 radians). Try it in the debugger and see the change.

The last two lines are updating the x,y location of the car using it's orientation (angle). cos(angle) is typically the x portion of an angle so I'm not sure why it modifies the y coor with that but that's what it does. sin(angle) or cos(angle) produces a value from 0-1 (which it uses as a percentage) * speed. That means x or y changes by a fraction of speed in the direction of angle.

It would probably help you to print out the values or use the debugger.

Hope this helps,
John
GeneralRe: To find the angle of turn in a car racing game in C++/SFML Pin
Tarun Jha25-Jul-18 7:36
Tarun Jha25-Jul-18 7:36 
QuestionSmall RAII-like cleanup class in C++/CLI Pin
John Schroedl15-Jun-18 9:08
professionalJohn Schroedl15-Jun-18 9:08 
QuestionInformation Edit Source code for c++ Pin
Member 1165875229-May-18 19:48
Member 1165875229-May-18 19:48 
AnswerRe: Information Edit Source code for c++ Pin
Richard MacCutchan29-May-18 21:05
mveRichard MacCutchan29-May-18 21:05 
AnswerRe: Information Edit Source code for c++ Pin
Jochen Arndt30-May-18 2:55
professionalJochen Arndt30-May-18 2:55 
QuestionError On a Project I'm Working On. (Sorry If Not descriptive enough, 1st time) Pin
CyberFaggot9-May-18 15:53
CyberFaggot9-May-18 15:53 
AnswerRe: Error On a Project I'm Working On. (Sorry If Not descriptive enough, 1st time) Pin
Richard MacCutchan11-May-18 21:19
mveRichard MacCutchan11-May-18 21:19 
QuestionPrint causes in afxtls.cpp Pin
Erich Ruth19-Apr-18 5:37
Erich Ruth19-Apr-18 5:37 
AnswerRe: Print causes in afxtls.cpp Pin
Richard Andrew x6413-May-18 7:22
professionalRichard Andrew x6413-May-18 7:22 
QuestionWhat is the alternative of _kbhit_ in linux ? Pin
Tarun Jha16-Apr-18 4:04
Tarun Jha16-Apr-18 4:04 
AnswerRe: What is the alternative of _kbhit_ in linux ? Pin
Maria Okta25-Jul-18 19:23
professionalMaria Okta25-Jul-18 19:23 
QuestionMore Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 5:26
Paramu197313-Apr-18 5:26 
QuestionRe: More Than One Operator "+" Matches These Operands Pin
Richard MacCutchan13-Apr-18 5:51
mveRichard MacCutchan13-Apr-18 5:51 
AnswerRe: More Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 6:05
Paramu197313-Apr-18 6:05 
GeneralRe: More Than One Operator "+" Matches These Operands Pin
Richard MacCutchan13-Apr-18 6:40
mveRichard MacCutchan13-Apr-18 6:40 
GeneralRe: More Than One Operator "+" Matches These Operands Pin
Paramu197313-Apr-18 14:18
Paramu197313-Apr-18 14:18 
QuestionHow to access the ref class declared DataTable ? Pin
Paramu197311-Apr-18 21:10
Paramu197311-Apr-18 21:10 
SuggestionRe: How to access the ref class declared DataTable ? Pin
Richard MacCutchan11-Apr-18 22:53
mveRichard MacCutchan11-Apr-18 22:53 
GeneralRe: How to access the ref class declared DataTable ? Pin
Paramu197312-Apr-18 1:42
Paramu197312-Apr-18 1:42 
GeneralRe: How to access the ref class declared DataTable ? Pin
Richard MacCutchan12-Apr-18 2:26
mveRichard MacCutchan12-Apr-18 2:26 
GeneralRe: How to access the ref class declared DataTable ? Pin
Paramu197312-Apr-18 7:50
Paramu197312-Apr-18 7:50 
QuestionString class using dynamic memory allocation Pin
Member 137677597-Apr-18 12:12
Member 137677597-Apr-18 12:12 
QuestionRe: String class using dynamic memory allocation Pin
Richard MacCutchan7-Apr-18 21:04
mveRichard MacCutchan7-Apr-18 21:04 
AnswerRe: String class using dynamic memory allocation Pin
Gerry Schmitz8-Apr-18 7:11
mveGerry Schmitz8-Apr-18 7:11 

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.