Problem 12

September 13, 2006

I used a tutorial of the net to make my pong game which could have been done without it except the code to one of the objects to make it a single player game

I edited this code to suit my game but if i didn’t have it, i’d have to make it a multiplayer pong

Tutorial here http://pjrgaming.f2g.net/gmbook/Chapter3.htm

This tutorial can be used by complete gamemaker beginners

(it even has install info in the first two chapters)


Problem 11

September 13, 2006

push a rock

First you’ll need to make a pushing character and a rock to be pushed.

The pusher will need to move the same as problem 3 so that it can move the rock.

Once you’ve done that you can put a collision event with the character in the rock.

Control Tab, If an expression is true, “pusher objects name”.direction=0 in the pop up menu.

then create a start of block and end of block and inbetween them put:

Move Tab, Start moving in a direction, click the right arrow and enter the same speed as the pusher.

Main2 Tab, Set an alarm clock

  • steps=1.5
  • alarm=alarm0.

Now you need to create an alarm event and put in start moving in a direction from the move tab. Click the middle square and leave the speed at 0.

Now your character can push a rock naturally.

this wasn’t too hard although i did follow a blog by pikmik’s friend from that other class, and couldn’t get the rock to stay in the room for a while


Problem 10

September 13, 2006

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

Information about object: guy

Sprite: guy

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 .75 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)

stefen’s file helped me big time and so did another student’s blog (not sure who), and kingy helped with touch ups as this is in his game


Problem 9

September 13, 2006

A character fires a bullet and has to wait one second before being able to fire the next bullet.

Load a character sprite and a bullet sprite.

Add an object and use the bullet sprite. Click on add event, create. Drag the red arrows, under the move tab, into the action section. When the popup appears, click only the up arrow. Type how fast you want the bullet to go in the speed section.

Add another object and use the character sprite. Click on add event, create. Drag set the value of a variable, under the control tab, into the action section. When the popup appears, type canshoot into the variable section. Also, type 1 into the value section.

Click on add an event, keypress, space. Drag if a variable has a value, under the control tab, into the action section. When the popup appears, type canshoot into the variable section. Type 1 into the value section, and select equals to in the operation section.

Drag both start and end of block, under the control tab, into the action section. In between them, drag create instance of an object. When the popup appears, select the bullet object in the object section, and click the relative box.

Also between the blocks, drag set the value of a variable. When the popup appears, type canshoot in the variable section, and 0 in the value section.

Also between the blocks, drag set an alarm clock, under the main2 tab. When the popup appears, type 30 in the number of steps. and press ok.

Click on add an event, alarm0. Drag set the value of a variable, under the control tab, into the action section. Type canshoot in the variable section, and 1 in the value section.

Test this by putting the character in a room, and pressing space. You should only be able to shoot a bullet every second.

king helped me as this is in his game

also stefen and that 1945 game sorta helped me


Problem 8

September 13, 2006

You have to hit a character 3 times with a bullet before it dies.

Load up your problem 4 game.

Make and enemy sprite, amd then an object. Click on the create event. Drag set the number of lives, under the score tab, into the action section. When the popup appears, type 3 in the new lives section. Click ok. Click on the already made collision with bullet event. Drag set the nuber of lives, under the score tab, into the action section. When the popup appears, type in -1 in the new lives section. Click the relative box, then ok. Delete the change instance into explosion.

Click on add event, Step. Drag If lives are a value, under the score tab, into the action section. When the popup appears, type 0 in the value section, and select equals to in the operation section. Then drag both start of block and end of block, under the control tab, into the action section. In between these, drag change the instance, under the main1 tab. When the popup appears, select object explode in the change into section, and yes in the perform events section.

Test the game, to see if the enemy will explode after 3 bullets.

i got this workin easy but couldn’t think of a way to get rid of the bullet after the third hit (so it looks a bit shotty, even though getting rid of the bullet isn’t a requirement)


Problem 7

September 13, 2006

Make a timer which counts up or down how much time is left to play.

Create an object. You do not need a sprite. Click on add event, create. Drag set the value of a variable, under the control tab, into the action section.When the popup appears, type mytime into the variable section. Type how long you want the timer to countdown into the value section (mine is 20). Drag set an alarm clock, under the main2 tab, into the action section. Type in room_speed, or 30, into the number of steps section. Select alarm0 in the alarm no. section.

Click on add event, alarm0. Drag set the value of a variable, under the control tab, into the action section. When the popup appears, type mytime in the variable section. Then type -1 in the value section. Tick the relative box.

Click on add event, draw. Drag draw a text, under the draw tab, into the action section. Type ‘Time left in game: ’+string(mytime)+’ seconds’ into the text section. Leave the x and y sections 0.

Put this object in a room, and play it, to see if it works.

stefen helped me with the mytime part, and then using the equal to and or else functions i was able to stop the timer at 0 seconds.

Information about object: obj_timer

Sprite: <no sprite>Solid: false Visible: true

Depth: 0

Persistent: false

Parent: <no parent>

Mask: <same as sprite>

Create Event:set variable mytime to 20set Alarm 0 to room_speed

Alarm Event for alarm 0:if mytime is larger than 0set variable mytime relative to -1

set Alarm 0 to room_speed

if mytime is equal to 0

set variable mytime relative to 0

Step Event:if number of objects obj_timer is Equal to 0Draw Event:at position (0,0) draw text: ‘Time left in game: ‘+string(mytime)+’ seconds’


Problem 6

September 13, 2006

A ball goes through a goal and the score goes up by one…the score does not go up if the ball misses the goal

Add a sprite of a ball. Also add a sprite of goal posts (does not have to look like actual goal posts, mines just a small barrier sprite)

Add an object and use the ball sprite. Click add event, key press, space. Drag the blue arrows, under the move tab, into the action section. when the popup appears, type in 45+random(90) in the direction section. Type how fast you want the ball to move in the speed section. Click on add event, other, outside room. Drag jump to the start position, under the move tab, into the action section. When the popup appears, click self, then ok. Then drag the red arrows, under the move tab, into the action section. Click only the square, stop button, when the popup appears.

Create an object and use the goal sprite. Click on add event, collision with the ball object. Drag set the score, under the score tab, into the action section. When the popup appears, type 1 in the new score section and tick the relative box. Drag jump to the start position, under the move tab, into the action section. When the popup appears, click on other. Drag the red arrows, under the move tab, into the action section. When the popup appears, click on other.

Test the game by creating a room, and putting a ball at the bottom of the screen, and if you followed my directions, put the goal only at the top.

Looked at “pimmiks” blog from that other class


Problem 5

September 13, 2006

Make one object follow another object.

Add 2 sprites, they can be anything you want them to be.Add an object. Use the sprite you want to be the leader. Call the object ”whatever the you want the leaders name to be”.Click on add an event, Create. Drag the red arrows, under the move tab, into the action section. When the pop up appears, click all the arrows, but not the square in the centre. In the speed section, type how fast you want the object to move.Click on add an event, other, outside room. Drag jump to a random position, under the move tab, into the action section. When the popup appears, click ok. Drag the red arrows, under the move tab, into the action section. When the popup appears, click on all of the arrows, except the square in the centre.

Add an object, and use the other sprite. Call the object “sheep or follower, etc”. Click on add an event, step. Drag move towards a point, under the move tab, into the action section. When the popup appears, type in (“leader’s name”).x in the x section, (“leader’s name”).).y in the y section. Type how fast you want the object to move in the speed section. Click on add an event, collision with leader. Drag jump to a random position, under the move tab, into the action section. When the popup appears, click ok. Open the leader object again. Click add an event, collision with the follower. Drag jump to a random position, under the move tab, into the action section. When the popup appears, click ok. Then drag in the red arrows, under the move tab, into the action section. When the popup appears, click on all of the arrows, not the square. Type how fast you want the object to move in the speed section.

Create a room, and put in one leader and one or more followers/sheep. Play the game to test if the follower moves towards the leader( i called mine a shepherd).

I looked at Jack Grigoul’s gamemaker blog for help with this, and then added another with a slower speed.


Problem 4

September 13, 2006

When a bullet hits a character, the character explodes and the explosion then disappears.

Once you have completed making a character move and shoot, add another sprite. Load a sprite you think will be good for an enemy.Create an object and use the enemy sprite.

Add another sprite in, of an explosion. Our animation was provided by our teacher. The animation should look like something exploding.Add an object and use the explosion sprite. Click add event, then other, then Animation end. Drag destroy the instance, under main 1 tab, into the action section, and when it loads, click on the applies to self.On the enemy object click on add an event, collision with the bullet. Drag in change the instance, under main 1 tab, into the action section. When the popup appears, under the change into section, click the explosion. Under the perform events section, click yes.

When a bullet hits the enemy, it now should explode and the explosion should disappear.  

easy stuff used the explosion part from 1946 game


Problem 3

September 13, 2006

A character can move left and right with arrow keys (you have to keep pressing the key for it to keep moving) and fires a single bullet forward when you press space bar. You have to release and press space bar again for more bullets.

Add a sprite. Load a sprite you would like to use, eg a character or a space ship. Also, load a bullet sprite.
Create an object, and use the character sprite. Add an event, and click on key press, left. Drag the red arrows, under the move tab, into the action section and click only the left arrow when the pop up appears. Type how fast you would like the character to move under the speed section. Add another event and click on key press, right. Drag the red arrow keys, under the move tab, into the action section. When the pop up appears, only click the right arrow.
To make the character stop when the key is released, add an event, then click key release, left. Drag the red arrows, under the move tab, into the action section. Only click the stop button which is square, when the pop up appears. Add an event, then click key release, right. Drag the red arrows, under the move tab, into the action section. Only click the stop button which is square, when the pop up appears.
Test if the character moves by creating a room and putting the character object in it. Play the game and see if it moves.
Add an object and use the bullet sprite. Click on add event, create. Drag the Red arrow pointing down (set the vertical speed) into the action section. When the popup appears, type in the speed you want the bullet to move, with a negative in front. This will make it shoot up.

To make the character shoot bullets, click on add event on the character object. Then click on keypress, space. Drag the yellow light bulb (create the instance of an object), under the main 1 tab, into the action section. When the popup appears, in the object section, locate your bullet object. Then click on relative, so whenever you press space, a bullet will appear where you are.

To test the game, put your character in a room and when it loads, press space to see if it shoots.

I learnt how to do this in class when i started making the 1945 game


Follow

Get every new post delivered to your Inbox.