Haha, thanks Zotoaster.
One improvement I was thinking of adding to the game was special moves for troops. Imagine a soldier is fighting, then all of a sudden he flips into the air, and comes down shooting out a very short wave sonic boom, killing a few enemies.
I am most familiar with Java so I wrote up some pseudo-ish code for how the engine might work. I've only written a few classes. Now that I think about it I don't even know if dbp even does inheritance... Any suggestions on how to convert this to dbp?
The hex battle grid. Splits the level into hexes and keeps track of what is in all of them.
public class BattleGrid{
private grid[][] = new Hex[][];
public BattleGrid( ){
//equation to divide the level into hexes. Store all vertexes into hex objects. Put the hexes into the grid[][] array
}
public Troop get( int x, int y ){
return grid[x][y].contains;
}
public void change( int x, int y, Troop replacement ){
grid[x][y].contains = replacement;
}
}
Hex Class
public class Hex{
public Troop contains;
public points[] = new Point[];
//defines the 6 vertexes of the hex
public Hex( Point[] vertexes ){
points = vertexes;
}
}
The basic Troop class
class Troop implements Comparable<Troop>{
private boolean side;
private int _x;
private int _y;
private int _z;
private int state; //attacking, walking, at rest, etc
private int class;
private Model appearance; // ???
public int compareTo( Troop other ){
return 2DTable[class, other.class];
}
public move( int direction ){
//start walking animation, change state
//move in direction
}
public attack( Troop other ){
if( Math.rand(between 0-1) < compareTo(other) ){
//kill animation
//other.die()
}
else{
//attack animation
//play clank sound
}
}
public die(){
//play death animation and delete object
}
}
The different classes of soldiers will inherit from the Troop class and contain any class-specific differences.
2DTable will a global variable be like this:
soldier monk
soldier[ .5 ] [ .8 ]
monk [ .2 ] [ .5 ]
A 2 dimensional array to grab the percentage that a killing blow will be struck.