-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
4 changed files
with
97 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
package game.snake; | ||
|
||
public class SnakeGame { | ||
public static void main(String[] args) { | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package game.tictactoe; | ||
|
||
public class Main { | ||
|
||
public static void main(String[] args) | ||
{ | ||
TicTacToe ticTacToe = new TicTacToe(); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package game.tictactoe; | ||
|
||
import java.awt.*; | ||
import java.awt.event.*; | ||
import java.util.*; | ||
import javax.swing.*; | ||
|
||
public class TicTacToe implements ActionListener{ | ||
|
||
Random random = new Random(); | ||
JFrame frame = new JFrame(); | ||
JPanel title_panel = new JPanel(); | ||
JPanel button_panel = new JPanel(); | ||
JLabel textfield = new JLabel(); | ||
JButton[] buttons = new JButton[9]; | ||
boolean player1_turn; | ||
// boolean player2_turn; | ||
|
||
TicTacToe() | ||
{ | ||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||
frame.setSize(800, 800); | ||
frame.getContentPane().setBackground(new Color(50, 50, 50)); | ||
frame.setLayout(new BorderLayout()); | ||
frame.setVisible(true); | ||
|
||
textfield.setBackground(new Color(25,25,25)); | ||
textfield.setForeground(new Color(25,255,0)); | ||
textfield.setFont(new Font("Ink Free", Font.BOLD, 75)); | ||
textfield.setHorizontalAlignment(JLabel.CENTER); | ||
textfield.setText("Tic-Tac-Toe"); | ||
textfield.setOpaque(true); | ||
|
||
title_panel.setLayout(new BorderLayout()); | ||
title_panel.setBounds(0, 0, 800, 800); | ||
|
||
button_panel.setLayout(new GridLayout(3, 3)); | ||
button_panel.setBackground(new Color(150,150,150)); | ||
|
||
title_panel.add(textfield); | ||
frame.add(title_panel, BorderLayout.NORTH); | ||
frame.add(button_panel); | ||
|
||
for (int i = 0; i < 9; i++) { | ||
buttons[i] = new JButton(); | ||
button_panel.add(buttons[i]); | ||
buttons[i].setFont(new Font("MV Boli", Font.BOLD, 120)); | ||
buttons[i].setFocusable(false); | ||
buttons[i].addActionListener(this); | ||
} | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) | ||
{ | ||
//TODO Auto-generated method stub | ||
} | ||
|
||
public void firstTurn() | ||
{ | ||
try { | ||
Thread.sleep(2000); | ||
} catch (InterruptedException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
if (random.nextInt(2) == 0) { | ||
player1_turn = true; | ||
textfield.setText("X turn"); | ||
} else { | ||
player1_turn = false; | ||
textfield.setText("O turn"); | ||
} | ||
} | ||
|
||
public void check() { | ||
|
||
} | ||
|
||
public void xWins(int a, int b, int c) { | ||
|
||
} | ||
|
||
public void oWins(int a, int b, int c) | ||
{ | ||
|
||
} | ||
} |