Hey guys, so well i was trying to make a game (yay) but everyone said that in c it was not going to work well (sob) so fast forward to today where i learnt a bit of c++, and to make a game i have to make a map! so should i use linked list and some rpg maker tileset (one member of the linked list = one of the tileset, and then i draw those on the screen depending on a file with number to know where to put what) or should i plan all my maps in advance and do it like "oh player is in map 3, i should load this set!" with linked list it might be easier to know where a wall is.... as you can probably see i am a bit lost about where to start -.-
It might be easier to use rpg maker. if u do all the maps in advance then u need to do it all hardcoded right?
I’m curious why you went with C++ for your first try at game dev. You might want to consider something a little more user friendly in your first attempt. Personally I prefer Unity and C# as there’s a huge amount of tutorials and knowledge base out there, and it’s free to use for your purposes. Also wondering why you chose a linked list instead of an array.
Since you will traverse it a lot of times all the time, a linked list might not be a good idea as it will cause some performance loss due to a large number of RAM access requests. I suggest an indexable structure. Perhaps, the hashmap or a map data structure would be best? Or make your own class with an array as storage and implement navigation methods for it. If this is your first game, I suggest also do not go for the fancy stuff like dynamic loading of procedurally generated maps. Try to use static maps first, try stuff out, see how it works and get some experience. You can modify them later to be more fancy.
Try pre allocating nodes of the linked lists together. So the memory is next to each other, and it doesn't have to jump from one address to another that's far away...?
Who ever that said, C isn't going to work well for a game, is pretty much an amateur within coding. The C language is in the forefront regarding optimization and coding of games, especially the core of a game. Then, sure... you can make games using Java and other languages. But you have to realise, that these languages are generally Slower to be read etcetera. For example, Most JAVA games have the bottleneck in the RAM... Minecraft as a good example. So just keep at it. If anything, learning C makes learning anything other than that, easier.
you have no control over it, especially since each node has to be allocated separately, you can't really just reserve the block. And your program might be put to sleep and run later in the middle of the allocation by the scheduler. There is no way to guarantee you will get consecutive memory unless maybe you use some special custom allocator. Even if that happens, you still get a bunch of garbage in the cache to go together with the actual data you want
And here I am here, thinking that you need advice how to do a container... About question - first you need to understand your tools and only after that you can plan what you can do.
You can make games in any language but unless you it's just a demonstration for university or something, you should stick to java or C#.
Tbh an array sounds way better here. You will need to access each tile a lot (to check if tile is traversable or not) and going through ll every time is not a great idea. Nope array is better coz O(1) access to every tile and you can always define each tile to have an isWall variable or use simple math to determine the map limits. As for maps, I would suggest loading data from a file. Generate a map object out of it and use that object for display. The object would take I guess tileset(as in the look of the tile) and the filename. I believe there are tutorials on yt too about creating games in c++
well i also want to use this as an opportunity to learn ^^ but yeah hardcoded is one of the option i thought of well i used CSFML in c to make an rpg last year so i thought SFML and c++ was the obvious next step and yeah an array might have been better -.- for whatever reason when i think of a structure the first thing that pop into my mind is "LINKED LIST!" it is weird oh thanks, it is quite the detailed answer i am not bad in c, and it indeed speed up the process of learning c++ quite a lot! but in a previous thread i made everyone told me that making a game in c was the step just above making a game in ASM (Rollercoaster tycoon i am looking at you) to have control over it you need to re-code malloc and make some sort of temporary memory keeper -.- not something to be enjoyed thats exacty why i am asking ^^ discussing it help me understand it better Nah it's for fun ^^ well mostly because i have a lot of free time recently oh thanks, indeed array look better for this, but i am unsure about what you mean by 'generating a map object'
Honestly, traversing the array is going to take no time relative to loading the map itself. As long as you don't load every map as a precache step, it shouldn't matter which route is most efficient. Try not to prematurely optimize or you'll spend too much time thinking and no time doing.
it has been done before, but not for the purpose of allocating consecutive ram chunks sounds like he talking about reading map information and put in in some C++ object that you will use after reading the information from a file
Make a map (defined by you) object. In the init method/constructor, make the tile array and the tile objects for it. Taking height and width as parameters or passing it as first values in the file would also be a good idea. Remember to destroy the tile objects inside it in the destructor/finalize methods too btw
oh thanks i think i see ^^ Oh? why would someone do something so masochistic =P well maybe but i still remember the time i had to redo my whole code to optimise it T-T but yeah i just wanted different point of view in order to not go at it blindly like a dog an a mine field edit: also you can now have a title ya know?
you definitely need rpg maker, you would have alot easier time in longterm, ALSO IF ITS AN INTERESTING GAME CAN I JOIN TOO
Hint: The context for that affirmation is not the performance side. It's what they should put their focus on when they don't know neither programming nor game development; and that depends on their goals.
SURE, I WOULD LOVE TO! well i also wanna learn a new language so rpg maker is not what i really want to do it is true i am a bit of a noob =P
You might want to watch this chanel https://www.youtube.com/channel/UCQ-W1KE9EYfdxhL6S4twUNw he does a lot of stuff about game engine (in C++, java, etc. i forgot the complete list), you can try to use some of those game engine knowledge into your game.