Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED]Final Score Screen Effect Libgdx  (Read 1662 times)
0 Members and 1 Guest are viewing this topic.
Offline Andre Lopes
« Posted 2013-11-27 15:12:12 »

Hey guys, i want to do this in my game :

http://youtu.be/fleXXgasKV8?t=13s

exactly starting at 13 seconds, it will happen the score calculator.
That effect is awesome... Any ideas how to do that?

In my case, the high score is just calculated in the end of the game. And i may upload to a database.. but thats off limits.
Anyway, i want to know how to make that effect :p

Im using libgdx.

Any ideas , where can i start? How should i think the logic? Will i need a timer?
Offline goblinJoel

Junior Member


Medals: 2



« Reply #1 - Posted 2013-11-27 15: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
Offline Andre Lopes
« Reply #2 - Posted 2013-11-27 17:32:05 »

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

Thanks for the reply.
I guess now i get it how to start but, what about the sound... Should i just get a normal sound and play it or, faster the points go down, faster the sound? idk
How do i manage the sound for it?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline bilznatch

Senior Member


Medals: 8
Projects: 2
Exp: 1 year


I'm bad, I'm bad, I'm really... really bad T_T


« Reply #3 - Posted 2013-11-27 21:23:21 »

You should get a sound that fits your tick down time. So if you make the score go down every second, then you play a 1 second or less sound every tick.

Although, that's really up to you how the sound works.
Offline Andre Lopes
« Reply #4 - Posted 2013-11-27 21:51:17 »

You should get a sound that fits your tick down time. So if you make the score go down every second, then you play a 1 second or less sound every tick.

Although, that's really up to you how the sound works.

I see....

Well, in the final Screen, i have this :
Quote
package br.views.levels;

import br.data.Data;
import br.data.SaveData;
import br.dir.DirectoriesLevel_Extend;
import br.player.Player;
import br.tools.MyTimer;
import br.views.MenuView;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;

/**
 *
 * @author André  Lopes
 */
public class GameOver extends Level_Extend implements Screen {

    private Texture gameOver;
    private Texture gameOver1;
    private Texture gameOver2;
    private MyTimer timer;
    private int color;
    private Data data;
    private SaveData saveData;

    public GameOver(Data data) {
        this.data = data;
    }

    @Override
    public void updateCamera() {

    }

    @Override
    public void configLoadedLevelData(Data data) {

    }

    @Override
    public void configLevelData() {

    }

    @Override
    public void script() {

    }

    @Override
    public void nextLevel() {

    }

    @Override
    public void teleportTile(TiledMapTileLayer collisionLayer, Player player) {

    }

    @Override
    public void render(float delta) {
        if (!timer.isDone()) {
            Gdx.gl.glClearColor(0, 0, 0, 1);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

            color++;
            if (color > 240) {
                color = 0;
            }

            batch.begin();
            if (color < 60) {
                batch.draw(gameOver, 0, 0);
            } else if (color < 120) {
                batch.draw(gameOver1, 0, 0);
            } else if (color < 240) {
                batch.draw(gameOver2, 0, 0);
            }
            batch.end();

        } else {
            saveData.saveData(data);
            ((Game) Gdx.app.getApplicationListener()).setScreen(new MenuView());
            dispose();
        }
    }

    @Override
    public void resize(int width, int height) {

    }

    @Override
    public void show() {
        color = 0;

        batch = new SpriteBatch();
        gameOver = new Texture(Gdx.files.internal("imagens/Resources/GameOver/GameOver.jpg"));
        gameOver1 = new Texture(Gdx.files.internal("imagens/Resources/GameOver/GameOver1.jpg"));
        gameOver2 = new Texture(Gdx.files.internal("imagens/Resources/GameOver/GameOver2.jpg"));

        DirectoriesLevel_Extend directoriesLevelExtend = new DirectoriesLevel_Extend();
        simpleRedFont = directoriesLevelExtend.getSimpleRedFont();

        timer = new MyTimer(5);
        timer.start();
        saveData = new SaveData();

    }

    @Override
    public void dispose() {
       
        batch.dispose();
        gameOver.dispose();
        gameOver1.dispose();
        gameOver2.dispose();
    }

    @Override
    public void hide() {

    }

}


So heres the logic,
I want to sum the

(quantity of diamonds the player was able to get  * 1000)
+
(the normal score)
=

__________________________________________________

For now will be very simple. I have other better ideas, but for now, that will be ok.

So i will need three text fields, one for the score, one for the diamonds score, and other for the result.

After that, i need to set the timer in a appropriate way....Or just remove it. And once the score is calculated, just press enter and it goes?

Offline goblinJoel

Junior Member


Medals: 2



« Reply #5 - Posted 2013-11-28 14: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.
Offline Andre Lopes
« Reply #6 - Posted 2013-11-28 16:16:41 »

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.

"Remember, you don't need to actually change the score numbers. It's just an effect. You're just changing what the player sees."

What you mean exactly?
I was thinking in subtracting certain amounts each frame and rendering...
Offline goblinJoel

Junior Member


Medals: 2



« Reply #7 - Posted 2013-11-28 17: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.
Offline Andre Lopes
« Reply #8 - Posted 2013-11-30 03:37:53 »



Tongue


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  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
/**
 *
 * @author André Lopes
 */

public class GameOver extends Level_Extend implements Screen {

    private Texture gameOver;
    private MyTimer timer;

    private int color;

    private Data data;
    private SaveData saveData;
    private DrawText drawText;

    private TextField dataScore, diamondScore, totalScore;

    private Table scoreTable;

    public GameOver(Data data) {
        this.data = data;

    }

    @Override
    public void updateCamera() {

    }

    @Override
    public void configLoadedLevelData(Data data) {

    }

    @Override
    public void configLevelData() {

    }

    @Override
    public void script() {

    }

    @Override
    public void nextLevel() {

    }

    @Override
    public void teleportTile(TiledMapTileLayer collisionLayer, Player player) {

    }

    @Override
    public void render(float delta) {
        if (!timer.isDone()) {

            Gdx.gl.glClearColor(0, 0, 0, 1);
            Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

            color++;
            if (color > 240) {
                color = 0;
            }

            batch.begin();
            batch.draw(gameOver, 0, 0);

            batch.end();

            stage.act(delta);
            stage.draw();
            //Table.drawDebug(stage);
       } else {
            saveData.saveData(data);
            ((Game) Gdx.app.getApplicationListener()).setScreen(new MenuView());
            dispose();
        }
    }

    @Override
    public void resize(int width, int height) {

        stage.setViewport(width, height, true);

        int w = (Gdx.graphics.getWidth() / 2);
        int h = (Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 5);

        scoreTable.setPosition(w, h);

        scoreTable.invalidateHierarchy();
        camera.position.set(0, 0, 0f);
        camera.viewportWidth = 800;
        camera.viewportHeight = 600;

    }

    @Override
    public void show() {
        color = 0;
        stage = new Stage();
        camera = new OrthographicCamera();
        batch = new SpriteBatch();
        drawText = new DrawText();

        scoreTable = new Table();
        scoreTable.pad(15f);

        //
       gameOver = new Texture(Gdx.files.internal("imagens/Resources/GameOver/BlackScreen.png"));
        gameOver.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        //

        DirectoriesLevel_Extend directoriesLevelExtend = new DirectoriesLevel_Extend();
        simpleRedFont = directoriesLevelExtend.getSimpleRedFont();
        simpleWhiteFont = directoriesLevelExtend.getSimpleWhiteFont();

        timer = new MyTimer(20);
        timer.start();
        saveData = new SaveData();

        LabelStyle ls = new LabelStyle();
        ls.font = simpleWhiteFont;
        Label titleLabel = new Label("Game Over", ls);

        TextField.TextFieldStyle textFieldDataScore = new TextField.TextFieldStyle();
        textFieldDataScore.font = simpleWhiteFont;
        textFieldDataScore.fontColor = Color.YELLOW;
        textFieldDataScore.background = (new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box.png")))));
        textFieldDataScore.background.setLeftWidth(10f);

        TextField.TextFieldStyle textFieldDiamondScore = new TextField.TextFieldStyle();
        textFieldDiamondScore.font = simpleWhiteFont;
        textFieldDiamondScore.fontColor = Color.RED;
        textFieldDiamondScore.background = (new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box.png")))));
        textFieldDiamondScore.background.setLeftWidth(10f);

        TextField.TextFieldStyle textFieldStyle1 = new TextField.TextFieldStyle();
        textFieldStyle1.font = simpleWhiteFont;
        textFieldStyle1.fontColor = Color.WHITE;
        textFieldStyle1.background = (new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box_lit.png")))));
        textFieldStyle1.background.setLeftWidth(10f);

        dataScore = new TextField("123456789", textFieldDataScore);
        dataScore.setSize(400, 55);
        diamondScore = new TextField("123456789", textFieldDiamondScore);

        totalScore = new TextField("246913578", textFieldStyle1);

        scoreTable.add(titleLabel);
        scoreTable.row();
        scoreTable.add(dataScore);
        scoreTable.row();
        scoreTable.add(diamondScore);
        scoreTable.row();
        scoreTable.add(totalScore);

       
        int w = (Gdx.graphics.getWidth() / 2);
        int h = (Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 5);

        scoreTable.setPosition(w, h);
       
        scoreTable.debug();

        stage.addActor(scoreTable);
        //stage.setCamera(camera);
       
    }

    @Override
    public void dispose() {
        batch.dispose();
        gameOver.dispose();
    }

    @Override
    public void hide() {

    }

}
Offline Andre Lopes
« Reply #9 - Posted 2013-11-30 03:39:02 »

Im having a problem.
The Drawable background is way bigger but it isnt showing up completely.
What am i doing wrong?

The background is 400x55 pixels....

Why isnt showing up as it should?
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Andre Lopes
« Reply #10 - Posted 2013-11-30 15:02:46 »

Ok Guys, its working ! But, i have a question, how do i calculate the rate "PASS_FRAME_SCORE" ? I want to calculate it in a way that the score calculus doesnt take more than 10 seconds.
Plus, the table is small... I will create a new topic about that. Anyway, heres the 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  
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  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
182  
183  
184  
185  
186  
187  
188  
189  
190  
191  
192  
193  
194  
195  
196  
197  
198  
199  
200  
201  
202  
203  
204  
205  
206  
207  
208  
209  
210  
211  
212  
213  
214  
215  
216  
217  
218  
219  
220  
221  
222  
223  
224  
225  
226  
227  
228  
229  
230  
231  
232  
233  
234  
235  
236  
237  
238  
239  
240  
241  
242  
243  
244  
245  
246  
247  
248  
249  
250  
251  
252  
253  
254  
255  
256  
257  
258  
259  
260  
261  
262  
263  
264  
265  
266  
267  
268  
269  
270  
271  
272  
273  
274  
275  
276  
277  
278  
279  
280  
281  
package br.views.levels;

import br.data.Data;
import br.data.SaveData;
import br.dir.DirectoriesLevel_Extend;
import br.player.Player;
import br.tools.MyTimer;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.maps.tiled.TiledMapTileLayer;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextField;
import com.badlogic.gdx.scenes.scene2d.utils.SpriteDrawable;

/**
 *
 * @author André Lopes
 */

public class GameOver extends Level_Extend implements Screen {

    private final int PASS_FRAME_SCORE = 50;


    private Texture gameOver;
    private MyTimer timer;

    private int color;

    private Data data;
    private SaveData saveData;
    private DrawText drawText;

    private TextField dataScore, diamondScore, totalScore;

    private Table scoreTable;

    public GameOver(Data data) {
        this.data = data;

    }

    @Override
    public void updateCamera() {

    }

    @Override
    public void configLoadedLevelData(Data data) {

    }

    @Override
    public void configLevelData() {

    }

    @Override
    public void script() {

    }

    @Override
    public void nextLevel() {

    }

    @Override
    public void teleportTile(TiledMapTileLayer collisionLayer, Player player) {

    }

    @Override
    public void render(float delta) {

        Gdx.gl.glClearColor(0, 0, 0, 1);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        color++;
        if (color > 240) {
            color = 0;
        }

        batch.begin();
        batch.draw(gameOver, 0, 0);

        batch.end();

        stage.act(delta);
        stage.draw();
        Table.drawDebug(stage);

        update();

    }

    @Override
    public void resize(int width, int height) {

        stage.setViewport(width, height, true);

        int w = (Gdx.graphics.getWidth() / 2);
        int h = (Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 5);

        scoreTable.setPosition(w, h);

        scoreTable.invalidateHierarchy();
        dataScore.invalidate();
        totalScore.invalidate();
        diamondScore.invalidate();
        camera.position.set(0, 0, 0f);
        camera.viewportWidth = 800;
        camera.viewportHeight = 600;

    }

    @Override
    public void show() {

        color = 0;
        stage = new Stage();
        camera = new OrthographicCamera();
        batch = new SpriteBatch();
        drawText = new DrawText();

        scoreTable = new Table();
        scoreTable.pad(15f);

        //
       gameOver = new Texture(Gdx.files.internal("imagens/Resources/GameOver/BlackScreen.png"));
        gameOver.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Nearest);
        //

        DirectoriesLevel_Extend directoriesLevelExtend = new DirectoriesLevel_Extend();
        simpleRedFont = directoriesLevelExtend.getSimpleRedFont();
        simpleWhiteFont = directoriesLevelExtend.getSimpleWhiteFont();

        timer = new MyTimer(60);
        timer.start();
        saveData = new SaveData();

        LabelStyle ls = new LabelStyle();
        ls.font = simpleWhiteFont;
        Label titleLabel = new Label("Game Over", ls);

        TextField.TextFieldStyle textFieldStyleDataScore = new TextField.TextFieldStyle();
        textFieldStyleDataScore.font = simpleWhiteFont;
        textFieldStyleDataScore.fontColor = Color.YELLOW;

        Sprite sprite = new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box.png")));
        SpriteDrawable sd = new SpriteDrawable(sprite);

        textFieldStyleDataScore.background = sd;
        textFieldStyleDataScore.background.setLeftWidth(10f);

        TextField.TextFieldStyle textFieldStyleDiamondScore = new TextField.TextFieldStyle();
        textFieldStyleDiamondScore.font = simpleWhiteFont;
        textFieldStyleDiamondScore.fontColor = Color.RED;
        textFieldStyleDiamondScore.background = (new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box.png")))));
        textFieldStyleDiamondScore.background.setLeftWidth(10f);

        TextField.TextFieldStyle textFieldStyleTotalScore = new TextField.TextFieldStyle();
        textFieldStyleTotalScore.font = simpleWhiteFont;
        textFieldStyleTotalScore.fontColor = Color.WHITE;
        textFieldStyleTotalScore.background = (new SpriteDrawable(new Sprite(new Texture(Gdx.files.internal("imagens/Resources/ui/textField/natyyr/box_lit.png")))));
        textFieldStyleTotalScore.background.setLeftWidth(10f);

        dataScore = new TextField("123456789", textFieldStyleDataScore);

        diamondScore = new TextField("123456789", textFieldStyleDiamondScore);

        totalScore = new TextField("246913578", textFieldStyleTotalScore);

        scoreTable.add(titleLabel);
        scoreTable.row();
        scoreTable.add(dataScore);
        scoreTable.row();
        scoreTable.add(diamondScore);
        scoreTable.row();
        scoreTable.add(totalScore);

        int w = (Gdx.graphics.getWidth() / 2);
        int h = (Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 5);

        scoreTable.setPosition(w, h);

        scoreTable.debug();

        stage.addActor(scoreTable);
        int current_Red_Diamond = data.getCurrent_Red_Diamond();
        int current_Blue_Diamond = data.getCurrent_Blue_Diamond();

        setDiamondScore(10 * (100 * current_Red_Diamond + 100 * current_Blue_Diamond));
        setDataScore(data.getCurrent_Score());
        setTotalScore(0);
    }

    private void update() {
        int dataScoreInt = getDataScore();
        int diamondScoreInt = getDiamondScore();
        int totalScoreInt = getTotalScore();

       
        if (dataScoreInt - PASS_FRAME_SCORE > 0) {
           
            totalScoreInt = totalScoreInt + PASS_FRAME_SCORE;
            setDataScore(dataScoreInt - PASS_FRAME_SCORE);
           
        } else if (dataScoreInt > 0) {

            totalScoreInt = totalScoreInt + dataScoreInt;
            setDataScore(0);

        }

        if (diamondScoreInt - PASS_FRAME_SCORE > 0) {
           
            totalScoreInt = totalScoreInt + PASS_FRAME_SCORE;
            setDiamondScore(diamondScoreInt - PASS_FRAME_SCORE);

        } else if (diamondScoreInt > 0) {

            totalScoreInt = diamondScoreInt + totalScoreInt;
            setDiamondScore(0);

        }

        setTotalScore(totalScoreInt);

    }

    private int getDiamondScore() {
        String text = diamondScore.getText();
        int parseInt = Integer.parseInt(text);
        return parseInt;
    }

    private int getTotalScore() {
        String text = totalScore.getText();
        int parseInt = Integer.parseInt(text);
        return parseInt;
    }

    private int getDataScore() {
        String text = dataScore.getText();
        int parseInt = Integer.parseInt(text);
        return parseInt;
    }

    private void setDiamondScore(int score) {
        diamondScore.setText("" + score);
    }

    private void setTotalScore(int score) {
        totalScore.setText("" + score);
    }

    private void setDataScore(int score) {
        dataScore.setText("" + score);
    }

    @Override
    public void dispose() {
        batch.dispose();
        gameOver.dispose();
    }

    @Override
    public void hide() {

    }

}
Offline bilznatch

Senior Member


Medals: 8
Projects: 2
Exp: 1 year


I'm bad, I'm bad, I'm really... really bad T_T


« Reply #11 - Posted 2013-11-30 23:22:23 »

There are 600 frames in 10 seconds. Do the math.
600/score = score reduction per frame.
Offline trollwarrior1
« Reply #12 - Posted 2013-12-01 06:49:06 »

There is no "right" way to do it. Just do it. After you have done it, you will know a better way to do it.
Offline Andre Lopes
« Reply #13 - Posted 2013-12-01 20:03:34 »

There is no "right" way to do it. Just do it. After you have done it, you will know a better way to do it.

Ok! It was my first Score Calculator... So yeah ! Thanks guys! Tongue

I just want to let this here for any comments...


1  
2  
3  
4  
5  
6  
7  
8  
 //There are 600 frames in 10 seconds. Do the math.
       //600/score = score reduction per frame.
       //5 Seconds
       PASS_FRAME_SCORE = ((data.getCurrent_Score() + data.getCalculatedDiamondScore())/300);
        System.out.println("data.getCurrent_Score() = " + data.getCurrent_Score());
        System.out.println("data.getCalculatedDiamondScore()) = " + data.getCalculatedDiamondScore());
        System.out.println("Total Score = " + (data.getCurrent_Score() + data.getCalculatedDiamondScore()));
        System.out.println("PFS " + PASS_FRAME_SCORE);


Quote
data.getCurrent_Level()8
data.getCurrent_Score() = 8000
data.getCalculatedDiamondScore()) = 10000
Total Score = 18000
PFS60
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (18 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

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

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

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

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

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

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

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

BurntPizza (38 views)
2014-08-08 02:01:56
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!