Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Objects in Game Maker

No description
by

Keilfer Blank

on 26 April 2010

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Objects in Game Maker

Classes and Objects in Game Maker In Game Maker, the "objects" shown here on the left are classes. Every one of these "objects" are actually blueprints to create real instances of an object in a room. They each contain several methods that tell the instance of the object how to behave. What is a class in Game Maker? This is what an "object", or class, really looks like in Game Maker. Every one of the events on the left is a method. Every "event" has a series of actions it will perform whenever the appropriate conditions needed to trigger it are met. These actions are actually methods themselves. For example, the Create event, which is triggered when an instance of this object is first created, will set a variable, numshields, to 5. Instantiation in Game Maker
This is a room. In game maker, rooms can be compared to the Main method in a java program. When a game is run, it will load the room, and create instances of every one of the objects placed in the room. once they are created, the objects will run thorugh their methods whenever they are triggered. This is an instance of pacmanObj. When the game runs, it is placed in the room. Whenever one of it's events are triggered, such as the <left> key being pressed on the keyboard. It will perform the appropriate actions. The Constructor Method The constructor method is the method that will run right when an instance of an object is created. It will usually set the initial value for certain variables, and can often call other methods. This method is only called once however: when the object is created. In Game Maker, the create event would be considered the constructor method. This is the constructor method (create event) for the Level1Obj class. This object is a controller object, so its main purpose is to control different parts of the game such as ammo count and lives. Therefore, this class' constructor method sets the number of bullets at the start of the game, and gives the player three lives. It also sets an alarm, who's purpose is to trigger another one of the object's methods. Inheritance This is the pacmanObj class. It contains a variety of methods that make it perform as the player character in the game. This is a child of the pacmanObj class. You will probably notice that it contains no methods. This is because, as a child of the pacmanObj class, it has inherited all of its methods. Child objects automatically get all the methods of its parent class. This is called Inheritance. However, while child objects inherit their parent methods, they do have the ability to override them. In this case, the sprite of this object has been changed to show a change in direction. Example of Java Code public class TopGhostObj
{
public TopGhostObj(int xPos, int yPos)
{
setPosition(xPos, yPos);
setSprite(TopGhostObj);

int dirRand = Math.floor(Math.random()*2+1)
switch (dirRand)
{
case 1: setDirection(left);
case 2: setDirection(right);
}
setSpeed(9);
Alarm0(60);
}

public Destroy()
{
score += 1;
TopGhostObj Ghost = new TopGhostObj(TopGhostObj.x, (TopGhostObj.y)+50);
}

public Alarm0(int t)
{
if(t = 0) //This would actually need some sort of countdown listener.
{
gBulletObj b = new gBulletObj(TopGhostObj.x, TopGhostObj.y);
Alarm0(60);
}
}
} Review Instances Classes Inheritance Constructor Method
Full transcript