PART THIRTEEN
WATER

CONCEPT

Expanding Gameplay Choice

IMPROVED BUCKET

Updating Bucket

Filling The Bucket

Using The Bucket

Updating the Cursor

In ItemBar

In Game

CHECKPOINT
Run your code and see...

RAIN

Creating Weather

Adding Weather To Your World

Making The Soil Wet

CHECKPOINT
Run your code and see...

Rain Animation

White lines (above), Gradient Lines with splash zones (below)

BASIC SPRINKLER

Adding Functionality to the World

(above) Stardew Valley Sprinklers

By teaching our cells to detect neighbors, we can easily add sprinklers with different radius of effect.

Implementing Sprinklers

Splitting up the entities can be implemented in two ways.  You choose!

Option #1 - Loop through entities twice, using instanceof to decide which are permitted to call nextDay() each time

Option #2 - Rework code to seperately track Sprinklers and Crops each time they are added and removed in addition to a general list of entities, then loop through those respective lists.

CHECKPOINT
Run your code and see...

BUYING AND PLACING SPRINKLERS

Sprinkler Items

In this part of the program, we're starting to see some limits of our program's core design.

(1) We've split items and entities up entirely, so we end up with duplicate classes sometimes.  This made sense with seeds.  But there's no way to simply put the same item in the shop then place it directly into the world.  This is something you'd want to consider for future projects.  Perhaps both of these classes should have a super class which handles some generic functionality.

(2) Early on we added a specific function to seeds that allowed them to place crops.  Here we are taking time to refactor that code.  Notice how much harder it is to make all these little changes than places where it was carefully mapped out from the start.

The big lesson here is to carefully plan your program's structure early on!

Shop and Usage

CHECKPOINT
Run your code and see...

ADVANCED SPRINKLER

The Advanced Sprinkler

CHECKPOINT
Run your code and see...