THE WELL - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

THE WELL

Description:

Model takes care of the game execution and contains all the game state ... This can be used in Tetris, where the UserControlled behavior gets reasigned to ... – PowerPoint PPT presentation

Number of Views:42
Avg rating:3.0/5.0
Slides: 18
Provided by: marcin7
Category:
Tags: the | well | tetris

less

Transcript and Presenter's Notes

Title: THE WELL


1
THE WELL
  • XOOGA

2
Design Goals
  • Game Framework
  • Easy to use
  • Easily extensible
  • Pluggable components

3
MVC
  • Standard MVC design
  • Viewer responsible for game selection through a
    drop down menu (can be provided dynamically by
    examining available xml files) and showing game
    play.
  • Model takes care of the game execution and
    contains all the game state information.
  • Controller provides Model with information about
    user input. User input can be recorded so that
    the game can be replayed with identical user
    actions.

4
Overall program execution
  • MVC gets connected.
  • User chooses a game from the available set of
    options.
  • Game gets loaded from xml using a parser.
  • Game state is initialized to first level and play
    begins.
  • Model maintains knowledge of game state in a
    GameState object.
  • Game runs in a loop until either the win or lose
    conditions get satisfied (or the player quits the
    game), at which point the appropriate action is
    taken (advance to next level, end playing, etc.)
  • Viewer has a list of elements to be displayed
    that gets modified as needed.

5
Game Representation
6
Game and GameLevel Classes
  • Stores all the information obtained from parser
    levels, game state, conditions, etc.
  • Basically they are placeholders for information.
  • The Model loads required game state information
    from these classes and uses it to play the game.

7
GameEntity Class
  • Every element of the game is a GameEntity (no
    subclassing needed).
  • Allows to plug in behavior, image, and any other
    properties.
  • This allows for flexibility in creating new game
    elements.

8
GameEntity displaying
  • A GameEntity implements Animatable, so it can be
    used in a Canvas, but drawing functionality is
    delegated to an Animatable that is an instance
    member of GameEntity.
  • Through this the appearance of a GameEntity is
    easily replaceable with a completely different
    shape. For example an alien animation can turn
    into an explosion animation.

9
GameEntity properties
  • A GameEntity can have any number of property
    objects ID, velocity, dimension, number of
    lives, point value, etc.
  • This is done by using a map of Strings to
    Objects.
  • This adds flexibility allowing different elements
    (bricks, balls, etc.) to have different
    properties.
  • Entities can be queried about their properties
    and these properties can be modified externally,
    if necessary.
  • Corresponds to characteristic tag in xml spec.

10
GameEntity behavior
  • Behavior anything that an entity can do move,
    morph, disappear, shoot bullets (spawn new
    GameEntities), teleport, including special
    entities like timers ticking off seconds.
  • Each GameEntity has a List of Behaviors that it
    exhibits.
  • Behaviors can be exhibited in different ways
    always, every now and then, etc. This is
    supported by concrete implementations of the
    abstract Behavior class.
  • More details on Behaviors later on.

11
GameEntity interaction
  • The Model contains information about all the
    elements currently in the game (via a GameState
    object) and identifies collisions between them.
  • Upon a collision, each involved GameEntity is
    messaged about colliding with the other entity.
  • Each GameEntity has a mapping (determined by
    entity property correspondence) of other entities
    to reaction Behaviors for collisions with those
    entities.
  • This way objects can behave differently based on
    what kind of other GameEntity they collide with
    (useful in Pac-Man)

12
Behavior Hierarchy diagram
13
Behavior Hierarchy and Events
  • Behaviors represent any activity that an entity
    can perform.
  • Concrete implementations control when those
    activities get performed (randomly,
    conditionally, continually, etc.).
  • Behaviors can be added and removed from
    GameEntities. This can be used in Tetris, where
    the UserControlled behavior gets reasigned to new
    game pieces as necessary or in Breakout when a
    user collects an upgrade and gains new abilities
    (i.e. Behaviors).

14
Events
  • The execution of a Behavior is carried out in
    terms of Event objects. Many Events might be
    needed to carry out a Behavior.
  • Events are the unit actions the make up a
    behavior. For example, when a brick gets knocked
    out, the following events happen make ball
    bounce, delete brick from game, add points to
    score.
  • Events are executed on a target, which is
    provided dynamically (for example, which brick
    should disappear) or predefined (there is only
    one score entity that needs to be updated)
    depending on the actual concrete Event used.

15
Condition Hierarchy
  • Conditions return a boolean value based on the
    state of the game or other factors.
  • Can have different kinds of conditions flags,
    timers that switch value after time runs out,
    counters, conditions based on object properties,
    etc.
  • Conditions can be composed using logical
    operators and, or, not to create complex
    conditions.
  • Conditions can be used to evaluate the state of
    the game, reaching game goals (all enemies die),
    etc.
  • They can be used to enable behaviors. This
    mechanism can be used to provide rudimentary AI

16
Putting it together
  • Components are structured to be independent of
    one another and provide flexibility in composing
    basic building blocks (behaviors, properties,
    shapes, conditions) to create a wide variety of
    game elements.
  • This separation allows for easy expansion by
    creating additional building blocks.

17
Putting it together exampleImplementing a
Breakout paddle
  • A paddle is a GameEntity (since its part of the
    game).
  • Properties appearance (an Animatable), size,
    position
  • Behaviors moveable by user
  • Interactions comes in contact with a ball, the
    walls, and possibly power-ups. It has appropriate
    reaction Behaviors installed.
  • Collision events gets hit by a ball nothing
    happens (the ball will know to bounce on its
    own), hits a wall movement behavior gets
    changed to disallow going past the wall,catches a
    power-up appropriate power-up behavior will
    modify the properties of the paddle (appearance)
    and its behavior (e.g. ability to shoot)
  • Ball will have Behavior to know if it is out of
    bounds, and will modify the game state through
    appropriate Events.
  • An extension like sounds can easily be added by
    adding extra Events to the appropriate Behaviors
    that would be responsible for playing the sounds.
Write a Comment
User Comments (0)
About PowerShow.com