bullet Problems!?!?!?!?! PLEASE HELP!!!!

Non-platform specific questions.

bullet Problems!?!?!?!?! PLEASE HELP!!!!

Postby Fl3tch » Tue Jun 19, 2007 11:24 am

Hi. I have been creating a game and have 1 more thing to fix before completion. My game is a side scroller and i am having a little trouble with shooting bullets.

I have got the bullet to come out when runnign right but when i turn around and move the other direction it still goes right. I have tried a few methods of fixing this problem and have read some techniques from the forum. The only problem is they all include variables and i really dont know how to use them and what they really are. Would disabling and enabling the bullets at different times help, if so how would i insert this?

Some help would be amazing and if possible a walk through of any methods to solve this problem. Thanks for any help

Fl3tch
Fl3tch
 
Posts: 11
Joined: Wed Jan 17, 2007 9:33 am
Score: 0 Give a positive score

Postby pixelpoop » Tue Jun 19, 2007 1:13 pm

In your player's Draw Actor, Script Editor
Click on Variables.
Click on Add.
Type in bulletdirection
Click on Add.
Close that little dialoge box.
Copy paste this:

if (x<xprevious)bulletdirection=0;
if (x>xprevious)bulletdirection=1;
//this changes bulletdirection to a 1 or 0 depending on
//which way the player is moving

Click on Add, Click on Immidiate


Now in your bullet's Create Actor, Script Editor
Copy paste in this:
if (bulletdirection==0){xvelocity=5}else{xvelocity=-5}
//this sets the bullet into motion
//adjust the 5 to the speed you want
//you may have to switch the 5 with -5 if the \
//bullets come out the wrong direction

Click on Add, Click on Immidiate


I haven't tested this but it should work
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score

Postby pixelpoop » Tue Jun 19, 2007 1:33 pm

a variable is like a place holder for information. the thing that it is holding can change and so the information it holds is variable.

examples using variables called x and y and fdsa:

x=rand(40);
//this makes x equal to a random number between 0 and 39.

y=40-20;
//this makes y equal to 20.

if (x==y){xvelocity=5; fdsa=1;}
// this test to see if x is equal to y
// if it is true then it sets the xvelocity to 5 and sets fdsa to equal 1;

Note:
-an actor(or local) variable is only changed for the actor it is on
-a global variable is shared by every actor
-an Integer is a whole number
-a Real variable is can hold decimal places like 3.1234
User avatar
pixelpoop
 
Posts: 276
Joined: Tue Aug 29, 2006 9:32 pm
Score: 28 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest