Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (606)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Organizing class heigharchy in a game  (Read 1643 times)
0 Members and 1 Guest are viewing this topic.
Offline Sequalit

Junior Devvie





« Posted 2006-04-16 01:57:54 »

I'm a bit confused as to how to organize classes and maket hem interact when developing a game that has multiple levels in it, or if your developing an RPG how to handle creating the world(terrain and stuff) and dealing with what location your ina nd stuff...

Ive made a guess as to how to structure this... its probably the completely wrong way to do this, but i dont know of any other way, imt rying to design a simple RPG game, classic zelda-looking.

Mainc lass that extends an interface that has final data on window size and get methods for different things, and in this main class, you loop a logic method, and then a drawing method... a seperate class for logic, to make all the entities move and stuff, then a class for drawing, the drawer class extends your window(canvas) so it can draw onto it. the drawer gets all positions of the entities and just draws them on the screen. a class for the resource cache to retrieve the sound and graphics... and then i was thinking about mabye a world class, that would deal with different levels and area's, say you want to be able to zone...


             Main class ---- extends Stage(interface)
               ||            |     ||   all classes can access
               ||           |     ||   data throug this
               ||            |     ||
               ||            |     |------ResourceCache
 World<-||            |     \/-holds sound + images
                |            |     Entities
  edits--Logic     \/
  entities            Drawer----------extends --- > window(canvas/jframe)
  positions           |
                          -retrieves entity positions and draws

while(gettingTired())
     crankOutMoreCode();
     if(asleep()){
          wakeUp();
          makeCoffee();
          chugCoffee();
     }
}

-Sequalit
Offline Mr_Light

Senior Devvie


Medals: 1


shiny.


« Reply #1 - Posted 2006-04-16 13:28:30 »

firstly use code tags secundly use uml.

anyways I can probebly save you time alltogetter: if your looking for a holy grail in architecting games programs buildings or whatever for that matther. there is none, sure there are best practices or patterns.

create stuff stuff to your specific needs.

if you have an isolated problem or reaccuring one I'm sure we can fix it.

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Sequalit

Junior Devvie





« Reply #2 - Posted 2006-04-17 00:57:09 »

I think you misunderstand me Mr_Light...

i know there is no holy grail, nor am i looking for that, im asking, is the way im doing it a good practice, or a bad one, or could someone refer me to a link that has some good practices regarding this.

I'm not asking for code, thats the easy part, im j ust wondering how people build levels or zone's intoa  game, thats all.

while(gettingTired())
     crankOutMoreCode();
     if(asleep()){
          wakeUp();
          makeCoffee();
          chugCoffee();
     }
}

-Sequalit
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline fletchergames

Senior Devvie





« Reply #3 - Posted 2006-04-17 02:07:54 »

Your diagram doesn't make alot of sense to me, but it looks like what you have can work.  However, please try to have fewer spelling errors in future posts - it makes you hard to understand.  An occaisional spelling is to be expected, but there were alot in your post.

It sounds like all your maps are going to be hardcoded into your World class.  This should work, but it's much better to use some sort of map file.  There's various freeware map editors on the Internet, and you can always write one of your own.

In the rpg I'm working on, here's how I have that part of the class hierarchy set up:

RpgEngine - runs the game and includes a few useful methods used throughout the code

GameViewPane - displays the game.  This normally displays 2 seperate classes: TileDisplayArea and PartyStatusViewPane.  And it also displays various dialogs on top of those areas.

RpgData and World - these classes include data about the world.  RpgData is mostly stuff about potential game characters, and World is mostly a class for game-wide settings.

RpgMap - contains the data for the current map.

Sprite and subclasses - contains the data for any objects appearing in the game

EventMapTrigger, GroundTileDefinition, MapTile, RoofTileDefinition - MapTile contains everything in a tile except for the Sprite.  It includes the ground tile and the roof tile, as well as any events that occur when that square is entered.  GroundTileDefinition and RoofTileDefinition define ground and roof tiles, respectively.  EventMapTrigger defines things that occur when a square is entered.

I don't actually have a ResourceCache class.  Each Sprite (or whatever) loads its own images.

My game actually includes 311 classes (or, at least, that's how many .class files are produced), so, obviously there's alot more to it than that.  But those 311 classes also include the map editor, alot of low-level stuff (e.g. loading music files, active rendering), and probably some stuff that isn't even getting used in this particular game.

That doesn't necessarily mean that your game will have alot of code.  Most open source RPGs I've seen are smaller than the code I have now.  I've defined more classes than I strictly need to.  For instance, I actually have classes like BaseRpgApplication which is extended by RpgEngine and RpgMapEditor.  All it does is include code that's used by both the game and the map editor.  There's quite a few classes like that.

Depending upon what exactly you're doing, you'll probably wind up with alot of small class that don't do much individually.
Offline Sequalit

Junior Devvie





« Reply #4 - Posted 2006-04-17 02:54:27 »

i am sorry about the spelling mistakes... I dont mean to but this keyboard is kinda crappy so it doesnt type what i want it to sometimes, and to add onto that, its very cold in my house so im typing with ice cold fingers... not fun

sorry about the confusion with my little layout too... it occured to me to use paint, but then id have to upload it and takes forever on dialup hehe >.< i guess next time i have a question like this i will do that.

Thank you fletcher, that helps me out alot, now that i know the way i planned on doing this is a okay way of doing it ill start on the game again, and you have given me some insight as to how ill do maps and stuff..

while(gettingTired())
     crankOutMoreCode();
     if(asleep()){
          wakeUp();
          makeCoffee();
          chugCoffee();
     }
}

-Sequalit
Offline woogley
« Reply #5 - Posted 2006-04-17 03:22:47 »

<political>
fletchergames, dont be so harsh dude... english isn't EVERYONE'S first language.

I don't see you criticizing Jeff Kessleman ...
</political>
Offline K.I.L.E.R

Senior Devvie




Java games rock!


« Reply #6 - Posted 2006-04-17 08:15:26 »

I've placed the guys original design into UML.
Should make it easier to read.


Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed. Wink
Offline Mr_Light

Senior Devvie


Medals: 1


shiny.


« Reply #7 - Posted 2006-04-17 20:42:39 »

I think you misunderstand me Mr_Light...

i know there is no holy grail, nor am i looking for that, im asking, is the way im doing it a good practice, or a bad one, or could someone refer me to a link that has some good practices regarding this.

I'm not asking for code, thats the easy part, im j ust wondering how people build levels or zone's intoa  game, thats all.

wenn I say if and if doesn't apply you can dismiss everything thats build on top of that.  Wink

I think it depence on how your levels are created and what there lifecycle is (hmm that applies to almost every object  Tongue)

be some fundemental questions probebly are do levels change wenn I start a new game(are level genarated on the fly?)
is there a specific order?
are levels submitted as a set or per level.(if you have a (fixed) order it's probebly by set.) simplicity versus coupling(with your code)

It's harder to read code than to write it. - it's even harder to write readable code.

The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
Offline Sequalit

Junior Devvie





« Reply #8 - Posted 2006-04-17 22:46:13 »

You guys are awsome, thanks KILER

well my levels lifetime cycle is as long as the person stays in that area, if they move to another area, then the lifetime cycle closes and another one opens. Each levels layout will be predetermined by a information file that is loaded in.

how should i structure a class to support dynamic levels, so i can create a seperate file and load levels into the game with that?

while(gettingTired())
     crankOutMoreCode();
     if(asleep()){
          wakeUp();
          makeCoffee();
          chugCoffee();
     }
}

-Sequalit
Offline Jeff

JGO Coder




Got any cats?


« Reply #9 - Posted 2006-04-20 04:42:51 »

FUndemetnally, I thin kyoua re making newbie programmer mistake #2.

SOme teacher talked all abotu the wonders of objects and got you focused on thinkign in these very abstract thinsg first.

FIRST decide what your game will be, what does it do?
SECOND decide what the mechanisms are by which it will do them.
THIRD design your objects to encapsulate those mechanisms.

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Elsealabs (20 views)
2014-12-28 10:39:27

CopyableCougar4 (21 views)
2014-12-28 02:10:29

BurntPizza (25 views)
2014-12-27 22:38:51

Mr.CodeIt (15 views)
2014-12-27 04:03:04

TheDudeFromCI (20 views)
2014-12-27 02:14:49

Mr.CodeIt (26 views)
2014-12-23 03:34:11

rwatson462 (60 views)
2014-12-15 09:26:44

Mr.CodeIt (48 views)
2014-12-14 19:50:38

BurntPizza (98 views)
2014-12-09 22:41:13

BurntPizza (116 views)
2014-12-08 04:46:31
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!