Click here to Skip to main content
15,891,657 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Split window in MDI Pin
Jochen Arndt8-May-12 21:04
professionalJochen Arndt8-May-12 21:04 
AnswerOdd MFC Dialog Executable Behavior Pin
wmallory8-May-12 8:20
wmallory8-May-12 8:20 
QuestionRe: Odd MFC Dialog Executable Behavior Pin
David Crow8-May-12 9:26
David Crow8-May-12 9:26 
GeneralRe: Odd MFC Dialog Executable Behavior Pin
Code-o-mat8-May-12 10:32
Code-o-mat8-May-12 10:32 
QuestionDiff of image Pin
john56328-May-12 1:06
john56328-May-12 1:06 
GeneralRe: Diff of image Pin
David Crow8-May-12 2:49
David Crow8-May-12 2:49 
QuestionSwitch To Another Doc Template Pin
002comp8-May-12 0:01
002comp8-May-12 0:01 
QuestionNeed help with my jump physics code Pin
Seeker20027-May-12 19:46
Seeker20027-May-12 19:46 
I need some help with the jump physics example I found on the web.

The following code makes my character go up and down, but I have to press and hold down the arrow-up key on my keyboard.

I want my character to complete a full jump cycle without having to hold the arrow-up key down.

I want to be able to press down on the key once and release to do a complete jump.

Do I need to somehow include a do while loop? :confused

Thanks! Smile | :)

C++
bool jumping;
const float step = 0.05f;      // how much the player will move per frame when jumping
const float limit = 1.0f;     // the maximum height the player can reach while jumping

if (GetAsyncKeyState(VK_UP)== TRUE)     // jump key
{

static float jump = 0.0f;
static float strength = limit;

if(jumping){

jump += step;

if(jump <= limit){

strength -= step;

player.y += (step * strength);
}
else{
strength += step;

// detect if moving the player down would put him below the ground
// 0.0f is assumed to be the ground here

if(player.y - (step * strength) <= 0.0f)){
player.y = 0.0f;

jumping = false;   // the player has landed
jump = 0.0f;
strength = limit;   // reset the strength
}

else{
player.y -= (step * strength);
}
}
}
// rest of rendering...
}

AnswerRe: Need help with my jump physics code Pin
Chuck O'Toole7-May-12 19:55
Chuck O'Toole7-May-12 19:55 
GeneralRe: Need help with my jump physics code Pin
Seeker20027-May-12 21:43
Seeker20027-May-12 21:43 
AnswerRe: Need help with my jump physics code Pin
CPallini8-May-12 0:03
mveCPallini8-May-12 0:03 
GeneralRe: Need help with my jump physics code Pin
Chuck O'Toole8-May-12 3:50
Chuck O'Toole8-May-12 3:50 
GeneralRe: Need help with my jump physics code Pin
CPallini8-May-12 3:52
mveCPallini8-May-12 3:52 
GeneralRe: Need help with my jump physics code Pin
Seeker20029-May-12 21:42
Seeker20029-May-12 21:42 
GeneralRe: Need help with my jump physics code Pin
CPallini9-May-12 21:55
mveCPallini9-May-12 21:55 
Questionallocating object in global storage Pin
ForNow7-May-12 15:21
ForNow7-May-12 15:21 
AnswerRe: allocating object in global storage Pin
Richard MacCutchan7-May-12 21:50
mveRichard MacCutchan7-May-12 21:50 
AnswerRe: allocating object in global storage Pin
ThatsAlok9-May-12 21:17
ThatsAlok9-May-12 21:17 
AnswerRe: allocating object in global storage Pin
Erudite_Eric9-May-12 21:27
Erudite_Eric9-May-12 21:27 
GeneralRe: allocating object in global storage Pin
ForNow10-May-12 2:50
ForNow10-May-12 2:50 
AnswerRe: allocating object in global storage Pin
Chuck O'Toole10-May-12 3:32
Chuck O'Toole10-May-12 3:32 
GeneralRe: allocating object in global storage Pin
Erudite_Eric13-May-12 21:02
Erudite_Eric13-May-12 21:02 
QuestionDigital Library system, Help needed Pin
ShayanTanwir7-May-12 13:32
ShayanTanwir7-May-12 13:32 
AnswerRe: Digital Library system, Help needed Pin
Chris Losinger7-May-12 13:35
professionalChris Losinger7-May-12 13:35 
Questiontry and catch, not sure how to handle catch Pin
jkirkerx7-May-12 10:34
professionaljkirkerx7-May-12 10:34 

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.