Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (290)
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 1681 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 12: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 18: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 23: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!
Try the Free Demo of Revenge of the Titans
Offline K.I.L.E.R

Senior Member




Java games rock!


« Reply #3 - Posted 2004-08-22 05: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 13: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
« League of Dukes »

JGO Kernel


Medals: 54
Projects: 20


Mentally unstable, best avoided.


« Reply #5 - Posted 2004-08-22 14: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-31 00: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.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (61 views)
2013-05-17 21:29:12

alaslipknot (70 views)
2013-05-16 21:24:48

gouessej (100 views)
2013-05-16 00:53:38

gouessej (98 views)
2013-05-16 00:17:58

theagentd (107 views)
2013-05-15 15:01:13

theagentd (98 views)
2013-05-15 15:00:54

StreetDoggy (144 views)
2013-05-14 15:56:26

kutucuk (167 views)
2013-05-12 17:10:36

kutucuk (166 views)
2013-05-12 15:36:09

UnluckyDevil (175 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.083 seconds with 21 queries.