Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About zappsweden

  • Rank
  1. When I took my old Jav 1.4 source code, compiled+ran in Java 6 I solved old annoying issues like the infamous "Gray rect" bug. Also, the main menu and its sub menus had the same speed, BUT as soon as I jumped into the war screen and started painting frames on my map it went WAY slower than in 1.4 There was also delay on my mouse clicks events. It was so sluggish I cannot use it. I am using full screen API, passive rendering. Are there any things I should be checking and tweaking when jumping to Java 6, like SwingWorker and stuff? Are there any "Must haves" ? By the way, I paint my graphic on a JPanel (map, units, Fow, icons and stuff).
  2. If map gets messy i.e that alot of areas are owned by different that the original owner, then your algoritm could slow down though. I myself had a minimap 277x176 which means 48762 pixels. The drawing itself is not the bottleneck but the bottleneck is the number of shapes. I think you can come up with an algoritm to get less amount of shapes drawn then it could speed up the drawing. Exploit the fact that similar neighbours can be drawn in one big swoop instead of drawing every little single dot. For Instance if you have a areas with squares painting the same stuff, why not instead of drawing 9 x's as below draw one 3x3 big X, if you see what I mean. x x x x x x x x x You can have an algoritm to check the neighbours of squares and if they are the same then draw something bigger that covers all of them. For instance if drawing a 10x10 area of 100 blue dots you can draw one fillrect(x, y, 10, 10) to cover the whole area. The algoritm determining neighbours can be done in a number of ways and I have not actually tried it yet myself.
  3. I had this problem for months without finding a solution. When setVisible(true) and especially setVisible(false) on my JDialog I get at leist one frame of white flashing by. I heard it is some kind of buffer problem and I do not use any manual buffering instead I let swing handle it. I am using java 1.4 and have no plans to switch to newer version for some while. Anyone else have this problem? [Edited by - zappsweden on January 24, 2007 7:53:51 AM]
  4. You should divide it into one basic layer and one layer you paint every frame. The basic layer: Always shown like the water, terrain, land, grass, ...) The top layer: - Show dots or whatever to mark some moving objects current position - Show rectangle on minimap to indicate what section of the minimap corresponds to the current screen in game. Start out drawing just the basic layer by code and use <print screen> to make an image of if (for instance .png is fast to draw in Java in my experience!). Afterwards, you adjust so that you paint the basic layer by the png image(instead of code) and then paint the top layer on top of it using code (every frame unless minimap is cluttered with "top layer" stuff then you might need to update it only each third frame or whatever). [Edited by - zappsweden on January 24, 2007 7:00:07 AM]
  5. Well, it is complicated and has to to with me using passive rendering and getting problem when scrolling. Since the Repaint is handled in a different thread than my event thread, scrolling get too fast and I get strange side effects. I solved that problem by limiting the scroll speed but since someone could be sitting with 400 MHz and someone else with 3 GHz I would want to vary the scroll speed accordingly and then avoiding the low spec user not to get buggy crappy software.
  6. Thanks for the tips, but I really cannot find any Java specific code or Class in the links u gave me.
  7. zappsweden

    [java] Firewalls

    So depending on his firewall he has to either unblock or open port? I get the feeling the bloke on the other side never gets a "would u like to unblock" message from the firewall, since he then would have solved the problem. [Edited by - zappsweden on December 29, 2005 12:28:40 PM]
  8. I have problems with firewalls stopping the connections. Is the best way to solve this by opening ports or is there any way of going around it? server side code -> -> -> int listenOnPort=Global.GAME_PORT; try { ServerSocket listenSocket = new ServerSocket(listenOnPort); Socket clientSocket = listenSocket.accept(); client Side code-> -> -> Socket serverSock= new Socket(this.connectToIP, Global.GAME_PORT);
  9. How do I quickly calculate and use the fastest route between A and B on a hexagon map where the hexes on map have different cost to cross?
  10. Quote:Original post by Son of Cain ... uh? Sorry, but I don't understand your question. In case you wish to find out at runtime what is the absolute path you're running on, you can print it out by calling: System.out.println(new java.io.File("").getAbsolutePath()); If you wish to load resources using relative paths, you must add the resources' folder to the classpath. Then you use a String like "res/images/myImage.jpg" to retrieve an URL with: MyClass.class.getResource("res/images/myImage.jpg"); If that's not what you want, sorry. I couldn't understand your question ;) Son Of Cain getAbsolutePath worked like a charm, THANKS dude :)
  11. I am programming a game and want to be able to run it from anywhere on the harddrive (so I do not need to install it). I need to be able to read the images, sounds and other files that are relative to my main Class. I do not know how to use the relative path (without first finding out the absolute) so I must first find out the absolute path? The game determines its absolute path at runtime by creating a URL using the ClassName of my main Class. Here is the problem. It only works if there are no blank spaces (using Windows) in the path, since blank spaces obviously get thrown away when creating the URL. What to do? [Edited by - zappsweden on November 24, 2005 1:29:06 PM]
  12. The mysterious answer I found to all this and which made it work for me was having a delay of some tenth of a second after the call to the repaint of th e first JPanel and before the repaint of the second JPanel. It now works totally, but I still do not understand this matter.
  13. I smell the need for Full Screen Mode, am I correct?
  14. At leist it works now in single player, but in TCP/IP some problems still exist. To me it seems that paintImmediately combined with other repaints can cause some trouble. But, I have been forced using paintImmediately when moving units because else it would not repaint until the unit had arrived at the destination. I have this problem that if i move a unit from A to B and there should be several frames in between showing the movement then I the last farme is the only one repainted. I use paintImmediately to solve this and it works fine in single-player. In TCP/IP, my Thread that handles the incoming moves from opponent screw this up somehow. [Edited by - zappsweden on November 24, 2005 8:49:52 AM]
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!