This file contains hidden or 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
// Jed Pommert | |
// CS 141 | |
// Final Tic Tac Toe Discussion | |
import java.util.Arrays; | |
/** | |
* Board represents a game board with a variable width and height along with various management | |
* methods for both Tic-Tac-Toe and Connect-4, such as checking win conditions and placing tokens. | |
*/ |
This file contains hidden or 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 moveBall(GOval ball, int height, int width, GRect paddle) { | |
// Update ball position | |
ball.setLocation(ball.getX() + vx, ball.getY() + vy); | |
// Make sure ball Y is within the area | |
if (ball.getY() <= 0) { | |
ball.setLocation(ball.getX(), 0); | |
vx += getVelOff(); | |
vy = Math.abs(vy); | |
} else if (ball.getY() + BALL_RADIUS * 2 >= height) { |