A Foresty Game

Fayabella

  • Posts: 239
very nice!!
Thanks!

Now, for the crafting system...

Again, I know what I want and ideas of how to get there, but not 100% sure how to do it.

The system I want is, if you have the required resources in your inventory, you can craft it. No need to configure them in an orientation, etc.

So, my idea is... A map attribute, with each craftable item as keys. The value of each key is a map, with the keys of that map the items you need and the values being the amounts.

This way, I can add recipes as to the main map as the player grows more advanced.

But my problems:
First, I don't know how I'm gonna present this to the player visually.
Second, I'm not sure how I can check if the player has every item needed in their inventory. A recipe could have 12 ingredients, meaning 12 if statements to see if the player has it, or 2 ingredients, meaning the other 10 are redundant and probably return null. I need to find a way to make it work with any amount of ingredients.

This is what I'm gonna be working on the next few days.

Any suggestions on how I should go about the UI would be appreciated!

Fayabella

  • Posts: 239
Wait, then I'd have to make a map attribute for every single recipe. That might be a bit much.

Hmm...

Luyren

  • *
  • Posts: 2807
Hopefully this will give you some idea on how to handle your recipe problem. This is how I customize my list for a trader NPC, one that trades any amount and combination of items and money for an item or skill. If you customize and parse your list correctly, you could make something like this (with less options or more options, of course).
My Stencyl resources are available here: https://luyren.itch.io/
Cutscenes, RPG Elements, Particles, Map System and many more.

Fayabella

  • Posts: 239
Wow, this is exactly  what I was trying to do. Not sure why I was trying to use maps.

Thanks for that! I'm gonna do it with a few less options.

Perhaps Name/Ingredient,Amount;Ingredient,Amount/Tool or Inventory/Amount Crafted/Workbench Type

« Last Edit: February 23, 2019, 03:02:37 pm by Fayabella »

Fayabella

  • Posts: 239
I decided to do a bit of pixel art for once, and came up with this workbench sprite.

I actually kinda like it. Problem is, the 'placing' in my game is grid-based, and the grid is 32x32 pixels, and this sprite is 32x32, so it's gonna look like there's a bunch of space between each table, and the only solutions I can think of (neither of which I like) are 1. making really tall sprites and 2. making the grid 32x16.

Ah well. More problems to figure out eventually.


« Last Edit: February 23, 2019, 03:02:09 pm by Fayabella »

Fayabella

  • Posts: 239
Small update:

I've made it so that you can select which item you're holding in the inventory, and you can now only place torches if you have the torches selected in your inventory. I'm probably going to change the controls for this, but right now it's E to move one item down and Shift+E to move up an item.

I'm not gonna release this as it's kinda really small, but I thought I'd at least post about it.

I've also realized something that could make my game more unique.
Right now the player actually only has 8 inventory slots. I could keep it that way. A small inventory would be more realistic, because nobody carries around a backpack that can hold thirty-four metric heck tons of items. More importantly, it would force the player to have to think about what they should have in their inventory, instead of throwing in a bunch of stuff and be like "I might need this eventually." The player would have to be more conservative about inventory space. My idea with the toolslot also would make more sense, as it would be convenient not to have to fill up half your inventory with an axe, pick, shovel, and hoe.

Just a random thought.

Fayabella

  • Posts: 239
At the moment, my problems are:

-Performance
-32x32 grid and 32x32 objects means there will be space between placed objects

What I'm working on,  however, is the crafting, and not fixing the problems.

I've never really made a behaviour, just added events to the actor/scene itself, but i feel like a behaviour would probably be the best way to go here.

JeffreyDriver

  • Posts: 2262
I really like the sprite. I'd go for your second option to change the grid size, but I'd suggest making 16 x 16, not 32 x 16. It's just a personal preference, but I find square tiles easier to work with as you don't know what problems you might encounter down the line.

As for behaviours, I stick everything in behaviours. Again this is just a precaution. Also, if you're going to have lots of scenes create a blank behaviour and attach it to every scene as you go. You might not need it, but if, later on, you need a global behaviour it'll save you some time. It's alwas good to try and plan for things you might need later on.

Fayabella

  • Posts: 239
Thanks! My problem with changing the tile size is that I'd have to basically rewrite a huge amount of my code, and I'd also have to add something to prevent overlapping objects (half of a 32x32 object on top of another half of a 32x32) and also rewrite the code that contains all placed objects in maps.

I really don't feel like doing that. It's not too big of a problem right now as you can't place the workbench yet, but eventually it will become and issue and I don't know what I'm gonna do about it.

JeffreyDriver

  • Posts: 2262
I know it's a massive pain to rewrite a lot of code but sometimes you just have to suck it up knowing it'll be worth doing it now rather than later.

A tip: When working with global values that you know you're going to use across your game, store them in a global map and then retrieve them that way so any updates take effect to your entire game.

Fayabella

  • Posts: 239
Hmm... I'll probably rewrite it eventually. Only problem is that then the cursor wouldn't make sense. If I made the cursor 16x16, then it would take up half of a tree instead of the whole tree and that might be confusing.

Another update:

Remember how I stored each tree in a map attribute with its position as the key, and the torches in another?

I realized that I can just combine the maps into one map for all items. With only a few tweaks to my code, I got this to work, and now all I have to do when I add new objects is add code to add them to the map attribute.

SO much simpler.

I've also edited the sprite a bit: There's no more cloth thing on it, just a hammer, and I've added 4 different hammer orientations for variation. There's now a shadow, too.

Bombini

  • *
  • Posts: 1400
I decided to do a bit of pixel art for once, and came up with this workbench sprite.

I actually kinda like it. Problem is, the 'placing' in my game is grid-based, and the grid is 32x32 pixels, and this sprite is 32x32, so it's gonna look like there's a bunch of space between each table, and the only solutions I can think of (neither of which I like) are 1. making really tall sprites and 2. making the grid 32x16.

Hey,
i dont see why you need to change the grid.
I attached some ideas how to deal with it.
You can adjst your standard table to decrease the space between each table. You can use custom tiles to make larger tables to have more variation.

See here:



Cheers!

Fayabella

  • Posts: 239
I- wow, that's actually pretty smart. Make the table longer instead of the legs. Cool, thanks for that. I'm not entirely sure what you mean with the custom tiles and really long table, but elongating the table...

Let me go do that real quick.

Fayabella

  • Posts: 239

(4x scale)

Here's my redone sprite, and since there's more room on the table I added 2 more variations.
I feel like the table needs more than a hammer, but I'm not sure what else goes on a workbench.


Here's what they look like on a 32x32 grid.
(Ignore that they're all the same variation, I haven't coded the variation yet)

Bombini

  • *
  • Posts: 1400
Looking good!
I'm not entirely sure what you mean with the custom tiles and really long table, but elongating the table...
I was talking about the left collumn of my example where i showed how to do long tables. You need a start, middle an end part. You can male the table as long as you want the more iddle parts you put it.