Having problems when fireing bullets.

Non-platform specific questions.

Having problems when fireing bullets.

Postby FiLLLe1 » Mon Feb 26, 2007 10:21 pm

Hi!
Im pretty new at The Game Creator, but im doing my best to learn. I need some help when im fireing bullets. The problem is when my player is running/standing right, the bullets go correctly - right. But when he rans/stands left, the bullets still go right. Can I fix that with scripts? Or paths? Activition events? I'm not so good at this so I need all help I can get.

What I want the player to make is:

When he stands right, he shoots right.
When he stands left, he shoots left.

EDIT" Now I also realised that I have no idea how to make an enemy try to kill to Player. Like shoot after him/chase him etc.

Would be wery thankful for answers to both of my questions.
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby DilloDude » Mon Feb 26, 2007 10:39 pm

You need to use some variable to check which way he is facing. For example, you could just use animindex, and check the animation, or you could assign a variable when you press the keys. Then check the variable with an if statement:
Code: Select all
Actor *bullet = CreateActor("YourBullet", "bullet", "(none)", "(none)", 0, 0, false);
if (facing == RIGHT)
{
    bullet->xvelocity = 10;
}
else
{
    bullet->xvelocity = -10;
}
Or something like that.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby FiLLLe1 » Mon Feb 26, 2007 10:46 pm

ok, i'll try that. Dont think i really uunderstand but i'll give it a try. Will reply and tell if it worked, thx for quick answer.
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby FiLLLe1 » Tue Feb 27, 2007 2:09 pm

Have I understood right now?:
The codes are Script codes i guess? And I should write the codes in the "bullet_actor" script editor? Not the "Player_actor" script editor?
(like I said before im pretty new with the programm so I dont get everything now at the beginning but i learn :)

Cuz now im doing like this:
Player_1 has an event at "Key Down" the key is space. The action is "Create actor" -> "Bullet_actor" (parent = Player_1). And that actor will directly follow the path "Bullet_path" in 60 frames or something. That makes player_1 shoot, but only in the path direction, if i create two paths at different directions, he will shoot at both directions. Should I let this setting stay or should I delete it?

You named "animindex" can i fix so the game know when the animation is standing to the right with that one, and then shoot right? If it is like that, can u say an script code to that if the actors are:

Bullet_1
Player_1

//Fille
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby DilloDude » Tue Feb 27, 2007 10:36 pm

If you are using animindex, you can use it to check the animation that is playing. So if you have four animations: stopleft, stopright, walkleft, walkright, an animindex of 0 or 2 means you are facing left. To make the bullet move, you can either use a path, set its xvelocity, or make some other variable that effects it in draw actor. If you are using paths, then on a keydown event on your player, put this script:
Code: Select all
if (animindex == 0 || animindex == 2)//facing left, || means or
{
    CreateActor("Bullet_1", "bullet", "(none)", "PathLeft", 0, 0, false);
}
else//facing right
{
    CreateActor("Bullet_1", "bullet", "(none)", "PathRight", 0, 0, false);
}
Just check the CreateActor code to make sure I got it right. You can modify things to suit.
Image
User avatar
DilloDude
 
Posts: 866
Joined: Tue Jan 24, 2006 9:51 am
Location: Nyerellion
Score: 58 Give a positive score

Postby FiLLLe1 » Wed Feb 28, 2007 3:27 pm

YES! It works! thank you so much DilloDude!
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby FiLLLe1 » Fri Mar 02, 2007 4:42 pm

Hi again, i need some more help. :?
The problem now is that I've made a new animasion for my game, and now it doesent work properly. The new animation is a bazooka guy, and I want to fire bazooka rockets at the same button as the ordinary gun. i have tried to change stuff in the script you sent to me DilloDude, but i didnt make it. So if someone know how to do plz tell me.

" 1 more thing.
If a script is following:
if (animindex == 1 || animindex ==2 etc...) //like the one you posted above DilloDude. What does the numbers mean? animindex =="2".

//Fille
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby Troodon » Fri Mar 02, 2007 5:33 pm

Animindexes go like this:

1st animation = 0
2nd animation = 1
3rd animation = 2
etc
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby FiLLLe1 » Fri Mar 02, 2007 5:45 pm

k, thx. now i think stuffs will work out :)
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby Troodon » Fri Mar 02, 2007 6:25 pm

No problem. :)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby FiLLLe1 » Sat Mar 03, 2007 3:27 pm

so, now i got another problem! :( srry for asking many things.
But i got a tank, when it gets blowed by a bozzoka rocket i got an animation for that, an exploding one. so now i add an collision event, when the rocket crashes with the tank, and its changeing animation like it should, but the animtion is looping. I just want it to be shown one time, then stay with the last animation, anyone know how to fix that ??

//Fille
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby UltimatHedgehog » Sat Mar 03, 2007 5:23 pm

event animation finish
set it to change to the last pic stopped
Image
I always thought Hell would be a giant load screen that goes on for eternity, then one day, eons later, it would end, only to reveal a slightly different loading screen.
User avatar
UltimatHedgehog
 
Posts: 325
Joined: Fri Jan 19, 2007 1:48 pm
Location: http://downloads.khinsider.com/?u=112542 plz click
Score: 10 Give a positive score

Postby Troodon » Sat Mar 03, 2007 5:36 pm

Game Editor loops all the animations if they aren't set to be stopped. :)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score

Postby FiLLLe1 » Sat Mar 03, 2007 6:59 pm

thx again :D
FiLLLe1
 
Posts: 16
Joined: Mon Feb 26, 2007 10:05 pm
Score: 1 Give a positive score

Postby Troodon » Sat Mar 03, 2007 7:01 pm

:)
I can't die, I already tried
~on the forums since GE 1.3.3~
User avatar
Troodon
 
Posts: 1539
Joined: Thu Jan 12, 2006 3:29 pm
Location: HELL
Score: 56 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest