About fstream and also the use of stupid pointers grrr

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
dream_coder
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Sat Mar 27, 2010 5:16 pm

About fstream and also the use of stupid pointers grrr

Post by dream_coder »

First of all I have just been following some tutorials on pointers and I still aint got my head round them but think I have the basic idea. Also I have been reading up on reading from files, which seems pretty straight forward.

Anyway the purpose of this thread is I have an idea for the next part of my random game. By the way this game is following no structure, Im just following tutorials then writing code that I want to implement into my game, I will fill in the gaps later, Im just doing what I can.

Anyway the next thing I a want to create is a way of loading some items and some monsters, plus info about the player into the game. I am planning on doing this using an array of structures(if that is possible). I have been messing around with a way of laying out the info I need in a file and so far the only way I can think of doing this is by having a seperate file for Monsters, Items and Player. DOes this sound about right, it just seems very complex having just one file holding a lot of different information.

Im then going to have my array of structures. However when I load the files, it will be in a seperate function(probably just one file handling class specific to game later on). However this is the bit where I am having difficulty, do I declare my structures as global and just load info into them, or do I pass them onto my functions a pointer to them? If it is possible to use pointers like this, which is how I see them as being used it would be a lot simpler. Or I could load them into a structure, pass the structure to main then copy the structure to the structures already set up, which just seems a waste.

So am I right in how I am planning on using pointers. I just aint sure becasue even when I did C++ at Uni years ago, I genrally avoided pointers like the plague.

Hope my question makes sense. Or am I just barking up the wrong tree. Cheers.
Image
Image
Image
User avatar
mv2112
Chaos Rift Junior
Chaos Rift Junior
Posts: 240
Joined: Sat Feb 20, 2010 4:15 am
Current Project: Java Tower Defence Game
Favorite Gaming Platforms: N64/Xbox 360/PC/GameCube
Programming Language of Choice: C/++, Java
Location: /usr/home/mv2112
Contact:

Re: About fstream and also the use of stupid pointers grrr

Post by mv2112 »

Ugh, i don't quite understand what your array of structures is. Are you using 1 file for all monsters and 1 for all items? Please explain so we can have a better chance of helping you out.
dream_coder
Chaos Rift Newbie
Chaos Rift Newbie
Posts: 34
Joined: Sat Mar 27, 2010 5:16 pm

Re: About fstream and also the use of stupid pointers grrr

Post by dream_coder »

I am going to use a seperate file for items, monster and player.

Lets say

items.txt
monsters.txt
player.txt

I aint to sure about doing one big file as I aint too keen on alll the parsing that would need to be done with loops, it would get pretty messy so just going to use seperate files.
Image
Image
Image
Post Reply