cassius Posted October 29, 2012 Share Posted October 29, 2012 Anyone know a better way of ending a game than this.( when main character is killed) I will be using a game over message but not implemented yet. int endgame() { Sleep(3000); return (0); } Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Canardia Posted October 29, 2012 Share Posted October 29, 2012 No need to sleep the game, just let the main character lie on the ground and maybe rotate the camera around him from dawn to dusk, until the player presses Escape. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
ChrisMAN Posted October 29, 2012 Share Posted October 29, 2012 i use events and promises for virtually everything. you can't block the thread which sleep will do. you need something attached to the update loop like an entity or you can make an object and call it every frame. this isn't very elegant but it works void endgame(callback) { this.end_game_callback = callback; this.start_end_game_animation = true; } void Update() { if (this.start_end_game_animation) { if (this.timer > 4000ms) { this.start_end_game_animation = false this.end_game_callback() } } } if you do megatron's idea just set a variable and poll them on every frame. when certain states are true change the actions that are happening. Quote Link to comment Share on other sites More sharing options...
cassius Posted October 29, 2012 Author Share Posted October 29, 2012 Thanks guys. Tried metatrons suggestion. Works fine. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
cassius Posted October 29, 2012 Author Share Posted October 29, 2012 asking this question has reminded me of a related question. There are several places in my game where the main character could fall from a great height, too many to deal with individualy so is there a way I can detect when a character drops from a great height anywhere in the game. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Rick Posted October 29, 2012 Share Posted October 29, 2012 Do you use the LE controller? If so there is an IsAirborne() or something like that. You could check to see if they are airborne for x seconds. Quote Link to comment Share on other sites More sharing options...
cassius Posted October 29, 2012 Author Share Posted October 29, 2012 Thats a great idea Rick. I look into it. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
gamecreator Posted October 30, 2012 Share Posted October 30, 2012 You could check to see if they are airborne for x seconds. Or check the y difference between when IsAirborne becomes false and when it was last false. Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted October 30, 2012 Share Posted October 30, 2012 Do you use the LE controller? If so there is an IsAirborne() or something like that. You could check to see if they are airborne for x seconds. That should work pretty well except that does not take into acount jumping up... say for example you jumped all that time going up contributes to the damage you take + all the time going down. In a game where you jump on jump pads and your landing is actually higher than your starting then you could still take damage with this technique. Not a problem if jumping is minimal, However, if it is an issue, You could also try recording the Z height at the beginning of being airborne and then record the Z height of when the controller is no longer airborne. Get the difference between the two and you have the height distance fallen / gained and base your damage / death off of that height difference value.... However, this doesn't take into acount if you jumped up you are getting more height from your initial airborne height. This may or may not be an issue but if it is you could find the height at the peak of the jump as your first Z height and then calculate the distance.. There are a range of ways to do it. Pick the one that suites the mechanics of your game and gives the best benefit cost ratio for your game. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
cassius Posted October 30, 2012 Author Share Posted October 30, 2012 Yeah there are pitfalls to watch out for whatever you do. I could restrict character dying to very high falls and just have it fall and get up again in less high places. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Canardia Posted October 30, 2012 Share Posted October 30, 2012 The correct way would be to check the collision speed of the character, then it doesn't matter if he collides with the ground, a wall, a falling brick, etc.... 1 Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
cassius Posted October 30, 2012 Author Share Posted October 30, 2012 How do I check collision speed? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Daimour Posted October 31, 2012 Share Posted October 31, 2012 How do I check collision speed? I don't know if you can check collisions for character controller or not. But you could measure it's speed with GetBodyVelocity() and check for difference from previous frame. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.