Skip to content

Commit

Permalink
grid
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaganx0 committed Sep 5, 2023
1 parent aeb676f commit 63a3310
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,27 @@
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.maps.tiled.TiledMap;
import com.badlogic.gdx.maps.tiled.TiledMapRenderer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer.Cell;
import com.badlogic.gdx.maps.tiled.renderers.OrthogonalTiledMapRenderer;
import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.utils.viewport.ScreenViewport;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.csse3200.game.areas.terrain.TerrainComponent.TerrainOrientation;
import com.csse3200.game.components.CameraComponent;
import com.csse3200.game.utils.math.RandomUtils;
import com.csse3200.game.services.ResourceService;
import com.csse3200.game.services.ServiceLocator;

import static com.csse3200.game.screens.MainGameScreen.viewportHeight;
import static com.csse3200.game.screens.MainGameScreen.viewportWidth;

/** Factory for creating game terrains. */
public class TerrainFactory {
private static final GridPoint2 MAP_SIZE = new GridPoint2(40, 21);
Expand All @@ -26,6 +33,10 @@ public class TerrainFactory {
private final OrthographicCamera camera;
private final TerrainOrientation orientation;





/**
* Create a terrain factory with Orthogonal orientation
*
Expand All @@ -44,8 +55,10 @@ public TerrainFactory(CameraComponent cameraComponent) {
public TerrainFactory(CameraComponent cameraComponent, TerrainOrientation orientation) {
this.camera = (OrthographicCamera) cameraComponent.getCamera();
this.orientation = orientation;

}


/**
* Create a terrain of the given type, using the orientation of the factory. This can be extended
* to add additional game terrains.
Expand Down Expand Up @@ -99,12 +112,18 @@ private TiledMap createForestDemoTiles(


private static void fillTiles(TiledMapTileLayer layer, GridPoint2 mapSize, TerrainTile tile) {
mapSize.x= 20;
mapSize.y= 8;



for (int x = 0; x < mapSize.x; x++) {
for (int y = 0; y < mapSize.y; y++) {
Cell cell = new Cell();
cell.setTile(tile);
layer.setCell(x, y, cell);


}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.csse3200.game.screens;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Pixmap;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.ScreenAdapter;
Expand Down

0 comments on commit 63a3310

Please sign in to comment.