Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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 ... 57
1  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:41:59
each integer on the line

Does that mean any single line contains more than a single integer, or read multiple lines, each containing one integer?
2  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:39:45
Java is general-purpose language, you can do whatever you want.

Until you say what that is, I'm convinced you don't know yourself and that we're wasting our time.
3  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:35:26
Well that's probably because int's have a bounded size, which you exceeded. Try BigInteger if you need arbitrarily-sized numbers.

What the hell are even trying to do, exactly? This whole thread reeks of "XY problem."
4  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:31:51
See my edit.

http://stackoverflow.com/questions/275711/add-leading-zeroes-to-number-in-java
5  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:28:01
Use System.out.println()

This still only prints one line from the file, but it will print it like so

0
0
0
0

So it will print one line from the file, which looks like this: 0000

Watch what happens when you change the numbers.

Integers don't keep the leading zeros. Sounds like you want Strings.
EDIT: or use NumberFormat etc. to print the integers padded with leading zeros.
This is why you don't have identical test data.

@Kudo
Use Scanner and rejoice that you never have to use a BufferedReader ever again.
6  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:20:38
Use System.out.println()
7  Game Development / Newbie & Debugging Questions / Re: Reading nextInt() from a text file on a new line? on: 2014-12-18 02:11:26
Integer.parseInt(foo.nextLine());
8  Discussions / Miscellaneous Topics / Re: Best way to learn to touch-type on: 2014-12-18 00:48:03
I figured as much, but if you have a bot, why not go all out? 214 seems modest in that case.
9  Game Development / Newbie & Debugging Questions / Re: ENUM Memory usage in Java on: 2014-12-17 18:40:05
Yes that is what I meant, it's because there is no way to stop one from modifying the ordinals in the array without doing a defensive copy.
10  Discussions / Miscellaneous Topics / Re: Best way to learn to touch-type on: 2014-12-17 18:31:15
I should really do this too, currently my typing is of a decent speed, and I don't have to look at the keyboard for everything, but it's nowhere near legitimate touch typing.
As I'm also trying to become proficient with emacs, being able to properly type would put me that much closer to becoming a wizard.
Apparently someone on TypeRacer is already a wizard:
-xKµkKain-x (tsvukk)      214 wpm      2 minutes ago  Clueless
11  Game Development / Newbie & Debugging Questions / Re: ENUM Memory usage in Java on: 2014-12-17 18:20:02
I don't know where that benchmark is, but I have found the same to be true in certain situations. It all depends on the bounds checks, although if the 2nd dimension is quite small you could see a larger improvement from flattening anyway.
I know that simple constant stride indices are simple enough for HotSpot, see here: https://wikis.oracle.com/display/HotSpotInternals/RangeCheckElimination

1  
2  
3  
...

TileFlag specificType = TileFlag.values[flags[0][10]];


Note that EnumType.values() creates a new array each time it is called, but I see you are indexing values as a array, so hopefully you are already caching it.
12  Game Development / Game Mechanics / Re: Biome and how to set them up on: 2014-12-16 22:17:05
The trick to get easy procedural generation is totality and structuring things as functions of location.
Instead of your map being "an array of tiles", it's a function (which can be a composition of smaller functions, such as heat and elevation) from coordinates to tiles.

E.g.
1  
2  
3  
4  
5  
6  
7  
8  
fn terrain (x, y) -> Tile {
    elevation = heightFunction(x, y); // has totality; not backed by an array or anything
                                      // creating a constraint for only positive numbers or something
    temp = heatFunction(x, y);        // same here
    biome = biomeMapping(elevation, temp);
    tileType = tileTypeMapping(biome, elevation, temp); // grass? dirt? snow? etc.
    return new Tile(tileType);
}


This is much nicer and easier to express in a functional language, but is still quite possible here and leads to highly extensible ways to create stuff like terrain.
You might notice that an array is a function from location to tiles, but it's not easily extensible, and certainly not total.
Pay attention in math class kids!
13  Game Development / Game Mechanics / Re: Biome and how to set them up on: 2014-12-16 21:17:51
Sounds like you already have it figured out.
14  Game Development / Game Mechanics / Re: Bioms and how to set them up on: 2014-12-16 21:03:41
Biome*
Perlin* (actually Simplex most likely)

So you seem to have done some research, but yet are asking the nebulous question "any ideas/suggestions?"
What, game design ideas or suggestions? I don't see how the question is relevant.

There are many ways in which one can simulate biomes.
I would start with the definition of what they are so you can understand what exactly it is you are trying to simulate: http://en.wikipedia.org/wiki/Biome

Then a quick google search reveals some techniques:

Elevation (from height map) + rainfall graph, grouped by polygonal regions:
http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/

Minecraft uses rainfall + temperature (similar to elevation): http://minecraft.gamepedia.com/Biome#Technical_Details
More conversation here, plus insight of using another noise function to create the biome regions (instead of say, polygons): http://gaming.stackexchange.com/questions/26531/how-do-minecraft-biomes-work
15  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 17:26:43
That's the byte[] being printed.
If you want to see the nubmers, use Arrays.toString(), and if you want to see the string representation, use new String.
16  Game Development / Newbie & Debugging Questions / Re: How to force OpenGL Version? on: 2014-12-16 05:41:06
Submit a pull request or issue, that will make sure it gets noticed.
17  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 04:00:01
I…I don't even see the code. All I see is blonde, brunette, red-head.



(Bonus pun relative to this thread if you know that guy's name....)
18  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 03:45:28
Sure. (as a bonus now that you hopefully understand it, here it is with byte arrays)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
byte[] data = "500".getBytes();
byte[] key = "imsorandom".getBytes();
         
System.out.println(Integer.valueOf(new String(data)));
         
// encrypt
for (int i = 0; i < data.length; i++) {
    data[i] = (byte) (data[i] ^ key[i % key.length]);
}
         
System.out.println(new String(data)); // not going to try and parse gibberish as an integer
         
// decrypt
for (int i = 0; i < data.length; i++) {
    data[i] = (byte) (data[i] ^ key[i % key.length]);
}
         
System.out.println(Integer.valueOf(new String(data)));


Quote
500
\]C
500

And the key, since it's random numbers; is there any maximum or minimum to the key length?

No, but using this method if the key is longer than the data (such as in this example) the excess is unused.
(Although a key length of 0 would break this code, but in theory you might consider it the identity function)
19  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 03:27:12
I don't understand the question.
20  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 03:21:27
No the key is just a random number. A "binary string," in this case (124 << 24) | (56 << 16) | (37 << 8) | (-77 & 0xFF) -> 2084054451 -> 1111100001110000010010110110011

xorWithKey just sets each bit of the data to that bit xor'd with the appropriate bit of the key, modulo the key length so that it acts like you repeat the key until it's the same length as the data.

Example:
data = 10010100110  (12 bits)
key = 1011              (4 bits)

key is shorter than the data so BitSet.xor() would only change the first 4 bits of data and the rest would be stay unencrypted. Not what you want.
So instead the key needs to be made longer. Simplest way to do that is to just repeat it until it's long enough:
key = 101110111011 (repeated 3 times, 12 bits)

Now xor them together to "encrypt":
10010100110
101110111011
= 111100011101

Which will be your encrypted data, which looks like gibberish when printed as Unicode.

Do it again, but this time on the encrypted data:
111100011101
101110111011
= 10010100110

Which you will notice is identical to the original data. That's how the "XOR encryption" works.

EDIT: here is the wikipedia page on the subject: http://en.wikipedia.org/wiki/XOR_cipher
21  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 02:53:32
Except those aren't binary numbers, they're Strings. (Well everything is numbers in memory when you get down to it, but they aren't the numbers you think they are)

charAt() returns a char, which is a number from this table: http://www.asciitable.com/ (technically it's Unicode, but the first 128 Unicode chars are identical to the ASCII standard)


Think about it. In the mean time here's a simple BitSet impl:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
BitSet key = BitSet.valueOf(new byte[] { 124, 56, 37, -77 });
BitSet data = BitSet.valueOf("Hello World".getBytes());

System.out.println(new String(data.toByteArray()));

xorWithKey(data, key);
System.out.println(new String(data.toByteArray()));

xorWithKey(data, key);
System.out.println(new String(data.toByteArray()));

// xor's data with key
private static void xorWithKey(BitSet data, BitSet key) {
    for (int i = 0; i < data.length(); i++) {
        data.set(i, key.get(i % key.length()) ^ data.get(i));
    }
}


Quote
Hello World
4]I�r�TA
Hello World

Unfortunately, BitSet.xor() doesn't cycle the shorter of two sets, so unless your key is the same number of bits as the data to be encoded, you have to use that helper function. Hopefully you get it.

If it's slow then you can extrapolate it to xoring a byte (or more) at a time with raw arrays, but BitSets are easier to understand.

EDIT: hey my forum rank comes in handy here  Pointing
22  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-16 02:06:07
Note that you are not XORing the numbers, but instead the ASCII char values.

Think about using a BitSet.
23  Game Development / Newbie & Debugging Questions / Re: Positive z-value flips 3d program (Pure Java) on: 2014-12-15 23:45:11
That's what happens in 3D projection when you have no front clip.
24  Game Development / Newbie & Debugging Questions / Re: Starting a Java Game, Where to Start? Eventually want to be network multiplayer on: 2014-12-15 23:02:10
I still use the android folder etc. for resources. Maybe you just had something weird going on with your eclipse/gradle install.
25  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-15 22:48:46
Or just base-whatever + gzip the save file and put it in a weird place with no file extension and you will have foiled 99+% of would-be hackers. If you're deploying to windows, make that effectively 100%
26  Game Development / Newbie & Debugging Questions / Re: Starting a Java Game, Where to Start? Eventually want to be network multiplayer on: 2014-12-15 22:45:30
I haven't tried Android, but in my experience the libGDX project setup (including gradle, note I have no experience there either) was a painless 30 second procedure from opening the gui to having the libGDX default program running.
27  Game Development / Newbie & Debugging Questions / Re: Java Cryptography on: 2014-12-15 22:42:42
But since they have your program, they can easily decompile it and have the key. No dice.
28  Game Development / Newbie & Debugging Questions / Re: 2D Random Map Generation: Where to start on: 2014-12-15 22:41:13
What happens if you interpret each pixel in the image as a tile? Voila.
29  Game Development / Newbie & Debugging Questions / Re: 2D Random Map Generation: Where to start on: 2014-12-15 22:15:34
I ninja'd you.
30  Game Development / Newbie & Debugging Questions / Re: 2D Random Map Generation: Where to start on: 2014-12-15 22:03:28
Those are all implementation details. OP needs to learn to think conceptually and mathematically; once you do that all kinds of applications for things like noise will spring forth unbidden.

Common example: sidescroller-type height maps:



Can be easily accomplished via the midpoint displacement algorithm: (or splines! or whatever you want, etc)
http://www.gameprogrammer.com/fractal.html

This is farther generalized to the diamond-square algorithm for more dimensions.
You can see that both in the link and in the post I made a little while ago:
http://www.java-gaming.org/topics/what-i-did-today/33622/msg/331221/view.html#msg331221

Other algorithms like Simplex can accomplish the same tasks as these, but may also have additional properties like continuous derivatives, etc. which may be desirable.

For the sidecroller, you could potentially even do a sum of sine waves to get you the wave-y line, it doesn't matter. All that matters is how you interpret the information.
Pages: [1] 2 3 ... 57
 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (37 views)
2014-12-09 22:41:13

BurntPizza (72 views)
2014-12-08 04:46:31

JscottyBieshaar (34 views)
2014-12-05 12:39:02

SHC (46 views)
2014-12-03 16:27:13

CopyableCougar4 (42 views)
2014-11-29 21:32:03

toopeicgaming1999 (110 views)
2014-11-26 15:22:04

toopeicgaming1999 (96 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
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!