noob game scripting question

Talk about making games.

noob game scripting question

Postby shady7twenty4 » Sat Apr 21, 2007 11:04 pm

Im workin on my first game a rip off mario side scroller just to get the hang of the program and am having some trouble makeing my character jump to a certin heigth and then fall stoping at the bottem of the view. Thanks.
~~shady~~
shady7twenty4
 
Posts: 10
Joined: Fri Nov 25, 2005 3:53 pm
Location: pa
Score: 0 Give a positive score

hmmm....

Postby d-soldier » Sat Apr 21, 2007 11:27 pm

Phyics is the issue here... since you didn't give any information regarding how your game is currently setup, I'll start with some basics...

Make sure your player(actor) has some gravity applied to him in the DRAW ACTOR section. The script should be:
yvelocity = yvelocity + .6;
(adjust the .6 to your liking)
So long as you have something below him (something to walk on) with a collision event (to the player)/ physical response, you should have no problem there.
Regarding jumping, your player will need a "key down" event which has a script:
yvelocity = -8;
(also adjust to your liking)..
In regards to the screen, do you have your VIEW (the white box) parented to your player?

I highly reccomend loading any of the tutorial games (caveman) and playing around with them to see how and why things are setup the way they are. It was a big help for me.
User avatar
d-soldier
 
Posts: 703
Joined: Sun Apr 08, 2007 2:13 am
Score: 61 Give a positive score

Postby Sgt. Sparky » Sun Apr 22, 2007 2:08 am

jumping mistake there,
first make a variable called jump,
if you do not know how to make variables,
just click on the script button then global code,
or just in any codeing box,
and click on the variables button there,
not the variables/functions .
after you make the variable called jump
put this on the collision event with the top side of the ground,
Code: Select all
jump = 1;

and put this as his draw actor event,
Code: Select all
if(yvelocity > 2)jump = 0;

and when the key to jump is pressed use this,
Code: Select all
if(jump == 1) {
yvelocity = - 8;
jump = 0;
                              }

that way there will not be a repeated jump.
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 shady7twenty4 » Sun Apr 22, 2007 12:04 pm

Ok thanks for the help but the other side of my problem is with my ground it and one of my other actors dissapear soon as I click game mode the only thing I did to them was add animations. The only way to stop them from dissapearing ive found is to put them on the top half of my screen which screws me because im talkin about my soild ground.
~~shady~~
shady7twenty4
 
Posts: 10
Joined: Fri Nov 25, 2005 3:53 pm
Location: pa
Score: 0 Give a positive score

Postby shady7twenty4 » Sun Apr 22, 2007 12:07 pm

I think i fixd my problem. or at least found a way to work around it
~~shady~~
shady7twenty4
 
Posts: 10
Joined: Fri Nov 25, 2005 3:53 pm
Location: pa
Score: 0 Give a positive score

Postby shady7twenty4 » Sun Apr 22, 2007 1:16 pm

I had to use some of both of your responses to get it to work. Sgt. with yours something was wrong with my key down to jump, it did nothing but the rest was helpful. Soldier yours gave me a bounce effect when he came back down to the ground. I stil have one problem i can jump as high as long as i keep the up button down, but i only want him to b able to jump a certin heighth.
~~shady~~
shady7twenty4
 
Posts: 10
Joined: Fri Nov 25, 2005 3:53 pm
Location: pa
Score: 0 Give a positive score

Postby Sgt. Sparky » Sun Apr 22, 2007 1:30 pm

shady7twenty4 wrote:I had to use some of both of your responses to get it to work. Sgt. with yours something was wrong with my key down to jump, it did nothing but the rest was helpful.[big space]problem i can jump as high as long as i keep the up button down, but i only want him to b able to jump a certin heighth.

did you do everything I told you to add?(without the other jumpin' script, just my jumping script only)remove the other jumping code you have now and try mine, I use it in all my games that jump.
but I usually do not make key down events,
I just make a code and put it in the draw actor event,
example:
Code: Select all
char*key=GetKeyState();
yvelocity += 1;
if(fly == 0) {
if(key[KEY_LEFT] == 1 && key[KEY_RIGHT] == 0)
{
    gs = 0;
    if(jump == 1)x -= 5;;
    if(jump == 0)xvelocity -= 1;
    if(af == 1 && jump == 1 && key[KEY_DOWN] == 0) {
    af = 0;
    ChangeAnimation("Event Actor", "WL 1", FORWARD);
                                                   }
        if(af == 1 && jump == 1 && key[KEY_DOWN] == 1) {
    af = 0;
    ChangeAnimation("Event Actor", "CL 1", FORWARD);
                                                   }
    if(af == 1 && jump == 0) {
        af = 0;
        ChangeAnimation("Event Actor", "LJ 1", FORWARD);
                             }
}
if(key[KEY_LEFT] == 0 && key[KEY_RIGHT] == 1)
{
    gs = 1;
    if(jump == 1)x += 5;
    if(jump == 0)xvelocity += 1;
    if(af == 1 && jump == 1 && key[KEY_DOWN] == 0) {
    af = 0;
    ChangeAnimation("Event Actor", "WR 1", FORWARD);
                                                   }
        if(af == 1 && jump == 1 && key[KEY_DOWN] == 1) {
    af = 0;
    ChangeAnimation("Event Actor", "CR 1", FORWARD);
                                                   }
    if(af == 1 && jump == 0) {
        af = 0;
        ChangeAnimation("Event Actor", "RJ 1", FORWARD);
                             }
}
if(key[KEY_UP] == 1 && jump == 1) {
    if(gs == 0)ChangeAnimation("Event Actor", "LJ 1", FORWARD);
    if(gs == 1)ChangeAnimation("Event Actor", "JR 1", FORWARD);
    yvelocity = - 15;
    jump = 0;
                                  }
if(xvelocity > 5 && jump == 0)xvelocity = 5;
if(xvelocity < -5 && jump == 0)xvelocity = -5;
             }
if(yvelocity > 2)jump = 0;

:D
there are alot of events in this,
here is what I have so far of this game I am workin' on xD
not much so far.
this game once I add more stuff is going to be like an Agent sort of game,
you have to do simple tasks in a complicated way.
xD
once I add stuff it is going to be stuff like getting bread off the top of the level,
I will add bomb dudes guys with guns, everything! :D
Attachments
startAgent2.zip
:)
(673.57 KiB) Downloaded 101 times
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


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest