Tuesday, May 27, 2014

Can't Sleep So You Guys Get an Update

A big new feature that I'm adding to this game will be the ability, or requirement, for you to build your own ships.  I'm in the process of making a ship builder.  Here are some screen shots of my progress.
I'll add more ship parts once I get the ship moving around the map.  It shouldn't be too hard.





You'll be able to make the ship as big or small as you want so long you have the parts!
I'm gonna have to figure out how to render these mofo's though... Gonna be a pain when I try to rotate the ship.

EDIT: figured it out. You have 2 for loops.   each going the length of the of the array that holds the individual blocks.  That part wasn't hard.  The hard part was figuring out the offsets.



for(int i = 0; i < sMap.map.ship2.blocks.length;i++)
for(int j = 0; j <sMap.map.ship2.blocks[i].length; j++){
// this convoluted mess offsets the ship so it renders all the squares in the right spots..
batch.draw(
// the texture that I'm using
sMap.map.ship2.blocks[i][j].tr1,
// the x location of the ship I'm using
sMap.map.ship.center.x + j *(size)- (float)sMap.map.ship2.blocks.length / 2*size,
// the y location of the ship I'm using
sMap.map.ship.center.y-i*(size)+(((float) sMap.map.ship2.blocks.length/2)-1) *size,
// the x offset
(float)size*sMap.map.ship2.blocks.length/2-size*j,
// the y offset
size/2 +size*i -size*2,
// the width of the textures in pixels
size,
// the heigth of the texture in pixels
size,
// the x scale
1f,
// the y scale
1f,
// the rotation of the ship, the dirction it is pointing.
sMap.map.ship.getDirection()-90 );
}
view raw gistfile1.java hosted with ❤ by GitHub



No comments:

Post a Comment