Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Best Way to Code Random Percentage of Something on: 2013-04-09 11:30:05
You would use a java.util.Random object. Define one somewhere, and use it like this (assuming your HashMap is of item IDs to percentages, if not you might need to change it a bit):

boolean dropped = false;
int highest = -1;
int highAmt = -1;
// Lets loop through all the items, because you said you didn't want it hardcoded
for (Entry<Integer, Integer> entry : drops.entrySet()) { // Where drops is the HashMap you spoke of. HashMaps are extremely fast, don't worry about that
   if (entry.getValue() > highAmt) {
        highest = entry.getKey();
    // Note <, not <=, because nextInt(100) will generate a number from 0-99, not 1-100.
   if (random.nextInt(100) < entry.getValue()) { // Will happen every (entry.getValue() / 100) times
       world.dropItemById(x, y, z, entry.getKey()); // Or however you do this
       dropped = true; // Set this to true for usage a bit later
       break; // Remove this if you want the chance of multiple drops
if (!dropped) {
    world.dropItemById(x, y, z, highest); // Slightly crude way of ensuring something is dropped. If we don't drop something, drop whatever has the highest percentage. If you want the possibility of no drop remove this
2  Game Development / Performance Tuning / Re: Speeding up Minecraft? on: 2013-03-30 19:06:54
Rewrite most of Minecraft to use rendering that isn't immediate mode and multithread some of it Tongue Realistically you could probably add a bit of multithreading, and if you want to spend a lot of time on it you could convert it to use DisplayLists.
3  Game Development / Game Mechanics / Re: Multiple threads on: 2013-03-29 23:19:51
It depends on how well you do it. It's can work to have a rendering thread, a logic thread, a resource loading thread, a world generation thread (if applicable), and even an input thread if you do it right, as well as threads for connections, etc. It all depends on how your game works and how well you know how to implement multithreading though.
4  Games Center / Cube World Projects / Re: Sparky's little Cube World Project on: 2013-03-29 21:55:39
Ok, I forgot about the jar if you like to try it. It should be ready for windows and linux:

Please report me any errors. Smiley

The download is a 404
5  Game Development / Shared Code / Re: [LWJGL] Easily render text. on: 2013-03-29 16:24:56
This looks exactly like Minecraft's renderString method looked in one of the early beta versions (before they optimised it quite a bit).
6  Game Development / Shared Code / Re: CyclicMap - A Map implementation perfect for games and faster than HashMap on: 2013-03-29 16:14:41
Well maybe you can talk to him about it. It's still twice the speed with his optimisation, and I'm fairly sure currentTimeMillis doesn't go 80ms off (at least most of the time).
7  Game Development / Shared Code / Re: CyclicMap - A Map implementation perfect for games and faster than HashMap on: 2013-03-29 15:53:46
If you are looking at optimising HashMaps, you could have a look at raphfrk's findings at
8  Games Center / Cube World Projects / Re: LWJGL BlockWorld on: 2013-03-29 14:50:06
Is it possible that we could get the source for the new version of your game? I've made my own block engine but it's not great on efficiency / performance, and I'd love to learn from someone better's code to see where it can be optimised and what methods I should be using.
Pages: [1]

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

The first screenshot will be displayed as a thumbnail.

Riven (20 views)
2014-07-29 18:09:19

Riven (13 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (31 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

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

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

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

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

ctomni231 (60 views)
2014-07-18 06:55:21
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 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‑
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!