Problem 10 Handy Hint

In my screenshot, you can see i have added enemies. This is how i created it:

Information about object: bear (enemy)

Sprite: bear
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Mask:

Create Event:
start moving in directions left and right, with speed set to 5
move in direction 270 at most 12 till a contact with solid objects

//Makes the enemy move left and right, and sit on the block, not above it.

Step Event:
if relative position (1,1) gives not a collision with Only solid objects
reverse horizontal direction
if relative position (-1,0) gives a collision with Only solid objects
reverse horizontal direction
if relative position (1,0) gives a collision with Only solid objects
reverse horizontal direction
if relative position (-1,-1) gives a collision with Only solid objects
reverse horizontal direction

//Makes the enemy bounce off the side walls, and change direction if there is not a platform under it.

Collision Event with object jumper:
for all jumper: jump to the start position
set the number of lives relative to -1.

// Makes the jumper lose lives when it hits the enemy and return to the start.

Information about object: jumper
 

Create Event:
set the number of lives to 3
//Makes the jumper have 3 lives

Step Event:
If lives are smaller than 0
      end the game
//Makes the game end if the jumper has no lives left.

Published in: on March 21, 2006 at 8:35 am  Comments (3)  

Problem 10.

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

Information about object: jumper

Sprite: jumper

Solid: true

Visible: true

Depth: 0

Persistent: false

Parent:

Mask:

Step Event:

If relative position (0,1) is collision free for Only solid objects

set the gravity to .5 in direction 270

//if there is no wall underneath the object, set gravity

else

set the gravity to 0 in direction 270

//if there is a wall under the object, destroy the gravity

if vspeed is larger than 12

set variable vspeed to 12

//if the object moves too fast, set the speed back to a slower realistic speed.

Collision Event with object wall:

move in direction direction at most 12 till a contact with solid objects

set the vertical speed to 0

// stop the gravity if it is touching the wall. Also makes it sit on the wall, not above it.

Keyboard Event for Key:

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

move relative to position (-4,0)

// Makes the object be able to move on the platform.

Keyboard Event for Key:

if relative position (0,1) gives a collision with Only solid objects

set the vertical speed to -10

// Makes the object jump up.

Keyboard Event for Key:

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

move relative to position (4,0)

// Makes the object be able to move on the platform.

I made this game by getting some information from the tutorial my teacher made. I would like to thank him for creating helpful tutorials.

platform.jpg

Published in: on March 21, 2006 at 12:09 am  Comments (2)  
Follow

Get every new post delivered to your Inbox.