Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
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 1479 times)
0 Members and 1 Guest are viewing this topic.
Offline stef569

Junior Devvie

« 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.
Offline stef569

Junior Devvie

« 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 Devvie

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

directly available in the javadoc  Wink

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

Junior Devvie

« 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) {
Offline broumbroum

Junior Devvie

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

exactly !

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

Junior Devvie

« 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

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);

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 Devvie

« 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 @
on /projects/sf3jswing
Java (1.6u10 plz) Web Start pool
dev' VODcast[/ur
Offline stef569

Junior Devvie

« 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.

Jesse (11 views)
2015-07-29 04:35:27

Riven (33 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (26 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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‑
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!