

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The development of a connect four game using java and standard draw. The project involves creating a two-dimensional array to track player moves, designing visual effects using standard draw, and implementing functions to check for a winner and a tie. Code snippets and explanations of the game mechanics.
Typology: Study Guides, Projects, Research
1 / 3
This page cannot be seen from the preview
Don't miss anything!


QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.
I planned to create an imitation of a connect four game. Connect Four is a two player board game, in which the players alternate dropping colored disk pieces into a vertical grid. The object of the game is to connect four of the same colored game pieces in a row, vertically, horizontally or diagonally, before the opponent can do the same. I began the project, intending to use java and Standard Draw to create the program how I desired. I started off creating a two dimensional array to keep track of the player moves. For the visual effects of the game, I used Standard Draw to create a grid to simulate the look of the classic game. The empty grid looks like this:
TIFF (Uncompressed) decompressorQuickTime™ and a are needed to see this picture. From there, I created a variable called playerId. Player 1, the red player, had a playerId of 1. Likewise, Player 2’s playerId number was 2 and used the black game pieces. The player would then click in a spot, and if it was empty, his piece would slide down to the lowest available slot. I created the visual game pieces by using Standard Draw, illustrating two filled circles in black and red. The code for each of those can be viewed below: QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture. After each turn, I designed the program to check for a winner and a tie and update the change to the array. I accomplished this by making two separate functions titled checkWinner and isTie.