Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Project 3

Here are some projects of actual programs you can practice making.

Project 3

Postby antiRTFM on Mon May 12, 2008 10:12 am

Lets make a Combat simulator.

Here are the rules:
1: The player will be a character having at least Health, strength, armor, experience, and level as combat factors. You can add any other factors you'd like. The player will start off with a minimum of stats, zero experience at level 1.

2: The player will have an inventory to carry items. The player also has a wallet of gold, starting off with a small amount of gold.

3: There should be a main menu offering the following choices:
- Buy items
Here the player can buy weapons, potions, magical items, etc. The details of these items and how much they affect combat is totally up to you.

- View Character Stats
Here the player can view his character's current stats such as how much health/strength/etc the player has, what weapon is wielded, etc.

- Combat zone
See 4.

- Quit
Exit the program.

4: Once the player decides to enter the combat zone, The player will be faced with an enemy which the player must fight. The enemy should have statistics comparable or less than the player's stats. The combat system should be turn-based, and the progress should be printed to the screen, such as:

Round 1:
Mordius attacks BigOgre with Sword and deals 10 damage.
BigOgre attacks Mordius with Fist and deals 8 damage.

Round 2:
...

How factors like health, strength, weapon, magic, experience, level, etc affect combat is totally up to you.

The player will receive experience points, gold, plus anything the enemy was carrying as a reward for winning the battle. The player upgrades another level every time the player surpasses a certain amount of experience points. Again, the details is up to your judgment.

The player will restart at the main menu with starting-stats if the player dies in battle.


Here are some useful stuff to help you:

Most of the time such games use a random number generator. Go Here for instructions to get random numbers.

On Microsoft windows, we have the "Sleep" function to pause gameplay for a given amount of milliseconds. so
Code: Select all
Sleep(1000);
will make the program freeze for 1 second. This is useful for example if you want the program to pause for a second between each combat round (so that it doesnt print the whole fight all in one shot).


Please read the posting rules to be able to post your code.

Good luck!
Last edited by antiRTFM on Mon Jun 02, 2008 11:47 am, edited 1 time in total.
User avatar
antiRTFM
Administrator
 
Posts: 470
Joined: Sun Apr 13, 2008 9:10 am

Postby C++ on Fri May 30, 2008 1:55 pm

Well I decided to try and do this little project. I must say it's quite some work to do something that is actually not that difficulf of a concept. It's when you have to think to put something simple into a computer algorithm, what makes it difficult.

I tried to make it adhering to the requirements. I made five different classes and the running algorithm is in main. It's quite big though.. It's my first attempt to actually program something somewhat bigger than the standard things in C++. The algorithms I used aren't the best ones since I thought them up while programming. It could be done much better, but I'm trying to get the hang of things in C++

Below is the download link for the project. It's made in Visual C++ 2008.

http://rapidshare.com/files/118893678/Combat_Simulation.rar.html

Don't have too high expectations though...it's not that much. :roll:
Last edited by C++ on Fri May 30, 2008 2:55 pm, edited 3 times in total.
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby antiRTFM on Fri May 30, 2008 2:18 pm

Cant wait to try it out :)

But hm... this is getting a little to big for the forum... we should use some online file uploading site like rapidshare etc where you could upload you whole project and we can just download it and try it out.

So if you could, please go to rapidshare.com or something, upload the headers and source files into one .zip or .rar or something, then edit your previous post to have the link to download the whole package of code (and delete all that massive code! :D )
User avatar
antiRTFM
Administrator
 
Posts: 470
Joined: Sun Apr 13, 2008 9:10 am

Postby C++ on Fri May 30, 2008 2:27 pm

antiRTFM wrote:Cant wait to try it out :)

But hm... this is getting a little to big for the forum... we should use some online file uploading site like rapidshare etc where you could upload you whole project and we can just download it and try it out.

So if you could, please go to rapidshare.com or something, upload the headers and source files into one .zip or .rar or something, then edit your previous post to have the link to download the whole package of code (and delete all that massive code! :D )


Yes you're right. I thought about that being to big and all... Give me a minute and I'll upload it with rapidshare.
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby antiRTFM on Sun Jun 01, 2008 2:44 am

WOW!!!

Didn't have time to look into it in detail but i did play a few rounds and stepped through some code... not bad at all i must say, you are really getting a hang of things in c++.

Though, probably not from the videos eh? i noticed you used the '->' operator which i didnt speak about yet (actually i did but i deleted that video). I also noticed the system("cls") command which again i didnt speak about yet (for good reason btw, its not standard c++ :) )

You can use some touch-ups in the combat luck generation, i was battling against the mighty Uber Duriel :D and it was getting to a point where exactly every sixth round (all of them being totally 'missed') would finally end up in me being hit by enemy. Didnt look all that random as one would expect a battle to look like.

But otherwise things were pretty cool and organized. I would use potions as soon as i was out of health :) i would deplete the store of all its merchandice :D and failed to die even when i tried :twisted:

excellent job! anyone else can do something comparable?
User avatar
antiRTFM
Administrator
 
Posts: 470
Joined: Sun Apr 13, 2008 9:10 am

Postby C++ on Sun Jun 01, 2008 9:25 am

antiRTFM wrote:WOW!!!

Didn't have time to look into it in detail but i did play a few rounds and stepped through some code... not bad at all i must say, you are really getting a hang of things in c++.

Though, probably not from the videos eh? i noticed you used the '->' operator which i didnt speak about yet (actually i did but i deleted that video). I also noticed the system("cls") command which again i didnt speak about yet (for good reason btw, its not standard c++ :) )

You can use some touch-ups in the combat luck generation, i was battling against the mighty Uber Duriel :D and it was getting to a point where exactly every sixth round (all of them being totally 'missed') would finally end up in me being hit by enemy. Didnt look all that random as one would expect a battle to look like.

But otherwise things were pretty cool and organized. I would use potions as soon as i was out of health :) i would deplete the store of all its merchandice :D and failed to die even when i tried :twisted:

excellent job! anyone else can do something comparable?


Thanks!

Well I did read some in books and looked up those things not mentioned in your tutorials yet. But I do watch your videos. Frankly I don't like reading books and your video tutorials are great, so watching them is much more fun than reading boring books. I only use books for reference really. I have a little bit experience with programming in Java. For the rest this is my first real attempt to learn OOP. I like C++ and hope to see a lot more of your tutorials. Is it one of the rules where you may only use the stuff you've learned so far from your tutorials?

I know the randomizing part isn't that good. I'm having trouble to get good randomizing even when using a different seed all the time. I have the seed changing in every randomize call. Frankly I saw I didn't even tweak the items yet, so they may seem a little bit expensive :lol:
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby antiRTFM on Sun Jun 01, 2008 12:21 pm

C++ wrote:Is it one of the rules where you may only use the stuff you've learned so far from your tutorials?

No, i haven't made such a rule... yet :)

I know the randomizing part isn't that good. I'm having trouble to get good randomizing even when using a different seed all the time. I have the seed changing in every randomize call. Frankly I saw I didn't even tweak the items yet, so they may seem a little bit expensive :lol:


You should only seed once per program run, not once per random number you want to generate.
User avatar
antiRTFM
Administrator
 
Posts: 470
Joined: Sun Apr 13, 2008 9:10 am

Postby C++ on Sun Jun 01, 2008 12:37 pm

antiRTFM wrote:You should only seed once per program run, not once per random number you want to generate.


Well I did that at first. The problem with that is that it keeps generating the same random sequences for each low to high interval for as long as it uses that particular seed. That's very undesirable when it comes to random drops or shop item generation for one game session.

If you change the seed the random numbers set for a particular low to high interval will be different instead of permanent for that game session. When you only seed once the same random number sequences will show up. That's what I noticed at least when randomizing.
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby antiRTFM on Sun Jun 01, 2008 12:51 pm

try seeding exactly as i posted above, srand((long)time(0));

p.s. GetTickCount isnt standard c++ as you probably know (though thats not the reason why things are not working well now)
User avatar
antiRTFM
Administrator
 
Posts: 470
Joined: Sun Apr 13, 2008 9:10 am

Postby C++ on Sun Jun 01, 2008 2:04 pm

antiRTFM wrote:try seeding exactly as i posted above, srand((long)time(0));

p.s. GetTickCount isnt standard c++ as you probably know (though thats not the reason why things are not working well now)


I did try that... The problem is that if you don't change the seed more than once per game session, the random numbers generated for a particular interval will be the same.

For example, if the seed would be 8, then all randomizes between 0 - 10 will produce the same output for as long as the seed 8 is used. That's what happened on my PC. I don't understand why it works for you...
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby Marss++ on Mon Jul 28, 2008 12:42 am

wait.. So has anyone actually made one of these yet. I would like to see one.

If anyone has any questions on them just ask I'll be more then happy to help.
I'm a 15 year old kid who has his heart set on Programming.

Came here hoping to help so if you have any questions just ask!
Marss++
 
Posts: 149
Joined: Fri Jul 18, 2008 3:20 pm

Postby asib on Mon Jul 28, 2008 4:34 pm

That's really cool! Like the names from Diablo 2 xD
And I like the auto equip too.

Edit : I found a tiny bug. When I auto took a potion in combat, my health went above the allowed limit, so now i'm "Hitpoints: 185/150".
asib
 
Posts: 86
Joined: Tue Jul 22, 2008 9:15 pm

Postby C++ on Sat Aug 16, 2008 9:29 am

asib wrote:That's really cool! Like the names from Diablo 2 xD
And I like the auto equip too.

Edit : I found a tiny bug. When I auto took a potion in combat, my health went above the allowed limit, so now i'm "Hitpoints: 185/150".


Yep you're right. I noticed that myself too. I used the wrong variable to adjust hit points. It's fixed now. Were you able to fix it yourself?
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Postby andr3 on Sat Aug 16, 2008 11:06 am

OMG this is GREAT!!

Wow, and thanks for the source code, I will learn so much from it!!!


*Speachless*
andr3
 
Posts: 7
Joined: Tue Aug 12, 2008 4:18 pm

Postby Doctor Salt on Sun Aug 17, 2008 3:21 pm

hehe, i'm gonna take this one on, and maybe expand it a little too....

What i'm planning is a mix between Elder scrolls: oblivion, the flash games Field Command 1-3, Oregon trails, and the story line of Eragon....

http://www.newgrounds.com/portal/view/264328
heres the second field command game, google the other two if you want.


So right now my 'game' is more theoretical then anything else, but before i really start working, i need to solve a problem.

What would be the best way to equip armor to specific slots? I want there to be different armor slots, for the most customization, meaning helmet, chest piece, gloves, belt, thigh armor, boots, etc. When coding, i want to be able to call on a class function and tell me the armor value of the specific piece, and name.

But how? would i have to create a boolean value for every single armor thing in the game for every single place where armor can be put on?
Doctor Salt
 
Posts: 147
Joined: Wed Jul 30, 2008 3:32 pm

Next

Return to Projects

Who is online

Users browsing this forum: No registered users and 0 guests

cron