Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
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 3 ... 18
1  Discussions / General Discussions / Re: dalvik, you suck on: 2014-07-22 22:23:17
I do too in IntelliJ, but I am using AIDE at the moment, it is not quite as richly featured.
2  Discussions / General Discussions / Re: dalvik, you suck on: 2014-07-22 22:18:08
Ah....

Dalvik, I suck  Cry
3  Discussions / General Discussions / Re: dalvik, you suck on: 2014-07-22 22:16:47
I'm not looping through the collection... Wrapping the int in an Integer fixes the issue.

Edit: replying to pandemoniumhun, but Riven has the answer.
4  Discussions / General Discussions / dalvik, you suck on: 2014-07-22 21:57:15
This will crash:

1  
2  
3  
4  
if (isBonus.contains(v)) {
   isBonus.remove(new Integer(v));
   lpb.getBackground().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
}


Where v is an int. Contains(int) is fine, but remove(int) aint.
5  Game Development / Newbie & Debugging Questions / Re: XMLUnmarshalling attribut linebreak ? on: 2014-07-18 12:36:59
You could do it with SAX. I guess JAXB is treating whitespace differences as nonsignificant, which would be always wrong in a text node.
6  Java Game APIs & Engines / OpenGL Development / Re: Shader not rendering correctly on: 2014-07-18 12:17:53
I introduced that small difference to ensure the compiler didn't optimize out the duplicate. Since then I optimised the function like this:


vec4 float getColorWave(in vec4 wave, in vec3 coord, in vec4 vcolor) {
   vec4 newColor = vec4(0.1, 0.2, 0.4, 1.0);
   vec4 white = vec4(1, 1, 1, 1);

   float distance = distance(coord.xy, wave.xy);
   float wave1 = abs(distance - wave.z);
   wave1 = return clamp(wave1, 0.0, 25.0);  
   wave1 = (25.0 - wave1) / 35.0;
   vec4 color = mix(vcolor, white, newColor.rrra);
   color = mix(vcolor, color, wave1);
   return color;

}


So all the color processing is only done once in main()... which gets me 5fps more on my tablet, but which also means the two functions really are identical now.

I have it working now - I call the duplicate function, discard its results then call the real function and it all works ok.
7  Java Game APIs & Engines / OpenGL Development / Re: Shader not rendering correctly on: 2014-07-17 08:47:36
I changed to max() only to see if that had an effect, before that I was doing another mix(). There is no difference between the two versions, they both show the flash to edge bug.

EDIT: It is definitely a bug in my Asus Memo Pad HD GPU. simply duplicating the function changes the behavior (the copied function behaves correctly)... In this I cut it down to two ripples, with a duplicate function only one has the flash bug.

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  
precision mediump float;

uniform vec4 u_Wave0;
uniform vec4 u_Wave1;
uniform vec4 u_Wave2;
uniform vec4 u_Wave3;

varying vec3 v_Position;
varying vec4 v_Color;

vec4 getColor(in vec4 wave, in vec3 coord, in vec4 vcolor) {
   vec4 newColor = vec4(0.1, 0.2, 0.4, 1.0);
   vec4 white = vec4(1, 1, 1, 1);
   float distance = distance(coord.xy, wave.xy);
   float wave1 = abs(distance - wave.z);
   wave1 = clamp(wave1, 0.0, 25.0);  
   wave1 = (25.0 - wave1) / 35.0;
   vec4 color = mix(vcolor, white, newColor.rrra);
   color = mix(vcolor, color, wave1);
   return color;
}

vec4 getColorD(in vec4 wave, in vec3 coord, in vec4 vcolor) {
   vec4 newColor = vec4(0.1, 0.2, 0.4, 1.0);
   vec4 white = vec4(1, 1, 1, 1);
   float distance = distance(coord.xy, wave.xy);
   float wave1 = abs(distance - wave.z);
   wave1 = clamp(wave1, 0.0, 25.0);  
   wave1 = (25.0 - wave1) / 35.0;
   vec4 color = mix(vcolor, white, newColor.bbba);
   color = mix(vcolor, color, wave1);
   return color;
}

void main()                          
{
   vec3 coord = gl_FragCoord.xyz;
   
   vec4 color = getColor(u_Wave0, coord, v_Color);
   vec4 color1 = getColor(u_Wave1, coord, v_Color);
   //vec4 color2 = getColor(u_Wave2, coord, v_Color);
  //vec4 color3 = getColor(u_Wave3, coord, v_Color);
 
   vec4 color3 = max(color, color1);
   //color3 = max(color3, color1);
  //color3 = max(color3, color2);
 
   gl_FragColor = color3;                                  
}                              
8  Java Game APIs & Engines / OpenGL Development / Shader not rendering correctly on: 2014-07-17 07:55:51
This is driving me mad... I have a fragment shader that generates up to 4 ripples on the screen, but it doesn't render correctly. The ripples go about halfway, then flash to the edge of the screen.

I used to have all the code (repeated 4 times) in main(). In that version, only one of my waves would render incorrectly. After moving the code to a function they all do. Also, performance is much worse with the function...

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  
precision mediump float;

uniform vec4 u_Wave0;
uniform vec4 u_Wave1;
uniform vec4 u_Wave2;
uniform vec4 u_Wave3;

varying vec3 v_Position;
varying vec4 v_Color;

vec4 getColor(in vec4 wave, in vec3 coord, in vec4 vcolor) {
   vec4 newColor = vec4(0.1, 0.2, 0.4, 1.0);
   vec4 white = vec4(1, 1, 1, 1);
   float distance = distance(coord.xy, wave.xy);
   float wave1 = abs(distance - wave.z);
   wave1 = clamp(wave1, 0.0, 25.0);  
   wave1 = (25.0 - wave1) / 35.0;
   vec4 color = mix(vcolor, white, newColor.rrra);
   color = mix(vcolor, color, wave1);
   return color;
}

void main()                          
{
   vec3 coord = gl_FragCoord.xyz;
   
   vec4 color = getColor(u_Wave0, coord, v_Color);
   vec4 color1 = getColor(u_Wave1, coord, v_Color);
   vec4 color2 = getColor(u_Wave2, coord, v_Color);
   vec4 color3 = getColor(u_Wave3, coord, v_Color);
   
   color3 = max(color3, color);
   color3 = max(color3, color1);
   color3 = max(color3, color2);
   
   gl_FragColor = color3;                                  
}                                                                        
9  Discussions / Miscellaneous Topics / Re: A rant on OpenGL's future on: 2014-07-15 12:19:07
Doesn't OpenGL ES cut out most of the legacy?
10  Games Center / Showcase / Re: We Shall Wake demo (v6.0) on: 2014-07-14 20:24:50
AAA.
11  Java Game APIs & Engines / Android / Re: update opelgl background with button click...? on: 2014-07-12 23:47:37
Thanks, gl_FragCoord was what I needed!
12  Java Game APIs & Engines / OpenGL Development / Re: VBO and Shaders on: 2014-07-10 21:59:45
Shouldn't it at least render a black box if it doesn't have color?

Depends on what colour you're passing in with your shader.

Impossible. Your fragment shader must return a color.
13  Java Game APIs & Engines / Android / update opelgl background with button click...? on: 2014-07-10 21:56:15
I'm working on a game with some simple Buttons, but behind them I draw an OpenGL dynamic background. How can I feed the location of my button to the fragment shader? I know how to get the screen coordinates of a View, but how do I translate them into something a shader would understand?
14  Discussions / Miscellaneous Topics / Re: Bought myself a new smartphone! on: 2014-07-10 19:00:42
Benchmark it with my app :-)

https://play.google.com/store/apps/details?id=com.clarke.agnes.benchmark.android
15  Java Game APIs & Engines / OpenGL Development / Re: GLES20.glUseProgram(0); on: 2014-07-08 23:26:30
@Riven, I have come to my senses and used a real shader. Shader Program Zero was just a random discovery when I loaded a program with an unititialized int handle.
16  Game Development / Game Mechanics / Re: Resizing a 2D array of objects on: 2014-07-08 20:54:44
Simple: change your file format to include a header row that tells you the dimensions, and walk away from all this hackiness.
17  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-08 20:33:55
I've thought about that... whether you need to follow the natural letter order of the word. But I think if that was the case it would make most sense to sort the words in order of least-frequent letters first. I also wondered if reversed words would go faster.

Why do you think an alphabetical sort will make things more efficient? You want more branches in the tree, not less. Also, many words would end up on the same node (e.g. dog and god), which can't happen with the current structure. Also, you would have to store the whole word at a word node, I don't like that.
18  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-08 16:42:42
I'm not doing it that way, but I am excluding most permutations from the search - this is the great advantage of a trie. Have a look at the implementation in the first post.
19  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-07 22:55:14
I added parent references to the nodes and used richierich's approach of fiddling with a single list object for the scrambled letters as it weaves its way through the tree. Those changes bring the unscrambling time down to 7 millis, a 50-100% improvement.

I think this is about done, so I will update the first post with the final code, after I have cleaned up the class and variable names a bit.

I never did the Riven 2-chars per node approach, but with my approach of dumbing down the app to use precalculated solutions on the SD card, I don't really need the headache it would give me.
20  Discussions / General Discussions / Re: The Wrath of Ackermann on: 2014-07-07 21:24:46
(ack(4,3))^ack(4,3)
21  Discussions / General Discussions / Re: The Wrath of Ackermann on: 2014-07-07 21:12:49
Write down the number of atoms in the universe. Put a squared next to it.
22  Discussions / General Discussions / Re: The Wrath of Ackermann on: 2014-07-07 21:02:57
You can always write down a number no matter how big it is. All you need is the right syntax.
23  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-07 20:59:31
Memory won't be an issue as this is now only going to run on my build machine. The game will just have a couple of megabytes of precalculated 9-letter puzzles, which I will load into HashSets for the in-game spell checks.
24  Discussions / General Discussions / Re: The Wrath of Ackermann on: 2014-07-07 10:35:25
I guess a 99.9% approximation of this function would be blindingly fast. After, even common functions like sin() or cos() are only calculated to a certain degree of precision.
25  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-07 00:57:12
That's a neat idea to cut down on the object creation. I can also cut out the unscrambled variable by giving each node a reference to its parent... Then every complete word can write itself out by recursing to the root of the trie.
26  Discussions / General Discussions / Re: Questions about game development cycle on: 2014-07-06 23:54:13
Make small changes and test frequently. Learn how to refactor your code, simple things like extracting methods or interfaces can improve your code a lot. Try to make as much of your code as possible independent of your user interface so you can create test cases.
27  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-05 23:36:45
What kind of game is this?! Is there such a thing as an arcade action twich spelling game Cheesy Is 15ms really too long to do the permutations search?

Well, there will be screen shake if you hit a triple combo on your words. And there are power-ups :-)

Quote
Wikipedia says SOWPODS has 267,751 words. Permutations of 9 means 362,880 lookups(*), most of which are quick failures a couple of letters down the trie. So is 15ms just a straight lookup for each permutation, or have you added more intelligence to the process?

E.g. maybe you could recode exists() to return a number which was the level of the trie at which the search failed, or 0 if the search was successful. Then e.g. with letters ACFFEKNSW you would test the first permutation "ACFFEKNSW" and get 3 back so you could skip testing all other permutations beginning with ACF. Just thinking aloud - maybe you did something like that already?

Here is the new node 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  
    private static class ArrayCharacterNode extends ArrayNode2 {
        private boolean completeWord = false;
        private static StringBuilder sb = new StringBuilder();
        public ArrayCharacterNode() {
            instanceCount++;
        }
        public void unscramble(Map<String, Object> results, ArrayList<Character> scrambled, ArrayList<Character> unscrambled) {
            if (completeWord) {
                outputWord(results, unscrambled);
            }
            for (int i = 0; i < scrambled.size(); i++) {
                Character c = scrambled.get(i);
                ArrayCharacterNode node = get(c);
                if (node != null) {
                    ArrayList<Character> newScrambled = new ArrayList<Character>(scrambled);
                    newScrambled.remove(c);
                    ArrayList<Character> newUnscrambled = new ArrayList<Character>(unscrambled);
                    newUnscrambled.add(c);
                    node.unscramble(results, newScrambled, newUnscrambled);
                }
            }
        }

        private static void outputWord(Map<String, Object> results, ArrayList<Character> unscrambled) {
            for (int i = 0; i < unscrambled.size(); i++) {
                sb.append(unscrambled.get(i));
            }
            results.put(sb.toString(), null);
            sb.delete(0, sb.length());
        }
    }


I'm not entirely happy with it, I feel the method is creating too many objects as it walks the tree.

Quote
Another thought, did you try just whacking the SOWPODS words into a HashSet<String> and forget the trie altogether?

HashSet is usually as  fast as Trie (for simple word lookups), but Trie can pull ahead if I do a vast number of checks. But remember, if I did not have the trie, for word combinations I would have to check every combination of the 9 letters. With the trie, i can exclude branches in one go.
28  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-05 19:23:18
I use the trie to discard branches of possible words, I will post the code later. I'm over the moon with 15 ms, although it would be longer than that in android. If i wanted to be a real hard case, I could multithread the search, it would be very easy, but possibly insane.
29  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-05 11:17:57
In my original post I did say " I need fast dictionary lookup and also to find words from random sets [of letters]".
30  Game Development / Shared Code / Re: Trie-based dictionary on: 2014-07-05 01:56:39
Well, I've built it up into my own little scrabble cheat program... If you write the cheat program yourself, is it still cheating?

Compared to spell checking, finding words from random letters is really slow. I can spell check the whole dictionary plus double that in spelling errors in 80 milliseconds, but to find thge words for one set of nine letters takes 10 to 15 milliseconds.
Pages: [1] 2 3 ... 18
 

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

The first screenshot will be displayed as a thumbnail.

pw (21 views)
2014-07-24 01:59:36

Riven (19 views)
2014-07-23 21:16:32

Riven (16 views)
2014-07-23 21:07:15

Riven (19 views)
2014-07-23 20:56:16

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

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

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

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

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

Riven (52 views)
2014-07-14 18:02:53
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!