Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (426)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (466)
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 ... 12
1  Discussions / General Discussions / Re: JDK 8 is released on: 2014-03-28 18:22:06
... The JRE is otherwise awesome, if a little overlarge these days. ...
Hopefully this will get a little better when we get Jigsaw and a module-based JRE *glares at Oracle*. Although I haven't heard/read anything about it recently...
2  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL mouse hover and clickable text on: 2014-02-09 08:10:17
An approach that I use and would suggest would be to encapsulate the code related to the different options in their own class. For example a Button class that knows it's position, it's bounds, knows what color it should be, and manages it's own drawing. Then you simply create a Button for each option, position them, and update them as to the location of the mouse (or simply check it's bounds against the mouse position). The Button class can then take care of deciding what color it should be and how to draw itself. Here is a rough sudo-code example to illustrate my point and to show you a couple ways you could implement this:
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  
// Update cycle
for(Button btn : buttons)
   btn.setMouseOver(btn.getBounds().contains(mouseX, mouseY));

//==========================================================//

// Alternative update cycle
for(Button btn : buttons)
   btn.updateMousePos(mouseX, mouseY); // Or whatever method name

updateMousePos(int x, int y) {
   mouseOver = bounds.contains(x,y);
}

//==========================================================//

// Render cycle
for(Button btn : buttons)
   btn.render();

render() {
   if(mouseOver)
      // Set text color one way
  else
      // Set text color the other way

   // Draw text
}


EDIT: As for your question about Color, it looks like you're using Slick2D so you can refer to the javadoc for Slick2D's Color class here. A brief glance looks like you can use the getRed() getGreen() getBlue() and getAlpha() methods to get the RGB components.
3  Discussions / General Discussions / Re: Building UI Components on: 2013-09-04 21:45:34
Regardless of what you're using for rendering, the idea behind a GUI component is the same. For my GUI system (built using LWJGL) I just took a look at Swing and how it's organized (Containers, Components, etc etc) and came up with an idea of how I wanted my system to be structured. I've changed mine a bit since then to better fit my needs and be more generalized but that was the basis. So far I basically have everything be a component, then there are components like a Frame that you can add other components to. I also wrote a mouse/keyboard input system that feeds into the component system for click events and keyboard events. Once you've got a design in your head all you have to do is implement it. For drawing the components all you really have to do is draw some images. For example, I have a top level component that handles loading the GUI's look from an image and then setting things up so that I can tile the different parts of the image to fit any sized component. Then any component that wants to have a GUI can extend the top level one. So a button is just a top level component with text and mouse handling added. Hope that gives you an idea of where to start.
4  Game Development / Newbie & Debugging Questions / Re: OpenGL OS/X, Linux problems on: 2013-08-30 06:07:43
I was planning to try it in VirtualBox. But I expect that it won't work.

Cas Smiley
I tried doing this with Mac OS X 10.6 and the OpenGL drivers are there but they aren't a very recent version, so you might have trouble with that.
5  Discussions / General Discussions / Re: Java games on PC's with no Java? on: 2013-08-25 17:54:21
I recall that launch4j never worked for me because I dont use fat jars
That's odd. I use Launch4j and it works fine with the LWJGL libraries along side the .exe in a libs folder. Are you sure you setup the path right in the jar before you created the .exe?

... snip ...

Lets back up for a moment. Launch4j (suggested earlier) has all of that, you don't need to play around with NSIS scripts, write a custom C++ stub or AOT compile your application. With Launch4j you can configure such that it will use either the local JRE (if it is found) or the packaged JRE.

You don't need to write a C++ stub, albeit it would be incredibly easy and there are probably tons of libraries that allow you to do it more cleanly.
An advantage to writing a C++ stub is that under processes you will see your games name instead of javaw.exe however this doesn't really make a difference to most users. Another might be that you could trim the JVM a little more when using a C++ stub because you don't need the JVM .exe's with a C++ stub and JNI. However I've never tried to slim down a JVM and package it with an .exe using Launch4j.
6  Discussions / General Discussions / Re: What You Do When You are Burnt Out on: 2013-08-17 03:40:36
I don't every really get burnt out on programming, what usually happens is a get burnt out on a project. So I just switch to working on a different project Grin granted jumping from project to project isn't very productive for any one project but it keeps me interested and having fun. However on the rare occasion that I do get burnt out on programming or just don't feel like programming I usually go play a game that someone else made. Playing other games also helps me come up with ideas for the games I'm working on.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL Tutorials 1_1 crash on: 2013-08-17 01:39:04
Hope it works out, and have fun with your new card  Grin I always love getting new parts for my rig, so exciting.
8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGL Tutorials 1_1 crash on: 2013-08-16 05:43:39
Well your drivers are from 2006 and the 7000 series is legacy at this point so I'm not sure that your card actually supports OpenGL 2.0. According to this forum hardware supported OpenGL 2.0 started in the 9000 series.
9  Discussions / Miscellaneous Topics / Re: Blogs? on: 2013-08-14 18:10:46
I hacked together an HTML front-end on my site for a Wordpress blog (love that you can do that by the way). Doesn't really have anything much on it at the moment, but I'm hoping to have more stuff on there in the near future. Your welcome to poke around zman3359.info/blog/
10  Game Development / Shared Code / Re: LWJGL SpriteSheet class on: 2013-08-09 20:50:25
I would suggest not chopping up the sprite sheet and uploading each chunk as a Texture. What I would do instead is simply upload the entire sheet as a texture and then draw only portions of it by using texture coordinates. I would also suggest using Matthias Mann's open source pure-Java PNGDecoder (or one of his other decoders if you don't want to use PNGs) to load your images. Both of these techniques can be read about in mattdesl's Textures tutorial.
11  Discussions / General Discussions / Re: Java SE 6 or 7? on: 2013-08-09 20:34:43
Java 6 it is then.

Now I need to do a bit of hacking around to install Java 6...
I love Arch Linux. Wink

EDIT: Eclipse says I need a compatible JVM for 1.6 compliance. Not sure what that means though. Whether it means Java 7 is compatible and works, or is warning me to install Java 6.
Java 1.7 will work, however the correct practice for compiling towards older bytecode is to use the -source setting for the older version and to set the bootclasspath to compile against the older version of rt.jar. However if you don't point the bootclasspath to the older JDK javac will do it's best to use the old language rules combined with the new libraries which can cause subtle bugs and bytecode that points to code that doesn't exist in the older libraries. (Source for that info) Now since that is just a warning you can probably get away with it and I never experienced any issues. However since I use an ant script to build my projects for actual deployment I just installed the latest JDK 6 build and told my ant script to run using that instead of JDK 1.7.
12  Discussions / General Discussions / Re: Sprite on: 2013-07-21 21:21:17
It sounds like the image is larger than your sprite. Java doesn't care that the sprite only takes up a (for example) 4x4 area of your 8x8 image. What you need to do is make sure that the actual image is the same size as the sprite. To do this simply crop the image to the size of the sprite. You can google how to crop an image in whatever image editor you're using.
13  Game Development / Newbie & Debugging Questions / Re: Moving logic in game loop on: 2013-07-19 19:43:57
I think you should take a look at this tutorial to see some different implementations of game loops and how they work. Then I'd use one of the good loops from that tutorial as an example for a way to structure your game loop.
14  Java Game APIs & Engines / Java 2D / Re: Game loop taking around 30% of CPU on: 2013-07-19 07:07:30
When I was still using Java2D I slept for 1 millisecond at a time until the extra time was used up (I believe it increased the accuracy), then I moved to sleeping for 1 millisecond for 80% of the extra time and then yielding for the rest of the time. I believe I also used aspects from other game loops I've seen here on JGO (sorry if my example includes someones code, I don't have a source) Something like this:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
 // Disclaimer: I haven't looked at this code in a while and it likely isn't the best solution, just an example of what seemed to work for me

 while (running) {
   long start, timePassed;
   start = System.nanoTime();
   // Update until we're caught up (hopefully just once)
  for (int updates = 0; (timePassed = start - lastUpdate) > waitTime && updates < MAX_UPDATES_PER_TICK; updates++) {
      // Update here
     lastUpdate += waitTime;
   }

   // Render

   while ((timePassed = System.nanoTime() - lastUpdate) < waitTime) {
      if (timePassed <= waitTime * 0.8)
         Util.sleep(1);
      else
         Thread.yield();
   }
}


I also used changed a few lines in the Sync class that Riven wrote for LWJGL so that it worked without LWJGL and used that for a while. It seemed to work pretty well. With that you just have to do something like this:
1  
2  
3  
4  
5  
6  
// Really simple example
while (running) {
   // Update
  // Render
  Sync.sync(60) // Or whatever FPS you want
}


EDIT: I forgot to mention that I have since moved to LWJGL and now that I've adjusted to the differences, I love it. I would highly recommend LWJGL if you want to mess around with more low level stuff and do more things yourself, or LibGDx if you want some higher level functionality already implemented for you and access to the low level bits as well.
15  Game Development / Newbie & Debugging Questions / Re: Reading Rar Files From Inside Java. on: 2013-07-10 05:42:47
If you're going to distribute the game at all then it is going to be more trouble than it's worth to try to keep people from changing the looks. My suggestion is to just not worry about keeping people from "modding" your game, and actually make the game Smiley
16  Game Development / Newbie & Debugging Questions / Re: Res Folder on: 2013-07-07 07:33:34
It has a little bit to do with how your project is setup in whatever IDE you're using. It also has to do with how you're loading the images, as some methods do not work in jar files. However as long as the resources are in your classpath (and thus included in your jar file) something like this should load the image both in a jar and simply running it from the class files.
1  
BufferedImage img = ImageIO.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("path/to/image.png");


I set up most of my projects in Eclipse using a top level folder named src that contains a folder for code and a folder for resources. That way both the code and resources get included in the classpath and jar file. Roughly like this:
1  
2  
3  
4  
src
-org.zman.game (code)
-resources
--images
17  Discussions / Miscellaneous Topics / Re: Runescape 3 and HTML5 on: 2013-07-03 20:00:50
There's also the fact that thanks to the way security has been handled, applets are about as welcome in today's browser ecosystem as Ted Nugent at the Lilith Fair.
Nice comparison there Cheesy I don't blame them for moving to HTML5 on that basis and the basis that Applets do suck. It just seemed to me that they were painting the transition as being performance and appearance driven when all of the new features could've been achieved in Java.
18  Discussions / Miscellaneous Topics / Runescape 3 and HTML5 on: 2013-07-03 19:39:08
I was browsing the interwebs this morning and came across RuneScape 3's release date reveal video that talks about what all is new in RS3. One of the first things they stressed was that they're now using HTML5 and that it's providing them with larger draw distances, dynamic shadows, higher resolution textures, and other graphical improvements. Now, correct me if I'm wrong but all of these improvements could've been achieved in Java through LWJGL. It kind of annoys me that they're heralding HTML5 as enabling these things when it can already be done on their current platform. Now since I don't often deal with applets (because they suck) there might be further performance restrictions added by Applets that I'm not aware of. Just thought I'd share Tongue
<a href="http://www.youtube.com/v/Knc_Trx_-5A?version=3&amp;hl=en_US&amp;start=" target="_blank">http://www.youtube.com/v/Knc_Trx_-5A?version=3&amp;hl=en_US&amp;start=</a>
19  Game Development / Newbie & Debugging Questions / Re: File reading for save function on: 2013-06-24 20:06:31
I'd just ignore the possibility that the line is formatted incorrectly. Then simply throw the line into a StringTokenizer and get the 3 ints you need.
1  
2  
3  
4  
5  
StringTokenizer tokenizer = new StringTokenizer(line, ",");
if(tokenizer.countTokens() >= 3) {
   list1.add(Interger.valueOf(tokenizer.nextToken());
   // etc, etc.
}


You could also take the approach of ensuring that each int is what you want, then just parsing out the ints. This is, in my opinion, a waste as you're unlikely to want to edit large maps by hand.
1  
2  
// Text file
x=0 y=595 id=1


Or, if you want to save space on map sizes you could just read/write integers to the file in sets of three. First three integers are a block and so on.
20  Discussions / Miscellaneous Topics / Re: Yippieeee! Got my new Graphic card! on: 2013-06-18 23:00:50
MSI R7870 Hawk (which is a Radeon HD 7870)
21  Game Development / Newbie & Debugging Questions / Re: Eclipse Messing Up Packages on: 2013-06-13 04:33:57
Eclipse will colapse packages if there is nothing in them because each part of a package is just a folder. So if your main package is com.zman.project and you have a class in the project folder, you will see a com.zman.project package listed in Eclipse. Now if you create com.zman.project.world.items and put a class in items, but not in world you will only see com.zman.project.world.items and no com.zman.project.world. Once you add a class to com.zman.project.world you will see that package displayed. You can also add subpackages by just adding a new package and entering the full name. For example if I want to create an entities package in com.zman.project.world I would just open up the new package dialog and type in com.zman.project.world.entities. You can also specify the package when creating a new class if the package you want it to go into is not currently being displayed by Eclipse.
22  Discussions / General Discussions / Re: Medals? on: 2013-06-12 20:07:47
Those are silly statistics that Riven came up with, if you're referring to your rank (JGO Wizard, Senior Member, Senior Noob, etc.) that is calculated based on (I think) the number of posts you've made, the number of medals you have, and the number of projects you have. Maybe some other things as well, I can't recall.
23  Game Development / Newbie & Debugging Questions / Re: Obfuscating code, and references to Java standard APIs on: 2013-06-12 19:58:44
Bugger.  Sad

I am building in statistical checks on the server to discard outlier results, and also the ability to query and bulk delete results if needed. And there will be a cap on the frequency of submissions from any given IP.
Maybe the calculus should be made on server-side ?
I don't know that this would help, then hackers would just fake the data being sent to the Server for calculations.
24  Game Development / Newbie & Debugging Questions / Re: How to load my image on: 2013-06-10 22:20:56
For smooth movement you should just use a Game Loop (take a look at this article about them) instead of only drawing when you receive user input. Just update the ship location when you get input and only draw in your game loop.
25  Game Development / Newbie & Debugging Questions / Re: How to load my image on: 2013-06-10 20:38:29
Stop sending a width and height of 5 to the drawImage() method. You're using drawImage(Image img, int x, int y, int width, int height, ImageObserver io) when all you really need is drawImage(Image img, int x, int y, ImageObserver io). Again, check the JavaDocs for stuff like this or when you aren't sure how something works.
26  Game Development / Newbie & Debugging Questions / Re: How to load my image on: 2013-06-10 20:29:26
I think it might have to do with the way you're loading your image. Using ImageIO instead of the Toolkit's getImage() fixed it for me. Try this instead:
1  
2  
3  
4  
5  
try {
   ship = ImageIO.read(getClass().getResource("images/spaceship.png");
} catch(IOException exc) {
   exc.printStackTrace();
}


EDIT: Also there isn't really a point in overriding a JFrame and a JPanel. You're better off only overriding a JPanel and then adding it to a frame. Something like this:
1  
2  
3  
4  
5  
6  
7  
JFrame frame = new JFrame("Title");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MyPanel panel = new MyPanel();
panel.setPreferredSize(new Dimension(600,600));
frame.add(panel);
frame.pack();
frame.setVisible(true);
27  Game Development / Newbie & Debugging Questions / Re: Cannot run my program on: 2013-06-10 20:18:34
it does not seem like you have a jframe to put the panel on. a jpanel is like a layer that goes ontop of a jframe while the jframe is the actual window that pops up. just read up on jframes and jpanels. btw just extending jframe wont work
His code works just fine (besides not opening), although it might not be the optimal way.

You're overriding addNotfiy() (which is kind of an important method, check the java docs) and having it to do nothing. This should fix it:
1  
2  
3  
public void addNotify() {
   super.addNotify();
}
28  Game Development / Newbie & Debugging Questions / Re: [Networking] (Client) Unique User Identification Number on: 2013-06-03 07:51:37
It might work, but switching object identifiers in a running program is not a good idea. Bad for consistency, understanding, debugging, etc.
Uniqe identifiers and list indexes are two things and should not be mixed up.

This. If you want unique IDs then don't change them in the middle of execution Tongue I'd go with ra4king suggestion of assigning each client an ID on connecting (0, 1, 2, 3, etc.) then when someone leaves their ID gets added to a sorted list that you can pull from the next time somebody connects.
29  Discussions / General Discussions / Re: Migration to more modern forum? on: 2013-06-02 04:32:25
There are plenty of sites with MUCH worse aesthetics than JGO. JGO has a simple look that functions well. Besides, I'm sure Riven has put more than a few hours into rooting around in the belly of the beast that is SMF in order to bring us nice features. So there isn't any point in throwing all that hard work (and frustration) away.
30  Discussions / Miscellaneous Topics / Re: Moving to Linux... on: 2013-05-28 01:47:27
thnx everyone,
i really like the new system, it's a LOT more faster than windows7, specially when it starts ,i think this is because windows execute many programs and services,
for now i spend more than one hour playing around and checking stuff here there, i managed to use the internet (i have a HUWAEI 3g Key so it wasn't that obvious)
am having a very nice impression about this new System, but i only have a small little issue,
my graphic card is not installed, i have an nVidia 610M (am using a laptop) and the weird thing is on Ubuntu the pc make much more noise, it must be the graphic card's fan, is it because it's not installed ??
It's likely that your GPU's fans are running at 100% speed all the time since there is no driver to interface with them correctly and determine a better speed. I, for example, have a custom fan curve set for GPU that causes the fan to rev up when the card gets hotter.

EDIT: As to fixing this, I think installing the proprietary drivers worked for me. I have a Radeon card though.
Pages: [1] 2 3 ... 12
 

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

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (75 views)
2014-04-15 18:08:23

BurntPizza (68 views)
2014-04-15 03:46:01

UprightPath (80 views)
2014-04-14 17:39:50

UprightPath (65 views)
2014-04-14 17:35:47

Porlus (81 views)
2014-04-14 15:48:38

tom_mai78101 (105 views)
2014-04-10 04:04:31

BurntPizza (165 views)
2014-04-08 23:06:04

tom_mai78101 (261 views)
2014-04-05 13:34:39

trollwarrior1 (210 views)
2014-04-04 12:06:45

CJLetsGame (220 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!