Advertisement

A ? for not so begginers

Started by January 09, 2003 03:17 PM
11 comments, last by Betrayer_of_Code 21 years, 10 months ago
quote: Original post by hammerstein_02
Superpig, sorry but no you don''t have to understand classes and inheritance.. I learnt how to program the basics using C++ by doing just this sort of project. I never used objects, just good old variables. The code ended up at 6000 lines.. and was messy as hell, but I wrote a text adventure.. (never finished it, and lost the source!)


I''m trying to encourage good programming practices here. Of course you can do everything in C (you call it C++ but without objects, it might just as well be C ). You can also attack a bear with a drawing pin, or build a computer out of sand. Might take you a while though... To know C++, you have to know classes. That''s pretty much the whole point of C++.

BTW, I was inspired to write a text game by this. I''ve reached around 700 lines (including the large amounts of whitespace added by VC++), and I''ve just about finished the socket-based client/server code. All that remains is soft architecture stuff. And it''s all done using classes. I think I''ll release it for people to use to develop their own (the game-specific code is isolated in a seperate DLL).

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.

Richard "Superpig" Fine - saving pigs from untimely fates - Microsoft DirectX MVP 2006/2007/2008/2009
"Shaders are not meant to do everything. Of course you can try to use it for everything, but it's like playing football using cabbage." - MickeyMouse

Hello again,
In reply to the idea of moveing monsters and items insted of a generic (solve the puzzle type adventure like the ones on the very old macs) you could set a value for each room and declare a function like int movemonster (x, y). Then have x be the value of the room your in and y be the value of his room. then set the map up as a multi demenstional array then in the array set the value in the square you are in and the square where the monster is. it is easyer to get what im saying if you view the array like this:
[][][][]
[][][][]
[][][][]
[][][][]
The have the monster move one room twords you by haveing him see if you are in a part of the array higher than 4 or if you are in the array higher than him but less than 4. If your more than four he will move upwards, if you are still greater than him but less than 4, it means you are either on the same level or very close to him. so he will move to the left. and so on. Then when he is in the same room with you use a if then to see if he is in the same room as you and if he is run a recursion. in the recursion draw a random number between the two damage levels you want each player to do. Then run the recursion and it will run over and over doing damage to the monsters health interger till one of you dies. you could also use a do while loop to say, do keep attacking while one of there healths is still above zero. this might be easyer than a recursion. To pick up a item just make another multi demensional array of how many items you want him to beable to carry. then make a table of what each items number that it is assighned to through a switch case. Then just put each number in a array spot. like if you decide to pick up the beano the action will put the number atomaticly in the next avariable open space in the array. Then when looking through you pouch, it will read each number and cross refrence that through a decoding mechanism tucked away in its int Decode(). In the decode it would have a switch case just saying that if the the number is this then coutt<<""; this. There you have it. This is just simple codeing and can get messy, but if you put in enuff coders talk (//this is what i call coders talk) and sub areas like int decode() it can stay pretty orgonised. I got one running at about 1000 lines now. dont rush it, just every once and a while just sit down and add some. Like i have a rock paper sicisors game that you have to play one of the monsters in. Just messaround, and dont be in a rush. Salutations again!
Advertisement
Thank you but the first two "encoured" me to do it by meself so I did. I hav the code posted at my site, as he said its messy as hell but it works (Kinda) and its got more bugs than the roach motel but Im proud of it. Its nowhere near finsihed.
My Site

Thanx
BoC HomepageLuck is a Horse to ride like any other...Luckily im not a gambler, I dont know how to ride.

This topic is closed to new replies.

Advertisement