Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (481)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
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  Discussions / Miscellaneous Topics / Re: A rant on OpenGL's future on: 2014-08-14 12:04:17
I dunnno about that... maybe I'm nuts, but it seems like things have been shifting away from custom rigs. Or maybe that's always been a niche thing, and the niche is swelling along with the overall amount of computer users? But if people start moving away from desktops and laptops... hm.
2  Discussions / Miscellaneous Topics / Re: A rant on OpenGL's future on: 2014-08-14 01:56:43
I have a 2009 computer with an integrated Intel card that may or may not even support fragment shaders. (It's whatever version supports it using an extension. 1.3? 1.4?) It's depressing, but still makes me counterproductively determined to make the game run on it anyway.
3  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 23:05:22
Glad to help!

I'll let someone else answer your latest question though. Since you're asking multiple questions on one thread, try editing/modifying your original post so you can change the title to reflect your current problem. That way, people know to stop by if they think they can help.

And you can always Appreciate my posts to get me imaginary medals if they've been helpful. Wink
4  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 21:15:29
I did something similar with my tile grid. (I have the map as a single image, but a bunch of grid outlines placed over it that slowed things down on large maps.)

You need to, before drawing each tile (either in renderMap() or in Tile.render()), calculate whether the tile is on the screen and only draw it if it is.

The information you need:
1. The tile's sides (the x of the left and of the right, the y of the top and of the bottom) or the x,y of a corner and the width and height for you to calculate this from.
2. The width and height of the draw area. I.e., if your window is 1200x800, this might be something like 1192x780. The space that graphics go. This is the cnvW and cnvH (from GameBase.getCnvW() and getCnvH()) in the Camera code I gave you, but you may have it labeled something different or may need to calculate it still by subtracting the frame from the window or something.
3. The position of the Camera. In the Camera code I gave you, I think it's the Camera.getX() and Camera.getY() that give you the top-left corner of the area you want to draw (i.e. the camera location).

Using that, can you figure out how to tell if a Tile is at least partially on-screen before bothering to draw it?
5  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 19:39:29
Glad to hear you got it working! So, if you centerOnCharacter(), it snaps the camera over to the Player you specify then? Obviously, you had to do a bit of converting to make it work with your classes.

For updating the screen, here's the approach I took:
1. Every time we are ready to update the screen, loop through all things that should be drawn and call their draw() methods.
2. In a draw() method, you do the work of picking the right image and drawing it. I believe you already do this.
3. When everything has drawn, flip the buffer strategy or whatever it is you need to do to put the new drawing on the screen.

For individual animations, here's the approach I took:
1. I made an Animation class.
2. Each thing that should draw has at least one instance of the animation class. Tiles would usually only need one, Players will need one for each pose and direction combination they can have (for example, walking west, idling facing north).
3. When a thing draws, it checks which animation it is currently using (which can be changed when, for example, a Player turns to a different direction or changes poses)...
4. ...then, it tells that animation to draw its next frame, giving it the x and y location minus the Camera's x and y. The animation grabs a BufferedImage, which it then draws.
5. This brings us to Animations themselves:
5a. An animation needs to know several things. First, which images it needs to use (or which directory to automatically load them from).
5b. It needs to know how many frames per second to play and whether it should go back to the first frame when it's finished and loop around, or if it should stay at the last frame when it's done.
5c. If you're allowing the players to pause, it needs to keep track of when it was last paused, last resumed, and be able to take that into account to avoid skipping frames, because...
5d. ...it needs to keep track of when it handed over the last frame to be drawn and what number that frame was...
5e. ...so it can decide what frame to give you when you ask it for the nextFrame(). It compares the current time, the lastFrameTime, and playRate to decide whether to give you the last frame again or move on to the next one. If it's time for a new frame, it needs to make sure that it either loops back to the beginning or gives you the final frame again if it's at the final frame, depending on whether it is a looping animation or not.

I've found this to be a pretty convenient way of doing things, once I got it working.
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2014-07-27 17:37:48
Today (and yesterday), I implemented controller support. A lot of copy-pasting and renaming of copied variables and methods. But now, you should theoretically be able to remap controller buttons and axes just like you can keyboard and mouse buttons, and it should process any input you do correctly.

Not that I've tested it yet. Would anybody find this sort of system for remappable keys, mice, and controller stuff useful?

Screenshots would not be terribly interesting. D:
7  Java Game APIs & Engines / OpenGL Development / Re: LWJGL Controller Advice [Getting false axis events] on: 2014-07-27 13:42:24
Thanks. It hands me events separately for horizontal and vertical movement, and I can compute the angle from those.

The events, as far as I can tell, only trigger when a stick position changes. The right stick gets labeled by LWGLJ as "X Rotation" and "Y Rotation", depending on which direction you push it. If you push it straight to the right, for example, it triggers an X Rotation event with a value of 1.0. All the way to the left is -1.0. If you were to push it, say, to the right and a little bit down, it would give a pair of events, something like X Rotation 1.0 and Y Rotation 0.4253412. And, if you let go of the stick, it fires an event for each axis with values of 0.0. So, on this controller at least, 0.0 is centered. You can set a dead zone where it's not supposed to notice little changes, if I understand correctly.

The weird thing is that, for any other stick movements, it only fires the event once each time you move. It doesn't keep creating events if you hold it still. Yet, the "X Rotation" axis (left-right on the right stick) keeps firing a 0.0 event. It looks as if the computer thinks that the stick keeps getting moved to the center from somewhere else, over and over again, instead of just staying there.
8  Java Game APIs & Engines / OpenGL Development / Re: LWJGL Controller Advice [Getting false axis events] on: 2014-07-27 03:09:08
Current problem, for those interested in helping, or for posterity:

The "X Rotation" axis (moving the right stick side-to-side on the Xbox 360 controller I'm using) is giving constant false positives. I keep getting events where the x- and y-axis values for the event are both 0.0, it's an axis event, and the axis name is "X Rotation". This regardless of what I set the RXDeadZone to (the default is 0.05, I think).

I guess I'll just ignore them for now, as they seem to be doing no real harm?

If anyone knows what's up here, I'd appreciate any advice.
9  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 01:22:14
Take a look when you've had some sleep; I think you might be able to figure it out. Sorry I won't be analyzing your code or game, but here are some hints on the camera:

The Camera represents where the person who is playing the game is. When that person moves, the things in the game world don't. When the things in the game world move, the person playing does not. But, when you move, it looks like everything else does, because they are being "drawn" through your eyes and in your brain based both on where they are and where you are. So, when we draw something in the game, we should draw it based both on where it is and where the human player is. Thus, g.drawImage(cheapAnimation(), x - Camera.getX(), y - Camera.getY(), width, height, null); . The x and y are where the thing is, and the Camera.getX() and Camera.getY() are where the human player is looking from.

Your Tile.render() should draw its image with its x and y minus the Camera's x and y. This way, if the camera moves to the right, the level gets drawn to the left, for example, making it look like your view has moved to the right.

Anything else that should be part of the game world -- Player, NPC, whatever -- should also draw its images minus the Camera's x and y.

Anything that should be part of the HUD, rather than the game world, such as menus, should not draw minus the Camera's x and y. This way, even if the Camera moves, the menus and stuff will stay in the same spot on the screen.

The principle here is that when something moves (changes its x and y position), that means that it has moved around in the game world. The Player and the Tiles don't move when the Camera does. They stay in the same spot. But, when the Camera moves, while their x and y stay the same, they get drawn with an offset based on where the Camera is. This way, if you move your Camera, you don't have to move all your Players and Tiles, but it's like the person playing the game moves around instead.
10  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 01:06:05
Looking at your source code, you would want to change this line in your Player.render(Graphics g):
1  
g.drawImage(cheapAnimation(), x, y, width, height, null);

to something like this:
1  
g.drawImage(cheapAnimation(), x - Camera.getX(), y - Camera.getY(), width, height, null);


This would mean that as you move the camera to the right, the player image moves to the left, and vice versa. You can do the same thing to your maps as well, so that as the camera moves, they move. If you want to keep a player or AI at the center of the screen, move the camera to their current position. Mine accomplishes this by Camera.centerOnCharacter(Person subject). If I want it to stay locked on to the player, I use that once each time I'm getting ready to draw everything. You could do the same (or modify my code if you like) by changing Person to Player and giving Player getCenterX() and getCenterY() methods so that the Camera knows where the middle of the player is, so that it can move to it.
11  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 00:57:51
Ah, I've been typing up an answer for you! Here's how I do the making the screen move:

My game's camera works more or less like Pokémon's, with the player (or whoever we're looking at right now) staying at the center of the screen. The player and everybody else keep track of their own position relative to the level they're on. (My game calls these levels "Boards", but you could call them levels, maps, boards, areas, whatever you want.) If a Person (a character) is at x: 0, y: 0, that means they're at the very top left of the board.

When you update the screen, draw everything with an offset equal to the camera's x and y. Example:
1  
drawThing(thing.getImage(), thing.x - Camera.getX(), thing.y - Camera.getY())
12  Game Development / Newbie & Debugging Questions / Re: [Game] How do i make a camera.class? on: 2014-07-27 00:49:00
For what it's worth, here's my Camera class. If any of it's of use to you (or anyone), feel free to use it for whatever.

It assumes certain things about what a Person is in your game (namely, that it's called Person, and it has getCenterX() and getCenterY() methods that tell you where the middle of the Person's graphic is relative to the game board/level). It also assumes that you have a thing called GameBase that has getCnvW() and getCnvH() to get the width and height of the drawable area of the game window, a variable brd to keep track of the current Board/Level, a variable to keep track of the main player character, and some numbers to symbolize directions (north, south, east, west) which can be sent in to the board/level's getBorder(directionNumber) method to find out where the edges of the level are.

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  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
package GameBase;

import Person.Person;

/**
 *
 * @author jemoore
 */

public class Camera {
    private static double x = 0;
    private static double y = 0;
   
    public static int getX() {
        return (int) x;
    }
    public static int getY() {
        return (int) y;
    }
   
    /*
     * Move Camera's top-left corner a given number of pixels,
     * but only if this wouldn't move the camera past the board edges.
     */

    public static void move(double x, double y) {
            //System.out.print("Camera moves from " + Camera.x + "," + Camera.y + " to ");
       set(Camera.x + x, Camera.y + y);
            //System.out.println(Camera.x + "," + Camera.y);
   }
   
    /*
     * Set Camera to have its top-left corner be a given position,
     * but only if this wouldn't move the camera past the board edges.
     */

    public static void set(double x, double y) {
        Board brd = GameBase.brd;
        int cnvW = GameBase.getCnvW();
        int cnvH = GameBase.getCnvH();
        double marginW = (cnvW - brd.getW())/2; //handle blank margins if canvas wider than board
       double marginH = (cnvH - brd.getH())/2;
            //System.out.print("Camera: cnvW,H="+cnvW+","+cnvH+" marginW,H="+marginW+","+marginH+" input x,y="+x+","+y);
       if(marginW < 0) { marginW = 0; }
        if(marginH < 0) { marginH = 0; }
        if(x + cnvW > brd.getBorder(GameBase.DIR_E) + marginW) { //can't move right
           x = brd.getBorder(GameBase.DIR_E) - cnvW + marginW;
        }
        if(x < brd.getBorder(GameBase.DIR_W) - marginW) { //can't move left
           x = brd.getBorder(GameBase.DIR_W) - marginW;
        }
        if(y < brd.getBorder(GameBase.DIR_N) - marginH) { //can't move up
           y = brd.getBorder(GameBase.DIR_N) - marginH;
        }
        if(y > brd.getBorder(GameBase.DIR_S) - cnvH + marginH) { //can't move down
           y = brd.getBorder(GameBase.DIR_S) - cnvH + marginH;
        }
        Camera.x = x;
        Camera.y = y;
            //System.out.println(" output x,y="+x+","+y);
   }
   
    /*
     * Reset Camera to be centered on subject's position,
     * but only if this wouldn't move the camera past the board edges.
     */

    public static void centerOnCharacter(Person subject) {
        centerOnCharacter(subject, 0, 0);
    }
    public static void centerOnCharacter(Person subject, double offsetX, double offsetY) {
        int cnvW = GameBase.getCnvW();
        int cnvH = GameBase.getCnvH();
        double newX = subject.getCenterX() - cnvW/2 + offsetX;
        double newY = subject.getCenterY() - cnvH/2 + offsetY;
        Camera.set(newX, newY);
        //System.out.println("cam xy: " + Camera.getDrawX() + ", " + Camera.getDrawY());
   }
   
    public static void centerOnMain() {
        centerOnCharacter(GameBase.mainPlayer);
    }
}
13  Java Game APIs & Engines / OpenGL Development / Re: LWJGL Controller Advice on: 2014-07-27 00:10:24
Having trouble getting it to recognize the binaries. It complained they weren't in java.library.path, so I set java.library.path to the same as org.lwjgl.librarypath , all before it ever tries to set up controllers, but it still complains. If I paste the same path into my NetBeans project properties -> run -> VM Options as -Djava.library.path="C:\Users\Joel\Documents\NetBeansProjects\hippo\native\windows" , it works. This, even though printing out java.library.path shows the same path whether I set it in the VM Options or in the program.

I'm trying this, but they call it a hack, which makes me raise an eyebrow about its reliability: http://blog.cedarsoft.com/2010/11/setting-java-library-path-programmatically/

[EDIT: that hack appears to work, and my, it recognizes a lot of controllers. My Xbox 360 controller comes up first, then my keyboard (twice), my microphone (twice, but very interesting), then the driver for my wife's not-connected drawing tablet (also twice), though it claims it failed to initialize said tablet driver (did it fail on both versions that it saw? on one? on a third one that didn't end up in the controllers list?)]
14  Java Game APIs & Engines / OpenGL Development / Re: LWJGL Controller Advice on: 2014-07-26 23:22:35
Good idea. That's what I did for keyboard and mouse -- there are default bindings, but it's basically agnostic to the actual names of the keys or mice, so it should be easy to reconfigure for non-English keyboards and such. I'll be doing something similar for controllers.
15  Java Game APIs & Engines / OpenGL Development / LWJGL Controller Advice [Getting false axis events] on: 2014-07-26 20:49:19
So, I've got Keyboard and Mouse redone to use LWJGL instead of AWT or whatever built-in thing I'd been doing. Remapping works pretty well, and everything. And now, I'm going to try and take this 360 controller we bought and try to make that happen.

Any advice, as I dive in to controller support? Any major differences I should be aware of between how LWJGL treats controllers versus keyboards or mice?

I suppose if I run into any nasty, stumping problems, I'll edit or reply to this topic.
16  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 19:30:21
Sorry for all the self-replies. I'm not sure whether to edit or add a new reply in cases like this, where it's new information being added.

As best I can tell, the window is being maximized behind my back somewhere. When the window ends up big instead of the size it's supposed to be, f.getExtendedState() is returning 6 of MAXIMIZED_BOTH instead of the 0 of NORMAL.
17  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 18:52:56
*Sigh*

Correction: It works sometimes. Other times, it still resizes the window to take up the whole screen.

EDIT: It also just used the right sized window, but the rendering was stretched, as if it was trying to stretch the correct size to fit a larger window than was there.

EDIT again: Looks like I'd also added an f.setMinimumSize() and f.setSize() after the second f.setVisible(). If I remove those, I get full screen sized window again.
18  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 18:44:29
Thaaaaat was weird. If I add another f.setVisible(true) before the f.add(c), it works as it should. The window is the right size, the rendering is the right size and isn't squashed or stretched.

I guess Frames need to be set to validated or made displayable or something before a Canvas is added to them, or the Frame can get resized (and the canvas with it) somewhere behind the scenes later. This even works if I then remove the f.setVisible(true) that came after f.add(c), even though I thought that needed to be called to re-validate stuff after adding a component. Weird.
19  Game Development / Newbie & Debugging Questions / Re: Collision bug in a 2D platfrom game. on: 2014-05-26 18:26:31
Hi,

Not sure if this will help with your specific problem, but it might be a better way to handle collisions during player movement.

You may find it useful to go ahead and move the character 1 pixel at a time until they've moved their whole speed -- but don't draw it yet! Every pixel the character moves, check to see if moving that pixel would make it collide with anything. Then, if it does, simply stop the movement before that pixel.

For simple collision, you can just see if a rectangle you make that surrounds it overlaps with the rectangles of other objects. Here is what you could do for each pixel of movement:
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  
int moveX = 0;
int moveY = 0;
if(movingLeft) { moveX = -1; }
else if(movingRight) { moveX = 1; }
if(movingUp) { moveY = 1; } //assuming y goes up and not down
else if(movingDown) { moveY = -1; }

//box is the rectangle around your character used for checking collision
//obstacles is an ArrayList of every other rectangle on the level the character can collide with
Rectangle nextSpot = new Rectangle(box.x + moveX, box.y + moveY, box.width, box.height)
boolean collided = false;
for(Rectangle thing : obstacles) {
    if(nextSpot.intersects(thing)) {
        collided = true;
        break; //no need to continue checking obstacles -- we've hit one
   }
}
if(collided == true) {
    //no more movement!
   break;
    //if we're inside another loop that goes until we've moved our whole speed,
   //we can get out of it with break.
} else {
    //move that little bit!
   playerX += moveX;
    playerY += moveY;
}


Then, once the character has moved as far as they can with that collision checking method, update the screen.
20  Java Game APIs & Engines / OpenGL Development / AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 18:03:28
This is baffling me. For some reason, the AWT Frame and its child canvas that I'm using with LWJGL's Display.setParent() is resizing itself away from the dimensions I set it as. This used to work fine, and looking through my revision history, I can't figure out how I broke it.

Relevant parts of my code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
//Frame f is a static final that is initialized when it is declared.

setupFrame(Canvas c) {
        //determine the width and height to use for the game window, put them in resX, resY
       f.setSize(resX, resY);
        f.setResizable(false);
        f.setIgnoreRepaint(true);
        f.add(c);
        f.setVisible(true);
}

setupLWJGL() {
        //locate natives, then...
       try {
            Display.setDisplayMode(new DisplayMode(resX, resY));
            Display.setParent(cnv); //cnv is the same as c from the setupFrame(Canvas c)
           Display.create();
        } catch(LWJGLException ex) {
            Logger.getLogger(GameBase.class.getName()).log(Level.SEVERE, null, ex);
        }
        cnvW = Display.getWidth();
        cnvH = Display.getHeight();
        //...lighting, blending, matrices, etc....
}


Currently, the size of the frame should be 1200x675, and the canvas and Display should be a little less than that (1194x647) because of window borders. However, at some point in the code, the frame and canvas (and thus Display) sizes change from about 1194x647 to 1280x1002.

I've been mucking around in NetBean's debug mode and also with a bunch of print statements to figure out where the canvas and frame end up changing their dimensions. This goes wrong in two different ways and seems to happen at two different spots:

1. Display.setDisplayMode(new DisplayMode(resX, resY)); Before that line, the canvas dimensions are 1194x647, afterward they are 1280x1002. The game renders correctly, but in a window that takes up the whole screen instead of 1200x675.

2. f.setVisible(true); The same dimension change occurs during that line. I tried to follow the source code, and it seems to happen when the Component calls peer.setVisible(true).

Sometimes, the window takes up the full screen (it is still a decorated window, it's not in full screen mode), but only draws on a section of it that looks like it's about the 1200x675 size the window is supposed to be. I can't reliably reproduce this, but it happens sometimes. Also, which spot the frame and canvas change dimensions at is unpredictable, but seems to happen more on f.setVisible() when I'm in debug mode.

I'm guessing this isn't actually due to something within the code I'm using so much as maybe a synchronization issue? Since it seems to change when it happens when I'm using debug mode, the timing seems important.

Any ideas?

EDIT: It looks like if I remove the Display.setDisplayMode(), which I think is supposed to be unnecessary anyway if I give the Display a parent, the resizing changes to during the Display.create() line, and I get the glitch where the window is still big, but the rendering is the right size and takes up only part of the window and is scaled oddly. No, wait... I just ran it again without setDisplayMode(), and it resized at Display.setParent(cnv) and rendered in the whole window. So, this is very inconsistent and seems to not be connected to any particular piece of code I'm writing.
21  Game Development / Newbie & Debugging Questions / Re: Hard to start a project. on: 2014-02-27 04:51:12
I'll pile on to what everyone else is saying.

Just start with what you can do, and do the best you can with that. If it turns out well, you can try to find someone to replace the art and music. Meanwhile, just hack together your own, even if it's bad, or find free stuff online. There is a significant amount of legitimately free resources, though if you use it in a game you release, you should double-check the licenses to make sure you don't have to pay or get permission or release the source code (unless of course you're ok with that!).
22  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-21 15:09:21
Lol.

It feels inappropriate to reply just to say that. This forum feels too official. Maybe something's wrong with me.
23  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-21 14:34:46
Thanks, Cas!

I'll have to remember that about distributing the JRE with the game. I'm guessing a bit of searching will reveal some solutions or at least instructions for the best ways to do that.

Unfortunately, I'm pretty sure my netbook's video drivers are as up to date as I can get them. Intel 945GM does not appear to be the hottest thing around. Which brings up the related question of how to use OpenGL extensions with LWJGL, but I'll search around a bit more before starting a thread about that. (Unless you already have a link handy. Tongue )

Btw, I think it's cool that you frequent these forums. I loved Revenge of the Titans (despite not being able to tell what upgrades would do ahead of time), and I can't help but wonder how you find/steal time to answer newbie questions.
24  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-21 14:26:02
Haha, thanks for the advice.

Hm... well, I'm a little blurry on how forwards compatibility works in Java. If I wrote something in Java 7, and someone had Java 6, would it always work, sometimes work depending on the features I used, or never work? (Or maybe I could bypass the whole issue by distributing the right JRE with the game... I think I've heard you can do that.)

If there's no reason to use Java 6, then I might as well follow your advice.

As a side note, it's my personal irrational goal to make sure the game can run on my netbook, which, despite coming with Windows 7 Starter, for some reason only supports OpenGL 1.4. Even though it was made in 2009. So I guess I have a lot of sympathy for people on old machines that just want to play a game that doesn't really look like it should need a new machine.
25  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-20 06:14:05
Looks like you guys are probably right!

If I search "java" in the start menu, it quickly comes up with Configure Java, About Java, and java.exe. If I open Configure Java, I'm seeing that I have Java 1.7.0_45 listed first in the User tab, with 1.6.0_31 second, and both are enabled. The System tab just has 1.7. All are located in Program Files (x86). So it looks like Windows is set up to use 32bit JREs.

If I instead open About Java, it tells me 1.7.0_45-b18. Presumably the same JRE that is listed first in Configure Java.

However, in control panel (Win7) -> Java, it lists only 1.6.0_26 in both User and System tabs, located in Program Files. So, that would indicate Windows is set up to use a 64bit Java 1.6 JRE.

In Control Panel -> Programs and Features, it looks like I have the following installed:
Java 7 Update 45
Java 6 Update 26 (64bit)
Java 6 Update 31
Java SE Dev Kit 6 Update 26 (64-bit)
Java SE Dev Kit 7 (64bit)

The NetBeans project is set to use JDK 1.6 as the platform. Under Tools -> Java Platforms, I have JDK 1.6.0_26 as the default, followed by JDK 1.7.0. I did pick 1.6 intentionally, because I assumed developing for Java 6 would have a broader install base than Java 7, and it would let me get a better idea of how it would run on less up-to-date systems even if that wasn't true. I don't know if that's really the case.

If I check java -version in command prompt, I see:
java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) 64-Bit Server VM (build 20,1-b02, mixed mode)

I guess what's going on is that command prompt and NetBeans are set to use 64bit Java 6, while double-clicking jars is set to use 32bit Java 7. Does that look like the case to you guys?

...how do I straighten Windows out? It has two separate Java Control Panels, one accessible from Windows Control Panel (the 64bit Java 6), one accessible from the start menu (the 32bit Java 7 and Java 6).

And what should I expect users to have if it's this messy on mine?! Thanks for your help in at least steering me in the right direction so far.
26  Game Development / Newbie & Debugging Questions / Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-16 09:40:27
The framerate on my game drops from 16-19 to 10 when I run it from a jar by double-clicking. Running it from the same jar by command prompt or from the project itself in the IDE gives me the higher framerate.

I'm using LWJGL, but I've found posts about this problem both elsewhere and here by people not using OpenGL. No solutions that I noticed though.

Any ideas?
27  Java Game APIs & Engines / OpenGL Development / Re: Texture binding not updating current texture on: 2013-12-30 16:21:21
I'm loading from two different libraries because slick lets me get them from the hard drive, but I needed to also be able to create them from BufferedImages that have had their pixel date manipulated at runtime, so I coded a version to do that.

Update:
Ok, tried your suggestion. I found TextureImpl.unbind() and TextureImpl.bindNone(), and both seem to work to get my texture out of the way and allow the slick textures to bind, so long as I call one and then bind the slick texture before glBegin(). Looks like it does the reverse as well. So, thanks! That seems to have fixed it. Odd though, as I'd made my own TextureRgba as an implementer of slick's Texture. Looking at the docs for the TextureImpl class you pointed out, maybe I should subclass that instead. Or maybe that will break things again. Suppose I'll have to try it.
28  Java Game APIs & Engines / OpenGL Development / [Solved, mostly] Texture binding not updating current texture on: 2013-12-30 14:36:17
UPDATE: Actually, if I try to render the norm TextureRgba, I get the equivalent problem. It looks like once I use texRgbaLoad(), it ignores Texture.bind() and only pays attention to glBindTexture(). I can swap out the return TextureRgba.loadTexture() in texRgbaLoad() with return null, and I don't get this problem. So it's definitely something in my TextureRgba.loadTexture() method. It's not the return new TextureRgba() line at the end, as commenting that out doesn't fix it. However, if I comment out both that line and the glBindTexture() in the same method and the glTexImage2D() line, the problem does go away. But of course, then I can't use the custom texture loading that TextureRgba.loadTexture() accomplishes. If I try to render the norm TextureRgba, it draws the door texture instead, scaled to the dimensions of norm.

I'm having a weird problem. If I load a Texture using slick's TextureLoader.getTexture(), all is well. However, if I afterwards load a different texture using a custom loader designed to create them from BufferedImages, I can no longer draw the one I loaded from slick unless I specifically use glBindTexture(GL_TEXTURE_2D, texvar.getTextureID()). Simply using texvar.bind() no longer seems to have any effect. Instead, it just draws the one I loaded earlier with my custom loader, but scaling to the dimensions of the texvar texture.
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  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
public class GLTest {

private Texture door;
private int texW;
private int texH;
private int w = 1280;
private int h = 1024;
public GLTest() {
    //make display

    door = loadTexture("normal-example");
    TextureRgba foo = texRgbaLoad();

    //lwjgl setup, loop begins
   while(!Display.isCloseRequested()) {
    glClear(GL_COLOR_BUFFER_BIT);
    door.bind();
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
        renderTexture(door, 100, 200);
    glEnd();
    //rest of loop
   }

    //relevant methods
   private TextureRgba texRgbaLoad() {
        BufferedImage img; int imgw = 0, imgh = 0; int[] rgba;
        int[] colors;
        try {
            img = ImageIO.read(new File(GameBase.assetsDir + "normal-example.png"));
            imgw = img.getWidth(); imgh = img.getHeight();
            rgba = new int[imgw * imgh];
            colors = img.getRGB(0, 0, imgw, imgh, null, 0, imgw);
            for(int y = 0; y < imgh; y++) {
                for(int x = 0; x < imgw; x++) {
                    Color c = new Color(colors[y*imgw + x]);
                    rgba[y*imgw + x] = c.getRGB();
                }
            }
            return TextureRgba.loadTexture(rgba, imgw, imgh);
        } catch(IOException ex) {
            Logger.getLogger(GLTest.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
   
    private Texture loadTexture(String key) {
        try {
            System.out.println("loading: assets/" + key + ".png");
            return TextureLoader.getTexture("PNG", new FileInputStream(new File("assets/" + key + ".png")));
        } catch(FileNotFoundException ex) {
            Logger.getLogger(GLTest.class.getName()).log(Level.SEVERE, null, ex);
        } catch(IOException ex) {
                Logger.getLogger(GLTest.class.getName()).log(Level.SEVERE, null, ex);
            }
        return null;
    }
   
    private void renderTexture(Texture t, float x, float y) {
        int tw = t.getTextureWidth();
        int th = t.getTextureHeight();
        glTexCoord2f(0,0);
        glVertex2f(x, y);
        glTexCoord2f(1,0);
        glVertex2f(x+tw, y);
        glTexCoord2f(1, 1);
        glVertex2f(x+tw, y+th);
        glTexCoord2f(0, 1);
        glVertex2f(x, y+th);
    }
   
    public static void main(String[] args) {
        new GLTest();
    }
   
}

Note that this code never actually does anything with the custom foo texture. All it does is load it. If I put that one line, TextureRgba foo = texRgbaLoad();, before door = loadTexture("door"); instead of after it, or if I just comment it out, everything works fine. Here is the TextureRgba.loadTexture() code, in another class, in another package:
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  
    private TextureRgba(int id, int imgWidth, int imgHeight, int texWidth, int texHeight) {
        this.id = id;
        this.imgWidth = imgWidth;
        this.imgHeight = imgHeight;
        this.texWidth = texWidth;
        this.texHeight = texHeight;
    }
    public static TextureRgba loadTexture(int[] rgba, int sourceW, int sourceH) {
        int textureID = glGenTextures();
       
        //determine texture dimensions
       //put the pixels from the provided rgba array into a ByteBuffer named buffer and flip it
       
        //"Bind the texture handle to the context"
       glBindTexture(GL_TEXTURE_2D, textureID);
       
        //"Set the scaling filtering"
       //specifies how it is handled when minified and magnified
       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
       
        //"Send the buffer to OpenGL"
       //makes the texture
       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texW, texH, 0,
                GL_RGBA, GL_UNSIGNED_BYTE, buffer);
       
        return new TextureRgba(textureID, sourceW, sourceH, texW, texH);
    }


Anyone got any ideas? I guess I could work around it by using the glBindTexture() instead of the Texture.bind(), or by extending the Texture class to override its bind() method to use glBindTexture()... but it's always nice to figure out what I'm doing wrong in the first place.

Thanks in advance for any insight.
29  Game Development / Game Play & Game Design / Re: RPG stats on: 2013-12-25 11:54:24
I've had troubles to come up with list of more than about 5 or 6 stats, so that each stat isn't overlapping with another one. Since you like games with many stats, maybe you can give me a few suggestions of sets with more than 6 stats, which all are meaningful and not overlapping or influencing each other?

This is a pretty late reply, but it looks like you're a regular member, so you'll see it eventually!

I actually think 5 or 6 is a pretty good number for basic, core attributes for a character. D&D is the classic example, with Strength, Dexterity, Constitution, Intelligence, Wisdom, and Charisma. In my own tabletop RPG, I use Strength, Endurance, Dexterity, Agility, Magical Aptitude, and Aura.

The trick is combining these in different ways to get other numbers. For example, you can throw in skill ratings with various weapons and combine those with a dex stat to get different accuracy stats for your different armament options. You can then combine those same weapon skill ratings with agility to get dodge stats. (And I do this in my game, of course.) Really, you need a couple small groups of intuitive stats that interact in various ways to influence what you can do in the game. In these examples, you just have a handful of physical stats to measure what the character is and a handful of skill stats to measure what they're good at, and they work together to create the final result, which is the number you would actually look at for a given task.

If you do ever use lots of different groups of stats, I'd suggest keeping the numbers in their own separate scales. So maybe one group of stats would typically be values from 10-20, while another group would be in the hundreds. On one hand, this could make things more confusing, but on the other, it communicates to the player that they're not comparable -- they're not looking at an overwhelming list of equally important things, but at a few different categories that do different things, where the numbers only need to be weighed against other numbers in the same group.

Of course, the more numbers you have, the easier it is to confuse people. So, your mileage may vary.
30  Game Development / Game Play & Game Design / Re: RPG stats on: 2013-12-05 15:22:23
My preference is for more stats. But that's because I like customizing things, which is what more stats typically enable. I think each stat should provide some meaningful option to the player. That could mean that different stats favor different playstyles, or it could mean that specific ones are useful in specific tactical situations. Generally speaking, more stats encourages more strategic, planned play, and fewer stats encourages more action-oriented play, at least in my experience.
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.

atombrot (26 views)
2014-08-19 09:29:53

Tekkerue (24 views)
2014-08-16 06:45:27

Tekkerue (23 views)
2014-08-16 06:22:17

Tekkerue (13 views)
2014-08-16 06:20:21

Tekkerue (20 views)
2014-08-16 06:12:11

Rayexar (58 views)
2014-08-11 02:49:23

BurntPizza (38 views)
2014-08-09 21:09:32

BurntPizza (30 views)
2014-08-08 02:01:56

Norakomi (37 views)
2014-08-06 19:49:38

BurntPizza (67 views)
2014-08-03 02:57:17
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!