Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [aron@aron-desktop hw6]$ cat TicTacToe.java
- import java.util.ArrayList;
- import fang2.core.*;
- import fang2.sprites.*;
- public class TicTacToe extends Game{
- private int width = 3;
- private int height = 3;
- private ArrayList<GameTile> gameBoard = new ArrayList<GameTile>(width*height);
- public TicTacToe(){
- super();
- setNumberOfPlayers(2);
- }
- public static void main(String[] argv){
- new TicTacToe().runAsApplication();
- new TicTacToe().runAsApplication();
- }
- @Override
- public void setup(){
- setupGameBoard();
- }
- @Override
- public void advance(double dT){
- }
- private GameTile getGameTile(int x, int y){
- return gameBoard.get(x + y*width);
- }
- private void setupGameBoard(){
- //initilize the gameboard array
- for(int n = 0; n < gameBoard.size(); n++){
- gameBoard.add(new GameTile());
- }
- for(int y = 0; y < height; y++){
- for(int x = 0; x < width; x++){
- GameTile tempTile = getGameTile(x,y);
- tempTile.setScale(0.3);
- tempTile.setLocation(x / width + 0.17, y / height + 0.17);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement