Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


adventure dungeon game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
19 replies to this topic

#1 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 17 September 2013 - 02:17 PM

here is a little adventure game I have made. it is not perfect. I made this game because I wanted to get better at c++. let me know what  you think.Attached File  adventure.zip   5.6KB   346 downloads



Sponsor:

#2 CJ_COIMBRA   Crossbones+   -  Reputation: 813

Like
0Likes
Like

Posted 17 September 2013 - 07:30 PM

Cool, gave me some nostalgic feelings. 



#3 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 17 September 2013 - 07:41 PM

so  you liked it? where can I improve it?



#4 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 17 September 2013 - 08:15 PM

When I went to the M and I pressed f after I killed the orc he comes back and I have to fight him again. I think this is a bug. also, I went to the other M and it there was an orc there and then he dissapeared.



#5 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 17 September 2013 - 08:17 PM

cool thanks for the input



#6 stitchs   Crossbones+   -  Reputation: 1307

Like
0Likes
Like

Posted 18 September 2013 - 04:06 PM

I like it. I have a few small issues.

 

  1. I get the same bug as mentioned, the Orc keeps fighting me even if I kill him.
  2. The second 'M' just says I found an Orc, but I never fight him
  3. Include your source code, as it is a much better way of telling you how to improve directly.

Regards,

 

Stitchs.



#7 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 18 September 2013 - 04:21 PM

well this is probably crappy code but it does work. there is always room for improvement. here is my source code

Attached File  adventure (2).zip   889bytes   136 downloads

 

 



#8 Master thief   Members   -  Reputation: 247

Like
0Likes
Like

Posted 20 September 2013 - 07:07 AM

I also noticed the map doesn't get shown after you defeat the bottom monster(orc), and that you will still find orcs at their locations even after they aren't shown on the map, and even though you can't fight them anymore.

 

This is nice little game, I guess I should follow your example and keep it simple as I'm learning c++. I realize I was overcomplicating my ideas on what to do while learning and it was being sort of an obstacle, I think it's better to do it simpler and expand from there...

 

Oh and one thing I might do if I was making a game like this one (you may have already thought about it) would be to clear the screen before updating the map with the new player position.


Edited by Master thief, 20 September 2013 - 07:08 AM.


#9 Chirieac   Members   -  Reputation: 141

Like
0Likes
Like

Posted 20 September 2013 - 07:28 AM

I've looked at your source code... I think you should pay more attention to code formatting, like consistent indentation and more empty lines.



#10 Crusable   Members   -  Reputation: 594

Like
0Likes
Like

Posted 20 September 2013 - 08:11 PM

Well, I just looked over your code and here are a few comments:

 

1- There are no comments. When someone is reading your code, you should make it as easy as possible for him/her to figure out what you are doing.

2-Some of your variables are quite vague. Flag for what?  hp of whom? You should make your variables as descriptive as possible without them being ridiculously long. 

3-You should use more spacing and tabs to make your code more readable.



#11 nesseggman   Members   -  Reputation: 364

Like
0Likes
Like

Posted 21 September 2013 - 02:26 PM

I played this but I haven't looked at the source code. Here's some things I noticed, and some suggestions on where to go next if you'd like to improve it/fix it:

 

* If you go into the space with a sword repeatedly, you will continue to pick up the sword. Since there's no indiciation of inventory, I can't tell if I'm getting multiple swords, or if it's just giving me the notification for walking on the space.

* When I fought the monster on the left, I got stuck. First I killed him, then he refought (like people have been saying) but no matter how many times I hit him, neither of us died. I pressed f like a million times.

* The map doesn't display again after a battle, so I have no idea where I am if I've forgotten my location. Since it updates every move phase, I think it should update here, too.

 

Here's some things you could try adding, that I think would be a good challenge based on what it seems you can do so far:

 

* Have the room be a random size and shape (even if it's just differenlty proportioned rectangles), instead of the same square every time.

* Have monsters and items appear at random locations. You don't have to have random amounts -- it could always be the same sword and two monsters, but in different places every time.

* Have a victory and loss condition (run out of HP and die, defeat all monsters and win, for example)

* Different weapons with different abilities, that they player can choose to replace with his current weapon.

 

Once you've done those, you can even try adding monsters that move and chase the player (or run, or do different things... they could have a simple AI). So you'll have to make an AI and turn-taking system.

 

Though to add these things, it might be good to look into object-oriented programming. I think that seems like a good next step after this. I haven't looked at the source code yet, but it doesn't seem like you're using classes based on the way it plays.

 

For example, if you wanted the monsters to be of random types and in random places, you could make a monster class, and when creating the initial map, create monster objects and assign them random coordinates (which are stored in the class in variables). Stuff like that. This will also make the program more expandable so you can add new things more easily.

 

OK, I decided to downlaod the source code. It's very difficult to read. Like said, use comments everywhere. Unless something would be glaringly obvious to someone looking at your code (imagine they've never even run the program and they're JUST looking at the code, figuring out what it does... they might not even know it's a game... pretend they'll never run the program and need to figure it out just from the code... comment all the time!)

 

Also, the formatting... like said, white space is important. You want to tab stuff. When your blocks are indented, they are a lot easier to read... especially when there are blocks within blocks. Just looking for braces nad trying to figure them in your head is a strain.

 

This will not only help others reading your code, but it will help you, too. If you leave to work on something else, then come back to this project later, you may find you have no idea what your code even does anymore... and without comments and nothing being indented or spaced well, you will have a lot of trouble trying to figure out how your program works anymore.



#12 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 21 September 2013 - 02:59 PM

thanks for all the input



#13 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 21 September 2013 - 03:04 PM

are there any general rules on commenting code?



#14 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 21 September 2013 - 03:32 PM

Attached File  adventure (3).zip   1.14KB   57 downloads well I put in some comments and spacing



#15 Trienco   Crossbones+   -  Reputation: 2212

Like
2Likes
Like

Posted 21 September 2013 - 11:37 PM


int x=0,y=0,w=4,attack=0,hp=6;//global variables

 

They are declared inside main(), how are they global? Maybe they "feel" global, because you dumped your whole program into a single function, but that's not the same thing.

 


cout << "***Welcome to Adventure***";//welcome text

 

This is a prime example for useless comments that only exist because someone said "you need to comment more".

 


for (int i=0; i<9; i++)//draw grid

 

I was wondering how many times you would copy/paste the same comment without eventually realizing that this code shouldn't be commented, but get its own function.

 

 

Comments should only be used where necessary. Prefer writing clean and readable code with decent names for variables and functions. Which means, don't be lazy and abbreviate the hell out of everything, keep functions short and have them do ONE thing, avoid confusion (don't use i and j as loop variables or any other combination of letters that look alike).

 

If you have a piece of code and feel the need to put a comment over it saying "this block does x", put it in a function and call it "x".

 

Comments are the last thing anyone ever updates, they are frequently copy/pasted along with the code and it's usually less than a month before they turn into a confusing mess of lies and deceit. Write code that speaks for itself and doesn't need comments in the first place.

 

Use comments where explanations are required or a chunk of code is impossible to quickly look at and understand what it's doing. "Find shortest path using A* (<link to more info about A*)" would be a helpful comment. "Assign sum of x and y to variable a" on the other hand is nothing but noise that actually makes it harder to read the code (seriously, if somebody needs you to explain what a=x+y does, they probably shouldn't be looking at any kind of source code in the first place).

 

Frankly, nothing I see in your code needs to be commented, because it's about as trivial and straight forward as it gets. Better names, clean formatting and at least an attempt at well structured code would make any kind of comment superfluous.

 

Get a book like "Clean Code", ignore the dogmatic parts and rather than taking everything as "how it always must be", read it as "what you should strive for within reasonable limits".


f@dzhttp://festini.device-zero.de

#16 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 22 September 2013 - 10:55 AM


Frankly, nothing I see in your code needs to be commented, because it's about as trivial and straight forward as it gets. Better names, clean formatting and at least an attempt at well structured code would make any kind of comment superfluous.
so I  don't need any comments?

#17 IYIonster   Members   -  Reputation: 104

Like
0Likes
Like

Posted 25 September 2013 - 09:32 AM

There are some game design related changes i would like to see (Hope you want feedback on that too). They will also give you some more stuff to program :).

 

Randomness ; Give the hits some chance, and with it some more outcomes. Think of DnD's die rolls to determine damage. This will give more depth than just the simple "hit or miss". 

Motivation ; What is the motivation behind hitting or running or doing anything in the game right now? Give the player a goal and with that possibly a winstate. A reason to run is also missing. Why would I run? I can't die anyways. 

Feedback ; Give some more feedback to the player as to what happens or what his surroundings look like. With the earlier mentioned damage  you can give a couple of different texts based on the severity of the hit. Also some feedback on how the enemy is doing after you hit him would be nice. 

 

I can't think of anymore right now but this should keep you busy for a bit too. :)

 

Cheers, 

IYIonster



#18 Kaptein   Prime Members   -  Reputation: 2174

Like
0Likes
Like

Posted 25 September 2013 - 10:08 AM

 


Frankly, nothing I see in your code needs to be commented, because it's about as trivial and straight forward as it gets. Better names, clean formatting and at least an attempt at well structured code would make any kind of comment superfluous.
so I  don't need any comments?

 

honestly, write all the comments you feel that you need, for yourself, 1 month from now

you are just starting out, and you will no doubt leave this project for another as you get better at programming and you realize that there are things that could be solved with easier and simpler code

so, this project could be like a reference for you, if you need to take alook at how you did a specific thing, when you need it

 

i frequently take a look at my previous code just because otherwise i would have to re-read documentation or "google it".. no one remembers every little thing smile.png

 

making your variable and function names "short sweet and to the point" is more important

so, for your ogres HP variable:

"hp"  bad

"ogre.getHP()" good

 

me post now (PS. take a quick look at classes, they really do help compartmentalize both your code and your thoughts)


Edited by Kaptein, 25 September 2013 - 10:10 AM.


#19 phil67rpg   Members   -  Reputation: 767

Like
0Likes
Like

Posted 03 November 2013 - 06:37 PM

I am going to work on this project more.



#20 Petter Hansson   Members   -  Reputation: 602

Like
1Likes
Like

Posted 03 November 2013 - 09:47 PM

"Writing the right comments" is an art an takes time to learn (heck, I need to constantly strive to improve myself). What you want your comments to do is to explain WHY the code does what it does, NOT what it does or how it does it. E.g. see the difference on the example that was posted above:

 

cout << "***Welcome to Adventure***";//welcome text

 

cout << "***Welcome to Adventure***";//need to display the welcome text already now or player won't know what game this is

 

Somewhat contrived example given how useless that text is anyway, but.. smile.png

 

Not that comments for explaining why will always be longer, sometimes they are shorter. What you want to ensure is that your variable and function names are so clear that people can figure out what the code does for themselves, but you explain the motivations with your comments. To compare with a normal language sentence "I do X because Y", you want to include the Y as your comment, rather than X (most of the time, there are always exceptions) - since the code should already say what X is if it's clear enough.

 

Even though I said "people", it will benefit your future self as well if you have to revisit the code.


Edited by Petter Hansson, 03 November 2013 - 09:59 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS