0% found this document useful (0 votes)
3 views26 pages

Topic5 GameMechanics

Chapter 3 discusses game mechanics as a fundamental aspect of game design, focusing on how players interact with a virtual universe through gameplay and decision-making processes. It outlines the importance of functional and aesthetic information in shaping the player's experience, as well as guidelines for designing engaging gameplay mechanics. Additionally, it introduces satellite mechanics that enhance core gameplay without adding complexity, providing strategies to maintain player motivation and interest.

Uploaded by

kennylatimore4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views26 pages

Topic5 GameMechanics

Chapter 3 discusses game mechanics as a fundamental aspect of game design, focusing on how players interact with a virtual universe through gameplay and decision-making processes. It outlines the importance of functional and aesthetic information in shaping the player's experience, as well as guidelines for designing engaging gameplay mechanics. Additionally, it introduces satellite mechanics that enhance core gameplay without adding complexity, providing strategies to maintain player motivation and interest.

Uploaded by

kennylatimore4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chapter 3: Game Mechanics

Table of Contents
Chapter 3: Game Mechanics......................................................................................................................1
Introduction...........................................................................................................................................1
1. Cornerstone of Game design........................................................................................................2
2. Gameplay......................................................................................................................................2
3. Game Mechanics..........................................................................................................................3
Guidelines for gameplay design.......................................................................................................6
ASSIGNMENT:....................................................................................................................................7
Exercise: Game Development- Pong....................................................................................................7
REFERENCES....................................................................................................................................26

Introduction

• A good product is one that satisfies customers’ needs, preferences and


expectations.
• Relevant players’ opinions and judgments always originate from the
play experience.
• While playing a game, the player interacts with a virtual universe,
which receives player’s inputs and responds by changing its status.
• Information regarding the outcome of the interaction is then conveyed
to player, and eventually gathered and used by him/her to decide what
to do next.

1 Pkasyoka
1. Cornerstone of Game design
• The play experience interactive cycle is centered on a decision-making
process that relies on the information conveyed to the player.
• Information is transmitted through visual (graphics and text), or even
tactile means (in case the game relies on force-feedback interface
devices).
• Properties of contextual game objects (i.e. elements perceived by the
player as belonging to the virtual world), or explicit interfaces ( e.g.
graphic user interface components)
• Information managed by the player during the interactive cycle can be
divided into two categories:
1. Functional information
Allows the player to undertake the activities he/she is supposed to
carried out in order to win the game.
2. Aesthetic information
Defines most aspects of the context in which the game takes place,
and is manly aimed at rendering an atmosphere capable of drawing
and maintaining players’ attention on an emotive basis.
• The context of the game encompasses the storyline, the setting of the
game and the goals.
• The context has to do mainly with aesthetic information, although the
goals have certainly a crucial functional importance,

2. Gameplay
Gameplay is the set of activities that can be undertaken by the player as the
of the game and what other entities can do, in response to player’s actions.

2 Pkasyoka
3. Game Mechanics
• A player-centered perspective can lead to defining game mechanics as
a proper tools for gameplay OR Atomic rule-based interactive
subsystems capable of receiving an input and reacting by producing an
output.
• Such output translates into a state change of the mechanics itself
and/or
into the triggering of new interactions with other game mechanics.
• A given game mechanics might be capable of receiving different inputs
and reacting consequently.
• In terms of gameplay, this means to the player that the mechanics has
features that allow triggering different interactions with it

• To understand all this through a concrete example, let’s consider the


case of a locked door connected to an alarm system.
• Assume that the player is required to unlock the door using a lock
pick, and that if he/she doesn’t disconnect the alarm, any lock picking
attempt will activate it.
• A comprehensive schematic of the door mechanics can be formulated
through the use of an UML finite-state machine diagram

3 Pkasyoka
• The workings of the system involves two game mechanics (the door
and the alarm system),and the interactivity, in the case in which the
alarm is connected, can be represented by using UML communication
diagrams as follows.

As for game mechanics, challenge and reward come from three mechanics-
related activities:
1. learning the mechanics;
2. using the mechanics as a tool for gameplay in ordinary situations;
3. using the mechanics as a tool for gameplay in extra-ordinary
situations, in presence of external factors that may alter the ordinary
working of the mechanics.

Guidelines to sustain and enhance motivation in learning and using


mechanics

4 Pkasyoka
1. Estimate the learning time for each feature of a specific mechanics,
and make sure that the time to learn is proportional to player’s
perceived complexity and relevance of the feature itself.
2. In order to avoid burnout, design the game to allow players using
game mechanics as gameplay tools as soon as they feel they’ve learned
them.
3. Increase the perceived appeal and relevance of the mechanics, ensure
that players will have enough opportunities to use game mechanics’
features enhanced through the influence of external factors, achieving
otherwise unattainable goals.
4. Balance time invested in learning with time spent applying what has
been learned.

Satellite game mechanics


• It is possible to enrich the core gameplay without increasing its
complexity, by introducing special kinds of mechanics, aimed at
enhancing already existing activities.
• We call these “satellite game mechanics”, since their design is
functional to already-existing core mechanics.
Types of satellite mechanics
1. Enhanced,
2. Alternative and
3. Oppositions

1) Enhancement mechanics:
• They have the purpose of enhancing already-existing core game
mechanics.
• This can be done in two ways: by adding new features to an existing
mechanics, or by modifying an existing feature.
Enhancement mechanics

5 Pkasyoka
• Add-on:For instance, in a war game shooting enemies could be the
core gameplay activity, and a rifle could be one of the core mechanics.
The player could be allowed to earn a telescopic sight that can be
applied to the rifle.
• Power-up: These have the sole purpose of changing an existing
feature, usually to empower the whole mechanics. A good example of
this is the silencer of a gun. It changes a feature of the gun, allowing
shooting without being noticed.
2) Opposition mechanics:
They are a powerful means of enhancing the challenge in a game.
Their main purpose is hindering the player’s progress.

Core gameplay as the set of activities that the player will undertake more
frequently during the game experience, and which are indispensable to win
the game.
Core game mechanics:
The game mechanics which allow carrying out the core gameplay activities.
Example, The Tetris’ core mechanics include the control system for blocks.

Guidelines for gameplay design


The following set of gameplay design guidelines:

6 Pkasyoka
• Minimize the learning time required to master core mechanics’ features.
• Minimize the number of core mechanics, and the amount of features for each one of them.
• Make sure that all core mechanics are relevant throughout most of the game, and that there are
no functional redundancies amongst them.
• Exploit satellite mechanics in order to sustain and enhance players’ motivation in using core
mechanics.
• Suspend temporarily the use of specific mechanics in order to renew players’ interest in
them.
• Build the gameplay mostly based on core gameplay and core meta-gameplay activities,
providing through them the doses of challenge, mastership and reward that players seek.
• Minimize the use of peripheral gameplay.

ASSIGNMENT:
Discuss two categories of interactive cycle involved in game play.

Exercise: Game Development- Pong


The game is composed of six classes : [Link], [Link], [Link], [Link],
[Link] and [Link]

Window class

package [Link];

import [Link];

public class Window {

public Window(String title, Game game) {


JFrame frame = new JFrame(title);

7 Pkasyoka
[Link](JFrame.EXIT_ON_CLOSE);
[Link](false);
[Link](game);
[Link]();
[Link](null);
[Link](true);
}
}

Game class
package [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].Graphics2D;
import [Link];
import [Link];

/**
* class that manages the game, drawing and updating physics
*/
public class Game extends Canvas implements Runnable {

private static final long serialVersionUID = 1L;

public final static int WIDTH = 1000;


public final static int HEIGHT = WIDTH * 9 / 16; // 16:9 aspect ratio

public boolean running = false; // true if the game is running


private Thread gameThread; // thread where the game is updated AND drawn (single thread
game)

8 Pkasyoka
// ball object -> the thing that bounces on the walls and paddles
private Ball ball;

// the paddles
private Paddle leftPaddle;
private Paddle rightPaddle;

private MainMenu menu;


public Game() {

canvasSetup();

new Window("Simple Pong", this);

init();

[Link](new KeyInput(leftPaddle, rightPaddle));


[Link](menu);
[Link](menu);
[Link](true);

}
private void init() {
// Initialize Ball object
ball = new Ball();
// Initialize paddle objects
leftPaddle = new Paddle([Link], true);
rightPaddle = new Paddle([Link], false);
// initialize main menu
menu = new MainMenu(this);
}

9 Pkasyoka
/**
* just to setup the canvas to our desired settings and sizes
*/
private void canvasSetup() {
[Link](new Dimension(WIDTH, HEIGHT));
[Link](new Dimension(WIDTH, HEIGHT));
[Link](new Dimension(WIDTH, HEIGHT));
}

/**
* Game loop
*/
@Override
public void run() {
[Link]();
// game timer
long lastTime = [Link]();
double amountOfTicks = 60.0;
double ns = 1000000000 / amountOfTicks;
double delta = 0;
long timer = [Link]();
int frames = 0;
while (running) {
long now = [Link]();
delta += (now - lastTime) / ns;
lastTime = now;
if (delta >= 1) {
update();
delta--;
draw();

10 Pkasyoka
frames++;
}

if ([Link]() - timer > 1000) {


timer += 1000;
[Link]("FPS: " + frames);
frames = 0;
}
}

stop();
}

/**
* start the thread and the game
*/
public synchronized void start() {
gameThread = new Thread(this);
/*
* since "this" is the "Game" Class you are in right now and it implements the
* Runnable Interface we can give it to a thread constructor. That thread with
* call it's "run" method which this class inherited (it's directly above)
*/
[Link](); // start thread
running = true;
}

//Stop the thread and the game


public void stop() {
try {
[Link]();

11 Pkasyoka
running = false;
} catch (InterruptedException e) {
[Link]();
}
}

//draw the back and all the objects


public void draw() {
// Initialize drawing tools first before drawing
BufferStrategy buffer = [Link](); // extract buffer so we can use them
// a buffer is basically like a blank canvas we can draw on
if (buffer == null) { // if it does not exist, we can't draw! So create it please
[Link](3); // Creating a Triple Buffer
/*
* triple buffering basically means we have 3 different canvases this is used to
* improve performance but the drawbacks are the more buffers, the more
memory
* needed so if you get like a memory error or something, put 2 instead of 3.
* BufferStrategy:
* [Link]
*/
return;
}
Graphics g = [Link](); // extract drawing tool from the buffers
/*
* Graphics is class used to draw rectangles, ovals and all sorts of shapes and
* pictures so it's a tool used to draw on a buffer
*
* Graphics: [Link]
*/
// draw background

12 Pkasyoka
drawBackground(g);
// draw main menu contents
if ([Link])
[Link](g);
// draw ball
[Link](g);
// draw paddles (score will be drawn with them)
[Link](g);
[Link](g);
// actually draw
[Link](); // Disposes of this graphics context and releases any system resources that it
// is using
[Link](); // actually shows us the 3 beautiful rectangles we drew...LOL
}

/**
* draw the background
* @param g - tool to draw
*/
private void drawBackground(Graphics g) {
// black background
[Link]([Link]);
[Link](0, 0, WIDTH, HEIGHT);
// Dotted line in the middle
[Link]([Link]);
Graphics2D g2d = (Graphics2D) g;
// How to make a dotted line:
Stroke dashed = new BasicStroke(3, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_BEVEL, 0, new float[] { 10 }, 0);
[Link](dashed);
[Link](WIDTH / 2, 0, WIDTH / 2, HEIGHT);

13 Pkasyoka
}

/**
* update settings and move all objects
*/
public void update() {

if (![Link]) {
// update ball (movements)
[Link](leftPaddle, rightPaddle);

// update paddles (movements)


[Link](ball);
[Link](ball);
}
}

/**
* used to keep the value between the min and max
* @param value - integer of the value we have
* @param min - minimum integer
* @param max - maximum integer
* @return: the value if value is between minimum and max, minimum is returned
* if value is smaller than minimum, maximum is returned if value is
* bigger than maximum
*/
public static int ensureRange(int value, int min, int max) {
return [Link]([Link](value, min), max);
}

/**

14 Pkasyoka
* returns the sign (either 1 or -1) of the input
* @param d - a double for the input
* @return 1 or -1
*/
public static int sign(double d) {
if (d <= 0)
return -1;
return 1;
}
public static void main(String[] args) {
new Game();
}
}

MainMenu

package [Link];
import [Link];
import [Link];
import [Link];
import [Link].Graphics2D;
import [Link];
import [Link];
import [Link];
import [Link];

public class MainMenu extends MouseAdapter {


public boolean active; // true if main menu is displaying
// Play button
private Rectangle playBtn; // Play Button

15 Pkasyoka
private String playTxt = "PLAY";
private boolean pHighlight = false; // true if the mouse hovered over the Play button
// Quit button
private Rectangle exitBtn; // Quit Button
private String exitTxt = "EXIT";
private boolean exitHighlight = false; // true if the mouse hovered over the Quit button

private Font font;

public MainMenu(Game game) {


active = true;
[Link]();
// position and dimensions of each button
int x, y, w, h;
w = 300;
h = 150;
y = [Link] / 2 - h / 2;
x = [Link] / 4 - w / 2;
playBtn = new Rectangle(x, y, w, h);
x = [Link] * 3 / 4 - w / 2;
exitBtn = new Rectangle(x, y, w, h);
font = new Font("Roboto", [Link], 100);
}

//Draw buttons (rectangles) and text in the Main Menu


public void draw(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
[Link](font);
// draw buttons
[Link]([Link]);
if (pHighlight)

16 Pkasyoka
[Link]([Link]);
[Link](playBtn);
[Link]([Link]);
if (exitHighlight)
[Link]([Link]);
[Link](exitBtn);
// draw button borders
[Link]([Link]);
[Link](playBtn);
[Link](exitBtn);
// draw text in buttons
int strWidth, strHeight;
// Play Button text
strWidth = [Link](font).stringWidth(playTxt);
strHeight = [Link](font).getHeight();
[Link]([Link]);
[Link](playTxt, (int) ([Link]() + [Link]() / 2 - strWidth / 2),
(int) ([Link]() + [Link]() / 2 + strHeight / 4));
// Quit Button text
strWidth = [Link](font).stringWidth(exitTxt);
strHeight = [Link](font).getHeight();
[Link]([Link]);
[Link](exitTxt, (int) ([Link]() + [Link]() / 2 - strWidth / 2),
(int) ([Link]() + [Link]() / 2 + strHeight / 4));
}
@Override
public void mouseClicked(MouseEvent e) {
Point p = [Link]();
if ([Link](p))
active = false;
else if ([Link](p))

17 Pkasyoka
[Link](0);
}
@Override
public void mouseMoved(MouseEvent e) {
Point p = [Link]();
// determine if mouse is hovering inside one of the buttons
pHighlight = [Link](p);
exitHighlight = [Link](p);
}
}

Paddle class

package [Link];
import [Link];
import [Link];
import [Link];
public class Paddle {
private int x, y; // positions
private int vel = 0; // speed and direction of paddle
private int speed = 10; // speed of the paddle movement
private int width = 22, height = 150; // dimensions
private int score = 0; // score for the player
private Color color; // color of the paddle
private boolean left; // true if it's the left paddle
//create initial properties for the paddle
public Paddle(Color c, boolean left) {
// initial properties

18 Pkasyoka
color = c;
[Link] = left;
if (left) // different x values if right or left paddle
x = 0;
else
x = [Link] - width;
y = [Link] / 2 - height / 2;
}
// add score
public void addPoint() {
score++;
}

//Draw paddle (a rectangle), Draw score too


public void draw(Graphics g) {
// draw paddle
[Link](color);
[Link](x, y, width, height);
// draw score
int sx; // x position of the string
int padding = 25; // space between dotted line and score
String scoreText = [Link](score);
Font font = new Font("Roboto", [Link], 50);
if (left) {
int strWidth = [Link](font).stringWidth(scoreText); // we need the
width of the string so we can center it properly (for perfectionists)
sx = [Link] / 2 - padding - strWidth;
} else {
sx = [Link] / 2 + padding;
}
[Link](font);

19 Pkasyoka
[Link](scoreText, sx, 50);
}
// update position AND collision tests
public void update(Ball b) {
// update position
y = [Link](y + vel, 0, [Link] - height);
// collisions
int ballX = [Link]();
int ballY = [Link]();
if (left) {
if (ballX <= width + x && ballY + [Link] >= y && ballY <= y + height)
[Link]();

} else {
if (ballX + [Link] >= x && ballY + [Link] >= y && ballY <= y + height)
[Link]();
}
}
//switches the direction
public void switchDirections(int direction) {
vel = speed * direction;
}
// stop moving the paddle
public void stop() {
vel = 0;
}
}

Ball class

20 Pkasyoka
package [Link];
import [Link];
import [Link];
public class Ball {
public static final int SIZE = 16;
private int x, y; // position of top left corner of square
private int xVel, yVel; // either 1 or -1
private int speed = 5; // speed of the ball
public Ball() {
reset();
}
private void reset() {
// initial position
x = [Link] / 2 - SIZE / 2;
y = [Link] / 2 - SIZE / 2;
// initial velocity
xVel = [Link]([Link]() * 2.0 - 1);
yVel = [Link]([Link]() * 2.0 - 1);
}
/**
* Draw ball (a square)
* @param g: Graphics object used to draw everything
*/
public void draw(Graphics g) {
[Link]([Link]);
[Link](x, y, SIZE, SIZE);
}
/**
* update position AND collision tests
* @param lp: left paddle
* @param rp: right paddle

21 Pkasyoka
*/
public void update(Paddle lp, Paddle rp) {
// update position
x += xVel * speed;
y += yVel * speed;

// collisions
// with ceiling and floor
if (y + SIZE >= [Link] || y <= 0)
changeYDir();
// with walls
if (x + SIZE >= [Link]) { // right wall
[Link]();
reset();
}
if (x <= 0) { // left wall
[Link]();
reset();
}
}
public int getX() {
return x;
}
public int getY() {
return y;
}
/**
* switch x direction IF ball going right, go left otherwise, go right
*/
public void changeXDir() {
xVel *= -1;

22 Pkasyoka
}

/**
* switch y direction IF ball going up, go down otherwise, go up
*/
public void changeYDir() {
yVel *= -1;
}

KeyInput Class

package [Link];
import [Link];
import [Link];
public class KeyInput extends KeyAdapter {
private Paddle lp; // left paddle
private boolean lup = false; // lup = left up (up1 in video)
private boolean ldown = false;
private Paddle rp; // right paddle
private boolean rup = false;
private boolean rdown = false;
public KeyInput(Paddle p1, Paddle p2) {
lp = p1;
rp = p2;
}
@Override

23 Pkasyoka
public void keyPressed(KeyEvent e) {
int key = [Link]();
if (key == KeyEvent.VK_UP) {
[Link](-1);
rup = true;
}
if (key == KeyEvent.VK_DOWN) {
[Link](1);
rdown = true;
}
if (key == KeyEvent.VK_W) {
[Link](-1);
lup = true;
}
if (key == KeyEvent.VK_S) {
[Link](1);
ldown = true;
}
// exit
if (key == KeyEvent.VK_ESCAPE) {
[Link](1);
}
}

@Override
public void keyReleased(KeyEvent e) {
int key = [Link]();
if (key == KeyEvent.VK_UP) {

24 Pkasyoka
rup = false;
}
if (key == KeyEvent.VK_DOWN) {
rdown = false;
}
if (key == KeyEvent.VK_W) {
lup = false;
}
if (key == KeyEvent.VK_S) {
ldown = false;
}
if (!lup && !ldown)
[Link]();
if (!rup && !rdown)
[Link]();
}

Output:

25 Pkasyoka
REFERENCES

1. Fabricatore, C., Nussbaum, M. and Rosas, R. (2002), “Playability in Action Videogames: A


Qualitative Design Model”, Human-Computer Interaction, 17 (4).
2. Lewinski, J. S. (1999), Developer’s Guide to Computer Game Design , Wordware
Publishing,Inc., Plano.
3. Fowler, M. (2003), UML Distilled: A Brief Guide to the Standard Object Modeling
Language,Third Edition, Addison-Wesley, Reading.

26 Pkasyoka

You might also like