I'm confused as to why they are using these values as well
this.width = matrix[0].length;
this.height = matrix.length;
package com.codegym.games.racer;
// import com.javarush.engine.cell.*;
import com.codegym.engine.cell.Color;
import com.codegym.engine.cell.Game;
public class RacerGame extends Game
{
public static final int WIDTH = 64;
public static final int HEIGHT = 64;
public static final int CENTER_X = WIDTH / 2;
public static final int ROADSIDE_WIDTH = 14;
public void initialize()
{
showGrid(false);
setScreenSize(WIDTH, HEIGHT);
createGame();
}
private void createGame()
{
drawScene();
}
private void drawScene()
{
drawField();
}
private void drawField()
{
for (int x = 0; x < HEIGHT; x++)
{
// create three conditionals
for (int y = 0; y < WIDTH; y++)
{
if (x == CENTER_X)
{
setCellColor(x, y, Color.WHITE);
}
else if (x >= ROADSIDE_WIDTH && x < (WIDTH - ROADSIDE_WIDTH))
{
setCellColor(x, y, Color.DIMGREY);
}
else
{
setCellColor(x, y, Color.GREEN);
}
}
}
}
public void setCellColor(int x, int y, Color color)
{
// super(x, y, color);
try
{
super.setCellColor(x, y, color);
if ((x > 64 || x < 0) || (y > 64 || y < 0))
{
throw new Exception();
}
} catch (Exception e)
{
System.out.println("x and y values are out of bounds");
e.printStackTrace();
}
}
}