-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f09adb
commit 7444623
Showing
7 changed files
with
68 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,46 @@ | ||
package sample; | ||
|
||
import javafx.scene.canvas.Canvas; | ||
import simulation.Location; | ||
import simulation.Simulation; | ||
|
||
import java.util.Locale; | ||
|
||
public class SimulationCanvas extends Canvas { | ||
private final Simulation simulation; | ||
private final TerrainTileFactory terrainTileFactory; | ||
private final AnimalTileFactory animalTileFactory; | ||
private final int tileSize = 5; | ||
private final int tileSize = 10; | ||
SimulationCanvas(Simulation simulation){ | ||
super(simulation.getWidth()*10,simulation.getHeight()*10); | ||
this.simulation = simulation; | ||
this.terrainTileFactory = new TerrainTileFactory(simulation); | ||
this.animalTileFactory = new AnimalTileFactory(simulation); | ||
} | ||
public void update(){ | ||
public void drawBackground(){ | ||
for (int i = 0; i<simulation.getWidth(); i++){ | ||
for (int j = 0; j<simulation.getHeight(); j++){ | ||
drawTile(i,j, terrainTileFactory.getTile(i,j)); | ||
drawTile(i,j,animalTileFactory.getTile(i,j)); | ||
if (!simulation.animalBoard.noAnimalsAt(i,j)) | ||
drawTile(i,j, animalTileFactory.getTile(i,j)); | ||
} | ||
} | ||
} | ||
public void update(){ | ||
drawBackground(); | ||
// for (Location location : simulation.animalBoard.getAnimalLocations()){ | ||
// int x = location.getX(); | ||
// int y = location.getY(); | ||
// drawTile(x,y,animalTileFactory.getTile(x,y)); | ||
// } | ||
|
||
|
||
} | ||
private void drawTile(int x, int y, Tile tile){ | ||
int drawX = x*tileSize; | ||
int drawY = y*tileSize; | ||
this.getGraphicsContext2D().drawImage(tile.getImage(),drawX,drawY); | ||
System.out.println("Drawing "+tile.toString()+" at "+drawX+" "+drawY); | ||
//System.out.println("Drawing "+tile.toString()+" at "+drawX+" "+drawY); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters