Show Posts
|
|
Pages: [1] 2 3 ... 13
|
|
3
|
Game Development / Shared Code / Re: 3DzzD - Applet Boot V2
|
on: 2010-04-12 23:45:43
|
WOW ! nice loader !  Is there any way to load native libraries ? I mean, the goal of a good applet loader is to make native stuff like a openGL context available... otherwise a loader deserves no real price to the usual applet. 
|
|
|
|
|
4
|
Game Development / Newbie & Debugging Questions / Re: Problem with Graphics/Graphics2D
|
on: 2010-03-27 23:10:30
|
for example if a window of antoher software go over your frame than a repaint will be launch by the "system" (AWT/Swing) and the frame paint method like paint(Graphics g) (or anyother system called paint method) may be called with a clipped graphics because not the whole graphics have been occluded(in this case the clip area will be a rectangle where the window is over you frame ).
such clipping area is returned by the getVisibleRect() of JComponent. However, it won't be usable in an active rendering mode. the clipping area will be useful when using the component in a Swing managed context, e.g. you paint a custom an animated component on a dektop panel. In that particular case, update(getGrahics()) may be replaced by a call to paintImmediately(getVisiblerect) which will repaint on the visible graphics clipped area. This can save memory when you are displaying several panels.
|
|
|
|
|
5
|
Game Development / Newbie & Debugging Questions / Re: Problem with Graphics/Graphics2D
|
on: 2010-03-24 13:12:17
|
|
1. Graphics2D g2 = (Graphics2D)g; is sufficient, a graphic2d context has not to be instanciated everytime in that way, java will decide. 2. JPanel are JComponent, and therefore will require to be painted alike. draw() must be implemented in the protected void paintComponent(Graphics) function while the LogicLayer will call either repaint() (for passive rendering) or Jpanel.update(Jpanel.getGraphics()) for active rendering. This is because Swing is required to be involved for repainting for the Java2D overlay gets lost with peer sync and edthread.
|
|
|
|
|
6
|
Game Development / Newbie & Debugging Questions / Re: Moving Player
|
on: 2010-02-06 23:08:55
|
Using Graphics2D direct transforms have issues that it can seriously damage the whole screen graphics if transforms are misused or in failure because it shares the peer-transform. As in fact I don't have much to conceal between both methods, either choose Graphisc2D or AffineTransform to your fit. I DO prefer making AffineTransform on singular drawImage() callbacks.
What must be clear is the context of the matricial transform, that is if running from the peer graphics, (i.e. g.translate() , g.rot..) ensure to store the original context and translate correctly, because you have to restore the original state after making your painting as follows to getTransform() <-> setTransform(). Whenever an exception occurs between getTransform() <-> setTransform() you have to catch it and restore back with setTransform(toTheoriginalContextMatrixTransform). ... 
|
|
|
|
|
7
|
Game Development / Newbie & Debugging Questions / Re: Java Games on Facebook?
|
on: 2010-01-31 12:02:17
|
But you're supposed to have a Facebook-enabled webserver, to use facebook-php-api Best way to relay on the java facebook api. In either case, the fb app must be registered as a Web Application NOT Desktop (be careful with that because it cannot be changed after your app is registered, then you can lose secret keys etc.).
|
|
|
|
|
9
|
Game Development / Newbie & Debugging Questions / Re: Moving Player
|
on: 2010-01-23 00:38:14
|
translate to the center of your sprite, call rotate by the rotation amount, then translate back to the origin and finally draw the image. this is trans = (Graphics2D).getTransform() ; ....do g.translate g.rotate.... (Graphics2D).setTransform(trans) 
|
|
|
|
|
11
|
Game Development / Newbie & Debugging Questions / Re: Making the character attack ONCE
|
on: 2010-01-05 11:01:10
|
This ain't easy stuff. But I'm just on the go to release a beta of THE GAME (M.U.G.E.N-like) for the sf3jswing project. I 've achieved about 90% of this game, now I'm right dealing with this exact same issue. What would be my advice, is focusing on Animation timing and KeyStroke's stacks. I done something like this : Animation is XX frames length and should play until the time length is gone, or the program calls stop(). Anyway it should stop whenever it is required. A Fighter is a collections of Animation so that it's not possible to have full control over the Animation's. That is, only a KeyStroke or a AI method such as doDefend() - doAttack() can change the state of that Fighter. Hence, writing the perfect loop is the goal. It should scan for remaining KeyStroke over time and state of each individual keystroke AND check for the Animation.STATE (PLAYING|STOPPED|LOOP). Subsequently, Fighter is needed to have a Stack of KeyStroke events, ordered ascendingly to time and the current Animation. Plus, the Animation that is linked to the IDLE state. Here it is : Fighter reads one sequence of, say, 3 Keystrokes (that be Punch-key pressed repeatly) and the IDLE Animation (call it "stance") LOOPING. read 3 KeyStrokes, the first is checked for CONSUMED and left off the stack because it's not needed anymore, then you can call doAttack(PUNCH) for that read keyStoke. It will then immediately check for the play time of that animation, whether it should return to the IDLE Animation or continue with Punch Animation. Resulting in 2 classes : Fighter{int currentAnimationHash, Stack<KeyStroke{int state=CONSUMED|FREE}>, int state=IDLE|ATTACK|DEFEND|MOVE} and Animation{int state = PLAYING,STOPPED,LOOPING}.  enjoy!
|
|
|
|
|
14
|
Game Development / Newbie & Debugging Questions / Re: Few questions to organize my game(How to create RTS?)
|
on: 2009-12-10 23:34:36
|
1
| contenu2.add(DoodeVert); |
most mistakes in your samples are layout settings. 1. Adding a component when using other layouts than FlowLayout is done with a constraint : BorderLayout -> South, north... ; GridBagLayout * -> gridbagconstraints instance; etc. 2. And at least one of the component must set a preferredSize if no "fixed" component like JLabel or JprogressBar are present. 3. each modification sequence after setVisible(true) must be explicitely validated 4. when handling multiple threads, ensure you're in the EventDispatcherThread to make such layout modifications : SwingUtilities are therefore recommended tools.  * : GridBagLayout may generally render a better look and feel, but is tricky.
|
|
|
|
|
15
|
Game Development / Performance Tuning / Re: Sprite Atlas vs. Sprite cache
|
on: 2009-12-09 23:34:22
|
(...) The real advantage of a sprite atlas is that, if you're smart in implementing them, you can end up with 3 or 4 texture binds per draw step instead of 50 or 100 or more. Texture binds have a high overhead, so keeping everything in as few textures as possible is a large advantage.
That's what I thought about atlas mode. Indeed, it'll end up in one big texture for a animation set... But that means the bigger the single sprite frame is, the biggest will be an atlas texture. I mean I have 200 sprites I'd store in one big atlas file. The texture will be 100x256 squared, which leads to a 25k texture, hence impossible to fit in the gl standard cache (limit is 4096 squared texture size on a geforce 6200). lol ! An animation of 1 sec long, at 24 fps would be 12x256 squared ≃ 2400 px large... that may be thinkable.. but 2400 is a 2Mpx texture, which should be raw-tiled in say 128px² tiles and behave like decoding 24 small png to textures. I'm currently using a so-called Sprite cache to store the data from one run to the other, not actually to use it in a real-time render. yet I cannot use the atlas mode for it .. .( maybe I should use the atlas for small sprite stores, like menu icons or small background patterns. As you said, a mix of both worlds would be fine.. thank you demonpants !
|
|
|
|
|
18
|
Game Development / Newbie & Debugging Questions / Re: Few questions to organize my game( JScroll bar with backgound)
|
on: 2009-12-07 23:26:52
|
assuming your container is a contentpane from applet or frame, you load an image map5.jpg and want to scroll over it. This is quite simple : 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
| Container contenu = getContentPane(); contenu.setLayout(new BorderLayout()); final Image map = ImageIO.read(new File("map5.jpg")); final MediaTracker myTracker = new MediaTracker(this); myTracker.addImage(map, 1); JPanel myPanelMap = new JPanel(true) { protected void paintComponent(Graphics g) { try{myTracker.waitForId(1);} catch(InterruptedException e) {} Graphics2D g2 = (Graphics2D)g; Color c = g2.getColor(); g2.setColor(getBackground()); g2.fillRect(0,0,getWidth(), getHeight()); AffineTransform tx = new AffineTransform(); g2.drawImage(map, tx, this); g2.setColor(c); } };
myPanelMap.setPreferredSize(new Dimension(map.getWidth(), map.getHeight())); JScrollPane sp = new JScrollPane(myPanelMap); sp.getHorizontalScrollBar().setBlockIncrement(30); sp.getVerticalScrollBar().setBlockIncrement(30); contenu.add(sp, BorderLayout.CENTER); contenu.validate(); contenu.repaint(); |

|
|
|
|
|
20
|
Game Development / Game Play & Game Design / Re: American football simulation
|
on: 2009-12-05 00:21:19
|
My next big hurdle is figuring out how to simulate playing a game.
You should read some about AI design... in a few words, you need to firmly define what are the individual actions--namely "states"--a player would do, the less actions the more reactive would the AI look like at a first glance. Actions are localized through some UID (unique identifier). A second important bunch of definitions is the so-called "inputs" each individual player would receive--actually in a FIFO order--those are e.g. other team is holding the ball, an opponent is very close to the player, etc. but in a really "live" fashion so that you think it is in the real game. Those "inputs" also have their UID. With those 2 sets of UID, try to find out a game strategy/tactic. THE BEST WAY IS TO OUTPUT A LOGICAL SCHEME that tells when the player changes from state A to state B and how it goes from B to A back, thus depending on inputs (notice that the fewer inputs, the lesser smart the player can react).  From such a scheme, there are various wayd of implementing it... I do prefer a sequential digital design which offers best performance result over complexity of the schemes (like robots would be designed). 
|
|
|
|
|
21
|
Games Center / 4K Game Competition - 2011 / Re: Applet templates
|
on: 2009-12-04 23:14:45
|
1 2 3 4
| public void start() { new Thread(this).start(); } (...) |
this is a true mess, it runs an anonymous Thread "open in the sky" where it couldn't be checked for a termination, an aborting, ... in shorter words with no control over it. A correct impl. would handle native lnstallation and loading, with control over start-stop behaviours, window focus and a caching system.  an applet is implemented through init-destroy and start-stop methods. So this template should define ignition AND shutdown otherwise anyone terminating the applet into a middle-aged browser would see its system crushing down out of memory and busy... I like the one from LWJGL or appletLoader from JOGL which truely provide a powerful interface to such complex applet management with high-valueable capabilities.
|
|
|
|
|
22
|
Game Development / Performance Tuning / Re: Speed with Java2D and full viewport Applet.
|
on: 2009-11-27 23:39:39
|
I have the OpenGL enabled option on, on my .PHP file. Why with OPERA or KONQUEROR the Applet wont get accelerated. ( only 2fps ) I have a full succes on all WinXP browsers ( 53fps ) and on Linux Firefox browser ( 52 fps ).
Opera and konqueror may not be using the java plugin 2, which means no args can be given to the JVM. e.g. <param name="separate_jvm" value="true"/> is not recognized. This is also an issue on non-plugin2 browsers as Safari. Then opengl pipeline or memory heap may not be modified from an applet.
|
|
|
|
|
23
|
Game Development / Newbie & Debugging Questions / Re: Jar Indexing progress bar
|
on: 2009-11-26 20:50:50
|
I'm not sure if this is what you're seeking for, you're supposed to put the whole input stream in a BufferedInputStream. I used to dowload .jar in this way : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| final URLConnection connection = src instanceof URL ? ((URL) src).openConnection() : null; final BufferedInputStream JXAextensionStream = connection instanceof URLConnection ? new BufferedInputStream(connection.getInputStream()) : src instanceof BufferedInputStream ? (BufferedInputStream) src : src instanceof InputStream ? new BufferedInputStream((InputStream) src) : null; (...) while ((r = inputStream.read(b)) != -1) { JXAtmpPath.write(b, 0, r); rBytes += r; if (progressBar) { if (!(src instanceof File)) { UIMessage.getProgressBar(id).setString("downloaded " + Math.rint(rBytes * 10 / 1024) / 10.0 + " Kbytes"); } UIMessage.updateProgress(id, rBytes, (int) connection.getContentLength(); } } |
you can find this in JXAenvUtils._fileCopy() of sf3jswing-jxakernel below at sf.net. 
|
|
|
|
|
25
|
Java Game APIs & Engines / JOGL Development / Re: Load Textures in Background while Rendering
|
on: 2009-11-20 23:49:02
|
Hey guys,
(...) Currently when I load textures, I load them from TextureData (which I pre-create in another thread) inside the loop (which pauses the rendering, since the loop is on a single thread).
Do you load it into GL directly ? I would like to export the texture generation to another thread and continue rendering, updating the render once the texture becomes available (probably using a volatile boolean to switch on while waiting for the texture to generate). Is this possible?
Actually, YES and NO. if you were not loading directly to GL, then you meant loading data from reading the data file and yes you be able to send a new Thread for this loading process. If you were loading into GL, then you meant using 2 Thread sharing the same GL context, which is afaik NOT possible. A good way to reduce the time your rendering loop is stalled, is to split the Image in Tiles and/or using GL subtextures functions to upload the data to GL, one sample at a time. This means that you either read the source file partially, or hardly split the file into parts that will be read one each other. What shouldn't be done is to open the source file and read the whole data at once before to upload it. I use for myself a Tile cache to load big textures.
|
|
|
|
|
27
|
Game Development / Newbie & Debugging Questions / Re: Few questions to organize my game.
|
on: 2009-11-13 23:25:38
|
A few advices : 1. You are targeting to a RTS (is that real time shooter ?), Swing is rather passive (indirect) rendering wised, so it be more understandable to use an accelerated rendering strategy like opengl. 2. A game should be as compact as possible in terms of objects concurrently loaded, as you said a game needs to react pretty fast. Then I'd use one JFrame and several JPanel's for menu, options and maybe a canvas to make real-time rendering. 3. following those advices makes you plently open to further implementations of third party libraries like LWJGL, JOGL, etc. As of 2. you will have your object amount increased by 10 in a later time and your code will stay "open" to high-end API's. Game design is not a fair work, you may spend more time on coding basic rendering aspects, where you may not have enough time to define a robust Threading concept, multi-player interface or AI simulation... Last but not least, books are not the best tutorials, but school curses (yes, school is teaching game design) or using a library designed for games (google it, but I know about Slick, JME, or even mine JIGAXtended API) make the approach easier to begginners. 
|
|
|
|
|
28
|
Java Game APIs & Engines / JOGL Development / Re: Drawing 2d shape in 3d scene?
|
on: 2009-11-13 23:01:56
|
There's no real need of an overlay, as you want a single rectangular shape to draw. OpenGL can render a quad (a GL_polygon) with no texture, you choose to fill it or the outline you want. GL_fill or GL_line There's no particular difficulty to doing this... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| protected static void _GLdoPolygon(AWTGLCanvas gld, boolean fill, float lineWidth, Point.Float[] vertexes, float[][] vertexesColors, double z) { GL11.glMatrixMode(GL11.GL_MODELVIEW); if (fill) { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); } else { GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE); } GL11.glPushAttrib(GL11.GL_LINE_BIT); GL11.glLineWidth(lineWidth); GL11.glEnable(GL11.GL_LINE_SMOOTH); float[] color = GLHandler._GLgetCurrentColor(gld); GL11.glBegin(GL11.GL_POLYGON); int i = 0; for (Point.Float pf : vertexes) { float[] c = vertexesColors[i++]; GL11.glColor4f(c[0], c[1], c[2], c[3]); GL11.glVertex3f(pf.x, pf.y, (float) z); } GL11.glEnd(); GL11.glColor3f(color[0], color[1], color[2]); GL11.glPopAttrib(); GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL); } |
This sample is part of the GLGeom class of JigaXtended API. I'm running LWJGL 2.1 but this could be easily ported to JOGL. 
|
|
|
|
|
30
|
Java Game APIs & Engines / Tools Discussion / Re: webstart with nativelibs
|
on: 2009-11-08 21:46:38
|
of course, native .jar are are common packages that may be built using jar command or ant <jar> tasks. Those jar have to be signed with the same certificate (same person) as the main .jar that holds your jnlp app. One single rule is necessary : all native libs must be found on the / root path of the .jar. e.g. 1 2 3 4 5 6 7 8
| - myNative.jar - META-INF/ + Manifest - myJNINativeLib.dll|jnilib|dylib|so - anotherJNINativeLib.dll|jnilib|dylib|so - myPackage/ + myClass.class -... |
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|