Show Posts
|
|
Pages: [1] 2
|
|
2
|
Game Development / Game Play & Game Design / Library/JAR Question
|
on: 2007-08-06 21:04:03
|
I've been thinking about something and hopefully some of the more experienced of you could lend me your knowledge. Take for instance that you have a working FPS using some open-source libraries in JARs. I'm wondering if a malicious user could compile their own (jME for instance) with some extra modifications to give them an unfair advantage (wallhacks?). Is this possible? Is there a mechanism in Java to prevent this? Am I worrying too much? Thanks 
|
|
|
|
|
4
|
Java Game APIs & Engines / OpenGL Development / Re: LWJGL and Microsoft's GDI Generic Renderer?
|
on: 2006-04-07 00:01:06
|
Thanks for the reply. I'll try this from the command line, however I already call setProperty on this lwjgl property inside my initalization code. Can I not do this? 1 2 3 4 5 6 7 8
| if( QConfiguration.getBoolean("allowsoftware", false) ) { System.setProperty("org.lwjgl.opengl.Window.allowSoftwareOpenGL", "True"); } else { System.setProperty("org.lwjgl.opengl.Window.allowSoftwareOpenGL", "False"); } |
|
|
|
|
|
5
|
Java Game APIs & Engines / OpenGL Development / LWJGL and Microsoft's GDI Generic Renderer?
|
on: 2006-04-06 14:59:08
|
Get guys, got a question for you, one that is confusing the hell out of me. Hopefully someone can help me. I have a Dell PC over here that doesn't have a decent graphics chipset (Some obscure ATi integrated thing) and ends up using the GDI Generic as the renderer for anything OpenGL. So here's my question: Why can I not run anything LWJGL using this renderer? Here are some specs from GLView: System Info Windows XP Professional
Vendor Microsoft Corporation 1.1.0
Renderer GDI Generic
Extensions GL_EXT_bgra GL_EXT_paletted_texture GL_WIN_swap_hint
Core features
v1.1 (100 % - 7/7) v1.2 (12 % - 1/8) v1.3 (0 % - 0/9) v1.4 (0 % - 0/15) v1.5 (0 % - 0/3) v2.0 (0 % - 0/9) OpenGL driver version check (Current: 6.13.3036, Latest known: 6.13.3036): Latest version of display drivers found
According the database, you are running the latest display drivers for your video card. No hardware support
Your current video configuration DOES NOT support hardware accelerated OpenGL. No compiled vertex array support
This may cause performance loss in some applications. No paletted texture support
This may cause performance loss in some older applications. No multitexturing support
This may cause performance loss in some applications. No secondary color support
Some applications may not render polygon highlights correctly. No S3TC compression support
This may cause performance loss in some applications. No texture edge clamp support
This feature adds clamping control to edge texel filtering. Some programs may not render textures correctly (black line on borders.) No vertex program support
This feature enables vertex programming (equivalent to DX8 Vertex Shader.) Some current or future OpenGL programs may require this feature. No fragment program support
This feature enables per pixel programming (equivalent to DX9 Pixel Shader.) Some current or future OpenGL programs may require this feature. No OpenGL Shading Language support
This may break compatibility for applications using per pixel shading. No Frame buffer object support
This may break compatibility for applications using render to texture functions. Few texture units found
This may slow down some applications using fragment programs or extensive texture mapping. Extension verification: GL_EXT_color_subtable was not found, but has the entry point glColorSubTableEXT
GLView can also show render demos, but LWJGL just utterly refuses to cooperate. Any help or insight into this problem would be excellent. 
|
|
|
|
|
9
|
Game Development / Game Play & Game Design / Engine Codebase Design
|
on: 2006-03-20 05:47:36
|
|
Does anyone have any resources on this? Perhaps it's just something that must be learned through experience but I'm one to learn from other's mistakes. I'd really like to see how a real game engine is layed out and used in the context of a real game. Diagrams, flow-charts, all that good stuff would be great.
The reason I ask is that I can't find much in the way of game creation patterns. You can find anything else, pretty much, but design of the code itself seems to be left out altogether. And, as I understand it, from experience and looking around, a good codebase can help you through a lot of problems that otherwise could force to rewrite something.
|
|
|
|
|
12
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-27 19:30:09
|
|
Ahh, I'm sure someone else will be happy for that.
Right now though, I've completely transferred over to LWJGL. The only reason I might go back and revisit Java2D is if I want to make a Java2D wrapper that is also compatible with my OpenGL wrapper.
|
|
|
|
|
13
|
Game Development / Shared Code / Re: Some code..
|
on: 2005-11-25 07:08:53
|
some particle engine stuff Excellent! :drools:  I love to see how others implement things. This is just in time, too. I just finished my own particle system 
|
|
|
|
|
16
|
Discussions / Miscellaneous Topics / Re: Unwelcome reminder
|
on: 2005-11-21 22:10:39
|
|
Well then... I'm just 16! My first gaming experience was on the NES, playing duck hunt. Damn that dog...
My first computer had Windows 95 on it, and I was acctually programming small C-Apps with it. (Think 'Hello World' and 'Console-Fireworks') I didn't get to have the joy of a command-line experience until I tryed out Linux. (Debian happens to be my favorite flavor, btw).
I feel young in this crowd...
|
|
|
|
|
19
|
Java Game APIs & Engines / OpenGL Development / 32-bit Graphics, getting dithered down to 16-bit?
|
on: 2005-11-20 16:56:21
|
Hey guys, I just recently made the switch to LWJGL from Java2D and I have to say I love it  Anyway, I'm having a slight problem: My 32-bit graphics are getting dithered down to 16-bit, and then being displayed on my 32-bit screen. Argh! Any ideas? Example:  I'll try to post any relevent code blocks as well: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| public static QTexture fromFile( String name, boolean flip ) { QTexture texture = null; ByteBuffer imageData = null; int ilImageHandle; int oglImageHandle; IntBuffer scratch = BufferUtils.createIntBuffer(1); try{ IL.create(); ILU.create(); ILUT.create(); } catch (LWJGLException ex) { } IL.ilGenImages(scratch); IL.ilBindImage(scratch.get(0)); ilImageHandle = scratch.get(0); if( !IL.ilLoadImage( name ) ) return null; IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE); if( flip ) ILU.iluFlipImage(); int width = IL.ilGetInteger(IL.IL_IMAGE_WIDTH); int height = IL.ilGetInteger(IL.IL_IMAGE_HEIGHT); int textureWidth = QUtil.getNextPowerOfTwo(width); int textureHeight = QUtil.getNextPowerOfTwo(height); if (textureWidth != width || textureHeight != height) { imageData = BufferUtils.createByteBuffer(textureWidth * textureHeight * 4); IL.ilCopyPixels(0, 0, 0, textureWidth, textureHeight, 1, IL.IL_RGBA, IL.IL_BYTE, imageData); } else imageData = IL.ilGetData(); GL11.glGenTextures(scratch); GL11.glBindTexture(GL11.GL_TEXTURE_2D, scratch.get(0)); oglImageHandle = scratch.get(0); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, textureWidth, textureHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageData); if (textureWidth != width || textureHeight != height) texture = new QTexture(oglImageHandle, width, height, (width / (float) textureWidth), (height / (float) textureHeight), textureWidth, textureHeight); else texture = new QTexture(oglImageHandle, width, height); scratch.put(0, ilImageHandle); IL.ilDeleteImages(scratch); IL.destroy(); ILU.destroy(); ILUT.destroy(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return texture; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| public static void drawImage( QTexture tex, int x, int y ) { if( color[3] == 0 ) return; GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0); GL11.glColor4f( color[0], color[1], color[2], color[3] );
if( ra != 0 && ra != 360 ) { float rx1 = rx - x; float ry1 = ry - y; GL11.glTranslatef(rx1, ry1, 0); GL11.glRotatef( ra, 0, 0, 1 ); GL11.glTranslatef(-rx1, -ry1, 0); } GL11.glEnable(GL11.GL_TEXTURE_2D); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureId() ); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f( 0, 0 ); GL11.glVertex2f( 0, 0 ); GL11.glTexCoord2f( tex.getWidthRatio(), 0 ); GL11.glVertex2f( tex.getWidth(), 0 ); GL11.glTexCoord2f( tex.getWidthRatio(), tex.getHeightRatio() ); GL11.glVertex2f( tex.getWidth(), tex.getHeight() ); GL11.glTexCoord2f( 0, tex.getHeightRatio() ); GL11.glVertex2f( 0, tex.getHeight() ); } GL11.glEnd(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0 ); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPopMatrix(); } |
|
|
|
|
|
22
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-19 02:09:41
|
I've made lots of progress with LWJGL, but I have just one question. And a rather puzzling one at that (to an OpenGL-beginner anyway). When I draw images with OpenGL, it looks ... crappier, for lack of a better word, than it does in the picture. It almost looks like it was dithered to 256 colors and then brought back up to 32-bit. Any idea? Images: Good:  Bad:  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| public static void drawImage( QTexture tex, int x, int y ) { if( color[3] == 0 ) return; GL11.glPushMatrix(); GL11.glTranslatef(x, y, 0); GL11.glColor4f( color[0], color[1], color[2], color[3] ); GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex.getTextureId() ); GL11.glBegin(GL11.GL_QUADS); { GL11.glTexCoord2f( 0, 0 ); GL11.glVertex2f( 0, 0 ); GL11.glTexCoord2f( tex.getWidthRatio(), 0 ); GL11.glVertex2f( tex.getWidth(), 0 ); GL11.glTexCoord2f( tex.getWidthRatio(), tex.getHeightRatio() ); GL11.glVertex2f( tex.getWidth(), tex.getHeight() ); GL11.glTexCoord2f( 0, tex.getHeightRatio() ); GL11.glVertex2f( 0, tex.getHeight() ); } GL11.glEnd(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0 );
GL11.glPopMatrix(); } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| import java.nio.*; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.devil.*; import org.lwjgl.*;
public class QTexture implements QDestroyable { public static QTexture fromFile( String name, boolean flip ) { QTexture texture = null; ByteBuffer imageData = null; int ilImageHandle; int oglImageHandle; IntBuffer scratch = BufferUtils.createIntBuffer(1); try{ IL.create(); ILU.create(); ILUT.create(); } catch (LWJGLException ex) { } IL.ilGenImages(scratch); IL.ilBindImage(scratch.get(0)); ilImageHandle = scratch.get(0); if( !IL.ilLoadImage( name ) ) return null; IL.ilConvertImage(IL.IL_RGBA, IL.IL_BYTE); if( flip ) ILU.iluFlipImage(); int width = IL.ilGetInteger(IL.IL_IMAGE_WIDTH); int height = IL.ilGetInteger(IL.IL_IMAGE_HEIGHT); int textureWidth = QUtil.getNextPowerOfTwo(width); int textureHeight = QUtil.getNextPowerOfTwo(height); if (textureWidth != width || textureHeight != height) { imageData = BufferUtils.createByteBuffer(textureWidth * textureHeight * 4); IL.ilCopyPixels(0, 0, 0, textureWidth, textureHeight, 1, IL.IL_RGBA, IL.IL_BYTE, imageData); } else imageData = IL.ilGetData(); GL11.glGenTextures(scratch); GL11.glBindTexture(GL11.GL_TEXTURE_2D, scratch.get(0)); oglImageHandle = scratch.get(0); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR); GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR); GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, textureWidth, textureHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, imageData); if (textureWidth != width || textureHeight != height) texture = new QTexture(oglImageHandle, width, height, (width / (float) textureWidth), (height / (float) textureHeight), textureWidth, textureHeight); else texture = new QTexture(oglImageHandle, width, height); scratch.put(0, ilImageHandle); IL.ilDeleteImages(scratch); IL.destroy(); ILU.destroy(); ILUT.destroy(); GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0); return texture; } } |
|
|
|
|
|
23
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-15 02:39:30
|
|
Great link! Again, Thanks.
Acctually, I prefer Targa to PNG, I acctually chose PNG as ImageIO doesn't have a Targa-reader (that I've found).
Only one thing that I don't like is pre-game/in-game image manipulation. Maybe it's just bad practice, but in this game I split a single image, namely a brick image, into several smaller parts that I use as a particle system to 'spray out' when a brick is hit. Cool effect, but I don't see how this could be possible with that loader. I also pre-rotate the paddle-image to -45 and 45 degrees of movement for some very smooth movement effects. (I saw something about a 'rotated-quad', somewhere, but I don't want to have to detect collisions for that, and leave it as a rectangle-pixel perfect) So, if you have any leads on how to get the best of both worlds, please let me know.
|
|
|
|
|
24
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-14 15:35:22
|
Roger.  Thanks for that. Well, I've started converting the project over to LWJGL. OpenGL doesn't seem that hard, and I've already got a 'wire-frame' with alpha-blending and LWJGL's jinput wrapper working. The new OpenGL coordinate system annoys me though, as I'm so ingrained in the Java2D way of doing things... That and I have no idea how to load an OpenGL texture from a BufferedImage... Back to the red-book  !
|
|
|
|
|
25
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-13 00:51:58
|
|
The problem seems to only occur when I have something with an alpha other than 0 or 255 being drawn. This includes BufferedImages and AlphaComposites. Otherwise, I get a 2x increase in framerate. Any idea? This slowdown doesn't occur so severely outside of fullscreen.
Also, there doesn't seem to be any leads about the KeyListener problem. I might have to switch over to jinput if I want to continue fullscreen support here, I suppose.
|
|
|
|
|
27
|
Java Game APIs & Engines / Java 2D / Re: Fullscreen Oddites
|
on: 2005-11-06 07:25:07
|
Input.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
|
import java.awt.*; import java.awt.event.*; import java.util.*;
public class Input implements MouseMotionListener, MouseListener, KeyListener, MouseWheelListener { public static void init() { typedKeys = new ArrayList<Integer>(); wheelUnits = 0; mouseBtns = new ArrayList<Integer>(); mousePosition = new Point(0, 0); } private static ArrayList<Integer> typedKeys; protected static synchronized void addKey( int key ) { if( !isKeyDown(key) ) typedKeys.add( new Integer(key) ); } protected static synchronized void removeKey( int key ) { for( int i = 0; i < typedKeys.size(); i++ ) { if( typedKeys.get(i).intValue() == key ) { typedKeys.remove(i); return; } } } public static boolean isKeyDown( int key ) { for( int i = 0; i < typedKeys.size(); i++ ) { if( typedKeys.get(i).intValue() == key ) return true; } return false; } private static int wheelUnits; protected static synchronized final void setWheelMoved( int i ) { wheelUnits = i; } public static final int getWheelMoved() { int i = wheelUnits; wheelUnits = 0; return i; } private static ArrayList<Integer> mouseBtns; protected static synchronized void addMouseButton( int key ) { if( !isMouseButtonDown(key) ) mouseBtns.add( new Integer(key) ); } protected static synchronized void removeMouseButton( int key ) { for( int i = 0; i < mouseBtns.size(); i++ ) { if( mouseBtns.get(i).intValue() == key ) { mouseBtns.remove(i); return; } } } public static boolean isMouseButtonDown( int key ) { for( int i = 0; i < mouseBtns.size(); i++ ) { if( mouseBtns.get(i).intValue() == key ) return true; } return false; } private static Point mousePosition; protected static synchronized void setMousePosition( Point p ) { mousePosition = p; } public static final Point getMousePosition() { return new Point( (int)mousePosition.getX(), (int)mousePosition.getY() ); } public static final Vector2D getMouseVector2D() { return new Vector2D( (int)mousePosition.getX(), (int)mousePosition.getY() ); } public static final int getMouseX() { return (int)mousePosition.getX(); } public static final int getMouseY() { return (int)mousePosition.getY(); }
public void keyPressed( KeyEvent evt ) { Input.addKey( evt.getKeyCode() ); } public void keyReleased( KeyEvent evt ) { Input.removeKey( evt.getKeyCode() ); } public void keyTyped( KeyEvent evt ) {} public void mouseClicked( MouseEvent evt ) {} public void mouseEntered( MouseEvent evt ) { Input.setMousePosition( evt.getPoint() ); } public void mouseExited( MouseEvent evt ) { Input.setMousePosition( evt.getPoint() ); } public void mousePressed( MouseEvent evt ) { Input.addMouseButton( evt.getButton() ); } public void mouseReleased( MouseEvent evt ) { Input.removeMouseButton( evt.getButton() ); } public void mouseDragged( MouseEvent evt ) { Input.setMousePosition( evt.getPoint() ); } public void mouseMoved( MouseEvent evt ) { Input.setMousePosition( evt.getPoint() ); } public void mouseWheelMoved( MouseWheelEvent evt ) { Input.setWheelMoved( evt.getWheelRotation() ); } }
|
There is more, of course, but I don't think it's relevant.
|
|
|
|
|
28
|
Java Game APIs & Engines / Java 2D / Fullscreen Oddites
|
on: 2005-11-06 07:24:45
|
Well, I'm working on a small Java2D-AWT-based breakout clone and I have a few problems, maybe you can help me with them. I designed the game engine with fullscreen or windowed mode in mind, but developed mainly in windowed. When I try to switch to fullscreen now, keyboard-input does not work, and my performance goes from somewhere in the 40-60FPS range to 5-15FPS. It's very puzzling, as I thought fullscreen exclusive was supposedly faster than windowed, and there doesn't seem to be any cause of the keyboard-input problem. ScreenCanvas.java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348
| import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.awt.geom.*;
public class ScreenCanvas extends Frame { protected static int width; protected static int height; protected static int fps; protected static boolean instance = false; public static int getScreenWidth() { return width; } public static int getScreenHeight() { return height; } public static int getFPS() { return fps; }
public static ScreenCanvas getInstance() { if( !instance ) return new ScreenCanvas(); return null; }
public static ScreenCanvas getInstance( String title ) { if( !instance ) return new ScreenCanvas( title ); return null; }
private GraphicsEnvironment env; private GraphicsDevice device; private GraphicsConfiguration gc; private BufferStrategy bufferStrategy; private DisplayMode fullscreenMode; private DisplayMode windowedMode; private DisplayMode displayMode; private int fps_max; private long startTime; private long endTime; private long wantedEndTime; private Canvas canvas; private Component raster; private boolean debug; protected ScreenCanvas() { this( "" ); } protected ScreenCanvas( String title ) { ScreenCanvas.instance = true; debug = Configuration.getBoolean("debug", false); ScreenCanvas.fps = 0; fps_max = Utility.clamp( Configuration.getInteger( "fps_max", 0 ), 0, 1000 ); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { cleanup(); } }); setBackground( Color.black ); setIgnoreRepaint( true ); setResizable( false ); setFocusable( false ); env = GraphicsEnvironment.getLocalGraphicsEnvironment(); device = env.getDefaultScreenDevice(); gc = device.getDefaultConfiguration(); int bitDepth = device.getDisplayMode().getBitDepth(); int refreshRate = device.getDisplayMode().getRefreshRate(); fullscreenMode = new DisplayMode( Configuration.getInteger("fs_res_w", 1024), Configuration.getInteger("fs_res_h", 768), bitDepth, refreshRate ); windowedMode = new DisplayMode( Configuration.getInteger("wnd_res_w", 1024), Configuration.getInteger("wnd_res_h", 768), bitDepth, refreshRate ); if( Configuration.getBoolean("fakefullscreen", false) ) { setupFakeFullscreen(); } else if( Configuration.getBoolean("fullscreen", false) && device.isFullScreenSupported() ) { setupFullscreen(); } else { setupWindowed(); } if( !isVisible() ) setVisible( true ); if( canvas == null ) { createBufferStrategy( Configuration.getInteger("buffers", 2) ); bufferStrategy = getBufferStrategy(); } else { canvas.createBufferStrategy( Configuration.getInteger("buffers", 2) ); bufferStrategy = canvas.getBufferStrategy(); } ScreenCanvas.width = raster.getWidth(); ScreenCanvas.height = raster.getHeight(); raster.addKeyListener( new Input() ); raster.addMouseListener( new Input() ); raster.addMouseMotionListener( new Input() ); raster.addMouseWheelListener( new Input() ); requestFocus(); try{ Thread.sleep(375); } catch(Exception e) {} Console.echo( Console.VERBOSE, "ScreenCanvas Initialized" ); setTitle( title ); } public void cleanup() { if( device.getFullScreenWindow() != null ) device.setFullScreenWindow(null); bufferStrategy = null; ScreenCanvas.instance = false;
setVisible(false); dispose(); } private void setupWindowed() { Console.echo( Console.NORMAL, "Using Windowed Mode" ); Insets windowInsets = Toolkit.getDefaultToolkit().getScreenInsets( gc ); setSize( windowedMode.getWidth() + windowInsets.left + windowInsets.right, windowedMode.getHeight() + windowInsets.top + windowInsets.bottom ); canvas = new Canvas(); canvas.setBackground( Color.black ); canvas.setIgnoreRepaint( true ); canvas.setFocusable( true ); canvas.setSize( windowedMode.getWidth(), windowedMode.getHeight() ); canvas.setLocation( 0, 0 ); add( canvas ); raster = canvas; displayMode = windowedMode; } private void setupFullscreen() { Console.echo( Console.NORMAL, "Using Fullscreen Mode" ); setUndecorated(true); if( device.isFullScreenSupported() ) device.setFullScreenWindow(this); if( device.isDisplayChangeSupported() ) { if( isDisplayModeSupported( fullscreenMode ) ) device.setDisplayMode( fullscreenMode ); } setSize( fullscreenMode.getWidth(), fullscreenMode.getHeight() ); raster = this; canvas = null; displayMode = fullscreenMode; } private void setupFakeFullscreen() { Console.echo( Console.NORMAL, "Using Fake Fullscreen Mode" ); setUndecorated( true ); if( device.isDisplayChangeSupported() ) { if( isDisplayModeSupported( fullscreenMode ) ) device.setDisplayMode( fullscreenMode ); } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setSize( (int)screenSize.getWidth(), (int)screenSize.getHeight() ); canvas = new Canvas(); canvas.setBackground( Color.black ); canvas.setIgnoreRepaint( true ); canvas.setFocusable( true ); canvas.setSize( getSize() ); canvas.setLocation( 0, 0 ); add( canvas ); raster = canvas; displayMode = new DisplayMode( (int)screenSize.getWidth(), (int)screenSize.getHeight(), fullscreenMode.getBitDepth(), fullscreenMode.getRefreshRate() ); } private boolean isDisplayModeSupported( DisplayMode dm ) { DisplayMode[] modes = device.getDisplayModes(); for (int i = 0; i < modes.length; i++) { if (dm.getWidth() == modes[i].getWidth() && dm.getHeight() == modes[i].getHeight() && dm.getBitDepth() == modes[i].getBitDepth() && dm.getRefreshRate() == modes[i].getRefreshRate()) return true; } return false; } public void setCursorVisible( boolean b ) { if( b ) { setCursor( Cursor.getDefaultCursor() ); } else { int[] pixels = new int[16 * 16]; Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16)); Cursor transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), ""); setCursor( transparentCursor ); } } public void setCustomCursor( ARGBImage img ) { int[] pixels = img.toIntArray(); Image image = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, pixels, 0, 16)); Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(image, new Point(0, 0), ""); setCursor( cur ); }
public Graphics2D getGraphics() { if( bufferStrategy != null ) { Graphics2D g = (Graphics2D)bufferStrategy.getDrawGraphics(); g.setClip( new Rectangle( 0, 0, raster.getWidth(), raster.getHeight() ) ); return g; } return null; }
public void StartFrame() { if( bufferStrategy == null ) return; startTime = Utility.currentTimeMillis(); Graphics2D g = getGraphics(); if(g == null) return; g.setColor( getBackground() ); g.fillRect( 0, 0, raster.getWidth(), raster.getHeight() ); }
public void EndFrame() { if( bufferStrategy == null || bufferStrategy.contentsLost() ) return; Graphics2D g = getGraphics(); if(g == null) return; if( debug ) { Console.render( g ); DynamicGrid.render( g ); } if( bufferStrategy != null && !bufferStrategy.contentsLost() && isVisible() ) bufferStrategy.show(); endTime = Utility.currentTimeMillis(); if( fps_max > 0 ) { wantedEndTime = ( 1000 / fps_max ) + startTime; while( wantedEndTime > endTime ) { endTime = Utility.currentTimeMillis(); } } if( endTime != startTime ) ScreenCanvas.fps = Utility.clamp( (int)( 1000 / (endTime - startTime) ), 1, Integer.MAX_VALUE ); else ScreenCanvas.fps = 1000; TimerSystem.update(); } public void setDebug( boolean b ) { debug = b; } public boolean getDebug() { return debug; } public void update( Graphics g ) {} public void paint( Graphics g ) {} }
|
|
|
|
|
|
30
|
Games Center / Archived Projects / First Fullscreen Game
|
on: 2005-04-29 23:24:20
|
Hey, I've been working on a game for my computer science class and I'd like any input you guys have on it. It's sort of a Sonic The Hedgehog-esqe game, and I'd like to share it here. I named it 'Java Quest' after the language I programmed it in. First, some background: - The teacher of my computer science class is named 'Steve Shannon' and I choose one of my friends in that class to be the main character, 'Nick Wood'. The author of the text-book, Exposure Java, is named 'Leon Schram'. Basically I was bored in Algebra 2 and I started writing a story line. It mostly consisted of Nick falling asleep while coding a lab assignment, but he still coded in his sleep. This code compiled to a portal into an alternate universe inside the computer. You later find out that he only activated a virius planted by Schram in his computer. Also, there is a slight inside joke in story line. 'Schram should Scram' is a little rhyme Nick yelled out during a test  Everything is original, down to the last sprite animation. (Except the music, which I got from http://www.flashkit.com/) My entire class loved it, hope you enjoy it as well. And with out further ado, my 3 weeks of hard work:   Download Link: http://modx.ath.cx:1337/JavaQuest.zipAll source code is included if you're curious. I've built it with the JDK 1.4_07. To run the game, run the included 'run.bat' file. (I know the sprite graphics aren't that good-looking, but I'm not in a Graphics Design class... I think the awesome particle system makes up for it though  Legal Garbage: Java is a registred trademark of Sun ... blah blah ... Known Bugs: If you hit a tile just right you will go straight though it. I've not a clue how this happens, but it does.
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|