Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 11
1  Game Development / Performance Tuning / Re: Speeding up Minecraft? on: 2013-05-21 04:14:25
The last version of Windows having a better support of OpenGL than GNU Linux was Microsoft Windows 98. After that, OpenGL was known to be faster and more reliable under GNU Linux in general.
Adding to this statement, IIRC Valve managed to get better performance on Ubuntu when they began porting some of their games to OpenGL.

Quote
"That the Linux version [of Left 4 Dead 2] runs faster than the Windows version (270.6) seems a little counter-intuitive, given the greater amount of time we have spent on the Windows version. However, it does speak to the underlying efficiency of the kernel and OpenGL" - Valve Linux Team (source)
2  Game Development / Newbie & Debugging Questions / Re: Game loop help on: 2013-05-16 02:39:05
When you say I should render 60 times per frame as well, do you mean I should just call tick() and then render()? or is there a better way of doing it?
Yes. If you looked at the two best examples from the article I linked to you updating and rendering are both done before the time wasting (or waiting for the next cycle) is. The article gets a little more advanced and compensates for running slow by "dropping" frames. It does this by updating without rendering until it catches up, and then it renders.
3  Game Development / Newbie & Debugging Questions / Re: Game loop help on: 2013-05-15 22:20:59
Well, you're currently rendering as fast as you possibly can. I would recommended rendering 60 times a second as well, since rendering is usually pretty costly. I would also suggest using Thread.sleep() to eat up the time between updates instead of just letting the loop run and eat up CPU cycles. To see what I'm talking about, have a look at this article on game loops, especially the fixed timestep loop that Yields/Sleeps for the left over time.
4  Game Development / Newbie & Debugging Questions / Re: Will I get the exact amount of memory usage? on: 2013-05-13 21:43:36
If I understand Riven's explanation correctly each char[] adds between 12 and 16 bytes of overhead, so in my mind that means using a single char[] would eliminate a majority of the overhead added by a char[][][].
5  Game Development / Game Mechanics / Re: Moving target path finding on: 2013-05-11 19:35:28
Little tips, you should separate entities into separate lists based on its type (alive, movable, etc) so it can reduce the looping time, since you need to perform this a lot.
Thanks for the tip. I've already done this in the way that path finding for each entity is done.

Are you setting the actual "moving target" as target or some sort of simple prediction? (Like p.e. x tiles into the direction the target is walking, where x is the distance between the chasing entity and the target now)

Depending on how much cpu you can afford to waste and how you want your entities to "react", you can get some neat looking "behaviour" by just messing around a little with the way the fake/prediction-target gets chosen or even comparing multiple fake targets (doing pathfinding from target to its potential goals first + choosing something on that path as target instead of the actual target itself can have neat results too).

If something like that makes sense can depend a lot on exactly how your game / levels look though, so maybe you should post a screen-shot or something in the hope that someone who's more experienced that me can give you more specific advice. Wink
Currently I'm just setting the "moving target" to the target's actual location. I'll play around with estimating where the target would be after x number of moves though, thanks for the suggestion Smiley I'm not sure how helpful a screenshot would be, as I don't have any of the final level designs done. I'm currently in the process of implementing features.

What I did for Guardian II is this:

1. Check if target is alive. If not, cancel.
2. If target is targetable with simple AI, switch to simple AI. Otherwise, continue:
3. Check if path to target has been found. If not, find a path.
4. Check if you are on the path. If not, try to get on path. If still not, find new path.
5. Check if target is within a certain distance of the path's end point. If not, find a new path.
6. If at end point and target not targetable with simple AI, find new path to target.

By 'simple AI' I mean, if target is left, go left. If target is right, go right etc.
I hadn't thought about separating it out into a simpler AI and a more complex one. However, I'm worried that determining if simple AI will work and then having to resort to complex AI would just worsen the performance problems. Perhaps I'm misunderstanding your explanation though.
6  Game Development / Game Mechanics / Moving target path finding on: 2013-05-11 06:28:19
In working on implementing better pathfinding than "which way is it? ok go that way." I decided to start with A* as I've heard it mentioned before. A* might be a bit overkill for a grid-based game where you can only move in four directions, but oh well. Unfortunately after getting it working I discovered that a basic A* implementation doesn't work very efficiently when the target is moving around. So, I'm trying to figure out a better way to get my enemies to find their way to the player with out getting stuck. If anyone has suggestions, or experience with doing something like this I'd love to read it Grin
7  Java Game APIs & Engines / OpenGL Development / Re: How to Control the "Button is pressed" ? on: 2013-05-11 05:30:18
While alasipknot is correct, he could've been a little nicer. New people don't know any better so it is good to inform them, but in a nicer way. "Hey, welcome to JGO! *answer question* and for future reference posts like this go in *insert board here*" or something like that.
EDIT: Also, take a page out of Cas' book and use a lot of smileys Grin they always help


On topic:
Another approach would be to have a set fire rate and simply check the time since you've last fired. The fire rate would be some amount of time, and you would need to initialize it somewhere. Then simply store a lastFire for the last time you fired. For example:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
// I suggest using System.nanoTime() instead of System.currentTimeMillis() as the millis timer resolution isn't very good

private fireRate = 1000000000; // This is 1 second in nanoseconds
private lastFire = System.nanoTime() - fireRate;

public void fire() {
   if(System.nanoTime() - lastFire >= fireRate) {
      // fire code
     lastFire = System.nanoTime();
   }
}
8  Discussions / Miscellaneous Topics / Re: Installing opencv on ubuntu on: 2013-05-10 04:39:00
use javacv it's java bindings to opencv, and the javacv-0.5-cppjars file has binaries.  you just need to set the jars in your classpath.

Downside to this is that the documentation is really crappy or non-existent I should say.
The JavaCV Google Code page has examples from the OpenCV Cookbook that have been ported to Java. This is the beginning one.

EDIT: The page I linked to also has information on how to convert from OpenCV to JavaCV if you scroll down. Using that and the OpenCV documentation should work just fine.
9  Discussions / Miscellaneous Topics / Re: Installing opencv on ubuntu on: 2013-05-09 23:22:45
Have you tried following these instructions on installing it?
10  Game Development / Game Play & Game Design / Re: RPG Object Variables on: 2013-05-09 02:44:25
To build upon the OOP suggestions that have already been made I would also create a basic super class for Entities. Then you can put common code and variables in it like health, speed, damage, etc.
11  Game Development / Game Mechanics / Re: First Post - Bufferstrategy, jpane and canvas? on: 2013-04-16 01:03:03
pack() will automatically shrink all components into the smallest size in a JFrame. So if your frame is 1600x900 and your canvas is 800x600 it will make the JFrame 800x600. I may be wrong on this one.
The JFrame will be a bit bigger than 800x600 to allow for an internal area (the Canvas) of 800x600 plus the window's border.

The only reason I haven't been looking into libraries is that I want to begin working on my projects the "right" way. I don't mind the idea of a library, I just wonder, are they really more efficient? I'm afraid of using them as a crutch simply because its easier. If they're actually better then I'm on board. Smiley
If that's the case, is there a pro/con page for the popular ones?
The OpenGL to java bindings are all more efficient simply because OpenGL is a native, hardware accelerated, library. I really wouldn't call LWJGL or LibGDX a crutch but, of the two LWJGL is definitely lower level as it's mostly a direct binding to the native OpenGL libraries. I switched from Java2D to LWJGL simply because I like learning how things work and writing more things for myself as a learning experience instead of using more of a game-dev library like LibGDX. Whichever you choose good luck Smiley
12  Game Development / Newbie & Debugging Questions / Re: Help on understanding the game loop on: 2013-04-14 02:48:12
So I was. My mistake.
13  Game Development / Newbie & Debugging Questions / Re: Help on understanding the game loop on: 2013-04-14 02:44:37
quew8 was more helpful than either of you, he gave the basic structure of a game loop and described it.

I'd suggest taking a look at Eli's article on game loops to see the different kinds and some ways to implement them. I also wouldn't use while(true), it's probably best to have a boolean that you can change in order to exit the loop and then exit the game.
14  Discussions / General Discussions / Re: Question about bundling custom OpenJDK on: 2013-03-27 02:15:55

Will you be adding the Mac and Linux examples for packaging the jre with an app soon? Also you link to launch4j for windows, is there any similar program for Mac and Linux?
If you mean Launch4j that runs on Macs and Linux, yes Launch4j has versions for Mac in Linux. If you mean a program that creates executables for Mac and Linux, not that I'm aware of. However creating an executable for Macs is as simple as copying a jar into a .app structure (which is basically just a folder with executables and resources in it). For Linux a shell script is usually used to launch a .jar, as has been mentioned in this thread. For example, I simply use an ant build script to create a runnable .jar (this is just generic and will run on any OS that supports Java), then run Launch4j on that jar to get a Windows .exe, and finally copy the jar into a prebuilt .app file structure.
15  Game Development / Shared Code / Re: LWJGL and File Choosers on: 2013-03-07 00:49:36
Nope. When I was trying to figure this out neither calling requestFocus() or requestFocusInWindow() caused the JFileChooser to come to the front.
16  Game Development / Newbie & Debugging Questions / Re: Programming inside an application in Android? on: 2013-03-07 00:10:20
The JVM supports hotswapping of methods for running programs. For example, in Eclipse if you run your program in debug mode then when you change a methods code you will see the change in the program the next time the method is called. Not everything can be hotswapped, I know you can't add or remove methods or modify global variables. I'm also not sure if this can be done on Android as I've not developed for it.
17  Game Development / Shared Code / LWJGL and File Choosers on: 2013-03-05 23:43:19
I recently ported my measly game to LWJGL for performance reasons and discovered that (on windows at least) the JFileChooser I was using in the built in map editor didn't like to grab focus from the main LWJGL window. After some googling and I couldn't find a solution and decided to just mess with it a little. The solution I found to work for me is to simply create an invisible frame to steal focus from the LWJGL window and then display the file chooser. I thought I'd share my solution as I had trouble finding one on my own. If anyone else has a more elegant solution please let me know Smiley

The code is fairly simple but here it is for the noobs.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
Frame frame = new Frame();
frame.setUndecorated(true);
frame.setOpacity(0);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.toFront();
frame.setVisible(false);
frame.dispose();

// File chooser stuff here
18  Game Development / Newbie & Debugging Questions / Re: Level, Asset, Save File storage on: 2013-03-05 22:29:08
As tyeeeee1 said there are a lot of different ways to store assets for a game so it really just comes down to your personal preference. For me I usually just store maps/character data/etc in a plain text file and read it in at some point in the game. I personally just don't feel like messing with a database, or an XML parser, or a JSON parser, or what have you. Of course that means I end up writing my own little parser but that doesn't take much effort at all really and it can just be reused from project to project.
19  Games Center / WIP games, tools & toy projects / Re: Pixely Adventure-thing on: 2013-02-06 23:40:12
This looks really good. I tried the demo, and that corn field-bear chase is ridiculous! Is there any way you could direct me to a tutorial on how to do the smooth scrolling like you have? I'm not sure how to implement it on a tile map.
In my tile based adventury game I move the player just like any other Entity would. Then if the player's position has changed I set his new position as the target center for the map and move toward it at some speed. So say you press the right arrow key, he moves one column to the right, then the center of the screen follows him. I accomplish this with an offsets variable, which is just a point that I use to offset tiles and entities, and a targetOffsets variable. If the offset doesn't match the target offset when I update then I add the speed of the camera to the offset.
20  Game Development / Newbie & Debugging Questions / Re: lastPosition always equals current Position on: 2013-02-06 00:47:52
Well you probably don't want to update the last position unless you can actually move to the new one, and there's no need for the x1 and y1 variables. I can't really see what would be causing your problem but I'd change the method to something like this:
1  
2  
3  
4  
5  
6  
7  
8  
public void moveTo(double x, double y) {
   if(map.get((int)x, (int)y).walkable) {
      lastPos.x = pos.x;
      lastPos.y = pos.y;
      pos.x = x;
      pos.y = y;
   }
}


Have you tried printing all the variables before and after to see what's actually happening? That can be helpful.
21  Game Development / Newbie & Debugging Questions / Re: Screen Tearing on: 2013-02-05 04:05:06
When your using a buffer strategy you really should put it in a do-while to make sure your not losing buffer contents. For example your render method would look something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
private void render() {
   do
   {
      do
      {
         Graphics2D g = (Graphics2D) bufferStrategy.getDrawGraphics();
         render(g);
         g.dispose();
      }while(bufferStrategy.contentsRestored());
   
      strategy.show();
   }while(bufferStrategy.contentsLost());
}
22  Discussions / General Discussions / Re: Gaming contests for people under 18? on: 2013-02-01 23:21:31
Most people that aren't in school have a day job Wink

My thoughts on how it should go:
1. I think restrictions should be minimal, perhaps just a time limit. It should be your own code (except for graphics libraries of course), no copy-pasta. It should be *mostly* written during the competition, basic libraries should be allowed though (much like Ludum Dare).
2. I vote no restriction on theme.
3. Posting to a thread is probably easiest unless someone wants to throw together a site.
4. I think anyone on JGO should be able to vote if they want.
5. Fun, Innovation, Graphics, Audio, Originality
23  Games Center / WIP games, tools & toy projects / Re: Pixely Adventure-thing on: 2013-02-01 22:29:46
That looks really good! Grin It puts the adventury game I've been sporadically working on with Oryx's sprites to shame. I'm excited to see how it turns out. I really like the effect of pushing around the frozen mob Smiley
24  Discussions / General Discussions / Re: How to think of game ideas??? on: 2013-02-01 22:26:03
I find playing other games inspiring. Especially if the game is really unique or fun. Although this may foster "cloning"  Roll Eyes
25  Game Development / Newbie & Debugging Questions / Re: Best free Java code repository? on: 2013-02-01 22:24:21
It depends on whether or not you mind your code being public. The free version of Github requires your repo to be public, where as the free version of Bitbucket allows a private repo with up to 5 people working on it. It also depends on the type of version control you want to use. Bitbucket supports both Mercurial and Git where as I believe Github only supports Git.
26  Discussions / General Discussions / Re: Gaming contests for people under 18? on: 2013-01-30 23:07:39
Neither Ludum Dare or Java4k have age limits, anyone can submit a game.
27  Discussions / General Discussions / Re: New feature: downtime on: 2012-12-10 02:23:51
I like it, although I'll begin to hate it soon. I just tried to post a one word answer to a quote and I got the warning
That's exactly what it is meant to stop. The signal-to-noise ratio was way too low.


Okay, I added a hook to the Post functionality, that demands that at least 10% of new posts is content you have written yourself.
persecutioncomplex
Yes, there are (currently) ways around it, but at least it makes you think twice.

Test

EDIT: Aw, editing pops up the message too. Darn.
28  Discussions / General Discussions / Re: New feature: downtime on: 2012-12-09 22:26:23
Okay, I added a hook to the Post functionality, that demands that at least 10% of new posts is content you have written yourself.
persecutioncomplex
29  Discussions / General Discussions / Re: javagaming.org URL available (?) on: 2012-12-02 20:50:59
Why would a strong leader care about 'fair' when he could use 'fear' to convince his minions?

I'm so paywalling this site!


*disables javascript* Smiley
30  Discussions / Miscellaneous Topics / Re: What music do you listen to while you code? on: 2012-11-29 23:02:17
Thank you you are awesome for showing me this. ah.fm is also pretty good.
Thank you, I had no idea it existed until a friend told me about it a few months ago. It's a great service. Thanks for showing me ah.fm it's pretty good too Smiley
Pages: [1] 2 3 ... 11
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (79 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (122 views)
2013-05-16 00:53:38

gouessej (114 views)
2013-05-16 00:17:58

theagentd (126 views)
2013-05-15 15:01:13

theagentd (113 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.204 seconds with 20 queries.