Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (483)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (550)
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  
  Seperating R, LP, A and I  (Read 2029 times)
0 Members and 1 Guest are viewing this topic.
Offline K.I.L.E.R

Senior Member




Java games rock!


« Posted 2004-08-21 10:43:28 »

Rendering.
Logic Processing (heart of the game).
Audio.
Input.

What I do is:

Audio is usually caused by switches(boolean values depicting something occuring like moving into a new area) so that is pretty easy to do.

Rendering, I just have each class contain it's own rendering definitions and then after calling the game processing function I pass the game processing function into the Render class which calls the game class's render method.

Input I just do a couple bool switches which then end up calling the appropriate methods.

An illustration of what I'm talking about.
http://members.optusnet.com.au/ksaho/show/class.gif

Is there a better way of doing these things?

I really hate it how a lot of people squash as much as possible into a single class.

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

Jeff:
Unemployed. Wink
Offline gangrel-br

Junior Member




Java and Scala! Thats the game =)


« Reply #1 - Posted 2004-08-21 16:49:21 »

Shouldn't Audio and Rendering be more coupled? If they are too separeted, wouldn't we get audio out of sync with the video? Or am I concerned too much for nothing?

Paulo "JCranky" Siqueira
Offline Jacko

Junior Member





« Reply #2 - Posted 2004-08-21 21:40:43 »

On the rendering side, one approach is to have a Render Queue. Your loop is basically doLogic, then render(renderQueue).  As you are going through the game logic things can decide if thay are visible and place themselves on the queue.

When you  render, you can sort the objects by render state and transparency and call them back to render themselves.

Have a look at the architecture of Ogre for a good example of this.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline K.I.L.E.R

Senior Member




Java games rock!


« Reply #3 - Posted 2004-08-22 03:26:38 »

What am I going to stick into a render queue?

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

Jeff:
Unemployed. Wink
Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #4 - Posted 2004-08-22 11:42:26 »

Something like this maybe?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
public class GameObject {
  Mesh mesh;
  ...
  void render() {
    if( inFrustum(MyRenderer.getFrustum())
          MyRenderer.addRenderQueue(this);
  }

  boolean inFrustum(Frustum f) {...}
  ...
}

public class MyRenderer {
  private static Queue renderQueue;
  ...
  private MyRenderer() {}
  public  static MyRenderer getMyRenderer() {}        
  public  static void addRenderQueue(GameObject) {}
  public  static Frustum getFrustum() {}
  public  static void drawAll() {
    //for each item in the queue
   drawMesh(renderQueue.getNext().getMesh());
  }
  private drawMesh(Mesh) {...}
  ...
}

Offline kevglass

JGO Kernel


Medals: 153
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #5 - Posted 2004-08-22 12:00:18 »

I think I've ranted on about seperating out the data model and rendering before. Another way to organise things is to keep a model of the actual game world in just pure data. Then run through your Renderable(i/f) objects asking them to render themselfs. They update themselfs based on the data object they represent and decide whether or not to render themselves.

Its worked quite nicely for me in the past, benefits being the ability to change rendering details without worrying about game logic.

Incidently, I've always considered audio as part of the rendering layer since you're rendering stuff its just not visual. Input is always tricky, theres this whole thing about using a controller interface but its never really worked out well for me. I tend to stick in in the main loop although I normally abstract away how the controls are actually being delivered, i.e. keyboard/joypad/etc..

Kev

Offline mhale

Senior Newbie




Take pity, I'm just a poor blob!


« Reply #6 - Posted 2004-08-30 22:28:54 »

I have used something like the GAGE sprite interface. I have various sprite classes for all my game objects. My parent sprite class is a composite of a java.awt.geom.Area instance (object geometry for stuff like collision detections) and a renderer instance which the sprite delegates to for rendering. Game object behaviour is determined by the methods in the sprite sub-classes.

I use renderer factories to construct the renderer delegates. At the moment I have two factories, the normal game one and a geometric one. The geometric one renders sprites according to their java.awt.geom.Shape and I use it to debug collision detection.

I have no sound currently and I handle input in the game frame class using boolean switches. Oh, I also went as far to abstract the rendering loop, so I can easily swap in different frame scheduling algorithms.  Grin
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.

CopyableCougar4 (15 views)
2014-08-22 19:31:30

atombrot (28 views)
2014-08-19 09:29:53

Tekkerue (25 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (15 views)
2014-08-16 06:20:21

Tekkerue (22 views)
2014-08-16 06:12:11

Rayexar (61 views)
2014-08-11 02:49:23

BurntPizza (39 views)
2014-08-09 21:09:32

BurntPizza (31 views)
2014-08-08 02:01:56

Norakomi (38 views)
2014-08-06 19:49:38
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

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!