Skip to content

This is a wheat farm game, allowing the user to click a piece of wheat, to gain wheat and make various items given the number of wheat the user has harvested. Made in Java.

Notifications You must be signed in to change notification settings

brendanddev/JavaFX-Farm-Wheat-Game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaFX Farm Wheat Game

Description

This is a JavaFX-based farm simulation game where the player can plant, harvest, and sell wheat. The game uses a graphical user interface (GUI) to provide an engaging and interactive experience. The player can plant wheat, harvest it when ready, and sell it for money. The goal is to manage the farm by growing wheat and selling baked goods such as bread loaves, slices, and cakes, all while tracking progress through the GUI.

Features

  • Farm Management: Plant, harvest, and sell wheat.
  • Upgrade System: Sell wheat and baked goods (bread loaves, slices, and cakes).
  • Graphical Interface: Uses JavaFX for an intuitive GUI with buttons, labels, canvas elements, and images.
  • State Tracking: Keeps track of farm resources (wheat, money, bread) and progress.

Classes Overview

1. FarmGame (View Class)

This class serves as the primary view for the game. It sets up the graphical interface and allows the player to interact with the game through various GUI components:

  • Buttons for planting and harvesting wheat.
  • Canvas and labels to display the current state of the farm (number of wheat, money, baked goods).
  • Event handlers to trigger actions when the player interacts with the interface.
  • It communicates with the model classes (Farm and Wheat) to update and track the game's state.

2. Farm (Main Model Class)

This is the main model class that handles the game logic and state:

  • Tracks the state of the farm: Number of wheat, money, bread slices, loaves, and cakes.
  • Methods for planting, harvesting, and selling: Handles all the logic for modifying farm resources and interacting with wheat.
  • Associates with Wheat class: Uses an array of Wheat objects to represent the wheat planted on the farm.

3. Wheat (Secondary Model Class)

This class represents individual wheat objects in the game:

  • Growth and Harvest Logic: Each wheat object tracks its growth level and determines when it can be harvested.
  • Encapsulates wheat properties: Manages the growthLevel and harvestFlag variables to determine harvest readiness.

Gameplay

  • Plant Wheat: Click the "Plant" button to plant a new wheat seed.
  • Harvest Wheat: Click the "Harvest" button once the wheat has grown to harvest it.
  • Sell Wheat and Goods: Sell harvested wheat and bake bread or cakes with the resources collected to earn money.

GUI Components

  • Buttons: Interact with the game by planting, harvesting, and selling wheat.
  • Canvas: Display the farm's graphical state.
  • Labels: Show current wheat count, money, and baked goods.

Getting Started

Prerequisites

  • Java 8 or higher
  • JavaFX SDK

Running the Game

  1. Clone this repository.
  2. Open the project in your preferred IDE (e.g., IntelliJ, Eclipse).
  3. Run the FarmGame.java file.

Author

  • Brendan Dileo - 000879513

About

This is a wheat farm game, allowing the user to click a piece of wheat, to gain wheat and make various items given the number of wheat the user has harvested. Made in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages