zbostock56 / Empire-of-Waves

Explore the world as a pirate, trading with merchants, and fending off enemies!
3 stars 0 forks source link

As a user, I would like pick up items #92

Closed zbostock56 closed 11 months ago

Jack-Saysana commented 11 months ago

@zbostock56 @griffintarzan @GameShiba I'm not working on much of any item management, but much of the current sprint's larger features like #100 and #93 are reliant on a unified system of item simulation in exploration mode, so it might be good if we had a solid plan laid out so everyone working with item simulation was on the same page. Here are some of the ideas I had for how we can get everything to work:

Item simulation

item entity structure

Item "containers" (chests, resource sources, treasure, etc)

Once again, these are just some ideas so everyone might have a jumping off point for keeping things organized, since item simulation will touch many different areas of the game, and relates to multiple peoples' work this sprint.

zbostock56 commented 11 months ago

@griffintarzan @GameShiba @Jack-Saysana

For the record, here it my plan as it pertains to item spawning:

For each island that is currently being rendered, we have a timer that is being run in the event.c file. This timer can be adjusted to change spawn rates. After the timer expires, an item tile that is located somewhere in the island will have an item spawned on it. If there are no free "item tiles", then an item will be despawned and replaced by a new item to keep an orderly policy of item spawning. Regarding the ITEM_TILE struct, there will be four things:

The TILE type will contain the terrain type of tile such that the terrain can be rendered properly underneath of the resource. REC_IDS resource will contain the type of resource to be spawned at the tile itself. Unsigned int quantity will denote the number of resources that are located at that tile. Finally, vec2 position will store two things. Firstly, it will store the tile location of the resource by casting the values of the vec2 to an integer. Then, secondarily, it will store the "intra-tile" position of the resource within the tile such that the resource can be located anywhere within the tile without being centered all the time. Think about how items in Minecraft can be located at many different places on top of a block.

When items are being spawned, the number of items that are being spawned on an island is determined by the size of the island. The current numbers I am using to determine the number of items is I_WIDTH I_WIDTH 0.001. This means, if the island of size 512 x 512 tiles, the maximum number of items that can be spawned is 262 items. This doesn't necessarily mean that there will be that many based on RNG.

Other details should be fairly self explanatory in the code. If I change any of the numbers that I am using that I mentioned above, I will try to remember to update this post to contain those new numbers.

zbostock56 commented 11 months ago

RESOURCE RNG TABLE:

Name Value Spawn Chance
Grain 5 30%
Cotton 6 ^
Wool 8 ^
Dyes 8 ^
Sugar 10 ^
Leather 12 25%
Cheese 15 ^
Iron Ore 18 ^
Wine 20 15%
Copper Ore 20 ^
Spice 25 ^
Herb 28 10%
Tea 30 ^
Silver Ore 30 7%
Porcelain 35 5%
Silk 40 3%
Pearl 45 2%
Gold Ore 50 1.5%
Saffron 55 1%
Ambergris 60 0.5%