Jump to content

game over


cassius
 Share

Recommended Posts

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);

}

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

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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

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.

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

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.

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

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....

  • Upvote 1

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...