Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

139 Neutral

About Malone1234

  • Rank
  1. Malone1234

    PostgreSQL anyone?

    Not gaming relevant, but anybody know what's wrong with this statement, within a Postgres function: select into transId currval('trans_id_seq'); transId is a bigint declared in the DECLARE section and 'trans_id_seq' is a valid sequence. Anybody know? I get: ERROR: syntax error at or near "trans_id_seq" at character 226 which is the 't' in 'trans_id_seq'.
  2. I'm fairly certain that in JDK 1.5 you can use the final keyword to specify that a function parameter is not to be modified. public void foo( final Bar bar ) {...}
  3. Malone1234

    decorator pattern & C++...

    Most implementations favor performance over saving memory. So to implement multiple inheritance you either need (1) a vtable pointer for each inherited class or (2) a single pointer to a table of vtable pointers that point to the vtables of each inherited class. The second approach saves you memory as each object needs only one "meta"-pointer, but it requires two pointer dereferences for every method call at runtime, as opposed to one dereference (following a simple offset calculation) in the first approach.
  4. Malone1234

    compiling perl source code

    Best perl editor I've found is: vi
  5. You can probably explicitly call Writer's write method ala super.Writer.write(...);
  6. Malone1234

    [java] Eclipse VM settings

    Thank you! I looked for hours and managed not to find that option!
  7. All right, I want Eclipse to launch every project with the VM flag -Xmx256m automatically. I know how to do this for each individual project, by going to the Launch Configuration Dialog and specifying that argument in the VM Arguments textbox. But I want this to be the DEFAULT! And apparently Eclipse cannot do this! The problem is, I'm working on a very large project with hundreds of JUnit tests. If I specify the large project itself to use that heap size flag, everything is hunky dory. But if I want to run only a small subset of the unit tests, I have to go to the Launch Configuration Dialog each time and specify that argument so I don't run out of heap space. (Each test case works with very large datasets) I want Eclipse to launch every Java program with -Xmx256m by default. Anyway to do this wihtout writing my own darn plugin?
  8. Malone1234

    [java] Java reference...help...

    It's really not a big deal but it tends to become a headache because in Java you cannot have a "reference" (pointer) to a variable of a primitive type.
  9. Malone1234

    Java vs. C++

    As has been said before, choice of language for an intro CS class should be at the very bottom of your priority list when evaluating schools. A good CS curriculum will expose you to at least half a dozen different languages, including C, some form of assembly, an OO language like Java or C++, a couple of scripting languages and a functional language. That's not to say you will take Ocaml101 or Perl400, but in the course of your studies you should come into contact with many different languages. For instance I used C and C++ mostly in my Operating Systems course, and the Compiler Design course I'm now taking involves a lot of Java code and some MIPS assembly. What matters is that the school has a good reputation for actually teaching Computer Science concepts, not for churning out Java developers (which are a dime a dozen).
  10. If you want something a little better than System.currentTime() there are a lot of really good (and free) profilers out there for Java. I've use a profiling plugin for Eclipse before, there are several to choose from. It'll tell you in which methods the most time is being spent and how many times they are called, etc.
  11. Malone1234

    2D displays in 3D RPG

    You probably just want to render the 3d and 2d portions separately. So in your game loop, render all the 3d stuff. Once that's finished, you'll have your 3d scene in the frame buffer. Grab a handle to that buffer and overlay your 2d menus or textboxes overtop of whatever is there. You can even make it semi-transparent.
  12. Looks like a pretty comprehensive book. One thing I notice is that only two chapters (16 and 17) are devoted to matrices. I assume it explains basic linear algebra concepts, but you may want to get yourself a book devoted entirely to linear algebra because it's very important in 3D programming.
  13. Malone1234

    Sorting in Java

    I think you could make this easier if you encapsulate each row into an object. You say you have Strings, numbers, and Dates. So let's make a class called DoHickey that is composed of those things. public class DoHickey implements Comparable { // these are your columns public Object[] cols; private int sortParam; // this will tell us which "column" to sort public DoHickey(String s, int n, float f, Date d) { cols = new Obj[4]; cols[0] = s; cols[1] = new Integer(n); // have to create an object from the primitive type cols[2] = new Float(f); // which comes in handy when we are going to sort cols[3] = d; } // set the parameter to sort on // (do a check here to make sure s is a valid column number) public void setSortParam(int s) { sortParam = s; } // In order to sort DoHickey objects you need to implement Comparable // which is just the compareTo() method public int compareTo(Object o) { DoHickey dh = (DoHickey) o; return cols[sortParam].compareTo(dh.cols[sortParam]); // this works out nice because String, Integer, Float, and Date all implement the Comparable interface } } Then you make a 1-D array of DoHickey objects which is an array of "rows" and sort it. DoHickey[] dharray; // initialize it somewhere Arrays.sort(dharray); // Arrays.sort will sort anything that implements Comparable Of course, the DoHickey class does make it so you need to cast from Object when retrieving objects from the cols[] array, or you could add getter methods for each element if there aren't too many.
  14. Perhaps I am missing something but it seems to me that filterRGB() is never called because you never call it. As for the images not showing up, I dunno, AWT stuff can be tricky and I'm not familiar enough with it to help.
  15. Ah, it's good that you make that distinction, because Java in general is not slow anymore. AWT is also not very slow, because it uses native platform-specific widgets, and that is also the reason it should not be used. (No portability) Java's threading system also adds some overhead when it comes to GUI apps. Swing, on the other hand, is slow. There is just no getting around it. In Swing, when a window is drawn (for instance) it uses simply Java graphics primitives rather than native platform-specific widgets. So here is a hypothetical timeline of events when you create a JFrame and call its show() method, which essentially calls paintComponent() on the frame and makes it visible. allocate memory for a JFrame of this size Graphics g is the object that we're using to draw the Swing widget g.setColor(...) g.drawRect(...) // window outline g.fillRect(...) // fill window g.setColor(...) g.drawRect(...) // draw inner border g.fillRect(...) // fill inner part Then of course your window contains a number of other widgets, say a title bar, a couple of menus, a text area, a few buttons, a panel that contains still more widgets. These objects form a hierarchical tree and when each top level object is done drawing itself, it calls paintComponent() of each of its children, who in turn call paintComponent() of their children and so on. Dozens or hundreds or thousands of fillRects and drawLines and so on get called to create a single window, all in straight Java code! All that overhead adds up, and when you take into account the added overhead of a Virtual Machine intefacing with your video hardware you have yourself a slow GUI system. That said, of course, on a brand-spanking new 3.0Ghz Pentium 4 system most people can't tell the difference, so it's becoming less of an issue.
  • 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!