Skip to content

Commit

Permalink
Merge pull request #731 from Elosanda/improv/RailsInBase
Browse files Browse the repository at this point in the history
[improvement] rails in base do u-turn
  • Loading branch information
danielduner committed Mar 4, 2012
2 parents 867f5a4 + 241af6a commit c3ad102
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 44 deletions.
Binary file modified res/levels/AsymeTrical.bmp
Binary file not shown.
Binary file modified res/levels/BlackHole.bmp
Binary file not shown.
Binary file modified res/levels/CataBOMB.bmp
Binary file not shown.
Binary file modified res/levels/Circular Shapes.bmp
Binary file not shown.
Binary file modified res/levels/DevMap.bmp
Binary file not shown.
Binary file modified res/levels/RailRoads.bmp
Binary file not shown.
Binary file modified res/levels/Siege.bmp
Binary file not shown.
Binary file modified res/levels/TheMaze.bmp
Binary file not shown.
Binary file modified res/levels/level1.bmp
Binary file not shown.
88 changes: 47 additions & 41 deletions src/com/mojang/mojam/level/Level.java
Expand Up @@ -304,55 +304,61 @@ public void render(Screen screen, int xScroll, int yScroll) {

Notifications.getInstance().render(screen);
}

private void renderTilesAndBases(Screen screen, int x0, int y0, int x1, int y1){
// go through each currently visible cell
// go through each currently visible cell
for (int y = y0; y <= y1; y++) {
for (int x = x0; x <= x1; x++) {

// draw sand outside the level
if (x < 0 || x >= width || y < 0 || y >= height) {
screen.blit(Art.floorTiles[5][0], x * Tile.WIDTH, y
* Tile.HEIGHT);
continue;
}

// if we are in the center area (4*7 Tiles): draw player bases
int xt = x - (width / 2) + 4;
int yt = y - 4;
if (xt >= 0 && yt >= 0 && xt < 7 && yt < 4 && (xt != 3 || yt < 3)) {
screen.blit(Art.getPlayerBase(getPlayerCharacter(1))[xt][yt], x * Tile.WIDTH, y
* Tile.HEIGHT);
continue;
}

yt = y - (height - 8);
if (xt >= 0 && yt >= 0 && xt < 7 && yt < 4 && (xt != 3 || yt > 0)) {
screen.blit(Art.getPlayerBase(getPlayerCharacter(0))[xt][yt], x * Tile.WIDTH, y * Tile.HEIGHT);
if ((xt == 0 || xt == 1 || xt == 5 || xt == 6) && yt == 0) {
screen.blit(Art.shadow_north, x * Tile.WIDTH, y * Tile.HEIGHT);
}
if ((xt == 2) && yt == 0) {
screen.blit(Art.shadow_north_west, x * Tile.WIDTH, y * Tile.HEIGHT);
}
if ((xt == 4) && yt == 0) {
screen.blit(Art.shadow_north_east, x * Tile.WIDTH + Tile.WIDTH - Art.shadow_east.w, y * Tile.HEIGHT);
}
continue;
}

if (canSee(x, y)) {
tiles[x + y * width].render(screen);
}
}
}
for (int x = x0; x <= x1; x++) {

// draw sand outside the level
if (x < 0 || x >= width || y < 0 || y >= height) {
screen.blit(Art.floorTiles[5][0], x * Tile.WIDTH, y
* Tile.HEIGHT);
continue;
}

// if we are in the center area (4*7 Tiles): draw player bases
int xt = x - (width / 2) + 4;
int yt = y - 4;

if (xt >= 0 && yt >= 0 && xt < 7 && yt < 4 && (isNotBaseRailTile(xt) || yt < 3)) {
screen.blit(Art.getPlayerBase(getPlayerCharacter(1))[xt][yt], x * Tile.WIDTH, y
* Tile.HEIGHT);
continue;
}

yt = y - (height - 8);
if (xt >= 0 && yt >= 0 && xt < 7 && yt < 4 && (isNotBaseRailTile(xt) || yt > 0)) {
screen.blit(Art.getPlayerBase(getPlayerCharacter(0))[xt][yt], x * Tile.WIDTH, y * Tile.HEIGHT);
if ((xt == 0 || xt == 1 || xt == 5 || xt == 6) && yt == 0) {
screen.blit(Art.shadow_north, x * Tile.WIDTH, y * Tile.HEIGHT);
}
if ((xt == 2) && yt == 0) {
screen.blit(Art.shadow_north_west, x * Tile.WIDTH, y * Tile.HEIGHT);
}
if ((xt == 4) && yt == 0) {
screen.blit(Art.shadow_north_east, x * Tile.WIDTH + Tile.WIDTH - Art.shadow_east.w, y * Tile.HEIGHT);
}
continue;
}

if (canSee(x, y)) {
tiles[x + y * width].render(screen);
}
}
}
}

private GameCharacter getPlayerCharacter(int playerID){
Player player = MojamComponent.instance.players[playerID];
if (player == null) return GameCharacter.None;
else return player.getCharacter();
}

private boolean isNotBaseRailTile(int xt){
return (xt != 2 && xt != 3 && xt != 4);
}


private void renderTopOfWalls(Screen screen, int x0, int y0, int x1, int y1){
for (int y = y0; y <= y1; y++) {
Expand Down
7 changes: 4 additions & 3 deletions src/com/mojang/mojam/level/gamemode/GameMode.java
Expand Up @@ -120,9 +120,10 @@ protected void setupPlayerSpawnArea() {
newLevel.addEntity(new ShopItemHarvester(32 * (newLevel.width / 2 - .5), (newLevel.height - 4.5) * 32, Team.Team1));
newLevel.addEntity(new ShopItemBomb(32 * (newLevel.width / 2 + .5), (newLevel.height - 4.5) * 32, Team.Team1));


newLevel.setTile((newLevel.width / 2) - 1, 7, new UnbreakableRailTile(new SandTile()));
newLevel.setTile((newLevel.width / 2) - 1, newLevel.height - 8, new UnbreakableRailTile(new SandTile()));
for (int i=0; i<3; i++){
newLevel.setTile((newLevel.width / 2) - i, 7, new UnbreakableRailTile(new SandTile()));
newLevel.setTile((newLevel.width / 2) - i, newLevel.height - 8, new UnbreakableRailTile(new SandTile()));
}
}

protected void setTickItems() {
Expand Down

0 comments on commit c3ad102

Please sign in to comment.