Archived

This topic is now archived and is closed to further replies.

Mage_gr

C++ question

Recommended Posts

Hey guys I followed your advice and I am a little confused by the swap function.What does it do?Moreover I have been adviced to start with a text game how do we wrtie such a thing?

Share this post


Link to post
Share on other sites
The swap() function swaps the values of two objects. It''s a templated function which takes 2 objects of the same type. You can use any type as long as that type is assignable. Are you having a specific problem with swap()?

Share this post


Link to post
Share on other sites
quote:
Original post by Mage_gr
DO you have any advice about the text game?

If I did, I would have mentioned it! It''s a looong time since I programmed a text game. The best advice I can give is to play some existing text games and get a feel for them. You need to have an idea what you are setting out to do. If you are unsure about what you are trying to achieve, the code you write will reflect that, and your project will eventually grind to a halt.

You might also find it enlightening to learn about state machines - they are likely to be useful in such a game.

Share this post


Link to post
Share on other sites
These guys are being a bit obtuse aren''t they? Listen, one of the best ways to learn coding is to look at other peoples code. So I suggest you get on the net and search around and look at the source other people are putting up then start your own project.

As far as a text game do you mean an adventure or an rpg where the player walks around and does stuff like a MUD? Your going to need some kind of data structure (start with arrays) to hold 1. the room description 2. the possible exits for that room, 3. the rooms contents 4. the players inventory etc.... Then you can add stuff like NPCs (or mobiles in MUD speak) and fighting or whatever. Set you initial conditions then loop through accepting input from the player and updating her data etc... Super easy to do with console app.

Hope I helped a little bit.

Share this post


Link to post
Share on other sites
I think the best way to learn is through your own experience, guided by a few choice books.

Judging by the number of posts on the NeHe forum that all revolve around the poster not knowing what the API he/she calls actually does, learning by example perhaps isn''t the best way to go.

Copy and paste is all too easy.

- Pete

Share this post


Link to post
Share on other sites