# Good class structure - Boulderdash

**URL:** https://forum.kirupa.com/t/good-class-structure-boulderdash/319963
**Category:** flash
**Created:** [March 9, 2011, 11:53pm UTC](https://forum.kirupa.com/t/good-class-structure-boulderdash/319963 "2011-03-09T23:53:30Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Dreddy](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@Dreddy](https://forum.kirupa.com/u/Dreddy)
#### Post date: [March 9, 2011, 11:53pm UTC](https://forum.kirupa.com/t/good-class-structure-boulderdash/319963/1 "2011-03-09T23:53:30Z")

</div>

Hi  
Im writing a game and wondering about some good class structure.  
It’s a Boulderdash game, top view, 4 directions, moves one square each movement, scrolling.

Currently I have a:  
Main - has all the gameloop, controls, player, and builds a class called World  
World - builds the map (which is a 2d array of dirt and boulder blocks)  
- map checking to see if the player can move  
- boulder dropping/sliding checks  
Everything that isn’t the player pretty much has to be inside world for scrolling purposes.

I was wondering whether I should split up the functions for the boulders into their own class, and whether having classes within classes was a very good idea, as all the checks from the gameLoop in Main are directed towards world.this, world.that. Is there a good explanation of class structure etiquette?

Also the boulder checking code has become quite big as boulders can:

- drop if the space below if empty
- if they are on top of another boulder, without a boulder above, but with a gap to the right, and right below, then they can slide off.  
There will eventually be other objects with their own checks, (like expanding jelly, if u played the original c64 version) so i am thinking this class will become massive.

Sorry if my post isn’t very clear, first time ever posting code questions on a forum…  
Thanx
