3
Okay, I’d like to play a game in C "console" but I’m having a question.... Basically the idea is to have a character that advances in a maze thanks to the user, if the user writes "right" the character moves to the right etc..
I imagine that the labyrinth is basically a two-dimensional array, and inside it all zeros and ones are inserted, "1" would be walls and "0" free paths.. (if there are better ideas please say)
Until then I imagine that there is not much difficulty, but I ask, if you want to put an inventory to the character, how do I make so that in a given house of the array have an object there? If for example in the map array[2][3] there is already a 0 "saying it is free path", how can I insert an object there? like a backpack or something?
I appreciate your willingness to help :)
It would be enough to have a separate array of objects. Assuming that knife is code 1, and ladder code 2:
objetos = { {1,9,1},{3,4,1},{3,4,2} }
(has a knife in position [1,9], another knife in position [3,4], and in this latter position there is also a ladder. Nothing would prevent you from using different values for the map itself if you prefer. Instead of zeroes and ones, you use one for the wall, two for the knife, four for the ladder, eight for the monster, and so on. A room worth 10 definitely has a monster and a knife.– Bacco
This reminded me of a game called Blip that came as a hobby within the Skilled Financial Manager whose stages followed this same style, but even simpler: # were walls, white spaces paths to follow, D was door, W, water and etc.
– Bruno Augusto
Hmmm, thanks for the answers, already gave me a very interesting idea of how to do :) However I was also advised to learn about "structs" and basically I’m new at this, I was told that it would serve me a lot, I saw one that another tutorial on how to use, but I’m not fitting the structs with my project, I don’t know what I could use it for.... any idea?
– macacomacho
@Bacco this deserves an answer.
– Jorge B.
I’m sorry, I’m not used to Stack Overflow, but if you don’t receive notification, I answered below the post...
– macacomacho