Help with 2 subjects please

Talk about making games.

Help with 2 subjects please

Postby ALK3_Steph » Tue Sep 20, 2005 8:34 pm

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
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby willg101 » Tue Sep 20, 2005 9:48 pm

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
http://www.wish-games.com
Old betas now available!!
User avatar
willg101
 
Posts: 473
Joined: Thu Dec 16, 2004 12:08 am
Location: West Michigan
Score: 5 Give a positive score

Postby Fuzzy » Tue Sep 20, 2005 10:48 pm

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.
Last edited by Fuzzy on Wed Jan 24, 2007 10:58 am, edited 1 time in total.
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby ALK3_Steph » Wed Sep 21, 2005 4:07 am

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
"Take your wings outside, you cant fly in here, besides purple skies are betting soaring for you my angel, you're an angel, you little devil. As for me I'll be just fine as I stay inside and watch from the window" -Alkaline Trio (Goodbye Forever)
ALK3_Steph
 
Posts: 27
Joined: Sat Sep 10, 2005 2:40 am
Location: Norfolk, VA
Score: 0 Give a positive score

Postby jazz_e_bob » Wed Sep 21, 2005 5:07 am

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)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Fuzzy » Wed Sep 21, 2005 10:15 pm

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.
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron