Skip to content
86LAK edited this page Aug 28, 2023 · 15 revisions

Items

Overview

The ItemFactory is a crucial part of the Entity-Component-System (ECS) architecture within our game. It represents the properties and behaviour of an in-game item. Items can be anything from weapons, tools, plants, to any other interactable objects that players can use or manipulate.

To make items using the ECS approach, components are added to the entity. This modular approach allows shorter and less complicated code.

How to create your own custom items

Example - Hoe

In the itemFactory.java a base item is shown below. With the default components added shown in green. image

To extend this base item into a hoe, we need to add the relevant components to this Entity to make it a hoe. For example a hoe would have the following added components.

image

Summary

In summary, the ItemFactory is a crucial part of our game's design, defining how in-game items work. These items can be things like weapons, tools, or plants that players can use. The factory uses a smart way of organizing things, making the game's code easier to manage.

To create new items, like a hoe, we start with a basic item and then add specific features to it, like making it work as a hoe. This way of building items lets us create a lot of different things in the game without making the code overly complicated. This makes the game development process smoother and gives designers the flexibility to create a variety of items for players to interact with.

Clone this wiki locally