Defining a Game CBP March 2006. Development Methodology We all discuss/analyze some games We...

Post on 14-Jan-2016

217 views 0 download

transcript

Defining a Game

CBP March 2006

Development Methodology

We all discuss/analyze some games

We identify OOP classes required

We negotiate some “base classes”

You extend these classes or introduce new classes to implement

your game. You sweat, and work hard to implement your game.

Your Tutor writes these classes

Two Options

Isometric

Platform

Isometric Tile Games

CBP March 2006tiles

Isometring

CBP March 2006

?

?

? ?

?

?

?

j

i

(0,0)

Screen axesx

y

Tile axes

Screen and Tile Coordinates

CBP March 2006

CBP March 2006

Buildings

Roads and Animations

Platform Games

i

j

0 1 2 3 4

0

1

2

3

4

CBP March 2006

?

CBP March 2006

Platform Games

CBP March 2006

i

j

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

0

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

Screen and Tile Coordinates

CBP March 2006

1. Tank at (i, j)

2. Remove from tile (i,j)

3. Calc vI, vJ

4. Update i += vI; j += vJ

5. Add to tile (i,j)

1

2

5

Moving gObjects over tiles

CBP March 2006

ActiveTile class methods -1-

public void addTileToContents(BasicTile tile) {

contents.add(tile);

}

public void addGameObjectToContents(GameObject gObj) {

contents.add(gObj);

}

private ArrayList contents = new ArrayList();

ActiveTile class methods -2-

RoadTile rTile = (RoadTile)acTile.getIfBasicTile(“CornerA");

GameObject occupied = acTile.isOccupiedByOtherGameObject(this);

bTile = (BuildingTile)acTile.getIfBasicTile(“Palace");

MagicCrystal crystal = (MagicCrystal)acTile.getIfPickup("MagicCrystal");

Behaviour FSM

Event CORNER_A

State RGT

vI = 0; vJ = -1

vI = 0 vJ = 1 State UPP

i

j

step() {

ActiveTile acTile = canvas.findActiveTile(i,j);

acTile.removeGameObjectFromContents(this);

int urgentEvent = boundaryDetect(vI,vJ);

if(urgentEvent == BOUNDARY) FSMPlayer(state,BOUNDARY);

if(urgentEvent == NO_EVENT){

FSMPlayer(state,event);

}

// get the active tile at this new position and add this object to it

acTile = canvas.findActiveTile(i,j);

acTile.addGameObjectToContents(this);

}

Building a Player step() method -1-

Event here from Keyboard

step() {

... // check to see if we have hit a blue ball and take some action

BlueBall ball = (BlueBall)acTile.getIfGameObject("BlueBall");

if(ball != null) {

System.out.println("Red Ball talking to Blue Ball");

// set some event here to react to interacting with a blue ball

// FSMPlayer(state,TOUCH_WITH_BLUE); if it urgent or

// event = TOUCH_WITH_BLUE; if it can wait.

}

if(urgentEvent == NO_EVENT){

FSMPlayer(state,event);

}

}

Building a Player step() method -2-

idle doneexploding

triggered

doExplode() doDone()

finished

triggered

doExplode()

Generates finished or triggered

Bomb class

idle chasing

Near_plr

Far_from_plrNear_plrFar_from_plr

Gremlin class

doIdle()

doChase()