UMD Game Design Club 2D Game Workshop 1 - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

UMD Game Design Club 2D Game Workshop 1

Description:

To give an introduction to the 2D platform game we'll be using for ... EF 1 CD 31 EGAD EGAD * BBBBBBBBGHBBBBBBBGHBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBGAAHBBBBBBBBBBB ... – PowerPoint PPT presentation

Number of Views:80
Avg rating:3.0/5.0
Slides: 23
Provided by: cisUm
Category:
Tags: umd | club | design | egad | game | workshop

less

Transcript and Presenter's Notes

Title: UMD Game Design Club 2D Game Workshop 1


1
UMD Game Design Club2D Game Workshop 1
  • website
  • http//www.cis.umassd.edu/u_ddaniels/gdc

2
Goals
  • To give an introduction to the 2D platform game
    we'll be using for the competition.
  • To get hands on experience developing add-ons to
    the 2D platform game.
  • Create a new bad guy for the game.
  • Add more complex movements, (jumping around, and
    over obstacles)
  • Add more complex behavior (tracking the player)

3
Game Competition
  • The first GDC game competition involves modifying
    an existing 2D platform game to create your own
    unique game.
  • You can edit the
  • images and tiles used in the game
  • edit how the game plays, modify the physics etc.

4
Creating a 2D Platform game
  • Platform games are games in which player runs and
    jumps from platform to platform, avoiding bad
    guys and collecting power ups.
  • To create a platform game you must learn about
  • tile-based maps
  • map files
  • collision detection
  • power-ups
  • bad guys
  • parallax background scrolling

5
Graphics Package
  • Contains the basic classes for running graphics
  • Sets up the output device for desired output
  • Contains Animation, NullRepaintManager,
    ScreenManager, and Sprite
  • Animation stores a list of images and times to
    display them
  • ScreenManager sets up a full screen display
  • Sprite is an animation with a location and speed
  • NullRepaintManager is RepaintManager that does
    nothing

6
Input Package
  • Handles the input from the keyboard or mouse
  • Can map actions to different keys
  • Contains GameAction, InputManager
  • GameAction toggles state when key is pressed or
    released
  • Can set action type, continuous action, or single
    action
  • InputManager sets specified keys to GameActions

7
Tile-Game package
  • Loads in the maps and sprite images for different
    objects
  • Runs the game through GameManager
  • TileMap holds the map of the level
  • TileMapRenderer draws the map onto the screen

8
Sprites Package
  • Handles the different sprites in the game
  • Contains Creature, Player, PowerUp, and enemy
    classes
  • Creature is base class for enemy and player
  • Enemy has a specified movement pattern
  • Player handles player movement and state
  • PowerUp is an object that can be picked up by the
    player

9
Creating a Tile-Based Map
  • A tile-based map is composed of several image
    tiles on a grid.
  • Like creating a game with building blocks
  • Makes it easy to determine what's solid and
    what's empty on the map.
  • See TileMap.java class for details

10
Loading Tile Maps
  • Tile maps can be stored in text files, which can
    contain characters that represent specific tiles.
  • This allows for easy creation and storage of
    levels for your game.
  • See TileMap.loadMap() for details.

11
Example Tile Map
Map file for tile-based game (Lines that
start with '' are comments) The tiles are
(Space) Empty tile A..Z Tiles A through
Z o Star ! Music Note
Goal 1 Bad Guy 1 (grub) 2
Bad Guy 2 (fly) 3 Bad Guy 3 (monkey)


o o
o o o
o o o 3 o o o
o o IIIIIII III
o o 2
3 o 2
2 EF 2EF 3
3 EF EGD 3 3
EGD EF 1 CD 31 EGAD
EGAD BBBBBBBBGHBBBBBBBGHBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBBBBGAAHBBBBBBBBBBB
12
Badguys
  • Bad guys are the creatures in the game that stop
    the player from reaching their goal.
  • In this workshop we'll be creating a new bad guy.
  • We'll take the existing framework used to create
    the other bad guys, and extend it, to make a more
    complex bad guy.
  • The new bad guy will be able to leap around and
    will also be able to follow and track the player.

13
BAD MONKEY!
  • The Bad Guy we'll be creating is the evil
    MONKEY!!
  • He is a ruthless, chaotic monkey who leaps around
    the level, viciously hunting down the player.

14
Creating the new creature
  • To create the new Creature we create Monkey.java
    in com.brackeen.javagamebook.tilegame.sprites.
  • The Monkey class extends the Creature class. The
    Creature class contains a lot of useful
    functionality that we'll be leveraging.
  • There is a basic Monkey.java class in your
    workspace, let's take a look at it now.

15
Adding the new Creature to the 2D Game
  • Now that we created the object how do we get it
    to display in a tile map that we create.
  • We must modify the ResourceManager.java class.
  • This class loads and manages tile Images and
    "host" Sprites used in the game. Game Sprites are
    cloned from "host" Sprites.
  • We can use the other bad guy sprites as a
    template for our sprite.

16
Adding Monkey to ResourceManger.java
  • The basic steps to add a new bad guy to the
    ResourceManager.java are as follows (follow the
    //TODO sections in the code)
  • declare the host sprite as a class variable this
    will be used so we can clone multiple instances
    of the same sprite.
  • Map the sprite to a character ('3',
    '4','k'...etc) so that when we read the tile map
    text file in we can place the bad guy on the map.
  • Load sprite animation images, and create
    animation.
  • Lets do this now and get a basic monkey creature
    running. Use maps/map1.txt as it already has
    functionality to include a monkey creature, just
    use character '3' to represent that enemy.

17
Making the creature jump
  • To make the creature jump we have to override
    it's update() method.
  • The update() method gets called every time a
    frame is drawn, and it updates the creatures
    state.
  • Important game state variables passed with the
    update method.
  • elapsedTime the time since the last frame was
    drawn
  • totalElapsedTime the total time the game has
    been running

18
Making the monkey jump every 2 seconds
  • How do we make the monkey jump every 2 seconds?
  • You must set a jumpInterval, and then use the
    elapsedTime and totalElapsedTime to figure out
    when the monkey should call the jump() method.
  • Be careful a straight modulus comparison against
    totalTime will not work, because update() is
    called with timeIntervals, not discrete
    quantities.
  • You must check if the elapsedTime passed the time
    you were waiting for.
  • For example if you were waiting for 2 seconds
    totalElapsedTime, you have to realize that if the
    elapsedTime goes from 1 to 3, then we passed 2 so
    we should jump().

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
18
19
Monkey Jump Solution
  • public void update(long elapsedTime)
  • // Call super to maintain animation behavior
  • super.update(elapsedTime)
  • //See if its time for the monkey to jump
  • //Because time comes in at intervals we have to
    make sure that
  • //we jump in whichever elapsedTime interval that
    the timer has
  • // gone off in.
  • if((totalElapsedTime jumpInterval)-elapsedTim
    elt0)
  • //Make the monkey jump if he's not already in
    the air
  • jump()

20
Additional behavior
  • Make monkey jump at a slightly different time
    every jump. Use the RandomUtil.getInt() method
    after the monkey jumps.
  • Tracking the player.
  • Add code in the GameManager.java class.
  • add code to the updateCreature() method.
  • Make sure creature is tracking the player
    creature.isTracking(), then make sure creature's
    horizontal (X) velocity is moving towards the
    player's position.

21
More Ideas to Expand The Game
  • Better collision detection, and handling.
  • Interactive tiles, breakable tiles, open doors,
    adds a puzzle element to the game.
  • walk-thru tiles that could allow users to pass
    into a tunnel or a cave.
  • Use different images for different actions, such
    as jumping, dying, collecting power up.
  • Better map-to-map transitions create a loading
    screen
  • Keep track of powerup collection add a scoring
    element to the game.
  • More bad guys, more levels, different images!

22
Next week
  • We'll be presenting another workshop on 2D Game
    Design, to give people more experience developing
    the 2D platform game.
Write a Comment
User Comments (0)
About PowerShow.com