/* TestTank.java (C) Copyright 2000 by Scott Sherman. All rights reserved. Scott Sherman 6-00... a sample pawn external to the CyberClash project */ import com.loki3.cyber.pawn.*; public class TestTank implements GameListener, DamageListener, EnergyListener { // GameListener public boolean use(Pawn pawn) { mPawn = pawn; // ask to be notified of damage to the pawn mPawn.addDamageListener(this); // ask to be notified when we run out of gas or start to get low mPawn.getEnergy().addEnergyListener(this, 40); return true; } public void gameStarted() { mTime = 0; } public void gameTick(double tick) { mTime += tick; // keep track of elapsed time // change speed occasionally for the fun of it if ( (mTime % 40) == 0 ) mPawn.changeSpeed(0); else if ( (mTime % 40) == 20 ) mPawn.changeSpeed(mPawn.getMaxSpeed()); // and direction too if ( (mTime % 49) == 0 ) mPawn.turnLeft(30); if ( (mTime % 49) == 25 ) mPawn.turnRight(40); } public void gameEnded() { mPawn = null; } // DamageListener public void unitDamaged(Unit unit, double amount) {} public void unitDestroyed(Unit unit) {} // EnergyListener public void energyLow(Unit unit, double remaining) {} public void energyDrained(Unit unit) {} Pawn mPawn = null; double mTime = 0; // number of ticks since game began }