Show ScreenTest.java syntax highlighted
/*
* Copyright (C) 2001-2005 Pleasant nightmare studio
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package skunkworks;
import com.jme.app.SimpleGame;
import com.jme.math.Vector3f;
import org.pleasantnightmare.riotinecity.spatials.QuadScreen;
import org.pleasantnightmare.riotinecity.spatials.Screen;
/**
* Class that can be easily modified to test out <code>Screen</code>
* implementations
*
* @author deus
* @version 1.0
* @see Screen
* @since Feb 10, 2007 9:20:18 PM
*/
public class ScreenTest extends SimpleGame {
private static final long SLEEP_DURATION = 500;
private static final String[] LINES = new String[]{
"The witness heard\n",
"a horrifying sound\n",
"he ran to find\n",
"a woman dead\n",
"and lying\n",
"on the ground...\n\n",
"<solo>\n\n",
"Standing by her\n",
"was a man\n",
"the best\n",
"shaking\n",
"gun in hand\n",
"witness\n",
"says he\n",
"tried to help\n",
"but he turned the\n",
"weapon\n",
"to himself...\n\n",
"<solo>\n\n"
};
protected void simpleInitGame() {
final QuadScreen screen = new QuadScreen("test-screen");
int height = display.getHeight();
screen.setLocalTranslation(new Vector3f(QuadScreen.WIDTH / 2, height - (QuadScreen.HEIGHT / 2), 0));
rootNode.attachChild(screen);
runScreeningLoop(screen);
}
private synchronized void runScreeningLoop(final Screen screen) {
try {
for (String line : LINES) {
Thread.sleep(SLEEP_DURATION);
screen.print(line);
}
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
public static void main(String[] args) {
ScreenTest g = new ScreenTest();
g.setDialogBehaviour(FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG);
g.start();
}
}
See more files for this project here