Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (688)
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  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-11-20 14:59:19
You misunderestimate our flood defences... Sad

I'll just show myself out now. Wink
2  Discussions / General Discussions / Re: Looking for a good book to learn C on: 2015-10-29 20:02:41
The C Programming Language - Still considered one of the best books on C.
The C++ Programming Language - Another "best of" books for C++.
3  Game Development / Newbie & Debugging Questions / Re: Better way to store a massive amount of variables on: 2015-09-04 14:16:41
I just want to find a way to easily declare a variable that will be accessed only once per instance without the clutter and mess of those getter and setter functions. This is kind of a noob question, but there has to be a more dynamic way, right?

Why would you think added complexity would be a better option. Set aside your sense of aesthetics when it comes to the code in the IDE and realize that the compiled code is what's important. Adding extra operations to the processors workload to make things prettier in the editor isn't really a great trade-off. Depending on the application, the extra overhead may not make much of a difference, but you still need to consider that someone other than you may potentially have to maintain the code somewhere down the line. I'm sure they won't be a fan of added complexity either. Wink

There are multiple better ways to approach this. Netbeans, the IDE I use, has built in functionality to generate standard getters and setters with just a few clicks of the mouse. I can't imagine it's unique in this respect. Code can also be "collapsed" in the IDE reducing visual clutter considerably. There are also numerous "beautification" tools to handle code formatting.

The old school approach is to just make variables public when it makes sense and get rid of un-needed getters and setters. I always go with the rule of thumb that unless I'm doing some sort of extra processing when a value is assigned to a variable in my class (such as setting other dependent variables or performing sanity checks), it's safe to have the variable public. There is no practical difference in encapsulation between this:
public class MyClass {
    protected int foo;

    public void setFoo(int foo) { = foo; }
    public int getFoo() { return; }

and this:
public class MyClass {
    public int foo;

(Just saw you posted this)
Unfortunately the company insists on using private variables and this is a "payload" class containing any relevant variable to the web application we are working on.
Just go with refactoring tools then. Let the IDE do the work instead of typing out getters and setters by hand. Pointing
4  Game Development / Newbie & Debugging Questions / Re: Frame moving to a higher resolution screen issues. on: 2015-09-01 02:14:49
Where'd you guys get resizing from?
Probably from your description of the frame getting "scaled up four times" in your original post. Can you post a before and after shot of the window so that we're all on the same page?
5  Game Development / Newbie & Debugging Questions / Re: Frame moving to a higher resolution screen issues. on: 2015-08-31 16:13:17
To fill out the suggestion made by @KevinWorkman, add a component listener to your frame and capture the resize event. From there you should be able to resize your buffer and be back on track. This also avoids having to grab the graphics object every iteration of your game loop.
6  Game Development / Newbie & Debugging Questions / Re: Handling curves in a platformer? on: 2015-07-22 14:33:07
I believe this is the tutorial @KevinWorkman was referring to. Good stuff indeed. Cool
7  Game Development / Newbie & Debugging Questions / Re: Self-cert Java Applet Issues on: 2015-06-09 17:27:01
For my purposes, I would like the application to be playable in the browser. You say that I can use libraries to convert my application to HTML/JavaScript - are you suggesting that I learn LibGDX and manually "re-implement" the entirety of my game into that framework, or are you saying that there exists some library (which?) that will take my Slick + LWJGL + Kryonet stuff and convert that into runnable HTML/JavaScript code for deployment?

I can't say for certain what libraries are out there that could possibly be used to convert a lwjgl+Kryonet+Slick application to a HTML/JavaScript based web package without modification (if any). As far as the porting your existing code goes, LibGDX uses lwjgl under the hood and seems to play well with Kryonet so those two items would most likely require the least amount of changes to integrate. The bigger issue would most likely be with going from Slick2D to LibGDX calls since they're alternate ways of doing similar things as opposed to complimentary technologies that work directly together to achieve an outcome.

As I said earlier, you could probably go the route of using a certificate from a trusted CA, but you've still got the missing permissions issue to straighten out before taking that step. Both approaches have their advantages and disadvantages, but gut feeling tells me that even signed applets are going to go away sooner or later so it would probably be a good idea to get familiar with the other alternatives if making browser based games is your long term goal.

8  Game Development / Newbie & Debugging Questions / Re: Self-cert Java Applet Issues on: 2015-06-09 16:07:06
The weirdest thing for me is that the exact same zip of everything runs in my browser locally, but after downloading it and running it from a website I am hit with this error.

Different security restrictions apply to applications launched from the web (highly restricted) compared to applications launched from your local machine (no restrictions). Java will try to protect you from unanticipated maliciousness such as applets launched through your web browser from unknown sources, but is perfectly content to let you shoot yourself in the foot with local code. (You knew the gun was loaded when you picked it up, why are your missing toes our responsibility?)

Also curious if purchasing a digital jar signing certificate would solve this issue.

Possibly, but this article from Oracle pretty much covers the situation you're experiencing now. From the link:
Quote from: Oracle
Java has further enhanced security to make the user system less vulnerable to external exploits. Starting with Java 7 Update 51, Java does not allow users to run applications that are not signed (unsigned), self-signed (not signed by trusted authority) or that are missing permission attributes.
I would try to suss out the initial "missing permissions" issue before considering purchasing a certificate.

As Mac70 points out, Applets are pretty much a dying aspect of Java because of security risks. You can still use libraries to convert your Java application to HTML/JavaScript for deployment, or just distribute your application as a self contained package that users extract/install and run from their local machine like many other widely used languages.
9  Discussions / General Discussions / Re: Programmer jokes on: 2015-05-29 20:00:14
Not exactly programming, but still pretty descriptive of my mindset when I approach a new problem:

A physicist, a mathematician, and an engineer were asked to establish the volume of a metal sphere. The physicist immersed it in a beaker full of water and measured the volume of the displaced fluid. The mathematician measured the diameter and calculated the volume as a triple integral. The engineer went to the vendor's website and found the spec sheet.
10  Discussions / General Discussions / Re: Rayvolution's JGO Appreciation Thread (AKA: Free copies of Retro-Pixel Castles!) on: 2015-05-27 16:34:26
I definitely wouldn't mind getting a copy of RPC to try, please and thank you. Smiley
11  Java Game APIs & Engines / Java 2D / Re: Mirroring Isometric image on: 2015-05-14 15:06:04
@jonjava is correct. This should do the trick:

g2.drawImage(sprite, sprite_x + sprite_width, sprite_y, -sprite_width, sprite_height, panel);

The "sprite_x + sprite_width" is there to move the sprite back into the correct position since drawing it with a negative width will shift it to the left.
12  Game Development / Newbie & Debugging Questions / Re: [Nope, not fixed] ArrayList remove() problem on: 2015-05-06 17:15:13
Have you tried using an iterator? It works wonders for me, although I don't think its the fastest way of doing this.

Indeed, this is a valid solution so long as all removals are done using the iterator's remove method (as illustrated in your example). As for efficiency when doing sequential accesses, iterators are generally the better choice vs index based lookups when using a list as the underlying data structure. Wink
13  Game Development / Newbie & Debugging Questions / Re: [Nope, not fixed] ArrayList remove() problem on: 2015-05-06 14:17:12
The exception shows the exact issue: " java.lang.IndexOutOfBoundsException: Index: 2, Size: 2". Maximum valid index for a list with a size of 2 elements is 1.

...will still cause the index exception since you're attempting to "get" an element at an invalid index.

Until you understand what's actually causing the issue, applying fixes blindly isn't going to help. persecutioncomplex
14  Game Development / Newbie & Debugging Questions / Re: ArrayList remove() problem on: 2015-05-06 14:05:17
The bigger issue is that when you're removing items from a list in this manner, you're going to end up skipping an element when an element is removed. You should walk the list backwards. This will correct the index out of bounds error.

Think about it this way. You have a list of 3 items. You set your loop counter to go from 0-2 (the size of your list) at the start. In the first pass, you remove an element. Suddenly, you've changed the valid index range of your list from 0-2 to 0-1. Unfortunately your counter variable in the loop doesn't recognize this change, and will happily keep going until it hits the now invalid index of 2.

Now reverse the scenario and set your loop counter to the size of the list-1 (2) at the start. On your first pass, you're loop removes an element from the list which leaves your valid index range at 0-1. Unlike the previous scenario, on the next pass, the loop counter will equal 1 which is still a valid index.

It's a small gotcha that can cause quite a bit of frustration if you've never encountered it before. The other issue may still persist (didn't have that much time to investigate), but it will get rid of the exception at least. Wink
15  Game Development / Networking & Multiplayer / Re: How to properly close a socket when program terminates? on: 2015-05-02 23:38:23
According to some research, the timeout period of a socket can vary by implementation, so if you want consistency, set the value.
16  Game Development / Networking & Multiplayer / Re: How to properly close a socket when program terminates? on: 2015-05-02 22:49:47
Personally, I'd say just go with the "classic" form of the try/catch block for that section of code. That gives you the option of using the parameterless version of ServerSocket's constructor which would then allow you to set the reuse address flag before binding the socket. The try with resources form of try/catch can be useful in many situations, but if you find it being more of a hindrance than a help in a situation, don't be afraid to use the alternate form. I wouldn't advise trying to call any further methods on a socket that's been put into an exception state, including close.

Addendum: As for what happens when the server is closed down, the socket will be cleaned up by the JVM as it's exiting. The connected clients, if any, will throw exceptions on their side.
17  Game Development / Newbie & Debugging Questions / Re: Create a "2D" game, with 3D characters on: 2015-04-14 12:54:14
Just render 3D models to 2D images then use those images in your game. There are limitations to the approach, but that's how it's generally done.
18  Game Development / Game Play & Game Design / Re: Theming Custom Game GUI Components on: 2015-04-14 00:01:51
MVC/MVP pattern is indeed sound advice. I've kept the controller separate from the other two aspects; however, I  muxed the view and model together. I may consider breaking them apart at some point, but since I don't foresee the scope of the projects I currently have in mind going beyond the functionality of Slick, it will probably be a while before I get motivated enough to do it.

Since I've managed to work out the last of the current, apparent bugs in the approach I threw together, I think I'll go with the "if it works use it" philosophy. I appreciate the input. Cheers! Grin
19  Game Development / Game Play & Game Design / Re: Theming Custom Game GUI Components on: 2015-04-13 17:03:01
I probably didn't explain what I was looking for clearly. It's less to do with how to develop a consistent style, and more to do with how to propagate the style through code with the least amount of work needed.

Essentially what I am looking for is a way to override the default properties for all instances of a control in my library without the need to modify the the library itself when a new look is needed. Pretty much the same concept as how CSS applies styles to a web page without changing the actual structure of the page, or more precisely how Swing can take a look and feel and have all controls inherit the theme.

I've managed to cobble together a solution that involved adding a few static methods and a static ArrayList to my base class. Basically the methods allow me to assign (a) "styler" class(es) to the base class that gets invoked whenever an instance of the base control is created. I'm then able to set basic properties from there. I'm sure there's some sort of "bad practice" involved in my approach, but it seems to be working for the most part with the exception of a minor bug that I'm looking into. persecutioncomplex

I'm still open to alternatives other than the implementation I have at the moment. I figure there must be something out there a bit more elegant than the one I brainstormed. Pointing
20  Discussions / General Discussions / Re: Legality of Retro-Engineered clients on: 2015-04-11 20:42:44
Using the default graphics, sounds, or music from Minecraft would be copyright infringement, no question, though

Using isn't the issue. Distributing is. That's why some open source game clones mitigate the issue by requiring that a copy of the original game is installed on the users hard drive. See CorisxTH (a clone of Theme Hospital) for an example.

Beyond that, server operators are definitely where you'll find the most resistance. As others have noted, an alternate client would be viewed as a potential cheat or hack by most official servers. Sometimes the court of public opinion is worse than the court of law. persecutioncomplex
21  Game Development / Game Play & Game Design / [Solved] Theming Custom Game GUI Components on: 2015-04-10 20:54:24
After quite a bit of tinkering around, I've finally gotten my 2D scene graph/controls to satisfactory point in regards to functionality. Now I'm trying to come up with a way to theme everything in a consistent way. For the moment I have to set individual properties on each control such as background color, foreground color, borders, etc. Ideally I'd like to set a basic theme and have that style applied to my controls when they're created similar to what Swing does with the L&F/componentui framework.

The controls have been developed to work with Slick2D and all of them inherit from a base control class that contains a majority of the appearance based variables. I've thought about using something like the builder or factory pattern, but I really don't want to have to write a new builder/factory for each type of control. I've also considered making a "themer" class that I can pass a component to after it's created, but that seems a bit cumbersome as well.

Has anybody had experience with this issue who can offer some suggestions for the best way to approach this? While it's not critical, it would certainly save me a lot of time when putting together an interface as well as cut down on the LOC I have to look through when developing other parts of my project. Any help would be greatly appreciated. Smiley
22  Game Development / Newbie & Debugging Questions / Re: Running jar files on Linux on: 2015-04-06 13:50:03
My assumptions woiuld be something related to openGL, I'm using a recycled Lenovo ThinkPad x230i. When this computer was running windows I would have no problems executing the file.

I installed the JDK via Oracle website and downloaded the .rpm. I did not use the terminal to install it. I'm not sure if there is a difference.

You can assume that the system is finding Java correctly due to the exceptions emanating from Java instead of being a standard shell exception.

Looking at the first part of your post, it would appear that the application can't find the shared object files (.so files are equivalent to .dll files in Windows) for LibGDX. Did you make sure to copy the appropriate .so files to somewhere in your applications class path? As a test, try putting them in the same folder as your .jar file and seeing if that alleviates the issue.

As for OpenGL being the source of the issue, the first error is related to audio, not video. The second error isn't quite as specific, but my guess is that it's something related to Copying the files as suggested in the last paragraph may alleviate this issue as well. Post the results and if you're still stuck, somebody around here should be able to get you over the hump. Smiley
23  Java Game APIs & Engines / Java 2D / Re: RadialGradientPaint problem on: 2015-04-03 16:05:00
If you're going to have multiple light sources, then you may want to consider creating a RGBA buffered image that's the same size as your view and initially filled with black. When you want to add a light source, paint it onto the buffered image using your gradient paint. Once you've finished drawing your lights, apply the buffered image to the whole scene. As a bonus, you can change the alpha/color of the buffered image to achieve "time of day" lighting type effects. If that's already the direction you were headed in, then carry on. It's a pretty simple yet effective way to approach lighting for 2D.

Cheers. Smiley
24  Java Game APIs & Engines / Java 2D / Re: RadialGradientPaint problem on: 2015-04-03 14:29:21
RadialGradientPaint takes a bit of getting used to. Assuming that the code you posted is in your paint method, try changing it to the following:
RadialGradientPaint whiteToBlack = new RadialGradientPaint(
    this.width/2,  //  x centre
    this.height/2,  //  y centre
    50,  //  radius of fill
    new float[] { 0.0f, 1.0f },   //  start position of each color
    new Color[] { new Color(1f, 1f, 1f, 0f), Color.BLACK }, //  the colors

lightG.setPaint( whiteToBlack );

//  draw in the centre of the screen, a 100x100 pixel oval
lightG.fillOval(this.width/2-50, this.height/2-50, 100, 100);

The first two parameters to radial gradient paint define an absolute position of where your start color appears in your viewport, it's not relative to the position of the shape being filled. The implication is that you'll have to recompute the x and y center of the gradient whenever your game's resolution changes, but that shouldn't be too difficult to work around.

One other thing. Assuming you're going for a 2D lighting effect around your character, use fillRect(...)  to fill the entire viewport instead of fillOval(...). You'll still get a nice, round, gradient cutout at the center of the viewport with the rest being filled by your end color. If you're going for a different effect, you can disregard the last part. Pointing

Hope this helps.
25  Game Development / Newbie & Debugging Questions / Re: Capturing - arrow keys and letters on: 2015-03-30 21:59:09
You were correct, you can't...

Oops, my bad on that one. That's what I get for trying to juggle too many things at once when I answered earlier. Pointing Apologies.
26  Game Development / Newbie & Debugging Questions / Re: Capturing - arrow keys and letters on: 2015-03-30 17:54:49
The problem with the workaround described by Kev is that I'm trying to keep track of the order in which the keys are pressed so when the user releases a key the character movement reverts back to the direction of the last-held-down key.

In that case, then my only suggestion would be to use an ArrayList<byte> instead of a byte[] as the basis for your input stack. In your controller class you can simplify things a bit:
public void addMovementKeyFlag(byte direction) {
    //  first, check if key is already being held down
    //  this should never happen but good to check anyway        
    if(!this.movementKeys.contains(direction)) {
        this.movementKeys.add(0, direction);

You're not going to be able to get around the checks, but it's not a huge issue. The impact on performance should be minuscule assuming that you're only capturing a few keys, 4 in your case, on the stack. Smiley

Out of curiosity, how are you handling the removal of a key(s) from the stack? Say I was pressing left, then pressed up, then released left before releasing up. What would be the state of the input stack after finally releasing the up button?
27  Game Development / Newbie & Debugging Questions / Re: Capturing - arrow keys and letters on: 2015-03-30 16:27:13
That's strange then, I wonder if it's a "feature" of my keyboard or something lol.

It's an OS thing. You'll get different patterns of repeat/no repeat between Windows and Linux (can't speak for OSX...never used it). Google has all sorts of information/workarounds if desired. KevinWorkman has suggested a good approach and it's the same one I'd recommend. It's tried and true and makes things consistent across the board. Smiley
28  Game Development / Game Mechanics / Re: Making my GUI right on: 2015-03-30 16:13:10
Sorry about the late reply. It was the wife's birthday this weekend, so I didn't have much of a chance to get online.

My controls all inherit off of a "BaseControl" class that holds common information/functionality that all controls need. In cases where a control needs special functionality, I just add the new methods/variables into a class that inherits from the base control without any sort of nested class. The "BaseControl" class contains a reference to a parent "BaseControl", so in your scenario, my approach is as follows:

1) The input event is routed down the graph and dispatched to the appropriate control.
2) From the control's handler for the event, I reference the "parent" variable. If I need a "grandparent", "great grandparent", etc, I can keep calling the get parent method on the returned reference to walk up the graph.
3) The parent (or grandparent) can then be cast to a specific control class allowing the handler to call the methods of the parent class directly.

The downside to this is that you have to be aware of where a control is in your tree structure or do some extra checking when walking the tree. In practice, I have some helper methods in the base control class that allow me to reference controls by name, so if I need a specific ancestor control, I can grab a direct reference to it without much hassle.

For an apples to apples comparison, my method to accomplish the task that your code does would look like the following:
MyControl.addExtendedInputListener(new ExtendedInputListener() {
    public void mouseClicked(int button, int x, int y, int clickCount) {
   // getParent called multiple times to get to the appropriate level.

There's nothing inherently wrong with your approach, it's just different than the way I chose to tackle the issue. In certain scenarios, your approach has advantages over mine, and vice versa. I would say keep going with the way you've been doing it and don't worry too much about the "circle of communication" issue. I can't think of a sane scenario where it would present any sort of real hurdle. Smiley
29  Game Development / Game Mechanics / Re: Making my GUI right on: 2015-03-29 02:05:34
Essentially what you're talking about is a scene graph. Your "another solution" that uses callbacks is the way I approach GUI interaction in my applications. It has its disadvantages, but it's a fairly sane approach. You're still in good shape in regards to the MVC pattern if you consider your visual element as your view and your callback as your controller. At worst you've created a loose coupling.

When it comes to games, if it works for you and you can grep what's going on, it's good enough. It's a far different beast than writing libraries for others or "mission critical" systems. Wink
30  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-02-19 16:53:34
Working on creating a custom control for one of the guys in our transportation division. (Warning: 2.3mb gif file.)

Click to Play

When it's finished, it will be used to provide a visual representation of curent shipment locations using tracking information provided by the shipping companies. Unfortunately, I'm still waiting for them to get back to me with some details.

For now it's pretty much eye candy. Its looks can be customized and it supports auto rotation/rotation via mouse drag. Built using "old school" visual trickery in Java2D mostly to prove to a manager that it could be done. Not a 100% perfect effect, but good enough for its intended purpose.

Since it's a slow day at the office I think I'll tie it to a METAR parser I've been developing and turn it into a weather widget while I have some idle time. I love my job most days. Pointing
Pages: [1] 2 3 ... 11
Dwinin (74 views)
2015-11-07 13:29:08

Rems19 (81 views)
2015-10-31 01:36:56

Rems19 (79 views)
2015-10-31 01:32:37

williamwoles (107 views)
2015-10-23 10:42:59

williamwoles (93 views)
2015-10-23 10:42:45

Jervac_ (111 views)
2015-10-18 23:29:12

DarkCart (137 views)
2015-10-16 00:58:11

KaiHH (118 views)
2015-10-11 14:10:14

KaiHH (158 views)
2015-10-11 13:26:18

BurntPizza (173 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 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‑
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!