When player hit - becomes invincible for a second?

Talk about making games.

When player hit - becomes invincible for a second?

Postby d-soldier » Wed Apr 18, 2007 12:30 am

I've been trying to figure out (from the 1942 demo) how to go about making my player invincible (and flashing transparent) for a moment after he's hit by an enemy... but with no luck... Anyone want to take the time to help me with this?
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Sgt. Sparky » Wed Apr 18, 2007 1:37 am

make a variable called hit.
and a variable called wait
when he is hurt,
Code: Select all
if(hit == 0)
{
 hit = 1;
 do_damage calculation;
}
wait = 30;
//or whatever you want it to be,
//if you're game runs at 30 fps set wait to the fps rate(30) for a 1
//1 second wait time

on draw actor event:
Code: Select all
if(hit == 1)transp = .5;
if(hit == 0)transp = 0;
wait -= 1;
if(wait <= 0)hit = 0;

that should work :D
if you have any problems let me know. :)
Last edited by Sgt. Sparky on Wed Apr 18, 2007 2:16 am, edited 1 time in total.
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score

Postby d-soldier » Wed Apr 18, 2007 1:47 am

Whats that "do_damage calculation;" for!?!
Haha, nevermind... figured it out!! :lol: Thanks for taking the time to spell it out for me, been racking my brain over that one for awhile now!
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Sgt. Sparky » Wed Apr 18, 2007 2:15 am

:D
welcome,
I used to do alot of playin' around with GE just to see what does what till I got the hang of it. :D
just let me know if you need help. :)
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest