Skip to Main Content
Killer Game Programming in Java
book

Killer Game Programming in Java

by Andrew Davison
May 2005
Intermediate to advanced content levelIntermediate to advanced
998 pages
26h
English
O'Reilly Media, Inc.
Content preview from Killer Game Programming in Java

The User's Touring Sprite

TourSprite subclasses Sprite3D to specify the movement step and rotation amounts of the user's sprite. Here are the relevant methods:

    private final static double MOVERATE = 0.3;
    private final static double ROTATE_AMT = Math.PI / 16.0;

    public TourSprite(String fnm, Obstacles obs)
    { super(fnm, obs);  }

    public boolean moveForward()
    { return moveBy(0.0, MOVERATE); }

    public void rotClock()
    { doRotateY(-ROTATE_AMT); }  // clockwise

TourSprite doesn't contain any behavior code to specify when the move and rotation methods should be called and is placed in a separate Behavior class (TouristControls for TourSprite). Behavior classes are explained after the next section.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java Game Development with LibGDX: From Beginner to Professional

Java Game Development with LibGDX: From Beginner to Professional

Lee Stemkoski

Publisher Resources

ISBN: 0596007302Supplemental ContentErrata Page