Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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 / Newbie & Debugging Questions / Re: blurry image - java slick2d on: 2013-12-22 18:10:26
Grab the latest version from the repo.

Lol, I'm downloading right now the latest version from http://slick.ninjacave.com/, no way that I had out out of date version.

EDIT:

I'm checking now javadoc for LoadableImageData, and it does not contain the getFormat() method:
http://slick.ninjacave.com/javadoc/org/newdawn/slick/opengl/LoadableImageData.html

Here's a slightly modified version of the function from Kevin's old codebase:
1  
2  
3  
public static boolean isGenerateMipmapSupported() {
   return GLContext.getCapabilities().OpenGL14;
}

Thanks for that, but what about the

1  
ImageData.Format fmt = imageData.getFormat();


There's no Format class :/, and getFormat() method from LoadableImageData class.. ?
2  Game Development / Newbie & Debugging Questions / Re: blurry image - java slick2d on: 2013-12-22 17:14:29
I've found a nice example on how to get smoother downscaling
https://bitbucket.org/kevglass/slick/src/tip/trunk/Slick/src/org/newdawn/slick/tests/MipmapTest.java?at=development

but it seems that latest version of Slick2D, does not include

1  
2  
3  
supported = InternalTextureLoader.isGenerateMipmapSupported(); // the InternalTextureLoader does not have this method
...
ImageData.Format fmt = imageData.getFormat(); // also this ImageData doesn't have that static class Format


So I can not run a test...
3  Game Development / Newbie & Debugging Questions / Re: blurry image - java slick2d on: 2013-12-22 12:11:21
Ok, thanks for the information.
4  Game Development / Newbie & Debugging Questions / Re: blurry image - java slick2d on: 2013-12-21 18:10:49
Have you considered using Slicks shape and gradient drawing functions to generate the image in question at run time instead of loading it from a preexisting image? It's a little work, but in this particular scenario it could give you the smooth look you want.

Yes, and I've already experienced that, when I used to make this components, and unfortunately found that it is really bad to draw rounded shapes in Slick2D, as I had the problems with using the AA on them. Whenever I would like to draw some rounded rectangle or circle, some strange pixels would appear above the corners. I have already asked for an answer to this problem on Slick2D forum, but they say that Slick2D not suitable for drawing rounded shapes.
5  Game Development / Newbie & Debugging Questions / Re: blurry image - java slick2d on: 2013-12-21 15:50:57
Quote
Odd question, but what is the original size of the image?
-580/320, png format.

Quote
GL_NEAREST is the fastest scaling filter but
GL_LINEAR is the one that gives you best appearance.

- It's same, nothing changes.



The image is going to look blurry no matter what, since we are re-sampling it and there are always artifacts.
To reduce artifacts, use a power-of-two texture size and snap to a scaling factor like 0.5 instead of 0.473.
For really small sizes, you can use mip-mapping in OpenGL to get smoother down-sampling, but that isn't well supported in Slick.

- Looks better if I set 0.5 value to scaling factor, but that's not size I need.



It seems, that everything below 0.5 is goint to make picture look blurry.. :/
You can see that these smaller circles (in above picture) are also blurry, which are images, scaled with factor less than 0.5..


6  Game Development / Newbie & Debugging Questions / blurry image - java slick2d on: 2013-12-20 23:20:25
So, I have a scaled image size, but the problem is, the image is blurry..
I've found related topic http://slick.ninjacave.com/forum/viewtopic.php?f=3&t=5145 on this problem, but for some reason it does not affect.

With out Image.FILTER_NEAREST
1  
2  
3  
4  
5  
6  
7  
            Image tableImg = new Image(tableImgRef);
            float miniTableScale = 0.35f;
            float miniTableX = miniTableBGX + (((miniTableBGX + miniTableBGWidth) - miniTableBGX) / 2)
                                                        - ((tableImg.getWidth() * miniTableScale) / 2);
            float miniTableY = miniTableBGY + (((miniTableBGY + miniTableBGHeight) - miniTableBGY) / 2)
                                                        - ((tableImg.getHeight() * miniTableScale) / 2);
            tableImg.draw(miniTableX, miniTableY, miniTableScale);



With Image.FILTER_NEAREST, it seems even worse.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
            String tableImgRef = UI_PATH + setupTable.getTableTheme() + "/table.png";
            Image tableImg = new Image(tableImgRef, false, Image.FILTER_NEAREST);
            float miniTableScale = 0.35f;
            float miniTableX = miniTableBGX + (((miniTableBGX + miniTableBGWidth) - miniTableBGX) / 2)
                                                        - ((tableImg.getWidth() * miniTableScale) / 2);
            float miniTableY = miniTableBGY + (((miniTableBGY + miniTableBGHeight) - miniTableBGY) / 2)
                                                        - ((tableImg.getHeight() * miniTableScale) / 2);
            tableImg.draw(miniTableX,
                          miniTableY,
                          tableImg.getWidth() * miniTableScale,
                          tableImg.getHeight() * miniTableScale
            );



7  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-19 16:49:58
Yep, that works.

This is what I did, when I was trying,
1  
multiplier = (this.value- (this.maxValue / this.minValue));

but, I forgot to subtract and minValue, so that's why it didn't want to work first time.

Thank once again!
8  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-19 13:48:59
K, I will be here.

EDIT:

This was the idea.
Now, it works for both cases:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
    public void setValue(float newValue) {
        if (this.value != newValue) {
            float multiplier;        
            this.value = Math.min(Math.max(this.minValue, newValue), this.maxValue);    
            multiplier = (this.value / this.maxValue);
            this.percentage = multiplier * 100.0f;  
            float sBoxX = this.lineX + (this.lineWidth * ((this.value / Math.abs(this.maxValue - this.minValue))))
                                     - Math.round(sliderBoxWidth / 2);
            if (this.minValue != 0) {
                sBoxX = sBoxX - this.lineWidth;
            }
            this.sliderBoxX = sBoxX;
//            this.sliderBoxX = this.lineX + (this.lineWidth * ((this.value / Math.abs(this.maxValue - this.minValue))))
//                             - Math.round(sliderBoxWidth / 2)
//                             - this.lineWidth;
        }
    }


But don't you think it's dirty..? Smiley
I believe, now you can maybe see where's the problem.
9  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-19 13:45:06
1  
2  
Values before recalculation: sliderBoxWidth=13.0, lineWidth=192.0, lineX=262.0
Values after recalculation: sliderBoxWidth=13.0, lineWidth=192.0, lineX=262.0


I could here set the condition before initializing sliderBoxX variable, so if minValue is 0, then subtract sliderBox for lineWidth, else, don't subtract that lineWidth.
But I think this is dirty way...
10  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-19 13:23:35
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
    public void setValue(float newValue) {
        if (this.value != newValue) {
            float multiplier;        
            this.value = Math.min(Math.max(this.minValue, newValue), this.maxValue);    
            multiplier = (this.value / this.maxValue);
            this.percentage = multiplier * 100.0f;  
            this.sliderBoxX = this.lineX + (this.lineWidth * ((this.value / (this.maxValue - this.minValue))))
                             - Math.round(sliderBoxWidth / 2)
                             - this.lineWidth;
        }
    }

I'm not sure is this correct way to compute slideboxx, but slider box does move now properly.

EDIT:
Just kidding, now it does not compute for case where we have for a minValue/maxValue 0/1000, but works for 500/1000...
11  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-19 12:59:13
There's nothing to test, the problem is in the computation for box, since multiplier returns correct value, 0.5 for 500.
12  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-18 17:54:50
Quote
I'm just hoping that if the TextField gets focus it doesn't suddenly cause the "if (!this.hasFocus) return;" check to fail.

Don't worry. Smiley
I should rename hasFocus into something else.
Anyway, the idea was to block the other components in updating, if any window, for example dialog, pops up.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
public abstract class PAbstractState extends BasicGameState {

    protected boolean hasFocus;
   
    protected PAbstractState() {
        this.hasFocus = true;
    }

    public boolean hasFocus() {
        return hasFocus;
    }

    public void enableFocus() {
        this.hasFocus = true;
    }
   
    public void disableFocus() {
        this.hasFocus = false;
    }
   
}


So, function works like pause/unpause. I just set "this" which points to PAbstractState, as a argument to the component method,
for components like a Dialog, in my case for now it's only PDialog.
So it's something like this,

1  
String s = JOptionPane.showConfirmDialog(this, "", "", );


But instead of static calling, I'm using the instance of the PDialog..
And simply, when some action occurs, dialog pops up, the method is activated and changes stance of the hasFocus variable for this state...

Anyway, let's back on the topic.
It seems that it is working. I tested quickly, unfortunately I do not have much time to play with programming now,
but the reason why I'm saying "seems",
for a min/max value 0/1000 SliderBox X coordinate, moves ok,
but for 500/1000, SliderBox for a min value starts from the center of the slider line, instead at the minX or start X of the slider line.
What is really interesting with this, no matter how it starts from the center of the line,
it still moves (computing)properly for that half line width, until 1000 or a maxX of the line. Cheesy

However,  I will leave for tomorrow, this testing, don't hate me Cheesy, because I have to go tonight to watch a Hobit movie Smiley,
but tommorow I will do test, and try to figure out.
So I will inform you tomorrow, what I assume that cause this.
 
13  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-17 23:57:51
Sorry for late response, I was doing some other work.
I was afraid that you misunderstood me, my english..
But anyway, this is how the things are.
 
The first snippet, is written in actionPerform method at the end, and that method is inside PSlider class.
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  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
    public void performAction(GameContainer gc, int mx, int my) throws SlickException {
        Input input = gc.getInput();

        this.sliderBoxWidth = Math.round(this.height / 2);
        this.sliderBoxHeight = Math.round(this.height / 2);
        this.sliderBoxY = Math.round(this.y + ((this.y + this.height) - this.y) / 2
                                 - (this.sliderBoxHeight / 2));
       
        this.lineWidth = Math.round(this.width - this.sliderBoxWidth);
        this.lineHeight = 1;
        this.lineX = Math.round(this.x + (this.sliderBoxWidth / 2));
        this.lineY = Math.round(this.y + ((this.y + this.height) - this.y) / 2);
       
        if (this.sliderBoxX < this.lineX - Math.round(this.sliderBoxWidth / 2)) {
            this.sliderBoxX = this.lineX - Math.round(this.sliderBoxWidth / 2);
           
            if (this.value != this.minValue) {
                this.value = this.minValue;
                this.newValue = this.value;
            }
        }
        else if (this.sliderBoxX > this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2)) {
            this.sliderBoxX = this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2);
           
            if (this.value != this.maxValue) {
                this.value = this.maxValue;
                this.newValue = this.value;
            }
        }
       
        float mxRelative = mx - this.lineX;
       
        if (my >= this.y && my <= this.y + this.height) {
            if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
                if ((mxRelative >= 0) && (mxRelative <= this.lineWidth)) {
                    this.percentage = (float) (mxRelative / this.lineWidth) * 100;
                    this.value = this.minValue + ((this.maxValue - this.minValue) * percentage) / 100;
                    this.sliderBoxX = mxRelative + this.lineX - Math.round(sliderBoxWidth / 2);
                   
                    this.newValue = this.value;
                }
            }
        }
       
        float minSliderBoxX = this.sliderBoxX;
        float minSliderBoxY = this.sliderBoxY;
        float maxSliderBoxX = this.sliderBoxX + this.sliderBoxWidth;
        float maxSliderBoxY = this.sliderBoxY + this.sliderBoxHeight;
        if ((mx > minSliderBoxX && mx < maxSliderBoxX) && (my > minSliderBoxY && my < maxSliderBoxY)) {
            if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
                wasSliderBoxDown = true;
            }
        }

        if (wasSliderBoxDown) {
            if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
                if (mxRelative >= 0 && mxRelative <= this.lineWidth) {
                    this.percentage = (float) (mxRelative / this.lineWidth) * 100;
                    this.value = this.minValue + ((this.maxValue - this.minValue) * percentage) / 100;
                    this.sliderBoxX = mxRelative + this.lineX - Math.round(sliderBoxWidth / 2);
                   
                    this.newValue = this.value;
                }
            } else {
                wasSliderBoxDown = false;
            }
        }

       
        if (this.newValue != this.value) {
            float tempSliderBoxX = 0;

            if (tempSliderBoxX >= 0 && tempSliderBoxX <= this.lineWidth) {
                if (this.newValue > this.maxValue) {
                    this.newValue = this.maxValue;
                    this.value = this.newValue;
                    this.percentage = 100.0f;
                    this.sliderBoxX = this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2);
                }
                else if (this.newValue < this.minValue) {
                    this.newValue = this.minValue;
                    this.value = this.newValue;
                    this.percentage = 0.0f;
                    this.sliderBoxX = this.lineX - Math.round(this.sliderBoxWidth / 2);
                }
                else {
                    this.value = this.newValue;
                    this.percentage = (float) (tempSliderBoxX / this.lineWidth) * 100;
                    this.sliderBoxX = tempSliderBoxX;
                }
            }
        }
    }


Second snippet, the method update, is part of the state class which extends BasicGameState. The class contains update, render, init methods...
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  
    @Override
    public void update(GameContainer gc, StateBasedGame sg, int delta) throws SlickException {
        Input input = gc.getInput();
        int mx = input.getMouseX();
        int my = input.getMouseY();

        setupTable.setTableStake((String) tableStakesCB.getSelectedItem());
        setupTable.setGameSpeed((String) gameSpeedCB.getSelectedItem());
        setupTable.setTableTheme((String) tableThemeCB.getSelectedItem());
       
        if (!this.hasFocus) return;

        float minValue = 500;
        float maxValue = 1000;
        // sets min & max values to slider component
        tempSlider.setInitialValues(minValue, maxValue);
        // performs actions
        tempSlider.performAction(gc, mx, my);

        // sets a slider value on the text field, if enter is pressed
        tempField.setText(String.valueOf(tempSlider.getValue()));
        System.out.println("Text field: " + tempField.getText() + " \t Slider: " + tempSlider.getValue());
       
        tableStakesCB.performAction(gc, mx, my);
        gameSpeedCB.performAction(gc, mx, my);
        tableThemeCB.performAction(gc, mx, my);
    }


One of the problems, which I was worried, when I was about to start to create these components, was listener.
I am familiar with it, and I had the opportunity to use an anonymous class listener, back when I made my first Swing project, but the problem is that I hadn't the opportunity to create the functionality to interface on the simpler examples, that will produce the listener system for the component.
So my idea was that (and since this is my first slick2d project), to make the simple components with out listener interfaces, which will use the basic functions update / render, literally acting as an entity, and I succeeded in that.
The only component that I have not still made, is a TextField, but I hope to the already existing one from Slick2D, that I will be able to do something with it.
So I can finally go to the most fun part, which is to create a game logic, which I have already had made, but as a console game.
14  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-17 19:19:25
Definitely agree with your idea after I read your code, that a newValue should not be part of the class PSlider.
But the 9 line in your code, which I don't understand, how I'm going to use the instance tempField,
as it's not the member of the PSlider class?
15  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-17 01:17:07
Hi again, I was adding a new feature, so it has some connections with slider.
I assume that you have tried already TextField component that comes together with Slick2D. However, I want to share value between TextField & Slider, which means that for a value which is shown in TextField, also and Slider should have, or vice verse.

So far I have only one problem with a slider, to compute tempSliderBoxX variable based on a newValue.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
        if (this.newValue != this.value) {
            float tempSliderBoxX = 0;

            if (tempSliderBoxX >= 0 && tempSliderBoxX <= this.lineWidth) {
                if (this.newValue > this.maxValue) {
                    this.newValue = this.maxValue;
                    this.value = this.newValue;
                    this.percentage = 100.0f;
                    this.sliderBoxX = this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2);
                }
                else if (this.newValue < this.minValue) {
                    this.newValue = this.minValue;
                    this.value = this.newValue;
                    this.percentage = 0.0f;
                    this.sliderBoxX = this.lineX - Math.round(this.sliderBoxWidth / 2);
                }
                else {
                    this.value = this.newValue;
                    this.percentage = (float) (tempSliderBoxX / this.lineWidth) * 100;
                    this.sliderBoxX = tempSliderBoxX;
                }
            }
        }


And a second problem is about, to re-write (inside a textfield) the value after calling the method setValue().
Right now, I can get a value from the slider and use setText method on the textfield component, in order to show current slider value, and it well performs actions.
But the problem is, when we set that value to text field from a slider, it blocks me to re-write again some value in the textfield.
I can only move the cursor position with left & right arrows or backspace or delete button, but not and to remove characters from it and then write.
So I'm not sure if I'm missing some additional conditions for this or the problem is order of performing the actions.

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  
    @Override
    public void update(GameContainer gc, StateBasedGame sg, int delta) throws SlickException {
        Input input = gc.getInput();
        int mx = input.getMouseX();
        int my = input.getMouseY();

        setupTable.setTableStake((String) tableStakesCB.getSelectedItem());
        setupTable.setGameSpeed((String) gameSpeedCB.getSelectedItem());
        setupTable.setTableTheme((String) tableThemeCB.getSelectedItem());
       
        if (!this.hasFocus) return;

        float minValue = 500;
        float maxValue = 1000;
        // sets min & max values to slider component
        tempSlider.setInitialValues(minValue, maxValue);
        // performs actions
        tempSlider.performAction(gc, mx, my);

        // sets a slider value on the text field
        tempField.setText(String.valueOf(tempSlider.getValue()));
        System.out.println("Text field: " + tempField.getText() + " \t Slider: " + tempSlider.getValue());
       
        tableStakesCB.performAction(gc, mx, my);
        gameSpeedCB.performAction(gc, mx, my);
        tableThemeCB.performAction(gc, mx, my);
    }

        @Override
    public void componentActivated(AbstractComponent source) {
        if (!this.hasFocus) return;
       
        if (source == nameField) {
            setupTable.setPlayerName(nameField.getText());
        }
        if (source == totalPlayersField) {
            setupTable.setTotalPlayers(totalPlayersField.getText());
        }
        if (source == tempField) {
            if (tempField.getText() != null && tempField.getText().matches("[0-9]+")) {
                tempSlider.setValue(Float.parseFloat(tempField.getText()));
            }
        }
    }



I apologize for bad english, so please tell me if something was not clear.
16  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-12 18:32:37
There it is, that's the right way to compute, you made it Smiley. It was so simple, that I forgot the basic math...

I just made a little change, in order to get the correct percentage between 0.0-100.0%, not 0.0-1.0.

1  
2  
this.percentage = (float) (mxRelative / this.lineWidth) * 100;
this.value = this.minValue + Math.round((this.maxValue - this.minValue) * percentage) / 100;


So that I don't have to multiply in the getPercentage method, I think that's better. Anyway, thanks!
1  
2  
3  
    public float getPercentage() {
        return Float.parseFloat(decimalFormat.format(percentage));
    }


p.s. This will be a nice resource for those who want to make a nice basic slider component.
17  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-12 16:54:01
Again me.
I totally forgot to tell you, about the initializing sliderBoxX before even all actions are performed on the slider.
So, I have this condition, because if I don't want slider box x coordinate to be initialized with 0 value:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
        // set sliderBoX X coordinate start position
        if (this.sliderBoxX < this.lineX - Math.round(this.sliderBoxWidth / 2)) {
            this.sliderBoxX = this.lineX - Math.round(this.sliderBoxWidth / 2);
           
            // set value & percentage on the min
            if (this.value != this.minValue) {
                this.value = this.minValue;
//                this.percentage = (this.value / this.maxValue) * 100.0f; // not needed
            }
        }
        else if (this.sliderBoxX > this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2)) {
            this.sliderBoxX = this.lineX + this.lineWidth + Math.round(this.sliderBoxWidth / 2);
           
            // set value & percentage on the max
        }


I also have the method called setInitialValues (which initializes min & max value), this method is called inside of a update method before actionPerformed method, which is needed, because, I will almost always change min & max values during the game. However, we forgot to set properly values, I mean, slider works fine if we have for a minimum value 0, but if we have any other value greater than 0 set for the minimum value, slider will still perform actions between 0 and any other maxmimum value instead of that minimum value we have set (example 200-700). I've set the minValue on the value, but that does not affect on the calculations, since that value is not affected on the any of the code, so it makes no sense. :/

18  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-11 22:35:33
It is really working man!

"It's floating point errors that are throwing the percentages off."

Well, you know what, I would never ever think of this as a problem, even tho this problem was really pain, at least I learned some new things. Wish you a long life!
19  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-11 22:27:15
holy s***, it seem it worked.. wait.. give me 5m to play with it and test it   Shocked Smiley
20  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-11 22:13:48
Thanks for your help ctomni231. But the thing is I need to adapt the percentage on the width, so width scale should not change if I change the max value, I mean, it should not increase the scale width.
21  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-11 19:03:32
Quote
No! Not UML... UML is banned in many workplaces, causes arguments, drives people crazy :-)

But if you want to play with quick UML diagrams:
I forgot to mention, I'm not going to learn UML for fun, that's just my task, because it will be on my exam, unfortunately ...

CodeHead, I just gave up on trying to fix my slider component with those +/- boxes on the left and right side.
So I started following your instructions, with first code, but I ended up with the same problem as with +/- box I had, so incorrect value and percentage.

This is how the slider looks now, also you can see the maximum value in text field, which shows the value(0-1000)/percentage.



p.s. I know, many things are not done properly here, for example using the listener interfaces, instead I was doing everything in actionPerform a.k.a. update method..
But I will take care of that later..

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  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
public class PSlider extends PAbstractComponent {

    private float value;
    private float percentage;
    private float minValue, maxValue;
   
    private float lineWidth, lineHeight, lineX, lineY;
    private float sliderBoxWidth, sliderBoxHeight, sliderBoxX, sliderBoxY;
   
    private boolean wasSliderBoxDown = false;
           
    private float minusBoxWidth, minusBoxHeight, minusBoxX, minusBoxY;
    private float plusBoxWidth, plusBoxHeight, plusBoxX, plusBoxY;
   
    private PLabel label;
   
    public PSlider(float width, float height) throws SlickException {
        super();
       
        this.width = width;
        this.height = height;
       
        this.label = new PLabel(PFontType.LucidiaFaxRegular, 26, false, false);
        this.label.setNormalColor(new Color(0, 0, 0, .75f));
       
        this.value = 0;
    }
   
    public PSlider(float width, float height, float currentValue) throws SlickException {
        this(width, height);
       
        this.value = currentValue;
    }

    @Override
    public void render(Graphics g, float x, float y) throws SlickException {
        this.x = x;
        this.y = y;
       
        // render rect and fill
        float cornerRadius = 0;
        g.setColor(new Color(0, 0, 0, .5f));
        g.fillRoundRect(x, y, width, height, (int) cornerRadius);
        g.setColor(Color.decode("#ffffbe"));
        g.drawRoundRect(x, y, width, height, (int) cornerRadius);
       
        // render line
        float lineX1 = this.lineX;
        float lineX2 = this.lineX + this.lineWidth;
        float lineY1 = this.lineY;
        float lineY2 = lineY1;
        g.setColor(Color.decode("#ffffbe"));
        g.drawLine(lineX1, lineY1, lineX2, lineY2);
       
        // render slider box
        float sBoxX = this.sliderBoxX;
        float sBoxY = this.sliderBoxY;
        float sBoxWidth = this.sliderBoxWidth;
        float sBoxHeight = this.sliderBoxHeight;
        g.setColor(new Color(223, 182, 105));
        g.fillRoundRect(sBoxX, sBoxY, sBoxWidth, sBoxHeight, (int) cornerRadius);
        g.setColor(Color.decode("#ffffbe"));
        g.drawRoundRect(sBoxX, sBoxY, sBoxWidth, sBoxHeight, (int) cornerRadius);
    }
   
    public void performAction(GameContainer gc, int mx, int my) throws SlickException {
        Input input = gc.getInput();

        this.sliderBoxWidth = this.height / 2;
        this.sliderBoxHeight = this.height / 2;
        this.sliderBoxY = this.y + ((this.y + this.height) - this.y) / 2
                                 - (this.sliderBoxHeight / 2);
       
        this.lineWidth = this.width - this.sliderBoxWidth;
        this.lineHeight = 0;
        this.lineX = this.x + (this.sliderBoxWidth / 2);
        this.lineY = this.y + ((this.y + this.height) - this.y) / 2;
       
        float mxRelative = mx - this.lineX;

        if ((this.sliderBoxX < this.lineX) || (this.sliderBoxX > this.lineX + this.lineWidth)) {
            this.sliderBoxX = this.lineX;
        }
       
        if ((my > this.y) && my < this.y + this.height) {
            if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
                if ((mxRelative >= 0) && (mxRelative <= this.lineWidth)) {
                    this.percentage = (float) (mxRelative / this.lineWidth);
                    this.value = Math.round(this.percentage * 100);
                    this.sliderBoxX = mxRelative + this.lineX - (sliderBoxWidth / 2);
                }
            }
        }
       
        float minSliderBoxX = this.sliderBoxX;
        float minSliderBoxY = this.sliderBoxY;
        float maxSliderBoxX = this.sliderBoxX + this.sliderBoxWidth;
        float maxSliderBoxY = this.sliderBoxY + this.sliderBoxHeight;
        if ((mx > minSliderBoxX && mx < maxSliderBoxX) && (my > minSliderBoxY && my < maxSliderBoxY)) {
            if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
                this.wasSliderBoxDown = true;
            }
        }
       
        if (this.wasSliderBoxDown) {
            if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
                if (mxRelative >= 0 && mxRelative <= this.lineWidth) {
                    this.percentage = (float) (mxRelative / this.lineWidth);
                    this.value = Math.round(this.percentage * 100);
                    this.sliderBoxX = mxRelative + this.lineX - (sliderBoxWidth / 2);
                }
            } else {
                this.wasSliderBoxDown = false;
            }
        }
    }
   
    public void setInitialValues(float minValue, float maxValue) {
        if (this.minValue != minValue) {
            this.minValue = minValue;
        }
        if (this.maxValue != maxValue) {
            this.maxValue = maxValue;
        }
       
    }
   
    public float getValue() {
        return value;
    }

    public float getPercentage() {
        return percentage;
    }
}
22  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-10 22:55:18
Well, this is the only component so far with which I'm stuck, and I think I know where's the problem,  but right now I just can't throw it out of my head.
Anyway, I'm going to call now a sleep() method on self, it will help me definitely.. and I believe I will find out the solution if not and more. Also, it is really intersting that you name your class HSlider, I call it PSlider, the reason is, I'm making a Poker game, just like the one on the facebook, and I'm not going to talk about how big differences are between your component design and my Cheesy. But I still like the way I created it, even tho it only contains one AbstractComponent, it still does some job and cuts a lot of the trash code from the component in general.
Hopefully, I will learn this semester pretty well UML diagrams, so I can start some serious projects and give focus more on implementation and less coding.
Thanks again and gn!
23  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-10 20:57:10
Hello again! It's been a week since last time we talk, I said I will continue tommorow night, but some other plans came out...
So you say that shift operator ">>", divides a number in half and discards the remainder, which I do understand now,
but, you also say in your comment above this code,

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
/* 
 * Technically the 5 variables below shouldn't be calculated every
 * update. They should be computed when the control is initialized
 * and only recalculated if the control is moved/resized or if
 * their dimensions are altered through setter methods.
 */

this.sliderBoxWidth = this.height >> 1;
this.sliderBoxHeight = this.height >> 1;
this.sliderBoxY = this.y;
this.lineWidth = this.width - this.sliderBoxWidth;


that this variables should be computed when the control is initialized and only recalculated if the control is moved/resized.
S, how this shift operator checks as well if a value is different (moved/resized), as you did not use an if condition,
or it was just your suggestion to me, in order to tell me how things should be done?

Anyway, let's back to the topic.
Everything works as intended, but the only problem now is I'm not getting a proper percentage and a value.

If i write,
1  
2  
this.percentage = (mxRelative / this.lineWidth) * 100.0f;
this.value = this.percentage / 100.0f * this.maxValue;

and I go maximum with slider box, this will return:
percentage: 99.775276
value: 997.7528
Which is not a 100%, and not 1000.00

I can round percentage, and it will go to 100 for percentage, and 1000.0 for value
1  
2  
this.percentage = Math.round((mxRelative / this.lineWidth) * 100.0f);
this.value = this.percentage / 100.0f * this.maxValue;

but that's not what I need, I need a precise number, like 957.50
24  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-04 22:00:09
Thank you on the constructive answer, I very appreciate it.
However, this is my first time creating GUI components, also my first serious game project, using some library.
By the way, it's nice to see that you're using shift operators, for which I've never had a chance to use them before nor to see them in any other code. So, I'd be thankful if you could tell me what this.height >> 1 does? Does it checks if the current height value was changed for 1 ?
Anyway, I'm really tired now, and I have to wake up early in a morning, so I will probably continue programming tommorow tonight and try out your solution.
I will reply if it worked.
All best!
25  Game Development / Newbie & Debugging Questions / Re: Making A Slider Component Problem on: 2013-12-04 15:33:05
Alright, thanks on the suggestion. I will take a deep look at it, after I back home.
26  Game Development / Newbie & Debugging Questions / Making A Slider Component Problem on: 2013-12-04 15:02:29
I'm creating a slider component for my game with graphics in Slick2D. Almost everything is working as supposed but there's a problem, to properly control the slider box. As you can see below in the code, I'm increasing or decreasing the value, instead of changing the sliderBoxX by the position of the mouseX. So tell me should I start all over again or is it still possible to make this code working in this code order, to make sliderBoxX and component values change by mouse X coordinate?
As a matter of a problem, is the order of the code where I compute and check things wrong?

Code is inside update method:
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  
this.minusBoxX = this.x;
this.minusBoxY = this.y;
this.minusBoxWidth = this.height;
this.minusBoxHeight = this.height;

this.plusBoxX = this.x + this.width - this.height;
this.plusBoxY = this.y;
this.plusBoxWidth = this.height;
this.plusBoxHeight = this.height;
       
this.sliderBoxWidth = this.height / 2;
this.sliderBoxHeight = this.height / 2;

this.minSliderX = this.minusBoxX + this.minusBoxWidth;
this.maxSliderX = this.plusBoxX;
this.lineWidth = Math.abs(minSliderX - maxSliderX) - this.sliderBoxWidth;

this.percentage = this.value / this.maxValue;

this.sliderBoxX = this.minSliderX + (this.lineWidth * this.percentage);
this.sliderBoxY = this.y + ((this.y + this.height) - this.y) / 2
                         - (this.sliderBoxHeight / 2);

float minSliderBoxX = this.sliderBoxX;
float minSliderBoxY = this.sliderBoxY;
float maxSliderBoxX = this.sliderBoxX + this.sliderBoxWidth;
float maxSliderBoxY = this.sliderBoxY + this.sliderBoxHeight;
if ((mx > minSliderBoxX && mx < maxSliderBoxX) && (my > minSliderBoxY && my < maxSliderBoxY)) {
    if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
        if (this.percentage * 100 >= 0 && this.percentage * 100 <= 100) {
            this.wasSliderBoxDown = true;
        }
    }
}
if (this.wasSliderBoxDown) {
    if (input.isMouseButtonDown(Input.MOUSE_LEFT_BUTTON)) {
        if (this.percentage * 100 >= 0 && this.percentage * 100 <= 100) {
            // this.sliderBoxX = mx; something like this
            if (mx > maxSliderBoxX) {
                this.value += 0.1f * 100.0f; // this works, but is not correct
            }
            if (mx < minSliderBoxX) {
                this.value -= 0.1f * 100.0f; // this works, but is not correct
            }
        }
    } else {
        this.wasSliderBoxDown = false;
    }
}




Edit:
Ok, I'm changing mind. I will make first the slider line made of a component width, and not like I did between minus and plus boxes. But now the questions is, what should I change current value or a slider box position from the mx and then compute percentage? And what checks should I provide, like should I check the percentage, value or current mx positon for bounds?
27  Game Development / Newbie & Debugging Questions / Re: Mouse scroll wheel? on: 2013-12-02 23:31:58
Thanks for that, but that's not way I'm doing. What I found, with the help of your, is MouseListener, MouseWheelEvent and MouseWheelListener which implements mouseWheelMoved(MouseWheelEvent e), but I'm not sure how to get this change value, just like mouseWheelEvent(int change) has.
However, the problem with MouseListener is that I don't need all of his implementation methods expect only mouseWheelMoved, so is there any other way of doing this so  that I can just call mouseWheelMoved method as annonymous class, inside my actionPerformed method, or somethingi?

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  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
public void performAction(MouseListener ml, GameContainer gc, int mx, int my) throws SlickException {
        Input input = gc.getInput();
       
        ml = new MouseListener() {

            @Override
            public void mouseWheelMoved(int change) {
                        if (change < 0) {
                            xpos -= 10;
                        }
                        if (change > 0) {
                            xpos += 10;
                        }
            }

            @Override
            public void mouseClicked(int button, int x, int y, int clickCount) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void mousePressed(int button, int x, int y) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void mouseReleased(int button, int x, int y) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void mouseMoved(int oldx, int oldy, int newx, int newy) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void mouseDragged(int oldx, int oldy, int newx, int newy) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void setInput(Input input) {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public boolean isAcceptingInput() {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void inputEnded() {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }

            @Override
            public void inputStarted() {
                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            }
        };
       
        float minusBoxMinX = this.x;
        float minusBoxMinY = this.y;
        float minusBoxMaxX = this.x + this.height;
        float minusBoxMaxY = this.y + this.height;
        if (contains(mx, my, minusBoxMinX, minusBoxMaxX, minusBoxMinY, minusBoxMaxY)) {
            if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
                if (this.currentPercentage > 0) {
                    this.currentPercentage--;
                    this.currentValue = (this.currentPercentage / 100.0f) * this.maxValue;
                }
            }
        }
       
        float plusBoxMinX = this.x + this.width - this.height;
        float plusBoxMinY = this.y;
        float plusBoxMaxX = this.x + this.width;
        float plusBoxMaxY = this.y + this.height;
        if (contains(mx, my, plusBoxMinX, plusBoxMaxX, plusBoxMinY, plusBoxMaxY)) {
            if (input.isMousePressed(Input.MOUSE_LEFT_BUTTON)) {
                if (this.currentPercentage < 100) {
                    this.currentPercentage++;
                    this.currentValue = (this.currentPercentage / 100.0f) * this.maxValue;
                }
            }
        }
       
       
    }
28  Game Development / Newbie & Debugging Questions / Mouse scroll wheel? on: 2013-12-02 21:41:46
Is there a way to grab the scroll wheel (on the mouse, both, when I scroll down and when I scroll up) in Slick2d? I looked in input but didn't see it.
29  Game Development / Newbie & Debugging Questions / slick2d init state on: 2013-11-27 11:24:45
I have a state called SetupState and a class SetupGame, which job is to initalize GameState with a values from SetupGame class before I enter GameState.
The problem is, how I'm going to pass SetupGame instance to GameState constructor as a parameter since enterState method from StateBasedGame, which method takes only ID parameter.
Should I make my SetupGame static with a static attributes so I can access it anytime, or there's some other way ?

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  
public class SetupScreenState extends PAbstractState {
   
    public static final int ID = 2;
   
    private Image titleImage;
   
    private PButton backButton;
    private PButton startButton;
   
    private SetupScreenUI setupScreenUI;
   
    public SetupScreenState() {
        super();
    }
   
    @Override
    public int getID() {
        return ID;
    }

    @Override
    public void enter(GameContainer gc, StateBasedGame sg) throws SlickException {
        setupScreenUI = new SetupScreenUI();
        setupScreenUI.init(gc);
    }
       
    @Override
    public void init(GameContainer gc, StateBasedGame sg) throws SlickException {
        titleImage = new Image("res/gui/titleSetUpTable.png");
       
        backButton = new PButton("buttonBack");
        startButton = new PButton("buttonStart");
    }

    @Override
    public void render(GameContainer gc, StateBasedGame sg, Graphics g) throws SlickException {
        PTheme.bgTheme(gc, g);
       
        float titleX = 50;
        float titleY = 50;
        titleImage.draw(titleX, titleY);
       
        float backButtonX = (gc.getWidth() / 2) - backButton.getWidth() - 10;
        float backButtonY = gc.getHeight() - backButton.getHeight() - 30;
        backButton.render(g, backButtonX, backButtonY);
       
        float startButtonX = (gc.getWidth() / 2)  + 10;
        float startButtonY = backButtonY;
        startButton.render(g, startButtonX, startButtonY);
       
        setupScreenUI.render(gc, g);
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sg, int delta) throws SlickException {  
        Input input = gc.getInput();
        int mx = input.getMouseX();
        int my = input.getMouseY();
       
        if (!hasFocus) return;
       
        setupScreenUI.update(gc, sg, delta);
       
        if (startButton.isActionPerformed(input, mx, my)) {
            // this way I can't because method does not include
            // example:  sg.enterState(PlayScreenState.ID, setupScreenUI.getSetupGameInstance());
            sg.enterState(PlayScreenState.ID, new FadeOutTransition(), new FadeInTransition());
        }
        if (backButton.isActionPerformed(input, mx, my)) {
            sg.enterState(StartScreenState.ID, new FadeOutTransition(), new FadeInTransition());
        }
    }
   
}


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  
80  
81  
82  
83  
84  
85  
public class SetupScreenUI extends PAbstractUI implements ComponentListener {

    private PLabel attributeLabel;
    private PLabel valueLabel;
   
    private TextField nameField;
   
    private SetupGame setupGame;

    public SetupScreenUI() {
        super();
    }
   
    @Override
    public void init(GameContainer gc) throws SlickException {
        attributeLabel = new PLabel(PFontType.CharlemagneStd, 22, false, false);
        valueLabel = new PLabel(PFontType.CharlemagneStd, 22, false, false);
       
        float nameFieldX = panelMinX + 235;
        float nameFieldY = panelMinY + 122.5f;
        Font nameFieldFont = valueLabel.getFont();
        nameField = new TextField(gc, nameFieldFont, (int) nameFieldX, (int) nameFieldY, 225, 25, this);
    }

    @Override
    public void update(GameContainer gc, StateBasedGame sg, int delta) throws SlickException {
       
        if (!this.hasFocus) return;
       
       
    }

    @Override
    public void componentActivated(AbstractComponent source) {
        if (!this.hasFocus) return;
       
        if (source == nameField) {
            // do something nameField.getText();
        }
    }
   
    @Override
    public void render(GameContainer gc, Graphics g) throws SlickException {
        String attName = "Player Name: ";
        float attNameX = panelMinX + 55;
        float attNameY = panelMinY + 125;
        attributeLabel.setTextColor(Color.decode("#ffffbe"));
        attributeLabel.render(attName, attNameX, attNameY);
        attributeLabel.setTextColor(attributeLabel.getDefaultColor());
        attributeLabel.render(attName, attNameX + 1, attNameY + 1);
       
        float b1X1 = attNameX;
        float b1X2 = attNameX + attributeLabel.getTextWidth(attName) + 225;
        float b1Y1 = attNameY + attributeLabel.getTextHeight(attName) + 20;
        float b1Y2 = attNameY + attributeLabel.getTextHeight(attName) + 20;
        g.setColor(attributeLabel.getDefaultColor()); // get default color
        g.drawLine(b1X1, b1Y1, b1X2, b1Y2);
       
        float cornerRadius = 0;
        float miniTableWidth = 260;
        float miniTableHeight = 180;
        float miniTableX = panelMaxX - miniTableWidth - 55;
        float miniTableY = Math.max(b1Y1, b1Y2);
        g.setColor(new Color(0, 0, 0, .5f));
        g.fillRoundRect(miniTableX, miniTableY, miniTableWidth, miniTableHeight, (int) cornerRadius);
        g.setColor(Color.decode("#ffffbe"));
        g.drawRoundRect(miniTableX, miniTableY, miniTableWidth, miniTableHeight, (int) cornerRadius);
       
        String attTable = "Table";
        float mtNameX = miniTableX + (((miniTableX + miniTableWidth) - miniTableX) / 2) - (attributeLabel.getTextWidth(attTable) / 2);
        float mtNameY = miniTableY + miniTableHeight + 10;
        attributeLabel.setTextColor(Color.decode("#ffffbe"));
        attributeLabel.render(attTable, mtNameX, mtNameY);
        attributeLabel.setTextColor(attributeLabel.getDefaultColor());
        attributeLabel.render(attTable, mtNameX + 1, mtNameY + 1);

        g.setColor(Color.decode("#ffffbe"));
        nameField.render(gc, g);
    }

     public SetupGame getSetupGameInstance() {
        return setupGame;
    }

}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public class SetupGame {
   
    private int name;
    // and more....

    public SetupGame() {}

    public int getName() {
        return name;
    }

    public void setName(int name) {
        this.name = name;
    }
   
}


30  Game Development / Newbie & Debugging Questions / Re: Slick2D Problem with state on: 2013-11-25 21:45:55
nvm.. i found out  :
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.

SHC (24 views)
2014-11-25 12:00:59

SHC (23 views)
2014-11-25 11:53:45

Norakomi (19 views)
2014-11-25 11:26:43

Gibbo3771 (22 views)
2014-11-24 19:59:16

trollwarrior1 (36 views)
2014-11-22 12:13:56

xFryIx (74 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (41 views)
2014-11-12 21:09:33

kovacsa (68 views)
2014-11-07 19:57:14
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!