Game Development Reference
In-Depth Information
private BLOCK_TYPE (int r, int g, int b) {
color = r << 24 | g << 16 | b << 8 | 0xff;
}
public boolean sameColor (int color) {
return this.color == color;
}
public int getColor () {
return color;
}
}
// objects
public Array<Rock> rocks;
// decoration
public Clouds clouds;
public Mountains mountains;
public WaterOverlay waterOverlay;
public Level (String filename) {
init(filename);
}
private void init (String filename) {}
public void render (SpriteBatch batch) {}
}
The Level class contains an enum data type that we will use to represent our entire
game world objects. These objects have a unique RGBA color value that is used to
identify them. We will not use the alpha channel and always expect full opacity for
our game object color values. As each color component is represented as an 8-bit
value, the sum of an RGBA color is 32 bits or 4 bytes. The int data type of Java is
also defined as a 32-bit value, which makes it the appropriate place to store RGBA
color codes in a compact way.
The compact color value is stored in RGBA format. Also, in the
following code, we are going to use bit shift operations. For more
information, check out the blog article at http://www.zimnox.
com/resources/articles/tutorials/?ar=t002 .
 
Search WWH ::




Custom Search