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
import de.ur.mi.graphicsapp.GraphicsApp; | |
import simulator.ColonySimulator; | |
import world.ColonyView; | |
public class AntColony extends GraphicsApp { | |
private static final int WIDTH = 300; | |
private static final int HEIGHT = 300; | |
private ColonySimulator simulator; | |
private ColonyView view; |
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
var canvas = document.querySelector("#canvas"), | |
context = canvas.getContext("2d"); | |
// Zeichne eine Linie von x1,y1 nach x2,y2 | |
function drawLine(x1, y1, x2, y2, color, weight) { | |
context.beginPath(); | |
context.moveTo(x1, y1); | |
context.lineTo(x2, y2); | |
context.strokeStyle = color; | |
context.lineWidth = weight; |
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
Compound board = new Compound() | |
private void initBoard(int fieldWidth, int fieldHeight) { | |
board = new Compound(0, 0); | |
for (int x = 0; x < ROWS; x++) { | |
for (int y = 0; y < COLUMNS; y++) { | |
Chessfield newField = getNewFieldForBoard(x, y, fieldWidth,fieldHeight); | |
board.add(newField); | |
} | |
} |
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
private void setupGrid() { | |
rows = (int) Math.sqrt(NUM_SQUARES); | |
columns = (int) Math.sqrt(NUM_SQUARES); | |
squareHeight = HEIGHT / rows; | |
squareWidth = WIDTH / columns; | |
} | |
private void drawGrid() { | |
for (int x = 0; x < rows; x++) { | |
for (int y = 0; y < columns; y++) { |
NewerOlder