Connect Four: A Java Implementation of the Classic Game by Lauren Smith, Study Guides, Projects, Research of Computer Science

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

Pre 2010

Uploaded on 08/30/2009

koofers-user-q3o-1
koofers-user-q3o-1 🇺🇸

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
QuickTime™ and a
TIFF (Uncompressed) decompressor
are needed to see this picture.
Connect Four
Lauren Smith
Final CS1 Project
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:
pf3

Partial preview of the text

Download Connect Four: A Java Implementation of the Classic Game by Lauren Smith and more Study Guides, Projects, Research Computer Science in PDF only on Docsity!

QuickTime™ and a TIFF (Uncompressed) decompressor are needed to see this picture.

Connect Four

Lauren Smith

Final CS1 Project

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.