Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
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
1  Game Development / Performance Tuning / Re: Taming Java GC to prevent stutter, an in-depth post on memory management on: 2014-04-24 20:15:54
Here is some code that is actually triggering the escape analysis to enable scalar replacement:
(after warming the VM... waiting for the performance to peak, averaging the results of a few runs...)
...
So, yeah, it works... but it's rare to the point of being damn lucky to see it in a real-world case.

Well good to know, I tend to make a fool of myself when I mention my experiences without researching first Tongue
2  Game Development / Performance Tuning / Re: Taming Java GC to prevent stutter, an in-depth post on memory management on: 2014-04-24 12:50:22
On the subject of escape analysis... I am becoming sceptical that it is working at all.

From my limited experience with the sun/oracle vm, I believe you are correct.  There's plenty of talk on the internet about escape analysis and the JVM, but I don't think there's much of anything actually implemented in the JVM. (i.e. it's mostly speculative hype Cranky).
I'd been annoyed lately that I had previously wrote a good chunk of my collision detection code to take floats, but this thread is a good reminder that it was probably a good way to design it.

I've experimented with OpenCL and on my computer (3GHz Athlon II, GTS 450) it's often faster to send large chunks of calculates to the GPU then wait around for the CPU to run them (of course there's the extra work of having to write an OpenCL program to model your calculations, but it's often worth it for performance critical sections of code).
Especially calculations involving trig and vector or matrix operations where Java's strict IEEE 754 compliance tends to hurt performance without benefiting game oriented data that can accept non-IEEE exact floating-point results.

There's a basic tutorial on LWJGL.org's wiki about OpenCL: http://lwjgl.org/wiki/index.php?title=OpenCL_in_LWJGL
3  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Scene2D, utter tedious on: 2014-04-17 14:49:50
:scratches-head: are we talking about the 23 lines of code in the OP because basic Swing GUIs I've worked have required 400-600 lines of code just to get a few buttons and text boxes aligned and properly resizing.
You can always make a utility class to create basic menus for you if your menus always consist of a few buttons in the same positions.
4  Game Development / Newbie & Debugging Questions / Re: Scaling my games? Performance loss? on: 2014-04-16 02:57:33
Monitors are generally becoming wider.  Most monitors these days fall somewhere in the range: 1024x768 (old desktops), 1280x720 (older laptops and tablets), to 1920x1080 (modern monitors, TVs, laptops).

When your application starts, check the resolution of your program's window (not screen size since some users may run the application in windowed mode).  Calculate the width/height ratio.
Assuming you have a 1920x1080 (16:9) texture to work with and you detect a monitor resolution ratio of 1.77+-10%, then create a 16:9 background image/texture.
If the monitor resolution ratio is 1.33+-10%, then create a 4:3 background image using only the central portion of the image.
Else check if the resolution ratio is some other popular ratio, else check another ratio, etc...

In other words, for a 4:3 window, only use the central 1440x1080 portion of your texture and create a sprite to match the width and height of the window.  If you are using a orthogonal view matrix, create a quad that has corners at -1,-1; -1,1; 1,-1; 1,1; (I don't remember, is [-1,1] standard OpenGL orthogonal matrix corners? I haven't worked with orthogonal matrices lately).

Then just let the graphics card scale the image down to the size of the window it is drawing in.  As long as you have the ratio relatively correct and use the right scaling parameters on the texture, the graphic card will do a pretty good job of scaling the image.

As you mentioned, if you are scaling a small image up, you will still have to clip some portion of it, either the top and bottom edges if the window has a much wider aspect ratio than the image, or the left and right edges if the window has a much narrower aspect ratio than the image.

This is the solution I've seen in a number of 2D games when I change the resolution/resize the window.  Granted this means that people with older monitors will not see the left and right edges of your beautiful backgrounds, but you can compensate for this by making the left and right edges something unimportant like some shrubbery or the continuation of a castle wall, or some mountains, etc.

In regards to performance, I wouldn't take the drop from 4,000 fps to 2,000 fps too seriously.  Most frame rates over 600-800 act very erratically in my experience.
A frame rate of 2,000 is once every 0.5 milliseconds!  A single frame involves hundreds of thousands to tens of millions of mathematical operations (a 1080p display has 2 million pixels!).
Small changes in the type of data being processed, such as a switch from geometry heavy environments to texture heavy environments can make huge changes in GPU memory access patterns, caching, parallelization, etc.

I've seen strange fps gains/loses in my own programs at high (+1,000) fps.  However, once you start adding multiple textures, geometry involving thousands of vertices, etc. these types of fluctuations tend to even out around 600-800 fps and adding X percent more objects on screen starts translating to equivalent performance drops.

*note these observations are on my own PC and are not conclusive benchmarks or cited facts of any kind Wink
5  Discussions / Business and Project Management Discussions / Re: [PAID] Searching for a programming instructor. on: 2014-04-15 15:35:13
I can agree with Grunnt, reading books and tutorials and learning that way is effective (you thoroughly understand the code you write), but it is not efficient.
Looking back on my experience learning OpenGL 1.1 and then realizing the programmable pipeline and OpenGL 2+ existed was not efficient.  I spent many months of evenings and weekends trying to learn basic things and fix basic issues that could have been explained to me in much less time.

Don't rediscover the laws of physics, just to reinvent the wheel, just to create a basic cart.  If want a basic cart, go buy a cart or ask someone to make one for you or help show you how to make one.

If a guy is willing to pay for tutelage than more power to him.  He has the foresight to understand that graphics programming is a complex maze of topics that can be efficiently learned through teaching.
I enjoy helping people learn Smiley (served as a tutor at university), but I don't think I am knowledgeable enough in the particular topics the OP is looking for (tile systems, possibly shaders, animation, etc).
6  Game Development / Newbie & Debugging Questions / Re: Almost Completely Static Class Design on: 2014-04-09 22:31:40
^Yes, possibly for lazy creation (use inner enum pattern to protect multi-threaded application).

You will never need to pass it in as an argument anywhere since any class can just fetch the instance through getInstance() so there's no need for it to be an object in the first place.

Singleton.getInstance() is easier to modify at runtime than Singleton.  In particular if the class handles something OS related (graphics, sound, user input) then being able to return different objects from Singleton.getInstance() when the program runs in a different environment is quite useful.
Using Singleton as a static class means we are assuming that it will not need to be changed or replaced, which, from programming experience, tends to be a bad assumption.

A good example in Java is FileSystem.getFileSystem() (package-private class in java.io) which just returns a file system handle.  However, underneath different file systems can be returned depending on the OS.
7  Discussions / General Discussions / Re: Libraries You Wish For on: 2014-04-06 22:36:50
The Properties class definitely gets me most of the way there, but it's still annoying to try and save for example a Color preference.

You ever try Preferences?
Good to know.

Yes, this thread ended up being a little broad, I was specifically wondering what types of libraries people wanted, but could not find.  Maybe most commonly needed library have already been developed, or maybe we don't know what we're missing until it gets developed.  Anyway, the focus was to talk about what does not exist currently, not things that did not exist previously, but does now  Smiley
8  Discussions / General Discussions / Re: Libraries You Wish For on: 2014-04-06 15:30:30
The example boiler plate code can easily be solved with a utility class.

I think my most common time sink that I wish was simpler is saving and load basic properties.  The Properties class definitely gets me most of the way there, but it's still annoying to try and save for example a Color preference.
One or two lines of code to convert the color to an integer or hex string, then another two or three lines to read it back and convert it to an integer and then to a color.  You end up with a lot of boiler plate code to support property types other than strings (file paths, floats, integers, colors, etc).

Princec, yes, I've been reading Effective Java and the last chapter of the book is about serialization and there are so many issues with just marking a class serializable: compatibility, injection attacks, security, etc.  Serialization is definitely a poorly implemented language feature; to do it properly you need to add read and write methods and do all of the serialization processing yourself.
9  Discussions / General Discussions / Libraries You Wish For on: 2014-04-05 01:59:21
I've seen a number of projects, libraries, and utilities pop up on this forum with varying degrees of adoption and acclaim.  Other than texture atlas/sprite sheet loading and manipulation and princec's interest in memory manipulation/mapped objects, I haven't seen many specific recurring complains about non-existent libraries.
Are most of JGO's family members happy with the tools and features available for Java game development?

Your problem could lie with the core Java libraries, or maybe OpenGL or lwjgl, or some pattern that you frequently encounter in your coding.
I'm sure some of you have at some point been annoyed at having to open a file reader with:
1  
new BufferedReader(new InputStreamReader(new FileInputStream(file)));

or at having to type:
1  
Map.Entry<Abc, Xyz> entry = new AbstractMap.SimpleImmutableEntry(a, x);

just to create an entry to store in some collection and wished for an Entry class in Java.

The example boiler plate code can easily be solved with a utility class.  Is there a specific library or functionality that you wish existed in Java, but you can't find anywhere online.  Maybe it's related to logging, or the Java collections framework, or OpenGL's state based nature, or serialization?

Please post, discuss, share your problems/solutions Smiley
10  Discussions / General Discussions / Re: The Big Linux Distro Thread on: 2014-04-03 16:22:16
You are right, I forgot about tab completion, that does solve my issue of mistyping stuff.  I agree, user's should have to learn config file formats, but depending on the distro and your preferences, I've found that application menus don't always contain the options I'm looking for, so I can only assume that the advanced settings are in some config file somewhere.

Also, I've noticed the same strange mouse behaviors on all linux distros I've tried, feels very sloppy.
I have never seen "strange mouse behaviors" on any Linux system I've used in the past five years. This isn't a real issue.

I don't know that it's not a real issue, princec mentioned it and I've seen it.  It may not be a universal issue, but it is real.  It might be a graphics driver issue, idk, which is another thing Linux doesn't tend to have great support for.  The shell has always been smooth in my experience (better than a windows shell), but distros with desktops tend to be far more laggy than Windows Clueless
11  Discussions / General Discussions / Re: The Big Linux Distro Thread on: 2014-04-03 14:28:52
Quote from: gene9
- The shell. A great shell is central for developers and science/engineering types. Windows cmd.exe is absolutely horrible. Microsoft tried to one-up the UNIX shell people with PowerShell, but it sucks and only appeals to the ultra-Microsoft types. Most of the Java ecosystem is designed for shell use. You should be using the shell for your primary build with a tool like Gradle or SBT (Maven is the dominant tool but it is not as good). You should be using the shell for git. You should use the shell for browsing files. Also Matlab/Octave/R/Python/Ruby work all are designed to be run in shells. Macs do have the same high quality shells that Linux does, but Windows is terrible for shell use.
I like the Linux shell, it's pretty nifty indeed, but I'd much rather not need to use it when I'm just monkeying around finding files and moving a few around and so on. I definitely don't ever want to have to touch it to do anything mundane like change any settings for something or install something.

^this, I don't want to type in a long path name and misspell a single character.  I like a GUI (that is keyboard navigable) that I can navigate files and folders with.
Also, I've noticed the same strange mouse behaviors on all linux distros I've tried, feels very sloppy.

I've thought about dual booting linux before, but it's just too much hassle.  Sure everything is customizable, but I don't want to spend a week trying to find all the configuration files and understanding all their different formats just to get my system working as smoothly as a default windows installation Cranky
12  Discussions / General Discussions / Re: What do you do to cut development time? on: 2014-04-02 16:29:22
I would agree about cutting features.  Planning ahead will save you a lot of trouble.  If you make an outline of your major 'have-to-have' features and functionality it's easier to detect when something is not contributing to the end goal.
Plus, if you have some type of plan, it's easier identify and stop yourself from adding those weird features you start thinking up at 12:00 am when your brain starts wandering  Wink

The catch here is to keep your initial plan small.  I've found that when I estimate how long something will take, I almost always have to double my estimate because I'm so poor at predicting how the feature will integrate into the rest of the project and what refactoring will have to occur Clueless
13  Discussions / Miscellaneous Topics / Re: Can anyone give me 10 words all related to one thing in common? on: 2014-04-01 17:44:28
encapsulation, abstraction, implementation, coupling, cohesion, delegation, polymorphism, composition, aggregation, synchronization.

All related to software design  Cheesy

^Yes, as Riven asked, what particular thing do you need the words to be related to?
14  Discussions / General Discussions / Re: Fewer end users? on: 2014-03-26 22:46:03
I think there is definitely a lot of negative feelings around Java.
When I mention that I develop software using java to family members, the general response is something along the lines of "oh, that thing that always pops up wanting to update."
Of course Windows, the Win API, drivers, OpenGL, etc. have to update as well for a C or C++ program to work, but people tend to accept these types of updates as necessary.

Smart applications like Firefox and Chrome just auto update (this relates to why browsers are trying to kill plugins). The average user never knows that applications auto-update except when the occasional program breaks, which the user blames on general computer unreliability.  On the corporate side, IT can tun off auto-updating into control panel or the program's settings if the company needs a specific version.

I've played Spiral Knights rather extensively, over a 1000 hours, and have heard very few complaints or even mentions of Java because Spiral Knights packages a small JRE within it's installation folder.  Everything runs exactly like Three Rings expects and no one ever complains; sure the bundled JRE might be out of date and security bug riddled, but end users will never know, so who cares...

There are so many compatibility and computer specific issues with Java's version, the Java class path, .jar double-click to run functionality, etc. that I think pre-bundled and jigsaw like JREs can solve.  The average user doesn't really care if your program takes up an extra 50MB of disk space.
Once jigsaw comes out, I'm sure a lot of LWJGL games could include a small pre-bundled JRE without their application size increasing dramatically by leaving out stuff like Swing (if possible), SQL, JDBC, XML, etc. packages.

I agree that Java has collected a lot of bad connotations over the years.  I think one of the easiest ways to 'fix' this perception is to hid Java.  Don't include the word 'Java' in error messages, bundle the JRE with your app, hid your .jar behind an .EXE or script wrapper.  Like Phibedy and Rayvolution have said, people don't understand and don't care Undecided
15  Game Development / Newbie & Debugging Questions / Re: Interface Design on: 2014-03-25 14:46:22
Hum, interface design Grin
I love interfaces, but most of what I've learned is from trial and error.
I would recommend Joshua Bloch's Effective Java book for general programming practices many of which are related to interfaces.

Online, maybe start with general design principles like:
http://en.wikipedia.org/wiki/Dependency_inversion_principle
http://en.wikipedia.org/wiki/Coupling_%28computer_programming%29
http://en.wikipedia.org/wiki/Cohesion_%28computer_science%29

For example, it's a very helpful that InputStream and DataInput are interfaces that do not require extending and can be implemented by any class.
However, it's also very helpful that there are default implementations for these interfaces such as FileInputStream, ObjectInputStream, and ByteArrayInputStream.

It's important to balance a package, module, or API with both interfaces and default implementations (commonly preceded by the word Abstract in the Java libraries).  For example: ListModel has an abstract and default implementation, making it much more useful.

Whereas something like TimerTask is more annoying to use since it must be extended.  In my opinion, TimerTask could have been a concrete class with a constructor that took a Runnable object and ran that object instead of forcing every class that ever wanted to use TimerTask to extend it.

Common interface designs that I use are the builder pattern (http://javarevisited.blogspot.com/2012/06/builder-design-pattern-in-java-example.html)
which is something like 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  
29  
30  
31  
32  
33  
34  
35  
public class Thing {
  private int id;
  private Element matter;

  public Thing(int id, Element matter) {
    this.id = id;
    this.matter = matter;
  }

  public void thingStuff() {
    // ...
  }
}

public class ThingBuilder implements Builder<Thing> {
  private int thingId;
  private Element thingMatter;

  public void setId(int id) {
    this.thingId = id;
  }

  public void setElement(Element matter) {
    this.thingMatter = matter;
  }

  @Override
  public Thing create() {
    return new Thing(thingId, thingMatter);
  }
}

public interface Builder<T> {
  public T create();
}


and the service pattern (couldn't find many good web examples, here's a general discussion about it: http://www.velocityreviews.com/forums/t302202-service-provider-pattern.html)
and it looks something like this in its most basic form:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public interface XyzService {
  // various service methods...
}

public interface XyzProvider {
  public XyzService newXyzService();
}

public class Services {
  private static final Map<String, XyzProvider> providers = new ConcurrentHashMap<String, XyzProvider>();

  public static void registerProvider(String name, XyzProvider p) {
    providers.put(name, p);
  }

  public static XyzService newInstance(String name) {
    XyzProvider p = providers.get(name);
    if(p == null) { throw new IllegalArgumentException("No provider registered with the name '" + name + "'"); }
    return p.newXyzService();
  }
}

-Adapted from Effective Design Item 1.

For example, in java.util.concurrent Executor serves the role of XyzService in our example and Executors fulfills the role of Services in our example.

Good interface design is normally about abstracting away details, such as hiding a database connection so that it could easily be replaced with a file or hiding LWJGL's rendering system so that you can easily modify it for better performance or update it when a new version of LWJGL comes out.
16  Game Development / Newbie & Debugging Questions / Re: Abort trap error with LibGDX and Box2D on: 2014-03-17 16:38:33
I don't think anyone here can tell you the exactly problem without knowing what your code is doing.
However the crash log does have some helpful information, the last point in your code before the crash is somewhere in your:
1  
 com.mesut.jumper.entities.Entity.init(...) 

method at a point where you call:
1  
 com.badlogic.gdx.physics.box2d.World.createBody() 

If you're project seems messy to you, maybe the first place to start is cleaning it up and cleanly separating methods, classes, and packages so that you can better debug the code.

The crash could be caused by any number of reasons, such as allocating too many or too large buffers (i.e. ByteBuffer, FloatBuffer, etc.) or when creating too many sockets/database connections or incorrectly calling an OpenGL method.
Like the log says, the exception occurred in native code so your best bet is to start debugging your code starting in your Entity.init() method and testing your game a lot to figure out why the crash is occurring.

To get started, I would recommend:
Watch your program's memory usage, CPU usage, number of open sockets, etc.  Which can all be done on windows using Task Manager or Resource Monitor.
Add log messages to your code starting in Entity.init() and going backward from there so you can figure out which methods are passing incorrect parameters, initializing an object incorrectly, etc.

Debugging is a strange art, I would start at the point that the log message mentioned (inside Entity.init() when you call World.createBody()) and work up from there. Remember a method call before that method call could be the issue.
17  Game Development / Newbie & Debugging Questions / Re: What excactly is a FloatBuffer? on: 2014-03-17 13:39:25
As tom_mai mentioned, a float[] is subject to the JVM's whim, it might be compacted, fragmented, or moved by the JVM or garbage collector. This means that an OpenGL driver might obtain a pointer to the array, queue a command involving the array, but then when it goes to execute the command and do something with the array, the array may have moved causing the pointer to point to an invalid memory location.

A native buffer with the correct ByteOrder, will store its contents in a fixed location in memory in the correct endian-ness of the host machine.  This allows the OS or drivers to receiver pointers to buffers and use them in the future because the location pointed to will always remain valid and will not be modified by the JVM or garbage collector.

That's my understanding after doing some research.
18  Game Development / Networking & Multiplayer / Re: NIO problem sending data when multiple requests in the queue on: 2014-03-15 14:32:12
Looks like you've got a good understanding of how socket channels work.  Took me weeks to understand them Wink
Yes, if you use TCP (Socket, SocketChannel) the underlying OS/socket protocol stack will arbitrarily decide when to send a packet, you can somewhat affect this by calling flush if you are using a Socket, but I'd have to do some research.
The JavaDoc for OutputStream's flush() method mentions:
Quote
If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

However, this doesn't really apply to SocketChannel's read() or write() method.  So I'm not sure that there are any guarantees about the behavior of either method.

If you use a DatagramSocket or DatagramChannel and keep the data you write under the maximum UDP transmission size, then the write methods will almost always send one packet per each write() method call, although it may vary from OS to OS.

So yes, the behavior you are describing is expected.  One way around it is to use a special marker byte/character between packets.
However, if the data in your packets might contain that special marker, then you will need to use an escape marker for your special marker to differentiate between the end of a packet and a marker that happens to be data in the packet.

Another solution is to include the length of the packet at the beginning of each packet, this way you don't need any special markers or escape markers.  Just read the length whenever you receive data and keep reading until number-of-bytes-read == length, then read the next packet's length and so on.
19  Game Development / Newbie & Debugging Questions / Re: API Programming in Java? on: 2014-03-14 00:59:49
Building on BurntPizza's reply, there are many concepts and structures that make a good API. People spend there lives designing good APIs.
Although that may not be the abstract answer you're looking for.

If you have time, pick up Joshua Bloch's "Effective Java" (2nd ed.), awesome, concise advice on overriding, overloading, abstract classes, interfaces, access modifiers, encapsulation, cohesion, etc. I've read through almost twice now and still learning stuff.

My personnel advice...
Make classes that are often used as parameters immutable (java's String class is a good example). A lot of methods in the Java API take strings and it's a good thing that Strings are immutable.
A example of this failing is the getDimensions() method in most Swing GUI classes.  Dimensions is a mutable class with publicly accessible .x and .y variables.

This slip on the part of Java's designers has caused headaches for developers the world over and has caused some performance problem's for Swing since every Swing class must make defensive copies of Dimensions objects when using them (Effective Java, p.235).

Higher level logic/processing classes (for example Scanner, Matcher, OutputWriter) that you don't envision being passed around as parameters, can have stateful methods, but should avoid it.
For example, a rendering class that requires startBatch() and endBatch() to be called before and after a group of render(Renderable r) calls is not really a good design.  It is easy to forget to call the methods in the right order which can end up trading valuable development time for debugging time.

For example, the class mentioned above could be consolidated to provide a renderBatch(Collection<Renderable> r) or renderBatch(Renderable[] r) method which removes the chance for the programmer to make an error when using the class.

This type of programming removes possible runtime errors and forces the programmer to program correctly and if the programmer makes a mistake, the mistake becomes a compile time error rather than a runtime error.  In one type of perfect programming world programmers could/would write code which would be impossible to compile with bugs.  In other words, null checking, bounds checking, error handling, error recovery, correct object state, etc. would all be part of the language/object syntax itself.

Such an idea is the extreme boundary of moving runtime errors to compile time errors, but in small doses the idea greatly improves API design Cheesy
20  Game Development / Newbie & Debugging Questions / Re: Inquiry about attribute locations in glsl on: 2014-03-12 03:56:59
The short answer is that the OpenGL graphics driver picks these values when it compiles the shader.
The long answer, buried somewhere in the Graphics driver, could relate to any number of variables including how the variables are used in the shader, what data types they refer to, which appear first in shader, their alphabetical names, etc...  Clueless
21  Discussions / Java Gaming Wiki / Re: Anonymous/Local/Inner class gotchas on: 2014-03-11 13:53:30
Why would anyone do that :/
 ^ Pointing I don't know
A new class creates more overhead than a new instance of an existing class.  The new class, even if it is an anonymous one, has to be loaded, linked, and initialized: JLS 12.3 - 12.4 Linking and Initialization of Classes and Interfaces.
This adds memory and processing overhead for a savings of 2 or 3 keystrokes.
Plus, when the code runs multiple times, each execution creates not one object, but 2 adding a non trivial amount of overhead if the code is in a method that runs frequently.
22  Game Development / Newbie & Debugging Questions / Re: Compile and Debug Java on: 2014-03-09 13:01:39
Ctrl + D deletes a line
Ctrl + T opens a class chooser to easily switch between files
Ctrl + Up/Down copies and pastes the current line you are on in the direction that the currently hit arrow key is pointing.
My fav so far is CTRL+clicking an object's method and going straight to the method in it's class. Cheesy
Everyone may already know these; they save me from having to click around Eclipse's menus quite often.

Alt + Shift + R = rename the variable, method, or class your cursor is currently on, amazing for cleaning up class and method names!
Ctrl + Shift + G = find all references to the variable, method, or class your cursor is currently on.
Ctrl + PageUp/PageDown = cycle through currently open files.
Ctrl + Shift + left/right arrow = select the next portion of text on the line, if the text in front of the cursor is a variable name in TitleCase/camelCase, it highlights up to the first capital letter and subsequent arrow key presses highlight the next portion of the name.
23  Discussions / Miscellaneous Topics / Re: what to do? on: 2014-03-08 20:42:05
Thanks that makes me feel better. I've got something to look forward to as my peer group gets old Cheesy, but the window of opportunity seems small, since a lot of people I know over ~40-50 tend to get all reminiscent about events that have already occurred rather than thinking about future possibilities.
Which is a peeve of mine, but I won't go there...
24  Game Development / Newbie & Debugging Questions / Re: Generics problem when extending on: 2014-03-08 18:34:28
UprightPath is correct, it's a visibility problem, if you want to skip the import statement you can use the inner class's full name like so:

1  
2  
3  
4  
public class BasicParticleSystem extends ParticleSystem<BasicParticleSystem.ParticleImpl> {
   class ParticleImpl extends Particle {
   }
}
25  Discussions / Miscellaneous Topics / Re: what to do? on: 2014-03-08 18:20:52
Good alternative viewpoint teletubo, thank you for the reminder.  I just haven't had any close friends for the past few years and I'm getting quite lonely Emo
It's easy to find different people in the world, but most of them aren't open minded and so don't seem interested in associating with people unlike themselves.

My mention of finding people who think the same way was more along moral lines rather than personnel interests.  I don't want to hang out with people who swear constantly, have their head in the gutter, or want to 'have a good time' and drink or go clubbing all the time.
I want to meet people who are calm and thoughtful, I love a good conversation whether similar or different from my own viewpoint persecutioncomplex
26  Discussions / Miscellaneous Topics / Re: This forum is honestly the best out there! on: 2014-03-08 04:45:33
inter-webs famous! The best kind of fame Cheesy Cool Cheesy Cool
How's it feel opiop?
27  Discussions / Miscellaneous Topics / Re: what to do? on: 2014-03-08 04:40:33
Your last two posts sound exactly like how I feel opiop.  Haha, I want to find friends that think the same way where I live.  I should probably try looking harder, thanks for the motivation!
P.S. you're lucky to have found someone who loves to play DnD  Cool Cheesy
28  Discussions / Miscellaneous Topics / Re: C++ standard library is really lacking - good or bad? on: 2014-02-26 23:43:33
Interesting question to think about. I understand what your saying opiop, I started in C and later learned Java and the difference moving to Java felt so gooood!
I remember having to implement my own line-by-line file reading, string comparisons and array searching in C for university programming classes and I had to do the same stuff so often that I just started copy pasting it from project to project so I didn't have to redo it (kind of like the start of a library).

I remember having to implement binary searches, bubble sort, quick sort, heap sort, etc.  Build binary tree structures and searches for them  Roll Eyes.  I wouldn't discount the experience that gave me, but I am never going back.
When I compare some of the code I wrote back then to a Java library object/method for sorting, searching, binary trees, etc., my code is far worse Tongue.  Why implement something you are never going to think about twice like string comparisons when a language already provides it.  Your own implementations are likely to contain a lot more bugs than a library.

I understand what Lion King is saying about C++ or a similar lower level language giving you a chance to practice your coding and algorithm solving skills, but at some point it becomes a futile exercise in wasting time.
Similar to how most universities' CS/CE programs have at least one assembly language class in 2014.  You will probably never use it, but the exposure is good.  Once you've had a few weeks or months of practice (depending on how intense the practice is) it's not really useful to continue. Why reinvent the wheel (although I guess we, on JG, tend to do that a lot so who am I to talk Wink)
29  Game Development / Newbie & Debugging Questions / Re: Can I Improve this level loader? on: 2014-02-25 15:47:33
It's not necessarily an optimization (although it kind of is).  When code converts one data type to another there should be a clear reason, the data should be better represented by the newly converted to type.
Converting a pixel, which can quite easily be represented by an integer, to a string feels strange.  What does a string have to do with a pixel?  Even if you want it as a string for readability, I would still store it as an integer and just toString it when you want to see it's value.

In this code...
1  
2  
3  
4  
5  
6  
7  
8  
9  
for (int x = 0; x < levelInfo.getWidth(); x++) {
      for (int y = 0; y < levelInfo.getHeight(); y++) {
            String val = Integer.toBinaryString(levelInfo
                  .getPixel(x, y));
            cells[x][y] = val;
            // System.out.print(" " + cells[x][y]);
      }
      // System.out.println("");
}

I feel like the String[][] cell array could be int[][] instead.

Then in the enum, just change the binary ID of each enum to an integer like so...
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  
30  
31  
32  
public enum TileType {
      PLAYER_SPAWN( Integer.parseInt("111111110000000011111111", 2) ),
      WALL( Integer.parseInt("11111111", 2) ),
      EMPTY( Integer.parseInt("11111111111111111111111111111111", 2) );

      /** Used to search through the ID's of the cell enums */
      private static final HashMap<Integer, TileType> search = new HashMap<Integer, TileType>();

      /** Binary ID of the cell */
      int binary;

      private TileType(int binary) {
         this.binary = binary;
      }

      public int getBinary() {
         return binary;
      }

      /** Iterate through enum and assign values to map */
      static {
         for (TileType type : EnumSet.allOf(TileType.class)) {
            search.put((Integer)type.getBinary(), type);
         }
      }

      /** Get the type of this cell given its binary data */
      public static TileType getType(int id) {
         return search.get((Integer)id);
      }

   }


Granted, this might require a few other changes in your code, but probably not many.
Just my thoughts, not necessarily right or wrong either way.
30  Game Development / Newbie & Debugging Questions / Re: library games 2d on: 2014-02-15 16:34:43
Yes, listen to opiop65.
Start as simple as possible.
If you want pain, and sadness, and hopelessness; long nights of debugging and days of reading OpenGL specs, start with 3D.
If you want to actually create something, start with 2D.

Source: I started learning OpenGL for 3D graphics about 2+ years ago and I still haven't created anything.
Pages: [1] 2
 

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

The first screenshot will be displayed as a thumbnail.

Longarmx (50 views)
2014-10-17 03:59:02

Norakomi (39 views)
2014-10-16 15:22:06

Norakomi (31 views)
2014-10-16 15:20:20

lcass (36 views)
2014-10-15 16:18:58

TehJavaDev (67 views)
2014-10-14 00:39:48

TehJavaDev (65 views)
2014-10-14 00:35:47

TehJavaDev (56 views)
2014-10-14 00:32:37

BurntPizza (72 views)
2014-10-11 23:24:42

BurntPizza (44 views)
2014-10-11 23:10:45

BurntPizza (84 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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!