Switching directions for bullets

Non-platform specific questions.

Switching directions for bullets

Postby AnimeTank » Tue May 08, 2007 2:04 am

My game is coming along great. One bug i have is the direction the bullets are going. You see, my character has a gun but when i shoot, the bullets go one direction. Even if i'm facing the other way. Can anyone help me out here please? :lol: :wink:
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 2:43 am

okay,
make a variable called DIR.
for the draw actor event of the player,
Code: Select all
char*key=GetKeyState();
if(key[KEY_LEFT] == 1)DIR = 0;
if(key[KEY_RIGHT] == 1)DIR = 1;

and for the create actor event for the bullet,
Code: Select all
if(DIR == 0)xvelocity = - 10;
if(DIR == 1)xvelocity = 10;

:)
if you still need help let me know. :D
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

Okay... a new problem...

Postby AnimeTank » Tue May 08, 2007 3:09 am

I wrote all the information you gave me in the script and it worked out fine, but theres another bug. It's kind of difficult for me to say but let me try anyway. When i shoot my gun one way and then i turn the other way, the bullets then change direction and head the way i am looking! If i shoot and turn the other way, the bullet is just gonna keep going the direction i'm facing... back and forth, back and forth. Can you help me out? :oops:
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Re: Okay... a new problem...

Postby Sgt. Sparky » Tue May 08, 2007 3:10 am

AnimeTank wrote:I wrote all the information you gave me in the script and it worked out fine, but theres another bug. It's kind of difficult for me to say but let me try anyway. When i shoot my gun one way and then i turn the other way, the bullets then change direction and head the way i am looking! If i shoot and turn the other way, the bullet is just gonna keep going the direction i'm facing... back and forth, back and forth. Can you help me out? :oops:

on create actor event use the velocity calculation,
not on the draw actor event. :D
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 AnimeTank » Tue May 08, 2007 3:31 am

??? Can you specify? :?:
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 8:07 pm

AnimeTank wrote:??? Can you specify? :?:

your code may look somthing like this on the draw actor event of your bullet,
Code: Select all
if(DIR == 0)x -= 10;
if(DIR == 1)x += 10;

do not use it like that,
use it on the create actor event,
only change x to xvelocity,
Code: Select all
if(DIR == 0)xvelocity = -10;
if(DIR == 1)xvelocity = 10;

:D
got it?
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 AnimeTank » Tue May 08, 2007 8:55 pm

Hmm... i don't know whats the problem. I tried everything you told me but it still does what it usually does... Hmmm, i wonder if i'm doing something wrong... :?:
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Postby Sgt. Sparky » Tue May 08, 2007 8:58 pm

AnimeTank wrote:Hmm... i don't know whats the problem. I tried everything you told me but it still does what it usually does... Hmmm, i wonder if i'm doing something wrong... :?:

Send me the file. :D (.ged and data)
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 AnimeTank » Tue May 08, 2007 9:42 pm

It won't let me. It says that the extension ged is not allowed?
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Postby Oman » Tue May 08, 2007 10:52 pm

you have to put it in a zip file, dont you?
"Beyond a wholesome discipline, be gentle with yourself." - Max Ehrmann
User avatar
Oman
 
Posts: 268
Joined: Tue Oct 31, 2006 4:00 am
Location: Somewhere out there...
Score: 6 Give a positive score

how about this

Postby d-soldier » Tue May 08, 2007 11:42 pm

Post your bullet actors scripts here. I want to see it's create actor script, and it's daw actor script. This information will help us fix your problem.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby AnimeTank » Wed May 09, 2007 12:52 am

It's exactly like the way sparky posted them, because i copied it then pasted it onto my scripts
Current Projects:

Some game about some guy... :)

Message me if you have an XboxLive account. Then send me a Friend Request to my Gamertag, AnimeTank.
Message me if you have a WoW account. Then tell me what server your on, along with your name.
User avatar
AnimeTank
 
Posts: 96
Joined: Sat May 05, 2007 10:37 pm
Location: At my House, on my computer, in my seat
Score: 13 Give a positive score

Postby Fuzzy » Wed May 09, 2007 1:00 am

Code: Select all
if(DIR == 0){x -= 10;}
if(DIR == 1){x += 10;}


Code: Select all
if(DIR == 0){xvelocity = -10;}
if(DIR == 1){xvelocity = 10;}


Corrected...
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Caaz Games » Wed May 09, 2007 2:36 am

... Use Two Bullets One Going One Way The Other Going The Other ...
You are welcome to join my forum. 4 active members lol but it's a cool place. active... much talking :D it's fun!
http://caaz.freeforums.org/
User avatar
Caaz Games
 
Posts: 729
Joined: Wed Feb 14, 2007 9:09 am
Location: California....knows how to party!
Score: 25 Give a positive score

Postby Sgt. Sparky » Wed May 09, 2007 3:13 am

Fuzzy wrote:
Code: Select all
if(DIR == 0){x -= 10;}
if(DIR == 1){x += 10;}


Code: Select all
if(DIR == 0){xvelocity = -10;}
if(DIR == 1){xvelocity = 10;}


Corrected...

you do not need the { and }
but
all you must use is the create actor event of:
Code: Select all
if(DIR == 0)xvelocity = - 10;
if(DIR == 1)xvelocity = 10;

if you used a draw actor event you would still have the same problem.
(it would change the direction of the bullet all the time)
on the create actor event it only changes it once.

sorry for the confusion. :(
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

Next

Return to General

Who is online

Users browsing this forum: No registered users and 1 guest