NEED HELP WITH VARIABLES PLEASE

Talk about making games.

NEED HELP WITH VARIABLES PLEASE

Postby PJ » Mon Jul 31, 2006 7:33 pm

on my last post, somebody told me to use variables to make my player shoot both ways. right now, when hes facing right, the bullet comes out of his back. can someone PLEASE write the variable for me? thanks.
PJ
 
Posts: 4
Joined: Thu Jul 20, 2006 3:03 am
Score: 0 Give a positive score

Postby relaxis » Mon Jul 31, 2006 9:34 pm

post me your code so far.
User avatar
relaxis
 
Posts: 82
Joined: Mon Jul 17, 2006 2:06 pm
Location: Luxembourg
Score: 1 Give a positive score

this is one way to do it.

Postby hollywoodcolor » Tue Aug 01, 2006 8:05 pm

//no left or right key have been pressed yet
if (lastDirection == 0)
DestroyActor("bullet");


// left key is last pressed
if (lastDirection == 1)
xvelocity =-20;

// right key is last pressed
if (lastDirection == 2)
xvelocity =20;


//this script is for your bullet actor under create actor
//in the script window click on Variables
// in the "User Variables" click on add
//under Name: put lastDirection and leave the defaults and click the add //button
hollywoodcolor
 
Posts: 4
Joined: Sun Jul 23, 2006 6:12 am
Location: California
Score: 0 Give a positive score

Postby relaxis » Wed Aug 02, 2006 1:05 pm

can you have continous conditionals like that? just use "if" with no "else" iver and over?

it's kinda inefficient...
User avatar
relaxis
 
Posts: 82
Joined: Mon Jul 17, 2006 2:06 pm
Location: Luxembourg
Score: 1 Give a positive score

Postby hollywoodcolor » Wed Aug 02, 2006 6:38 pm

Yes you can have "can you have continuous conditionals"
The code was pulled from working a script.

You are most likely correct in that one (if statement with else parts) would be more efficient
Do you know if there is a good way to test the difference in speed on something like this?
hollywoodcolor
 
Posts: 4
Joined: Sun Jul 23, 2006 6:12 am
Location: California
Score: 0 Give a positive score

Postby relaxis » Thu Aug 03, 2006 12:32 pm

well I guess that for one statement it would matter too much as long as if it were a one-time event (not in the controls - just a scene in the game).

But I suppose that a fps counter of somekind or a benchmarking tool could work. ask around.

Personally I would have devised some kind of "while loop" or used case switches. But even case switches are inefficient.
User avatar
relaxis
 
Posts: 82
Joined: Mon Jul 17, 2006 2:06 pm
Location: Luxembourg
Score: 1 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest