Don't kill me...

200-300fps when not limited, 63 otherwise.
winXP
geforce fx 5200
1.8ghz
768 megs of ram

Wow, I have no idea how you did those kind of effects with Java2D (or anything else actualy…) ;D looks great.

Impressive :slight_smile:

Runs with 25-55fps (~48 on average) on a K7 500, gf2mx, 128mb, 1.4.2_05, win98se (in 800x600). With everything off it ran of course faster.

On the page it says that it aims for 60fps. But its kinda weird that people whose machines can run at ~200fps don’t get steady 60fps (instead they get 50 or even less). I guess the frame capping routine you’re using is to blame. You might want to give my sync2 method a try (eg sync2(61); [hz+1]).

The screen trasition fades are quite slow.

Oh and you might want to change the name a bit in order to avoid trouble. “tetris” is really bad and anything with “tris” at the end, too.

Oh² and you can disable the cursor with something like this:
setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB),new Point(0,0),""));
(You can’t do anything with the mouse right?)

Tried it out and it ran great!

Noticed a few things -

  • Started game in fullscreen 1024x768. Played a round. Then switched to 800x600 res. When you go to pick the background, the sizing for the box is all messed up.

  • The animation speed is directly linked to your frame rate. Ie the fade effect on the main menu speeds up and slows down depending on if you are running at 60 fps or full out. I would think making the fade rate constant, regardless of the fps would be best. You also notice this when playing against the computer. If you are running faster than 60fps, he gets much faster too. That doesn’t seem fair.

Great graphics! Very nice effects and such. Does need sound for sure.

My 2 cents.

Regards,
Dr. A>

I’ve made a few changes to the app:

  1. Fixed the window not resizing to fit the view port during background selection. (Thanks to dranonymous for that one)

  2. Added a turbo toggle hack with F1 to enable and F2 to disable

  3. The main menu screen animations can now be skipped with the ‘ENTER’ key

  4. Increased the speed of screen fades and menu text fades

Current problems for which I’m totally stumped :-/ :

1. Frame rate issues.

There are SOME people like esdeboer and DrBizzar0 who report 30-50 FPS, yet with the turbo toggle off, they get around 200 FPS. Not sure why, since all I’m doing is limiting the FPS (and the game) using a hacked gagetimer to return accurate time in millis for the various platforms and using Thread.yield().

And then there are some like blahx3, tafty and DrBizzar0 who report unplayable frame rates on reasonable system specs yet there are others like esdeboer and weston who have similar machines but have much better performance.

I’m guessing it could probably be a video RAM issue, since I’m basically pre-rendering a lot of graphics and storing them in VRAM. That’s how I get all those accelerated translucent effects in Java2D, no big mystery there. However, if all of the major effects are turned off, there really shouldn’t be a reason for getting ~20 FPS on a 1 ghz machine.

2. Then there are the issues with web start. Once, I got 200+ FPS on the first run after a fresh update/download of the application. On the next run, I got 450 FPS average. On subsequent runs I get 600+ FPS which is what I normally get running the jar off the command line. Bizarre. :o

Not sure if you guys get the same thing. I’m running JRE 1.4.2_04 on a Windows XP platform, 3.0 P4, 1 gig RAM and ATI 9800 Pro.

EDIT: Try this little experiment. Click on the web start link. Upon first running the game in web start, press f1 to get the max FPS. Quit the game. Click on the web start link again to run the game and press f1. You should get MUCH higher FPS.

3. Mac display problems. Again, not sure why it displays properly on other platforms and not on the mac. I’m guessing it’s a BufferStrategy issue. This is what I was doing (I don’t want page flip since I’m using dirty rectangles to speed up rendering already)

createBufferStrategy(2, new BufferCapabilities(new ImageCapabilities(true), new ImageCapabilities(true), null));

@swpalmer, can you elaborate on the problem? Does it occur in windowed mode or at the different resolutions as well?

Appreciate all the feedback and suggestions guys. Keep em coming.

[quote]Current problems for which I’m totally stumped :-/ :

1. Frame rate issues.
And then there are some like blahx3, tafty and DrBizzar0 who report unplayable frame rates on reasonable system specs yet there are others like esdeboer and weston who have similar machines but have much better performance.
[/quote]
OK, dude, you have GOT to write an animation class!

As mentioned above, having ANY part of your game timed off your absolute frames is a suicidally stupid idea (always comes back to bite you eventually). I wasn’t sure, but it certainly looked like your effects (especially lines disappearing) are synched/locked to individual frames.

I just checked, and … with new version, I get 40-60 (yes, sometimes even 60!) fps throught the game, and it plays like real tetris (blocks move smoothly etc) right up until…the FIRST time either player gets a line. From then on it’s 16-17 fps all the way. Again, sometimes (rarely) after that you get a brief period of 40 odd FPS.

But what I noticed more than anything else (now that I was looking carefully) is that you have timed EVERYTHING off the frames, rather than time. So, not only do blocks “jerk” across the screen when the FPS drops but they also move 4 times more slowly! that’s why it feels sluggish and unpleasant for some of us, and fine for others.

So, for a start, you need to make an animation system that is frame-rate independent (just like every other game does with player / monster movement etc - your fades must also play back at constant time duration irrespective of frames elapsed).

Since you need to have a frame-independent animation system for any game anyway, is there really any point in not using it for everything?

Ah. I do only have 16 Mb VRAM (laptop card). Bear in mind that that’s enough to play Quake3 :D…

Anyway, the “starts at 60 fps, drops on first alpha effect” could be something to do with you “losing” the accelerated image (i.e. the alpha effect - which is not supportedby Sun for hw-accel except on windows - shunts your hw-accel images out of VRAM and then they can only go back when:

  1. There is no alpha going on
    and
  2. they are small enough to fit
    and
  3. the heuristics (and/or an explicit call) decide to

(I think that’s the set of reqs? But I’ve probably made a mistake somewhere ;D)

Certainly, it looks like they’re getting shunted out and never being allowed back in again. I did wonder if perhaps after the first alpha you left one pixel (or something like that) with a tiny amount of alpha still in the image somewhere, which was preventing the sytem from putting it all back into VRAM - but then, occasionally, that pixel would get overwritten (allowing a spurt of acceleration), only to be quickly written over with some alpha again.

Are you sure that your alpha routines always leave the alpha in the same state it was when they started? If there’s an out-by-one error in the loop…

awsome game! very nice.

Didn’t have any problems with the menu’s responsiveness or the FPS (which was 63 btw capped).

Very nice.

DP

Blah3 - I beg to differ about fixed frame rates :slight_smile:

Cas :slight_smile:

[quote]Blah3 - I beg to differ about fixed frame rates :slight_smile:
[/quote]
Yeah, I know. AF was uppermost in my mind when I typed that :P, but weighing up the pros and cons fixed frame rate can not only get you into a lot more trouble but unless you actually control the platform (e.g. consoles, which are nearly all identical) then you can never be truly guaranteed to keep your fixed rate. And then it all goes pear shaped.

Of course, if you’d like to argue it in detail, why don’t you write an article on it? ;D.

(OT: Speaking of which, no-one’s delivered on a JOGL article to go side by side with your LWJGL one. Sorting that out is on the todo list for immediately after the launch of the next JGF version)

I’ve traced a frame rate problem on my Windows PC to the combination of:

  1. createBufferedStrategy to not use page flip
  2. NOT setting the accthreshold=0 system property
  3. NOT setting the ddforcevram=true system property

= All graphics will not be accelerated

OR

  1. running web start for the 1st time after a download/update

= All graphics will not be accelerated

The problem lies somewhere with the combination of the BufferStrategy used, the system properties to enable acceleration and the way web start handles them.

Has anybody got any ideas on how to work around the issue, aside from waiting for hardware acceleration to actually be supported officially? :frowning:

@blah: Your suggestion to seperate the animation frames from the logic frames is a good idea in this context of wildly fluctuating frame rates… Although I’m more keen on getting the app to run properly on systems that SHOULD be able to render 60fps.

[quote]3. Mac display problems. Again, not sure why it displays properly on other platforms and not on the mac. I’m guessing it’s a BufferStrategy issue. This is what I was doing (I don’t want page flip since I’m using dirty rectangles to speed up rendering already)

createBufferStrategy(2, new BufferCapabilities(new ImageCapabilities(true), new ImageCapabilities(true), null));

@swpalmer, can you elaborate on the problem? Does it occur in windowed mode or at the different resolutions as well?
[/quote]
Hard to explain…

I see it switch to fullscreen. The Aqua background is painted (this is normal), and because you have hard-coded the display resolutions and I’m using a widescreen display I see black areas on the sides.
Then a fraction of a second later I see that square aqua background shift down and to the right by an inch or two, still being clipped by the original area of the screen. Then the background is drawn in this offset position and the progress bar is shown as you set up, the title screen appears and you can see that everything is obviously shifted down and to the right since the green bar border only shows on the top and the left.

I have never seen anything like it before. Other fullscreen games (e.g. Gravity Battle) work fine. I suspect it might be related to the order that certain things are done.

P.S. When I choose exit I’m left in fullscreen mode on a blank black screen. - though I don’t recall that happening before.

Made changes again:

  1. Now does frame skipping so it’s at least playable on slower computers.

There are now two counters on the bottom left corner:

FPS shows the amount of times the renderer is called
UPS shows the amount of times the game is updated

The game will try to render at 60FPS, failing that, it will skip frames to meet that goal.

Press F3 to enable/disable the counters
Thanks to blah3 for suggesting this

Wow. A completely different game when played at the normal speed ;).

Worked fine for everything EXCEPT the input (which is still losing keypresses and sometimes taking two keypresses where there was just one) and the menu screen whose fade appears to still be frame locked (i.e. slow).

The “READY GO” message is a LOT nicer when moving fast!

PS in all previous versions, when the red and blue bars scroll out at start of level, there was huge amount of tearing on both bars - approximately ten or twenty simultaneous tears on each bar. So, you’re not doing any double-buffering then?

The framerate mystery is because I didn’t have the timer.dll (webstart doesn’t like my proxy)
With the timer dll the framerates drop to 16 fps
Without the timer the framerate is still 50 fps and 63 updates

Just tried it on a 2ghz PC in windows with GF4MX.

Observations:

  • The IMHO v.annoying “feature” that once you hit drop you cannot move sideways becomes a LOT less annoying when you have the alpha shadow of where the block will land!

  • The controls work much better - you can actually smoothly slide the blocks. Although rotations are still sometimes being dropped or lost. I think you might need to re-examine your KB handler, it seems buggy.

  • What are the occasional flashes in random incomplete rows, or is this just eye candy? :slight_smile:

  • I was still getting a mere 25-26 FPS!!! (note PC specs above) but presumably because it’s windows with accelerated alpha everything not only ran smoothly but looked good too (I had all effects ON this time).

I’ve changed the screen setup a bit for FSEM mode. Mind trying again to see if the layout’s still screwed on your Mac?

This is probably due to the buggy nature of FSEM mode for 1.4.2.

I’ve been forced to restart the game to perform video mode changes, and add lots of ugly Thread.sleep()s to the code to get a bit of stability.

I’ve cleaned up the screen disposing routine so it hopefully won’t happen again.

[quote]The framerate mystery is because I didn’t have the timer.dll (webstart doesn’t like my proxy)
With the timer dll the framerates drop to 16 fps
Without the timer the framerate is still 50 fps and 63 updates
[/quote]
So you’re saying that WITH the timer you get 16 fps and WITHOUT you get better frame rates? Are you on a Windows platform?

Very wierd. ???

@blah: I kind of wish I could trade my com for yours for a couple of days to see and fix the problems you’re having on your machine. I’m kind of stuck otherwise since it seems to be working pretty well on a couple of PCs I’ve tested.

I’ve changed the KB handler to be a bit more robust. But I didn’t do any major changes, so it’s probably still fuctionally the same.

A shortcoming/feature of my game is that a piece cannot rotate if it’s blocked.

Here’s my keyboard handling classes, maybe you can help me figure out the problem:

This class basically represents all the states of the keys on the keyboard. If a key is depressed, it’s key code is added into a list

public class Keyboard extends KeyAdapter
{
      private IntList pressedKeys; // a list of all keys that are currently pressed
      
      public Keyboard()
      {            
            pressedKeys = new IntList(5); // A list of ints to represent the keys that are currently pressed
      }
      
      public synchronized void resetKeyStates()
      {
            pressedKeys.clear();
      }
      
      public synchronized void keyPressed(KeyEvent e)
      {
            int keyCode = e.getKeyCode();
            if(!pressedKeys.contains(keyCode)) // add the key to the list if it's not already in it
                  pressedKeys.add(keyCode);
      }
      
      public synchronized void keyReleased(KeyEvent e)
      {
            pressedKeys.remove(e.getKeyCode()); // remove the key from the list
      }
      
      public synchronized int[] getPressedKeysList()
      {
            if(pressedKeys.size() > 0)
            {
                  int[] keys = new int[pressedKeys.size()];
                  pressedKeys.toArray(keys); // returns a copy of the array of all keys pressed
                  return keys;
            }
            return null; // if no keys are being pressed, return null
      }
}

Then I’ve got a that class represents the player controls. It basically takes the current state of the keys on the keyboard (giving priority to the keys that have a movement function, and feeds them to the main game class). Here’s the main key handling code:

int[] keysPressed = keyboard.getPressedKeysList(); // the current list of all keys pressed
            
            if(keysPressed != null) // if there's at least 1 key being pressed
            {      
                  int keyCode; 
                  int keyFunction;
                  
                  for(int i=0; i < keysPressed.length; i++)
                  {
                        keyCode = keysPressed[i];
                        keyFunction = actionKeys[keyCode]; // get the game function of the key
                        if(keyFunction > NO_FUNCTION) // the current pressed key has a MOVEMENT TYPE function
                        {
                              if(previousKey == keyCode) // if the key is still pressed down
                              {
                                    if(previousTime >= 130) // delay to avoid typing too fast
                                          currentGameMode.keyPressed(playerID, keyFunction, keyCode); // feed the key to the current game mode      
                                    
                                    previousTime+=waitTime;      
                                    return;                        
                              }
                                                
                              currentGameMode.keyPressed(playerID, keyFunction, keyCode); // feed the key to the current game mode
                              previousKey = keyCode;
                              previousTime = 0;
                              return;
                        }
                  }
            }
            else
                  previousKey = 0; // no key is pressed at the moment

And then there’s the “advance game state” loop:

// handle input events
            player1.handleKeyInput(waitTime); // processes input for player 1
            player2.handleKeyInput(waitTime); // processes input for player 2
                  
            player1.handleMouseInput();
                
            // advance the game state
            currentGameMode.advanceGameState(waitTime);

Regarding the occasional flashes you see: it’s just eye candy. (That’s the simulated volumetric light effects which you can disable as well)

Yes indeed, whithout the timer the fps are much higher (on WinXP)

VERY nice!!!

  • with ‘turbo’ runs at approx 180fps

  • after 30 seconds my xp CRASHED! No blue screeen, just restart. Never happened before

  • Duron 1.2 Ghz, 512mb ram

  • Windows XP

  • jre 1.4.2_05-b04 (sun)

  • geForce 2 mx400

New version is a bit better. Now it only shifts to the right, and by a smaller amount. On the title screen I see that the border on the right just barely makes it on the screen now, so that is the amount of shift.

I turned on all the graphics options - bad idea FPS was 10… it is unplayable like that. Seems to miss keypresses.