Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - mcouk

Pages: [1]
Programming / Re: Inventory and pop-ups: Who calls what?
« on: November 26, 2014, 10:50:37 AM »
I was looking over the code for PugnaciousWizards2 ( the other day, I don't know much about ActionScript, and my JS is only for basic webpage DOM stuff, but it looks like it could be similar enough for you to get some ideas from. It uses screens, (MenuScreen, PlayScreen, etc.) but that to me looks the same idea as states.

Programming / Re: Inventory and pop-ups: Who calls what?
« on: November 25, 2014, 08:47:12 AM »
I'm new to game/roguelike development but I've also gone down the route that reaver mentions; I have a MenuState, PlayState, InventoryState, etc. It's still early stages but so far my main loop consists of just update/draw/input, so if I change to InventoryState the loop works only on that state. Once the state is over it passes back to PlayState; I return false from the (i)nventory input command so that PlayState knows the player hasn't yet taken their turn.

If each Actor has their own inventory then I guess you would need to pass that information into the InventoryState when you switch to it (switching is handled by the parent GameState). You could also implement enter/leave methods for each state if required.

Programming / Re: How big is your Level class/file?
« on: November 23, 2014, 06:30:11 PM »

Programming / Re: How big is your Level class/file?
« on: November 22, 2014, 10:05:55 AM »
...Also the earlier Design Patterns book, which Fowler was also a co-author on.

This is the third time is as many weeks I've heard this book mentioned. I may have to check it out.

I've read Design Patterns and I really hate that book and concept of patterns. It's like always in textbook examples which in no way can be applied in all real life situations.

It's in fact the opposite; these are often inspired from real life situations. You should take a look at Game Programming Patterns by Bob Nystrom. You don't even have to buy it, he's made it available to read online for free.

Programming / Re: How big is your Level class/file?
« on: November 21, 2014, 09:10:12 PM »
I prefer not to take file size too seriously and instead think about how many concepts are in each method/class/file....

...I think it's far more subjective and personal than people want to admit.


I know nothing about ActionScript, and only spent a handful of minutes looking over PugnaciousWizards2, but it was very easy going. I was able gain some basic understanding of what was going on very quickly, and left feeling like I'd perhaps want to spend a couple of hours on a code reading session with it.

Not a roguelike?

I don't see how that affects what makes good/bad code.

Programming / Re: How big is your Level class/file?
« on: November 20, 2014, 03:24:19 PM »
Well, did you ever write a roguelike? I'm interested to hear about real life examples and also know how many lines exactly you have on something like dungeon generation.

Apologies Krice, I misunderstood your original post. When you said;

I don't think it's that big, but.. I don't know how to break it to smaller pieces  ....  I think we may have discussed this before, but let's do it again.

I understood that as you wanting thoughts and ideas on how one goes about reducing the size of classes. Those we're my thoughts.

I still highly recommend the Refactoring book. Martin Fowler has a site where he's put up the basic catalog outline; it may give you some ideas.

Programming / Re: How big is your Level class/file?
« on: November 20, 2014, 11:23:01 AM »
When I see a class that is 500 lines or more I start to question the design of that class. That also goes for any methods that are more than just a handful of lines long.

For the last couple of months I've been reading through the source of various roguelikes and I'm shocked at how big some of the files can be -- one was almost 20K lines long. Yikes! We have a saying where I come from; "code is written once, but read many times."

Considering that many roguelikes take years to complete it's quite unlikely you'll remember exactly how all your code works, so you're going to be spending considerable time reading through what you previously wrote. Traversing a ten thousand line file trying to find where you think that piece of code is is not what I'd call an enjoyable pastime.

The basic rule of good OOP is that each class/method should have a single responsibility. Admittedly, that's a bit trickier in something such as dungeon generation, but any code with tightly related functionality could be split out into its own class. Methods that are dozens/hundreds of lines long should be extracted into smaller methods then where appropriate, extracted into additional classes or modules.

Arguments which state that many files end up creating a bigger a mess are in my eyes incorrect. In the worse case scenario, you're just moving the mess around. However, once we encapsulate related functionality we start to better understand what our code is doing, regardless of how many files that creates. I would agree though that having your 'src' directory containing thousands of files is going to be unwieldy so the answer to this is to create a proper directory structure. An example could be something like;

Code: [Select]

Over the last few months I've been working through a book about refactoring and this more than anything has helped me better understand how to break code up into more manageable chunks. I highly recommend you take a look at "Refactoring: Improving the Design of Existing Code" by Martin Fowler (

Other Announcements / Re: Roguelike Radio podcast
« on: October 21, 2014, 07:41:17 AM »
I really enjoy listening to the podcast Darren, but would it be possible to boost the volume...a lot! Perhaps a little compression to normalize the levels too.

Programming / Re: Realtime Ruby WASD
« on: September 27, 2014, 09:22:20 AM »
Like yourself I'm wanting to use Ruby to write games and from what I can see, the best place to start would either be directly in the terminal (pure ASCII) or to use Gosu.

I recently picked up the book "Developing Games With Ruby" ( It's still WIP (80% complete) but there's enough in there to get you going. I found it very useful and at $10, that has to be a bargain!

Some days back I updated the Ruby page on Roguebasin and included some useful resources which may be worth checking out (, but I'll go over them again here for completeness.

The RubyQuiz website ( has some really cool code* which I think can be used as examples for RL development. See the Sokaban entry (, it's a full game with examples that use Gosu, Curses, OpenGL and plain old terminal. James's 'unix' entry could be useful for a pure ASCII RL jump off point. There's also an AD&D Dice Roller (Dennis Ranke's full_parser_roll.rb is very interesting), Dungeon Generation examples and some for Maze Generation.

I hope some of that is useful.

* much of which is quite old now, but of those examples I tired the only thing I had to do was update how the files are included. Basically change 'require' to 'require_relative' and you'll be good to go.

Pages: [1]