Problem Number 10

March 1, 2006 at 4:19 am (Game Maker, Uncategorized)

A character jumps up off a platform, and return under the influence of gravity – you cannot jump from midair

Okay, It’s time for a new format for my game maker problems. It’s exactly the same as before, but, instead of me typing manually, I cut and paste, as well as add comments.

Okay, first create a sprite, He (or she) will be your jumping guy. I made mine a snake, as you can see. And make a wall sprite. Then create objects with the sprites you have, with the same attributes as below. I had to make a wall object (and sprite) first, and its attributes are visible below.

I needed heaps of help from Pikmik for this one.

(This object covers all the events, including the events for the other object below, objwall)

Sprite: sprsnakey (The jumping character)
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Mask:

(The following is to create constant gravity)

Step Event:

if relative position (0,1) is collision free for Only solid objects
set the gravity to 0.5 in direction 270
else
set the gravity to 0 in direction 270
COMMENT: limit vertical speed
if vspeed is larger than 12
set variable vspeed to 12

(The following is to prevent our character from falling to his death, in an eternal pit of fallingnes. ie, so he stops when he reaches the ground) 

Collision Event with object objwall:

move in direction direction at most 12 till a contact with solid objects
set the vertical speed to 0

(The following are direction buttons, so you can move around, and jump)

Keyboard Event for Left Key:

if relative position (-4,0) is collision free for Only solid objects
move relative to position (-4,0)

Keyboard Event for Right Key:

if relative position (4,0) is collision free for Only solid objects
move relative to position (4,0)

Key Press Event for Up Key:

if relative position (0,1) gives a collision with Only solid objects
set the vertical speed to -10

(This object does not need events, as we covered all the events in the one object, obj snakey)

Sprite: sprwall (the wall)
Solid: true
Visible: true
Depth: 0
Persistent: false
Parent:
Mask:


Okay, click the picture below to view it fully.

Screenshot10.jpg

This also goes for the ones in the Shadow of the colossus post.

Advertisements

7 Comments

  1. jrb01 said,

    Good work. You could also add enemies like pikmik did to make it better.

  2. Bill Kerr said,

    I think you have gone from too many comments to too few comments !!
    parts of the code need explanation
    would like to talk to you about ths one too
    1) lost indents on if statements
    2) which parts need explaining
    3) identify objects in the code headings

  3. spegimuss said,

    za? problem number 10?Im struggling with problem 3!

  4. pikmik said,

    hhe, that problems easy! great, i forgot we could copy that info from the objects, its really useful. ill be ahead of you soon then! anywho, since you like leavin stories everywhere, luckily not on mine! ill write one for you.

    A caterpilla went for a walk. he got los so he camped out in the open. he awoke hungry. he found some leaves to munch on. what he didnt know was that they were mutant zombie leaves!
    the caterpilla ate but the leave didnt want to be eaten. the zombie started throwing feaces at the caterpilla to get him off. the caterpilla kept eating. the zombie was almost all eaten, but what the caterpilla didnt know was that he came alive in his stomach!
    the zombie pierced the caterpilla stomach, blood spurting everywhere! He then hoped out and put dinamite into the caterpillas stomach. They exploded making poo go everywhere. the end. (c) pikmik 2006

  5. pikmik said,

    hope ya like my story! great site by the way. love the theme, good explanations! from ur pal pikmik!

  6. Bill Kerr said,

    > (The following is to create constant gravity)

    not really because the gravity is 0.5 when falling and 0 when on the platform

  7. eraklitos said,

    how i can make a sprite jump??/like super mario!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: