title: Implementation of gaining experience in the game
body: <p>I'm trying to implement such algorithm written by me:</p>
  
  <pre><code>// up to 2LVL (10) =&gt; 10 = 10 - 0 - 0
  // up to 2LVL (5) =&gt; 5 = 10 - 0 - 5
  // up to 3LVL (20) =&gt; 20 = 20 + (0+10) - 10
  // up to 3LVL (15) =&gt; 15 = 20 + (0+10) - 15
  // up to 3LVL (10) =&gt; 10 = 20 + (0+10) - 20
  // up to 3LVL (5) =&gt; 5 = 20 + (0+10) - 25
  // up to 4LVL (40) =&gt; 40 = 40 + (10+20) - 30
  // up to 4LVL (35) =&gt; 35 = 40 + (10+20) - 35
  // up to 4LVL (25) =&gt; 25 = 40+ (10+20) -45
  // up to 4LVL (20) =&gt; 20 = 40 +(10+20) -50
  // up to 4LVL (15) =&gt; 15 = 40+ (10+20) -55
  </code></pre>
  
  <p>here is a breach with other values</p>
  
  <pre><code>// up to 4LVL (10) =&gt; 10 = 40+ (10+20) -60
  // up to 4LVL (5) =&gt; 5 = 40+ (10+20) -65
  // up to 5LVL (80) =&gt; 80 = 80 +(10+20+40) -70
  // up to 5LVL (75) =&gt; 75 = 80 +(10+20+40) -75
  </code></pre>
  
  <p>My implementation looks like this:</p>
  
  <pre><code>    int j = dbHelper.getExpRequirementsByLvl(cc.getLv() + 1) - dbHelper.getProfile().getExp();
      int k=0;
      for (int i = 0; i &lt; dbHelper.getProfile().getLvl()+1; i++)
          k = k+ dbHelper.getExpRequirementsByLvl(i);
      int m = j+k;
  </code></pre>
  
  <p>and it works until the loop reaches 4LVL. But why it doesn't work further?</p>
  
  <p>I start the game and have 0exp. I kill one mob and get 5exp.Number in bracket on the left means how many exp we do need to get new level. Bracket on the right are numbers that means exp needed to lvl that we already gained.</p>
  
  <p>The method looks like this:</p>
  
  <pre><code>    public int getExpRequirementsByLvl(int lvl) {
      int expRequired=0;
      SQLiteDatabase db = this.getReadableDatabase();
      Cursor res = db.rawQuery("select * from levels where lvl=" + lvl + "", null);
  
      if (res.moveToNext()) {
          expRequired = Integer.parseInt(res.getString(1));
      }
  
      return expRequired;
  }
  </code></pre>