Skip to content

Commit

Permalink
grid 3/n
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Sep 5, 2023
1 parent 049a3bb commit 2a16064
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,11 +229,6 @@ private void spawnBuilding2() {
private void spawnMountains() {
ArrayList<GridPoint2> fixedPositions = new ArrayList<>(); //Generating ArrayList

fixedPositions.add(new GridPoint2(5, 8));
fixedPositions.add(new GridPoint2(12, 4));
fixedPositions.add(new GridPoint2(20, 10));
fixedPositions.add(new GridPoint2(33, 17));

for (GridPoint2 fixedPos : fixedPositions) {
Entity tree = ObstacleFactory.createMountain();
spawnEntityAt(tree, fixedPos, true, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

/** Factory for creating game terrains. */
public class TerrainFactory {
private static final GridPoint2 MAP_SIZE = new GridPoint2(40, 21);
public static final GridPoint2 MAP_SIZE = new GridPoint2(20, 8);


private static OrthographicCamera camera;
Expand Down Expand Up @@ -76,7 +76,7 @@ public TerrainComponent createTerrain(TerrainType terrainType) {
case FOREST_DEMO:
TextureRegion orthoGrass =
new TextureRegion(resourceService.getAsset("images/terrain_use.png", Texture.class));
return createForestDemoTerrain(0.5f, orthoGrass);
return createForestDemoTerrain(1f, orthoGrass);

default:
return null;
Expand Down Expand Up @@ -114,8 +114,6 @@ 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();
Expand Down
18 changes: 12 additions & 6 deletions source/core/src/main/com/csse3200/game/screens/MainGameScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,18 @@ public class MainGameScreen extends ScreenAdapter {

public MainGameScreen(GdxGame game) {
this.game = game;
camera = new OrthographicCamera();
camera.setToOrtho(false, viewportWidth, viewportHeight);
camera.position.set(viewportWidth / 2, viewportHeight / 2, 0);

batch = new SpriteBatch();

Pixmap pixmap = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pixmap.setColor(1, 1, 1, 1);
pixmap.fill();
whiteTexture = new Texture(pixmap);
pixmap.dispose();

camera = new OrthographicCamera();
camera.setToOrtho(false, viewportWidth, viewportHeight);
camera.position.set(viewportWidth / 2, viewportHeight / 2, 0);
Viewport viewport = new ScreenViewport(camera);
stage = new Stage(viewport, new SpriteBatch());

Expand All @@ -93,8 +95,8 @@ public MainGameScreen(GdxGame game) {
TextButton.TextButtonStyle textButtonStyle = new TextButton.TextButtonStyle();
textButtonStyle.font = font;
textButtonStyle.fontColor = Color.WHITE;
for (int y = 0; y < 8; y++) {
for (int x = 0; x < 20; x++) {
for (int y = 0; y < TerrainFactory.MAP_SIZE.y; y++) {
for (int x = 0; x < TerrainFactory.MAP_SIZE.x; x++) {
TextButton button = new TextButton("" + x + y * 20, textButtonStyle);
stage.addActor(button);
}
Expand Down Expand Up @@ -135,14 +137,18 @@ public MainGameScreen(GdxGame game) {
public void render(float delta) {
physicsEngine.update();
ServiceLocator.getEntityService().update();

batch.setProjectionMatrix(camera.combined);
batch.begin();
batch.draw(backgroundTexture, 0, 0, viewportWidth, viewportHeight);
batch.end();


batch.setProjectionMatrix(camera.combined);
batch.begin();
for (int i = 0; i < NUM_LANES; i++) {
float yPosition = i * LANE_HEIGHT;
batch.draw(whiteTexture, 0, yPosition, viewportWidth, 2);
batch.draw(whiteTexture, 0, yPosition, viewportWidth, 5);
}
batch.end();

Expand Down

0 comments on commit 2a16064

Please sign in to comment.