Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
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  
  active rendering  (Read 1313 times)
0 Members and 1 Guest are viewing this topic.
Offline stef569

Junior Member





« Posted 2007-11-21 14:27:45 »

Hi, I created a game engine as an abstract class
created a game class that extends it.
I want to use active rendering.
I use a frame and canvas.

I used mvc and repaint using swing for my tetris game, now I want to try active rendering.
And I'm a litlle confused if I want to use events and mvc again, because Active rendering is putting drawing methods in the main game class right?
I capped my fps to 60 so It's constantly drawing, so every render I need to draw what do I put in my render loop? in the game class, I don't mean what functions
but where to put the draw methods.

#1 fpsDraw()
#2 gameCanvas.fpsDraw() => then the game class will need a attribute gameCanvas..
#3 or an event, an event that is triggered loop after loop 60 times/sec :s

I think I still want to devide logic from drawing so #1,2 is ruled out
I think calling events is a waste of resources with this config?
I do think alot   Smiley
Please advise, Stef

Offline Majick

Senior Newbie





« Reply #1 - Posted 2007-11-21 14:59:22 »

Take a look at the active rendering framework in Killer Game Programming in Java..... It should answer your questions and more..... The chapters are also available online for free too.   http://fivedots.coe.psu.ac.th/~ad/jg/ch1/index.html
Offline stef569

Junior Member





« Reply #2 - Posted 2007-11-21 17:59:38 »

Hi, On chapter3 I found an active rendering class, and It's like every object has it's own render method? so I 'm using #2
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline broumbroum

Junior Member





« Reply #3 - Posted 2007-11-21 22:49:10 »

directly available in the javadoc http://java.sun.com/javase/6/docs/api/java/awt/image/BufferStrategy.html  Wink

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Member





« Reply #4 - Posted 2007-11-22 00:18:16 »

I know to use the buffered strategy,.. Just wanted to know where to put all my drawing/rendering in.

And I gues I go for each class each own rendering and painting methods, altought I've read that passing a graphic object around isn't smart?

I would use it like

render(Graphics g) {
 obj1.render(g)
 obj2.render(g)
etc
}
Stef
Offline broumbroum

Junior Member





« Reply #5 - Posted 2007-11-22 00:57:56 »

exactly !

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Member





« Reply #6 - Posted 2007-11-22 19:19:35 »

Ok great, and if I would use mvc all drawing code goes into my canvas and the model doesn't see the view so my code changes to

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
render(Graphics g) {
fireGameChangeEvent(this, State.CHANGE);
}

  private void fireGameChangeEvent(Map map, GameAction action) {
    // Generate the event.
   final BoardEvent event = new GameEvent(map, action);

    // Now tell everyone.
   for (int i=0; i < gameListeners.size(); i++) {
      GameListener bList = gameListeners.get(i);
      bList.gameChange(event);
    }
  }


My question will this be possible, and won't it be overkill?
atm this will create 500 obj / sec with my 2 ms loop
Offline broumbroum

Junior Member





« Reply #7 - Posted 2007-11-23 02:00:59 »

what are the type of your 500 obj's ? Can you serialize them to a file quickly ? Is there a cleanup action, too ? 500 obj/sec is really big...

::::... :..... :::::: ;;;:::™ b23:production 2006 GNU/GPL @ http://b23prodtm.webhop.info
on sf.net: /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Member





« Reply #8 - Posted 2007-11-24 00:30:15 »

Well I tought I would need an event but I then called the controller directly wich solved that.
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.

TehJavaDev (15 views)
2014-08-28 18:26:30

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

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

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

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

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

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

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

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

BurntPizza (34 views)
2014-08-08 02:01:56
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!