GPWiki.org
GPWiki.org
It is currently Mon May 20, 2013 7:08 am

All times are UTC




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: my 1st game
PostPosted: Sun Jan 18, 2009 7:16 am 
Level 1 Cleric

Joined: Sat Jan 17, 2009 11:13 am
Posts: 11
Location: Earth
Hello again,

just like to post my first creation. A text based arcade RPG.
This little game was originally programmed early last year with only the very basic knowledge from school and updated (mainly text & balance issues) in the following weeks after that. In total the game was written in ~1 week so tell me what you think about it?

I uploaded it on filefront.

http://files.filefront.com/onerar/;13010738;/filei

PS: you're free to use it as you wish, just don't go around saying that you created it(if it's even possible :P)

_________________
Sometimes when I have a lot on my mind it just helps to go AHHH!!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 11:50 am 
Digerati

Joined: Fri Sep 24, 2004 3:15 am
Posts: 1791
Location: No longer near Boston, MA
Hey, not bad. You've got a lot to learn still about objects and coding style, but that's solid. Great job for a first game!

A few tips - You have a lot of repeated code and strings, and you're probably going to want to read all your data in from files so you can add content to your game without touching your code.

If you're using goto you've probably got a design issue.

Classes, arrays, and the STL will make life worth living. They'll let you do the shops and stuff without thinking (and without tedium.)


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 11:57 am 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
Sadistic Penguin wrote:
You've got a lot to learn still about objects and coding style, but that's solid.

If you're using goto you've probably got a design issue.


As time goes by, I seem to use goto less and less. I don't know why that is. They say it's a good thing, but I don't know why that is either. :P


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 4:58 pm 
Sir Postalot
User avatar

Joined: Thu Aug 26, 2004 4:34 am
Posts: 2498
Image
Theropods is the main reason.

Almost all the reasons to use a Goto is replaced by either writing better code logic or using a command that jumps to a specific place such as break. You see that most often with switch/case, which is really just shorthand for a type of if and goto structure.

Today, Goto has very little use that isn't already covered by structured commands and Goto makes it very easy to completely screw up and hop over important things like delete[] statements. Also, as long as there are no Goto statements, you can just look at brace pairs to see where the instruction pointer can go. A Goto knocks that plan on its ass.

/I've never used Goto since I left Basic.
//Not even when I wrote some code for my TI calculator.
///Making function calls in a procedural language with only "subroutine" support kinda sucks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 7:40 pm 
Level 22 Norse Warrior-Librarian
User avatar

Joined: Mon Sep 04, 2006 5:25 pm
Posts: 517
Location: U.S.
note that goto is still pretty useful when something goes horribly, horribly wrong and you need to jump to a function that gives you as much information about the crash as it can and then exits; other than that, ya, don't use it :P

_________________
Worlds at War (Current Project) - http://www.awkward-games.com
Ganadu'r, The Eternal Sage (Other Current Project) - http://rpg.naget.com
Programming tutorials and web-design services: http://www.wyrmmage.com


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 18, 2009 9:20 pm 
Level 1 Cleric

Joined: Sat Jan 17, 2009 11:13 am
Posts: 11
Location: Earth
I had a feeling that goto will jump in your eyes.
The fact that goto is there and alot of horrible stuff is because this project was dropped. I also have a mage & assassin from that time, but I just got bored and said to myself "I'll just focus on RPGs when I learn more..."

I know goto is evil, I just couldn't gather enough willpower to change it, since the game was dropped & was running as planned anyway :)

Thx 4 liking it :D

_________________
Sometimes when I have a lot on my mind it just helps to go AHHH!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 2:02 am 
Dexterous Droid

Joined: Fri Aug 19, 2005 10:34 am
Posts: 3650
Holy crap, you actually did that in just one CPP file? With tons of GOTOs? This is almost worthy of submitting to the ioccc. :P

The game itself wasn't too bad. Sure as hell a lot better than my first games. Probably better than all my games, actually, since all I really make are engines it seems. Though it could have really used some control over the exploration. At first, I found myself fighting stuff too hard (since I didn't think to buy items), then I found myself dominating everything in one hit on skill 1, which only took me two strikes to build up. I'd just hold Q for the first few fights, then hold 1 for the next few. Also, there seemed to be no reason to continue exploring. At least when you stop, you get your life back. Maybe have a bonus multiplier, so the longer you last, the more you can earn? Could make them progressively more difficult as you continue to explore more times in a row, making more use of potions.

Overall, not bad. Kept me entertained for about 30 minutes.

_________________
NetGore - Open source online RPG engine


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 8:16 am 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
wyrmmage wrote:
note that goto is still pretty useful when something goes horribly, horribly wrong and you need to jump to a function that gives you as much information about the crash as it can and then exits; other than that, ya, don't use it :P

Exceptions, and the C++ set_terminate function are the replacements then :)

Besides, goto isn't anywhere near as evil as longjmp (which is what most people probably think of as goto anyway :)) Goto is at least scoped to the current block. Longjmp lets you jump ANYWHERE, and you won't even know where it's jumped to as it jumps to the last place that a setjmp was called. (This is all with C btw, and by extension C++. Other languages have different implementations of goto)

Still, just about every valid case of goto within a function are handled by the lovely wrappers around goto we now have (switch statements, if statements, loops, function calls, etc)

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 5:45 pm 
Level 1 Cleric

Joined: Sat Jan 17, 2009 11:13 am
Posts: 11
Location: Earth
Spodi wrote:
Also, there seemed to be no reason to continue exploring. At least when you stop, you get your life back. Maybe have a bonus multiplier, so the longer you last, the more you can earn? Could make them progressively more difficult as you continue to explore more times in a row, making more use of potions.

Overall, not bad. Kept me entertained for about 30 minutes.


sry 2 disappoint you but it was done in a rushed attempt to test my understanding at that time. plus I did add last summer in v1.9 a chance to find a treasure chest if you explore more than 5 times in a row. if u need a reason for the pots just jump to lvl 40 using the pass included. go fight some dragons :)

Edit:
Just looked back at my code. GOD it looks like *gasp**cough*, I can imagine if I were to rewrite it now it would probably be small & use everything from external files :) (gone a long way in 1 year - won't stop until I create my masterpiece)

_________________
Sometimes when I have a lot on my mind it just helps to go AHHH!!


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 19, 2009 7:21 pm 
Funky Monkey
User avatar

Joined: Sun Aug 15, 2004 1:07 pm
Posts: 1617
Location: Atlanta, GA
Spodi wrote:
Holy crap, you actually did that in just one CPP file? With tons of GOTOs? This is almost worthy of submitting to the ioccc. :P

The game itself wasn't too bad. Sure as hell a lot better than my first games. Probably better than all my games, actually, since all I really make are engines it seems.


ditto :rofl

_________________
Homepage: http://alwayschillin.net
Xbox Live: atlStylin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 20, 2009 8:10 am 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
iceshard wrote:
Just looked back at my code. GOD it looks like *gasp**cough*, I can imagine if I were to rewrite it now it would probably be small & use everything from external files :) (gone a long way in 1 year - won't stop until I create my masterpiece)


You'll be going for a long time :D I've not met anyone yet who can look at code they wrote a year ago and think 'yep, thats brilliant'. Maybe it's because if they still think that code is awesome then they haven't learned any new techniques over the past year and therefore aren't improving (which is ok if it's just a hobby, but the beginning of the end if you code professionally :))

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2009 11:01 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 21, 2009 11:52 pm 
Corpse Bride
User avatar

Joined: Tue Jul 01, 2008 11:44 pm
Posts: 2216
Location: England
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.


In basic we'd used Exit For to jump outside of the for...next, because just jumping out of it with a goto, the loop isn't terminated, and the essence of it will remain in memory. That is, which part of the code, the 'next' jumps back to, and which variable it is associated with and incrementing when it does jump back.

But I suppose it depends how the compiler deals with it.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 12:47 am 
King Code Monkey
User avatar

Joined: Wed Sep 01, 2004 3:05 pm
Posts: 11182
Location: Abingdon, MD
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

No. You'd have to put a check in the outer loop or redesign.

_________________
Bored? Head on over to my blog and see what I'm up to.

Microsoft XNA MVP


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 9:50 am 
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

I would have to ask the question why can the iteration goto( haha) nine yet it uses goto when its value is three. It just smells of poor design.


Top
  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 10:34 am 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
Machaira wrote:
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

No. You'd have to put a check in the outer loop or redesign.


Yes, flag in the outer loop is probably the best.

For the reasoning, if you did anything more complicated in the loop body such as creating stack allocated variables, then the goto would most likely cause their destructors to never be called. If you had a smart pointer obtain a reference in this, then that would mean you just created a memory leak.

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 10:34 am 
Bibliotherapist
User avatar

Joined: Wed Dec 21, 2005 6:23 pm
Posts: 6210
Location: Manchester, UK
workmad3 wrote:
Machaira wrote:
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

No. You'd have to put a check in the outer loop or redesign.


Yes, flag in the outer loop is probably the best (as a simple solution).

For the reasoning, if you did anything more complicated in the loop body such as creating stack allocated variables, then the goto would most likely cause their destructors to never be called. If you had a smart pointer obtain a reference in this, then that would mean you just created a memory leak.

_________________
God must love stupid people, he made so many.
theraje: 'God doesn't love stupid people, they're just easier to make'
http://sharedillusions.blogspot.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 12:10 pm 
Technomaniac

Joined: Sun Dec 05, 2004 11:27 am
Posts: 3249
Location: Sydney, Australia
Machaira wrote:
IGTHORN wrote:
Code:
for (int i=1; i<=10; i++){
   for (int j=1; j<=10; j++){
      //if (j==3) break; //would run this line full 10 times
      if (j==3) goto asdfd; //will only run this thrice
   }
}
asdfd:


Wouldn't that be a legitimate use of a goto? Like if you were looping through a 2D map array for a game to find a specific something.

No. You'd have to put a check in the outer loop or redesign.

Like all style rules, there are sometimes exceptions.

I wouldn't suggest putting a check in the outer loop (I don't think it makes things any clearer, and if your compiler is dumb, it could cause performance sadness).

However redesigning is definitely a ++ idea. When I have things like this, I generally will put the nested loops into a function, and then just return when I find the answer. Sometimes you can generalise the function a bit (e.g. make it take a function pointer for a function that will return true/false for each square, then your function just returns the first square that satisfies the function) which can lead to even clearer code.

Other times, it is better to put just the inside loop into a subroutine (typically if the two loops are anything other than x/y coordinates then this is correct :)).

Oh, and I don't believe that having a single return point in a function is a good practice (in case you couldn't tell from my advice :))

_________________
Trying is the first step towards failure
b


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 3:31 pm 
Dexterous Droid
User avatar

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3735
Location: South Africa
Andy wrote:
When I have things like this, I generally will put the nested loops into a function, and then just return when I find the answer. Sometimes you can generalise the function a bit (e.g. make it take a function pointer for a function that will return true/false for each square, then your function just returns the first square that satisfies the function) which can lead to even clearer code.


Ah, I like this idea! :) Sentinel bools would start sucking if you had a very deep structure.

_________________
Whatever the mind can conceive and believe, it can achieve


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 22, 2009 5:25 pm 
Digerati

Joined: Fri Sep 24, 2004 3:15 am
Posts: 1791
Location: No longer near Boston, MA
You can't do it fully with functions when things get really crazy though. Even for IGTHORN's example, even if you have lambda functions, things are a little dicey -

Code:
std::vector<std::vector<MapTiles> > MyMap;
std::vector<std::vector<MapTiles> >::iterator iter1;
std::vector<MapTiles> >::iterator iter2;

if (for_until(MyMap, DELAY(for_until, _1, PASS_LAMBDA(_1 ->* &MapTiles::Type == 3), iter1), iter2))
{
//found, position in iter1
}
else
{
//not found...
}


Can anyone think of a better way to do that with functions? I know you can mix traditional loops with functions there, or create a custom functor, but I'd really rather avoid that.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group