nankin.zheng.gatem.model
Class Background

java.lang.Object
  |
  +--nankin.zheng.gatem.model.Role
        |
        +--nankin.zheng.gatem.model.Background

public abstract class Background
extends Role

Background is in charge of the background of game, and it keeps and updates the viewport of the game.

Viewport is the visual part of the game background. Before every role is drawn onto the screen, the position of the viewport should be notified to DisplayCache.

NOTE that Background extends Role, and only one method notifyViewport() is added.

Version:
1.0_01, Date 2003-04-14
Author:
ZHENG Zhong

Field Summary
protected  Position viewport
          Positon of the viewport.
 
Fields inherited from class nankin.zheng.gatem.model.Role
attrSet, container, env, view
 
Constructor Summary
Background(GameContainer gcont, Env environ, BackgroundView v)
          Constructor.
 
Method Summary
 void notifyViewport()
          Notify the viewport of the game to DisplayCache.
 void testInitialization()
          Verify whether this Background object is initialized properly.
 java.lang.String toString()
          Convert to String.
 
Methods inherited from class nankin.zheng.gatem.model.Role
act, draw, getCreatedInstanceCount, init, receiveGameEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

viewport

protected Position viewport
Positon of the viewport.

Constructor Detail

Background

public Background(GameContainer gcont,
                  Env environ,
                  BackgroundView v)
           throws GameException
Constructor. NOTE that in the constructor, parameter v must be an instance of class BackgroundView that extends class RoleView. Background is a special role in the game container, so it must be specified. And instance variable viewport should be created.

Parameters:
gcont - game container.
environ - game environment.
v - RoleView object.
Throws:
GameException - if cannot set background of game container
Method Detail

testInitialization

public void testInitialization()
                        throws GameException
Verify whether this Background object is initialized properly. This method should be overwritten by its subclasses to provide more strict verification.

Overrides:
testInitialization in class Role
Throws:
GameException - if it is not initialized properly.

notifyViewport

public void notifyViewport()
                    throws GameException
Notify the viewport of the game to DisplayCache.

GameException

toString

public java.lang.String toString()
Convert to String.

Overrides:
toString in class Role