Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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]
1  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 21: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.
2  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 20: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.
3  Java Game APIs & Engines / OpenGL Development / Re: AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 20: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.
4  Game Development / Newbie & Debugging Questions / Re: Collision bug in a 2D platfrom game. on: 2014-05-26 20: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.
5  Java Game APIs & Engines / OpenGL Development / AWT Frame and Canvas parented to LWJGL Display is resizing on creation on: 2014-05-26 20: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.
6  Game Development / Newbie & Debugging Questions / Re: Hard to start a project. on: 2014-02-27 05: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!).
7  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-21 16:09:21
Lol.

It feels inappropriate to reply just to say that. This forum feels too official. Maybe something's wrong with me.
8  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: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.
9  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: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.
10  Game Development / Newbie & Debugging Questions / Re: Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-20 07: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.
11  Game Development / Newbie & Debugging Questions / Framerate cut in half when running by clicking jar vs command line or netbeans on: 2014-01-16 10: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?
12  Java Game APIs & Engines / OpenGL Development / Re: Texture binding not updating current texture on: 2013-12-30 17: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.
13  Java Game APIs & Engines / OpenGL Development / [Solved, mostly] Texture binding not updating current texture on: 2013-12-30 15: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.
14  Game Development / Game Play & Game Design / Re: RPG stats on: 2013-12-25 12: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.
15  Game Development / Game Play & Game Design / Re: RPG stats on: 2013-12-05 16: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.
16  Game Development / Newbie & Debugging Questions / Re: Final Score Screen Effect Libgdx on: 2013-11-28 18:15:11
You can either subtract the score each frame and add what you subtracted to the grand total (so, each frame you're transferring score from the countdown score to the player's total score) and then render the results, or you can just show the score minus: the amount of time passed times the amount to subtract per unit of time passed, and then transfer the score at the end.

You can treat it as subtracting from the score every frame and showing the result, or you can treat it as showing a countdown animation every frame. Either way will work. My point is that you don't have to confine yourself to thinking, "I have to change the score every frame!" You just have to change what the player sees every frame.
17  Game Development / Newbie & Debugging Questions / Re: Hello, and OpenGL? on: 2013-11-28 16:09:39
There we go. Looks like imageshack worked (and apparently I had an account there?). Odd that it stretches the image unless it is exactly 80x80 though. And that there are no instructions I can see. Tongue But it works! Thanks.
18  Game Development / Newbie & Debugging Questions / Re: Final Score Screen Effect Libgdx on: 2013-11-28 15:48:32
If you want it to take a certain amount of time, no matter what the score, a timer might be appropriate. (I've never used one -- just checking the current time via the System.getMilliseconds or System.getNanos methods (not their exact names).) If you want the speed at which it counts down to be constant, say 10,000 per second, so that it will take longer to count down big numbers than small numbers, I don't see why you'd need a timer. Even if you want it to take a certain amount of time, regardless of score, you don't need one. You just need to know when you started counting down and what time it is when you're ready to show the numbers. Remember, you don't need to actually change the score numbers. It's just an effect. You're just changing what the player sees. Whether you want to use a timer or not is up to you.

As for audio, that's also up to you, man. It's a matter of preference.
19  Game Development / Newbie & Debugging Questions / Re: Hello, and OpenGL? on: 2013-11-28 15:41:48
Quote
You'll find a lot of applications, especially games, contain certain amounts of hackery. It's not necessarily a bad thing so long as you understand the ramifications of your hacks. ... As for threads, give this one a try, and browse through the Java2D section.
Ah, yes, that was the thread I was referring to, since people argued vigorously over whether it was a dangerous hack. I think I'll take a look at the Java2D section.

By the way, how do forum avatars work here? Every time I tried to add one, it didn't work. Would that be because I tried using Google Drive, Picasa, Dropbox, and Facebook to upload it, and it can't handle those links? Or are there specific requirements for the images I'm missing?
20  Game Development / Newbie & Debugging Questions / Re: Hello, and OpenGL? on: 2013-11-28 02:54:13
Oh, wow. I forgot LWJGL's license was so short. Thanks for the link, and for both of you responding. I've looked at it before, and I guess I really was just being paranoid. I think I remember some games (Revenge of the Titans, maybe?) just having the LWJGL notice as a screen in their installer. If that's all I have to worry about, maybe I should stop doing things the hard way. Tongue

philfrei, I did see that audio thread the other day. Confusions like the one in that thread over whether the game aside from the assets themselves would have to be freed to use CC audio are a big reason I've been hesitant to stray outside the bounds of Java SE, but I suppose I really have nothing much to lose with some of the more permissive licenses.

OpenGL is pretty universal, right? If I moved my rendering over to LWJGL, would I be shutting out older computers, people with integrated graphics cards, etc? Would I be opening myself up to a whole new world of support nightmares with graphics driver bugs and finnickiness?

I've seen a thread or two about different ways of doing per-pixel manipulation of images without OpenGL, and it sounds like the fast ways are kind of hacky. So, for something like dynamic lighting with Sprite Lamp normal maps, where I have to change the color of each pixel in an image, is there a thread that discusses the best ways to do this? I've got the code to do it right now, but like I said in my OP my framerate dropped from 174 to 7.

Should I be posting these questions in their own threads? Or somewhere else? Sorry, got this gush of text and questions spewing forth...
21  Game Development / Newbie & Debugging Questions / Re: Final Score Screen Effect Libgdx on: 2013-11-27 16:23:17
The score numbers rolling down to 0? Yeah, that shouldn't be too bad. I'm not very knowledgeable about graphics or libgdx, but I can tell you the basic logic.

1. Figure out the scores, along with how fast you want them to go down. Let's say you're dealing with scores in the tens of thousands and want them to go down at 10,000 per second. That rate should be saved in a variable.
2. Display the scores. Note the time these are drawn to the screen.
3. Every time you get another chance to draw another frame to the screen, for the score currently being counted down:
1  
2  
3  
4  
5  
//set the score we'll display to be subtracted based on the amount of seconds that have passed * the amount we want to count down per second
currentScore = startingScore - (millisecondTimeRightNow - millisecondTimeOfStep2) / 1000 * rate
//check if we're done counting this score down, and if so, show 0 and add that score to the player's total score
if(currentScore < 0) { currentScore = 0; noMoreLooping = true; playerScore += startingScore }
//draw playerScore, currentScore, and any other scores you aren't currently counting down

4. When you've counted down the last score, you're done. Wait for the player to press a key or something.

Edit: And for the love of all that is good, don't make it count down too slow. Otherwise, impatient players like me will get bored after the first couple times and keep tapping buttons or keys in vain, hoping to skip to the end of the countdown. (Or just make it skip to the end by setting all the countdown scores to 0 and updating the player's score when you press a certain key.) It's still a cool effect though.
Edit edit: Note that my syntax is wrong in a couple places at least. My code is just for an example of the logic. It won't work just copy-pasted. Tongue
22  Game Development / Newbie & Debugging Questions / Hello, and OpenGL? on: 2013-11-27 15:33:53
Hello! I'm a newbie as far as video game development goes, and I suppose to Java as well. Maybe intermediate. I've been programming in a couple of classes and in spare time since 200...5? -ish? So, I understand a lot of basic programming concepts and thought processes, but not a lot of the lower-level science and engineering, and most of my experience is in Java. I leave it to you to label my skill level.

I wanted to join this forum because it's one of the two places I've frequently found answers while Googling for my own questions, because it only seemed right that as a person trying to make a game in Java I should join a Java game dev forum, and because I have questions. So, thanks for having me (so far!).

My question right now is, what risks (in terms of licensing, cross-platform compatibility, and system requirements) and learning curves am I in for if I switch to OpenGL rather than throwing BufferedImages onto an AWT Canvas and a BufferStrategy with Graphics2D?

Background: I'm trying to make a pseudo-isometric, 2d, tactical RPG. It is intended to be a commercial release, however long it takes us to get there. I'm developing in Java 6 SE, with nothing extra at the moment because licenses scare me, and I honestly don't know how distributing it would work once I go beyond the built-in stuff. I'd really love it to run at no work for the user on Windows XP and onward, recent versions of Mac OS X, and the more popular Linux distributions. I'd love for it to run at at least 30fps on my 1.6GHz netbook. So, I'm casting a pretty broad net. The OpenGL question is being pressed because our Illustrious Art Director is very interested in using Sprite Lamp for dynamic lighting. I got the game to process a normal map (this one) to light a blank, grey square that covers maybe 2/3 of the game window, but this dropped the fps from 174 to 7 on my mid-range machine.

If anyone is interested in giving advice or suggestions on OpenGL or alternate routes (I could post my normal mapping code), or just a link to a topic I've missed where this has been covered before, I'd appreciate the help.

Thanks, and hope that question wasn't too demanding for a newcomer!
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

ctomni231 (35 views)
2014-07-18 06:55:21

Zero Volt (31 views)
2014-07-17 23:47:54

danieldean (26 views)
2014-07-17 23:41:23

MustardPeter (28 views)
2014-07-16 23:30:00

Cero (43 views)
2014-07-16 00:42:17

Riven (45 views)
2014-07-14 18:02:53

OpenGLShaders (34 views)
2014-07-14 16:23:47

Riven (35 views)
2014-07-14 11:51:35

quew8 (31 views)
2014-07-13 13:57:52

SHC (67 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!