You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
2.9 KiB
Plaintext
41 lines
2.9 KiB
Plaintext
<!--200917,201112-->
|
|
<h1>inventory as a system diagram </h1>
|
|
october 1, 2020<br>
|
|
#design #systemdiagram #gamemechanics<br>
|
|
<br>
|
|
<b>System diagrams</b> illustrate how components interact within a system. It saves so much headache to step back and plan with a system diagram before jumping into code. <br>
|
|
<br>
|
|
<br>
|
|
<h2>stop + plan before coding </h2><br>
|
|
I want to move blessfrey's inventory into an app on the player character's smartphone. Before, it was displayed in a random pop-up window. It was poorly planned, so the programmatic inventory and the UI were too tightly coupled to easily pop into the phone screen. Instead of wrestling, it's easier to start over and actually plan before I code this time. <br>
|
|
<br>
|
|
<br>
|
|
<h2>list out your nouns </h2><br>
|
|
A simple way to start thinking about a system is to list out its nouns + verbs. Jot down the entities that interact with your system. <br>
|
|
<br>
|
|
<center><img src="/static/img/ent/systemdiagram_inventory.jpeg" alt="(image: system diagram for inventory)" width="500" height="250"></center> <br>
|
|
<br>
|
|
For blessfrey's inventory, that's the inventory (programmatic), the player character, the inventory app (UI), and base items. The inventory app is related to the smartphone and inventory items. Items are related to floor items, which are related to rooms. <br>
|
|
<br>
|
|
(blessfrey has three different kinds of items. <br>
|
|
<br><ul>
|
|
<li><b>Base Item</b>: holds all the data regardless of how the item is currently expressed </li>
|
|
<li><b>Floor Item</b>: sits on the ground and gets picked up by characters. </li>
|
|
<li><b>Inventory Item</b>: displayed in inventories, store windows, containers, etc </li>
|
|
</ul><br>
|
|
Floor + Inventory Items hold a base item inside them that gets popped out and traded around as the item gets expressed in different forms.) </br>
|
|
<br>
|
|
<h2>connect your nouns with verbs </h2><br>
|
|
I wrote the entities in pink and moved them around until the placement was decently readable. Then I connected the concepts with arrows. These arrows represent the verbs, which I explicitly labeled in yellow. <br>
|
|
<br>
|
|
The flow of these arrows can be very important. If you are modeling AI, for instance, no matter what path the program takes, there shouldn't be dead-ends. Seeing mistakes like that is easier with a diagram than lines of code. Otherwise, the flow is always generally useful for figuring out which methods are needed for each class and how they connect. <br>
|
|
<br>
|
|
<br>
|
|
<h2>write the code </h2><br>
|
|
At this point, coding is a bit easier now that it's in some ways a transcription of the diagram. The entities are data (classes or objects), and the arrows are logic (methods). <br>
|
|
<br>
|
|
<br>
|
|
<h2>conclusion </h2><br>
|
|
Your diagram doesn't have to be fancy or formal to get the point across to yourself, and it just takes a minute to save all the headache later. Don't skip this step or you'll have to rewrite the inventory system just to display it in a different window. <br>
|
|
<br>
|