Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Help making simple RPG game less boring

by jethro (Monsignor)
on Oct 30, 2012 at 13:22 UTC ( #1001498=note: print w/replies, xml ) Need Help??

in reply to Help making simple RPG game less boring

You don't have a single subroutine in your script. I have coded lots of simple scripts without subroutines or modularisation, but even a simple game should be so complex that it becomes impossible to manage without some abstraction and structure.

For example, make a subroutine that does the monster selection. The subroutine should be called with the parameters $lvl and possibly location type (so that wild pigs are only encountered in forests, Mothers-in-Law only in towns). Also not every location should have a monster

Make a subroutine that is called whenever the player moves into a new location. It should select and print what the location is (hill, road, forest, town) and return the location type. Maybe add some special events that can happen

Make a subroutine that asks the player what to do when he enters a location without a monster. Possible things to do: Heal, select a different weapon, search the area, goto next location

Make a subroutine for fighting monsters. This subroutine should ask the player each round what to do (attack, change weapon, run away, make a special attack (more damage, but less defense on the counter attack of the monster), heal ...) and resolve that. Don't hesitate to put each action the player can do in its own subroutine.

Try to give each subroutine everything it needs as a parameter. Your main script should essentially be a few subroutine calls that show the structure of the game.

If you have done that your script has become more maintainable and your game is probably a bit more fun.

UPDATE: I forgot the usability hint: Don't let the player enter 1,2,3... to select the options, attack should be 'a' not '1'.

  • Comment on Re: Help making simple RPG game less boring

Replies are listed 'Best First'.
Re^2: Help making simple RPG game less boring
by jms53 (Monk) on Oct 30, 2012 at 13:27 UTC
    After the previous comments I'm restructuring the whole thing to work with subroutines.
    I really like the location idea.
    J -

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001498]
What's the matter? Cat got your tongue?...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2018-05-24 10:32 GMT
Find Nodes?
    Voting Booth?