Page 1 of 1

Help with 2 subjects please

PostPosted: Tue Sep 20, 2005 8:34 pm
by ALK3_Steph
Hi, thanks for taking the time out and reading this over, hopefully some one can steer me in the right direction or help me a little.

Im foolin' around with a R-Type game (for the SNES if anyone remembers it) and I want to do 2 things that I cant figure out how to do.
-I wanna make it so you hit a key and it turns on the shields, and if you hit the same key, it turns them off
-And, I wanna make it so that when the shields are on, and you get hit by something, the shields will flash. Like, Ive got them pretty transparent and Ive tried making a timer to change the transparency but, its not working out for me.
Anyways if you all could help me out it would be appreciated! Thanks again! -ALK3_Steph

PostPosted: Tue Sep 20, 2005 9:48 pm
by willg101
I wanna make it so you hit a key and it turns on the shields, and if you hit the same key, it turns them off

Use a variable to test whether shields are on or off

And, I wanna make it so that when the shields are on, and you get hit by something, the shields will flash.

On "collision" event, use change transparency?

HTHs

PostPosted: Tue Sep 20, 2005 10:48 pm
by Fuzzy
willg101 wrote:Use a variable to test whether shields are on or off


Here is a neat little trick.

in your global code, type this:

#define TRUE 1;
#define FALSE !TRUE;

Those might be predefined, I cant check right now..

create a variable for your player, shieldon
make it an integer
if only the player actor needs it, make it global, to save memory.
select player...create actor.... script.... put this line:
shieldon = FALSE;

now, in the key down event for the shield key, you put the first line like this:

shieldon = !shieldon;
shield.collisionstate('Event Actor", shieldon);
transparency = !transparency;

the benefit to this is that you dont have to keep track of what it shieldon was on the last keypress, it flips automatically. you can use this sort of trick in al sorts of places. it also eliminates an "if" statement, speeding things up.

This is all off the top of my head, i dont know if the functions and capitalizing in my code is right, but it gives you an idea.

PostPosted: Wed Sep 21, 2005 4:07 am
by ALK3_Steph
Thanks for the help guys, Im gonna try this out soon and if I am still getting caught up on it, I'll give you a shout and work out the bugs. Thanks again

PostPosted: Wed Sep 21, 2005 5:07 am
by jazz_e_bob
ThreeFingerPete wrote:Here is a neat little trick.

in your global code, type this:

#define TRUE = 1;
#define FALSE = !TRUE;

Those might be predefined, I cant check right now..

create a variable for your player, shieldon
make it an integer
if only the player actor needs it, make it global, to save memory.
select player...create actor.... script.... put this line:
shieldon = FALSE;

now, in the key down event for the shield key, you put the first line like this:

shieldon = !shieldon;
shield.collisionstate('Event Actor", shieldon);
transparency = !transparency;

the benefit to this is that you dont have to keep track of what it shieldon was on the last keypress, it flips automatically. you can use this sort of trick in al sorts of places. it also eliminates an "if" statement, speeding things up.

This is all off the top of my head, i dont know if the functions and capitalizing in my code is right, but it gives you an idea.


Man you are full of neat little tricks.

I didn't know you could use #define. I've always used const.

TRUE and FALSE are not predefined but if 0 = FALSE then !FALSE = -1.

I like your toggle trick too.

8)

PostPosted: Wed Sep 21, 2005 10:15 pm
by Fuzzy
jazz_e_bob wrote:
Man you are full of neat little tricks.

I didn't know you could use #define. I've always used const.

TRUE and FALSE are not predefined but if 0 = FALSE then !FALSE = -1.

I like your toggle trick too.

8)



Thanks! you've inspired me lots! thats a nice compliment coming from you.

A mistake I made;

dont use = with #define. its should be:

#define TRUE 1
#define FALSE !TRUE

the logical negation of 1 is zero. test it and you will see.

I've got a global script planned with all sorts of neat tricks, like integer math functions... I'll release it in a few days.