Don't kill me...

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

[quote]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.
[/quote]
Is the entire screen shifted to the right, including the background graphics (that means the area to the left would probably have a strip of black/white), or is it just the foreground that is shifted?

Kind of expected not-so-good performance on non-windows platforms since there’s no hardware acceleration of translucent effects.

What is your UPS counter like? The only reason it should miss keypresses is if the the game isn’t updating at 60 UPS.

Hey and thanks for helping to test my game on your Mac swpalmer. Man, wrestling with the blasted Mac VM to get it to run my app like other VMs is damned frustrating.

Thanks for your comments.

Since your machine is capable of running the app at 180FPS in turbo mode, what’s your normal FPS / UPS like? Is it a steady 63FPS?

About the xp reboot issue, i hope you saved your work. :slight_smile:

Okay I’m lost on that. What’s your UPS count like with the timer? The timer.dll is basically the same one provided in the gagetimer package.

Anyway, I’ve uploaded a different native .dll clock and timer class Hopefully, this one works properly on your system.

Thanks for testing.

The slickest tetris game I’ve seen, so far :slight_smile:
The presentation is really awesome!
I also got some input problems (double keypresses), and when I left the game, my XP task bar was somewhere floating at the lower half of the screen. ??? This was on my PC at work (P4, JRE 1.4.2_04, ATI mobility radeon).
Probably a driver issue, maybe combined with a bug in the fullscreen API. On my PC at home, I don’t have the problem…

It seems that the problem was not the timer.dll, I tried it today and I got 63/63 but sometimes a game has very low fps (16) and high UPS (70 to 200)

Your new version also has 63/63 (no low fps yet after two games)

@esdeboer:

Thanks heaps for helping me out here.

Actually, that sounds like a timer issue. If FPS is this low and UPS that high, then it could be that the timer isn’t returning accurate timings on your machine (which makes my frame skipping algo do crazy things).

Just to clarify: So you’re saying you get a steady 63 FPS/UPS now after downloading the most recent version (with a new timer.dll) but before you were getting crazy numbers in the FPS/UPS?

Hopefully this updated timer would settle the FPS issue on some machines (like blahx3’s and DrBizarr0’s).

[quote]The slickest tetris game I’ve seen, so far
The presentation is really awesome!
I also got some input problems (double keypresses), and when I left the game, my XP task bar was somewhere floating at the lower half of the screen. This was on my PC at work (P4, JRE 1.4.2_04, ATI mobility radeon).
Probably a driver issue, maybe combined with a bug in the fullscreen API. On my PC at home, I don’t have the problem…
[/quote]
@erikd: Really appreciate those encouraging comments! :smiley:

Regarding the double keypresses issue, can you elaborate on when/how it happened (within the game while moving a piece or menu screen) ? Everything seems to be fine on my side… Are you running at a steady 63FPS/UPS?

[quote]Regarding the double keypresses issue, can you elaborate on when/how it happened (within the game while moving a piece or menu screen) ? Everything seems to be fine on my side… Are you running at a steady 63FPS/UPS?
[/quote]
I only get the double keypresses at my work PC, where I get 17-23 FPS (don’t recall UPS there). I mainly notice the problem when rotating the blocks (it often rotates more than intended).
Here at home, I don’t get the problem (getting 30-35 fps/62-63UPS, running on an athlon XP 2200+, Ti4200).

[quote]Is the entire screen shifted to the right, including the background graphics
[/quote]
yes

[quote]What is your UPS counter like? The only reason it should miss keypresses is if the the game isn’t updating at 60 UPS.
[/quote]
55-60

When I exit the game the taskbar is not at the bottom of my screen. I have fixed this before by restoring the user’s original display mode before the program exits.

yes the FPS is now mostly a steady 63, One time it was 6/63 but that was probably because exceed was open (exceed and fullscreen java don’t go along nicely)

simply put: the best Tetris game i ever played!!!
great job!