shooting

Game Editor comments and discussion.

shooting

Postby BogdansB » Tue Feb 28, 2012 12:58 pm

hello

how can i make just one actor, the bullet, wich goes up when you press [8] or down if you press [2] and so on..
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby SuperSonic » Tue Feb 28, 2012 2:26 pm

Here you go :D

On key down -> [8] -> Repeat -> Script editor
Code: Select all
y -= 2;
On key down -> [2] -> Repeat -> Script editor
Code: Select all
y += 2;
On key down -> [4] -> Repeat -> Script editor
Code: Select all
x -= 2;
On key down -> [6] -> Repeat -> Script editor
Code: Select all
x -= 2;
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: shooting

Postby BogdansB » Tue Feb 28, 2012 2:42 pm

doesn't works.

so i need to put the code in players key down event? and then bullet.x -=2? or how?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby skydereign » Tue Feb 28, 2012 6:41 pm

If you understand the code you should be able to figure out what actor it belongs to, or to be able to apply it to the actor you need it to. All SuperSonic's code does is change the position of an actor (the event actor). So you said you wanted your bullet to move up and down on the keydown events, so give that code to the bullet.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: shooting

Postby BogdansB » Tue Feb 28, 2012 6:56 pm

no ment the bullet needs to create each time so its like a normal shot.
so i want every time you press [8], the bullet creates and goes up when you press [8] again, another bullet creates and so on...
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby skydereign » Tue Feb 28, 2012 8:54 pm

So both keys fire bullets, but one fires the bullet actor up and the other fires one down? In that case you can do this for your keydown events (same for the other key, just make yvelocity negative).
player -> Key Down [8] -> Script Editor
Code: Select all
CreateActor("bullet", "bullet_anim", "(none)", "(none)", 0, 0, false)->yvelocity=15; // bullet will have a yvelocity of 15
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: shooting

Postby BogdansB » Wed Feb 29, 2012 5:57 am

thanks
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby BogdansB » Fri Mar 23, 2012 6:02 pm

how can i make it diagonal , so yvelocity and xvelocity are 15?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby skydereign » Fri Mar 23, 2012 6:48 pm

You can use the default actor struct to do this. If you didn't already know, you can type view.x to get or change the view's x position. The same can be done here for the actor you created. Do watch out though because normally the default clone that it gets is the lowest cloneindexed one, but since you called CreateActor gE knows to update it to the newest one (but only for that event).
Code: Select all
CreateActor("actor", "anim", "(none)", "(none)", 0, 0, false);
actor.xvelocity=10; // but remember don't do this unless you have the CreateActor
actor.yvelocity=10; // otherwise it will only change the lowest cloneindexed actor
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: shooting

Postby BogdansB » Fri Mar 23, 2012 6:56 pm

but i want to make one bullet for alldirections. i think if i do it like that , when i press up the bullet goes up and when i press down i bullet wich go up goes down ... :S you know what imean?
BogdansB
 
Posts: 94
Joined: Tue Oct 25, 2011 2:30 pm
Score: 0 Give a positive score

Re: shooting

Postby skydereign » Fri Mar 23, 2012 10:56 pm

What that code does is make the newly created bullet move with an x/y velocity of 10. So if you have a keydown event that has that script, all the newly created bullets will move in the specified direction. It doesn't however make bullets that have already been created change direction. Is that what you want?
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest