Health bar reaches 0 but no death animation?

Game Editor comments and discussion.

Health bar reaches 0 but no death animation?

Postby Irondan75 » Sun Apr 10, 2011 5:58 pm

I have a working health bar that has a maxhp of 100, and my enemy bullets do -10 damage and my health packs +10.
Everything is working great but I'm not sure where or how to script out my player explosion when hp reaches 0. :?
So as of now the health bar reaches 0 and my player is alive and well, but I would like him to explode and trigger a game over screen.
Do I add collision>script> (not sure how to write it, not good at code) on my player, health bar canvas or enemy bullet?
Very close to the end of my 1st game...have learned a lot but have A LOT to learn :lol:
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby savvy » Sun Apr 10, 2011 6:52 pm

on the player, use draw actor and this code...
Code: Select all
if(hp<1)
{
create the explosion
destroy the player
create the game over screen
}

as simple as that
if your hp is working with an animation with 100 frames or so, then..
if(animpos<1)
or
if(animpos>98)

depending on which way round it goes.
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby Irondan75 » Sun Apr 10, 2011 7:19 pm

Thank you very much Savvy!
+1 to you for your very helpful knowledge :D
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby Irondan75 » Mon Apr 11, 2011 2:08 am

I'm so close....but, when I add the change actor and game over animation in the last line of the script you gave me my game over screen only appears in the top corner of the View and game still playing in the background.
I'd like after my player dies to show the game over screen with my end music and buttons to retry or quit.
Any idea to fix?
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby skydereign » Mon Apr 11, 2011 4:36 am

The game over appearing in the top right is probably due to you setting its xy values to the views. Wire actors (view, filled region, canvas, and wireframe) have their xy coordinates as the top left, while normal actors have theirs in the center. So create the game over text with the position (view.x+view.width/2, view.y+view.height/2). The other problems have to do with you not actually disabling the level. An easy way to stop the level is to use PauseGameOn(). Also to get the retry and quit buttons, put the create actor function calls in the game over text's create actor event, and create them relative to the text.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby Irondan75 » Mon Apr 11, 2011 11:43 am

So I did like you advised Skydereign and it moved my game over screen more into the frame but not fully in. I can still see the Top 1/3 and Right Side 1/3 of
the game behind my Game Over screen. I tried changing the value /2 to /3 or 4 or 5 etc. but no change and I tried

if (hp==0)
MoveTo("Event Actor", -1197.000000, -798.000000, 1.000000, "GameoverFrame", ""); //The xy of the center of my Game Over actor.

But that didnt work either.
Maybe I'm doing the Game Over wrong?
I created an actor with a .PNG animation that is 480 x 320 with my game over grafix and text. I was trying to get it to appear when my player dies and if I got that done
then I would add the retry/quit button actors and script them to do what I need done. I maded the Game menu already with buttons that can load, quit and take me to the game direction screens so I figured the Game Over screen would be the same.

(EDIT)

Ok, so I played around with some x y views and got it perfectly lined up with the script below. :D

if(hp<1)
{
CreateActor("explosion", "explosion_3", "(none)", "(none)", 0, 0, false);
PlaySound2("data/16c_explode.wav", 1.000000, 1, 0.000000);
DestroyActor("Event Actor");
view.x=-1195;
view.y=-797;
}

Thanks again Skydereign and +1 to you for your help!
Irondan75
 
Posts: 22
Joined: Thu Mar 10, 2011 12:10 pm
Score: 0 Give a positive score

Re: Health bar reaches 0 but no death animation?

Postby savvy » Tue Apr 12, 2011 9:06 pm

instead of moving the view to where the game-over is, try making the game over move to the view using:
Code: Select all
gameover.x=view.x+view.width/2;
gameover.y=view.y+view.height/2;


that should work, you could even move the game over screen into the view and set it so the view is its parent, then when game over happens the tarnsparency (transp) becomes 0, but when your playing transp=1.
--> For my help, i ask for a simple +1 if it helps! ^-^
--> I dont code, I type art which you dont understand.
--> I keep winning the 3D model challenge at college, teacher says: "you keep winning im not giving you prizes".
User avatar
savvy
 
Posts: 494
Joined: Wed Jun 03, 2009 11:55 am
Location: England
Score: 44 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron