Example #1
0
  public static void initialize(JSONArray shotDefs) throws JSONException {
    for (int i = 0; i < shotDefs.length(); i++) {
      JSONObject shotDef = shotDefs.getJSONObject(i);
      int type = shotDef.getInt("type");
      types.add(type);

      widths.put(type, (float) shotDef.getDouble("width"));
      heights.put(type, (float) shotDef.getDouble("height"));
      speeds.put(type, (float) shotDef.getDouble("speed"));
      damages.put(type, shotDef.getInt("damage"));
      textures.put(type, shotDef.getString("texture"));
      upgradeables.put(type, shotDef.getBoolean("upgradeable"));
    }
  }
Example #2
0
 private float getAndIncrementStash(int key, float defaultValue, float increment) {
   int[] keyTable = this.keyTable;
   for (int i = capacity, n = i + stashSize; i < n; i++)
     if (key == keyTable[i]) {
       float value = valueTable[i];
       valueTable[i] = value + increment;
       return value;
     }
   put(key, defaultValue + increment);
   return defaultValue;
 }
Example #3
0
 private void putStash(int key, float value) {
   if (stashSize == stashCapacity) {
     // Too many pushes occurred and the stash is full, increase the table size.
     resize(capacity << 1);
     put(key, value);
     return;
   }
   // Store key in the stash.
   int index = capacity + stashSize;
   keyTable[index] = key;
   valueTable[index] = value;
   stashSize++;
   size++;
 }
Example #4
0
 public void putAll(IntFloatMap map) {
   for (Entry entry : map.entries()) put(entry.key, entry.value);
 }