Player Shooting on a Platform Game

Game Editor comments and discussion.

Player Shooting on a Platform Game

Postby Turon » Thu Nov 18, 2010 2:06 pm

I have been a bit puzzled about shooting. Ever played Mario? Well if you have he collides with the fire flower! And he can shoot left and right........HOW? :P :roll:
Attachments
fire ball.png
Then shoots with this!
fire ball.png (235 Bytes) Viewed 2401 times
fire flower.png
Collides with this...
fire flower.png (491 Bytes) Viewed 2401 times
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Player Shooting on a Platform Game

Postby lcl » Thu Nov 18, 2010 2:44 pm

Kren made tutorial for that also, here: viewtopic.php?f=2&t=8681
Just use xvelocity instead of yvelocity. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Player Shooting on a Platform Game

Postby Turon » Fri Nov 19, 2010 5:00 pm

Thank you Lcl! But i can only shoot right with the command
Code: Select all
yvelocity=-10;
well that go's right.... right? so please tell me the command to go right! :wink:
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Player Shooting on a Platform Game

Postby skydereign » Fri Nov 19, 2010 8:21 pm

That doesn't make the actor go right. This does.
Code: Select all
xvelocity=10;


This is left.
Code: Select all
xvelocity=-10;


Up.
Code: Select all
yvelocity=-10;


Down.
Code: Select all
yvelocity=10;


If you want to shoot in two directions, what are you using as a direction variable? You can use the player's animation, like this.
player -> Create Actor -> Script Editor
Code: Select all
if(creator.animindex==4) // This assumes the shoot fireball animation is the fifth animation on your player
{
    xvelocity=10;
}
else
{
    xvelocity=-10;
}


**Note if you have ordered your animations properly this will work. If not, you'll have to use a direction variable. Also if you don't have a shot right, shoot left animation then you'll have to use % to find even odd (assuming your animations jump back from right, left, right or vice versa). This probably didn't make a lot of sense to you, but for it to I need to know your animation ordering, or how you distinguish direction.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Player Shooting on a Platform Game

Postby Turon » Sun Nov 21, 2010 4:40 pm

Cooooooooooooooool!!!!!!!!!!!!!!
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Player Shooting on a Platform Game

Postby NightOfHorror » Sun Nov 21, 2010 4:58 pm

sky you said yvelocity=10;, you forgot the plus sign
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Player Shooting on a Platform Game

Postby NightOfHorror » Sun Nov 21, 2010 4:59 pm

same for xvelocity=10;, you forget plus sign
viewtopic.php?f=2&t=12136
"I have not failed. I just found 10,000 ways that wont work." quoted by Thomas Edison.
Over the year, I decided my motto for me is I am knowledgeable, but not practical.
User avatar
NightOfHorror
 
Posts: 1823
Joined: Fri Aug 27, 2010 2:50 am
Location: Cedar Hill, MO, of the USA
Score: 51 Give a positive score

Re: Player Shooting on a Platform Game

Postby skydereign » Sun Nov 21, 2010 8:48 pm

I didn't need a +, I was setting xvelocity to equal 10. If xvelocity already equals 0, then they would do the same thing. But if xvelocity is already 10, adding the += would make it 20, which I don't want. So, using =10 and =-10 is exactly what I meant and wanted.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Player Shooting on a Platform Game

Postby Turon » Thu Nov 25, 2010 4:45 am

Yes but how does the fire ball change direction? like when my players animation is on player stop right the fire ball must shoot right. And when the animation is on stop left the fire ball must shoot left! HOW?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Player Shooting on a Platform Game

Postby lcl » Thu Nov 25, 2010 6:36 am

Ok turon, here is the basic method. :D
First do this. Go to some script editor, click variables, click add, name the variable dir, click ok.

Then add that to player key down right script:
Code: Select all
dir = 0;

And this to key down left:
Code: Select all
dir = 1;


Now add this to the shot's create actor script:
Code: Select all
switch(dir)
{
    case 0:
        xvelocity = 10;
    break;

    case 1:
        xvelocity =-10;
    break;
}

It is so simple. :D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Player Shooting on a Platform Game

Postby Turon » Thu Nov 25, 2010 7:19 am

Thank you Lcl I think you saved me again thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!! :D :D :D :D
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Re: Player Shooting on a Platform Game

Postby lcl » Thu Nov 25, 2010 8:19 am

:D
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Player Shooting on a Platform Game

Postby Bee-Ant » Thu Nov 25, 2010 9:09 am

lcl wrote:Ok turon, here is the basic method. :D
First do this. Go to some script editor, click variables, click add, name the variable dir, click ok.

Then add that to player key down right script:
Code: Select all
dir = 0;

And this to key down left:
Code: Select all
dir = 1;


Now add this to the shot's create actor script:
Code: Select all
switch(dir)
{
    case 0:
        xvelocity = 10;
    break;

    case 1:
        xvelocity =-10;
    break;
}

It is so simple. :D

Player -> Keydown -> Right:
Code: Select all
dir=1;

Player -> Keydown -> Left:
Code: Select all
dir=-1;

Shot -> CreateActor:
Code: Select all
xvelocity=dir*10;

This is even simpler :P :D
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: Player Shooting on a Platform Game

Postby lcl » Thu Nov 25, 2010 10:17 am

Bee-Ant wrote:Player -> Keydown -> Right:
Code: Select all
dir=1;

Player -> Keydown -> Left:
Code: Select all
dir=-1;

Shot -> CreateActor:
Code: Select all
xvelocity=dir*10;

This is even simpler :P :D

Oh, yeah, I thought of something like that, but decided to write the another one still. :P :lol:
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Player Shooting on a Platform Game

Postby Turon » Thu Nov 25, 2010 5:07 pm

Now how do you make it shoot only when you collide with the fire flower?
Turon
 
Posts: 862
Joined: Sun Jan 24, 2010 5:23 pm
Score: 32 Give a positive score

Next

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest