Skip to content

Commit

Permalink
First stable version, fix #11
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando Lincoln committed Jul 20, 2020
1 parent 5438def commit 7a37c80
Show file tree
Hide file tree
Showing 27 changed files with 489 additions and 171 deletions.
2 changes: 0 additions & 2 deletions core/src/com/usp/corrida/Core.java
Expand Up @@ -138,8 +138,6 @@ public void dispose () {

background.dispose();

charPlayer.dispose();

res.dispose();
}
}
8 changes: 0 additions & 8 deletions core/src/com/usp/corrida/logic/Character.java
Expand Up @@ -242,12 +242,4 @@ public void render(float delta, float offsetX){
core.res.font20.setColor(1, 1, 1, 1);
}
}

/**
* Descarrega todos os recursos
*/
public void dispose(){


}
}
72 changes: 47 additions & 25 deletions core/src/com/usp/corrida/screens/GameScreen.java
Expand Up @@ -18,11 +18,11 @@ public class GameScreen extends ScreenAdapter {
public static final long HURT_INTERVAL = 1500;
public static final long GAMEOVER_SLIDE = 1500;
public static final int MAX_NPC = 3;
public static final int MAX_LEVEL = 3;
public static final int MAX_LEVEL = 7;

private final Core core;

private Texture texLife;
private final Texture texLife;

private long tickPoints = 0;
private long tickHurt = 0;
Expand All @@ -34,8 +34,8 @@ public class GameScreen extends ScreenAdapter {
private final Character[] npc = new Character[MAX_NPC];
private float lastNPCX = 0;

private final int numberRangeMin[] = new int[MAX_LEVEL];
private final int numberRangeMax[] = new int[MAX_LEVEL];
private final int[] numberRangeMin = new int[MAX_LEVEL];
private final int[] numberRangeMax = new int[MAX_LEVEL];

private int life = 3;
private long scoreAdd = 0;
Expand All @@ -51,9 +51,13 @@ public GameScreen(Core core){

texLife = new Texture(Gdx.files.internal("life.png"));

numberRangeMin[0] = 11; numberRangeMax[0] = 100;
numberRangeMin[1] = 101; numberRangeMax[1] = 500;
numberRangeMin[2] = 501; numberRangeMax[2] = 1000;
numberRangeMin[0] = 10; numberRangeMax[0] = 100;
numberRangeMin[1] = 100; numberRangeMax[1] = 500;
numberRangeMin[2] = 100; numberRangeMax[2] = 500;
numberRangeMin[3] = 500; numberRangeMax[3] = 1000;
numberRangeMin[4] = 500; numberRangeMax[4] = 1000;
numberRangeMin[5] = 1000; numberRangeMax[5] = 5000;
numberRangeMin[6] = 1000; numberRangeMax[6] = 5000;

resetScreen();
}
Expand Down Expand Up @@ -85,12 +89,15 @@ public void resetScreen(){
}

/**
* !!!!!!!!!!!!!!!!!!!!! AINDA INCERTO !!!!!!!!!!!!!!!!!!!!!!
* @return Nível de dificuldade atual com base na pontuação
* @return Nível de dificuldade
*/
private int getLevel(){
if (npcRecycled >= 40) return 2;
if (npcRecycled >= 20) return 1;
if (npcRecycled >= 150) return 6;
if (npcRecycled >= 100) return 5;
if (npcRecycled >= 70) return 4;
if (npcRecycled >= 50) return 3;
if (npcRecycled >= 30) return 2;
if (npcRecycled >= 10) return 1;
return 0;
}

Expand Down Expand Up @@ -128,24 +135,43 @@ private void updateNPCAnswer(int i){

// 60% to pick a correct answer
if (correct <= 6) npc[i].setValue(challengeValue);
else npc[i].setValue(core.rand.getIntRandDiff(challengeValue-challengeValue/10-2, challengeValue+challengeValue/10+2, challengeValue));
else npc[i].setValue(core.rand.getIntRandDiff(Math.max(10, challengeValue-(level+1)*5), challengeValue+(level+1)*5, challengeValue));

if (level == 0){ // Only + and -
int a = core.rand.getIntRand(1, 10);
if (level == 0){ // X = [10, 100]
int a = core.rand.getIntRand(1, 9);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 1){ // Only + and -
int a = core.rand.getIntRand(1, 10);
else if (level == 1){ // X = [100, 500]
int a = core.rand.getIntRand(1, 9);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 2){ // Only + and -
int a = core.rand.getIntRand(10, 99);
else if (level == 2){ // X = [100, 500]
int a = core.rand.getIntRand(10, 20);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 3){ // X = [500, 1000]
int a = core.rand.getIntRand(10, 20);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 4){ // X = [500, 1000]
int a = core.rand.getIntRand(20, 50);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 5){ // X = [1000, 5000]
int a = core.rand.getIntRand(20, 50);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}
else if (level == 6){ // X = [1000, 5000]
int a = core.rand.getIntRand(50, 99);
if (operation <= 5) npc[i].setText(a+"+"+(npc[i].getValue()-a)); // + operation
else npc[i].setText((npc[i].getValue()+a)+"-"+a); // - operation
}


}

Expand Down Expand Up @@ -268,8 +294,8 @@ private void recycleNPCs(float offsetX){
else npc[i].setY(32);

// Setting a new position
float x1 = offsetX + core.width + core.rand.getIntRand(0, (int)(core.width/2f));
float x2 = lastNPCX + core.rand.getIntRand(80, (int)(core.width/2f));
float x1 = offsetX + core.width + core.rand.getIntRand(0, (int)(core.width/3f));
float x2 = lastNPCX + core.rand.getIntRand(80, (int)(core.width/3f));
float newX = Math.max(x1, x2);
lastNPCX = newX;
npc[i].setX(newX);
Expand Down Expand Up @@ -396,9 +422,5 @@ public void render (float delta) {
@Override
public void dispose(){
texLife.dispose();

for(int i = 0;i < MAX_NPC;i++){
npc[i].dispose();
}
}
}
2 changes: 1 addition & 1 deletion core/src/com/usp/corrida/screens/TitleScreen.java
Expand Up @@ -19,7 +19,7 @@ public class TitleScreen extends ScreenAdapter {
private Texture texHelpButton;
private Texture texHelpScreen;

private Boolean helpScreen = true;
private Boolean helpScreen = false;

public TitleScreen(Core core){
this.core = core;
Expand Down
4 changes: 2 additions & 2 deletions docs/allclasses-frame.html
Expand Up @@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_252) on Fri Jun 19 01:08:57 BRT 2020 -->
<!-- Generated by javadoc (1.8.0_252) on Mon Jul 20 20:10:25 BRT 2020 -->
<title>All Classes (Corrida Aritmetica - docs)</title>
<meta name="date" content="2020-06-19">
<meta name="date" content="2020-07-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Expand Down
4 changes: 2 additions & 2 deletions docs/allclasses-noframe.html
Expand Up @@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_252) on Fri Jun 19 01:08:57 BRT 2020 -->
<!-- Generated by javadoc (1.8.0_252) on Mon Jul 20 20:10:25 BRT 2020 -->
<title>All Classes (Corrida Aritmetica - docs)</title>
<meta name="date" content="2020-06-19">
<meta name="date" content="2020-07-20">
<link rel="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script type="text/javascript" src="script.js"></script>
</head>
Expand Down
81 changes: 68 additions & 13 deletions docs/com/usp/corrida/Core.html
Expand Up @@ -2,9 +2,9 @@
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (1.8.0_252) on Fri Jun 19 01:08:57 BRT 2020 -->
<!-- Generated by javadoc (1.8.0_252) on Mon Jul 20 20:10:25 BRT 2020 -->
<title>Core (Corrida Aritmetica - docs)</title>
<meta name="date" content="2020-06-19">
<meta name="date" content="2020-07-20">
<link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style">
<script type="text/javascript" src="../../../script.js"></script>
</head>
Expand All @@ -18,7 +18,7 @@
catch(err) {
}
//-->
var methods = {"i0":10,"i1":10,"i2":10,"i3":10};
var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10};
var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"]};
var altColor = "altColor";
var rowColor = "rowColor";
Expand Down Expand Up @@ -139,42 +139,46 @@ <h3>Field Summary</h3>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#batch">batch</a></span></code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>private OrthographicCamera</code></td>
<td class="colFirst"><code>OrthographicCamera</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#camera">camera</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/logic/Character.html" title="class in com.usp.corrida.logic">Character</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#charPlayer">charPlayer</a></span></code>&nbsp;</td>
</tr>
<tr class="altColor">
<td class="colFirst"><code>private static float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#FIXED_WIDTH">FIXED_WIDTH</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/screens/GameScreen.html" title="class in com.usp.corrida.screens">GameScreen</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#gameScreen">gameScreen</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<tr class="altColor">
<td class="colFirst"><code>float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#height">height</a></span></code>&nbsp;</td>
</tr>
<tr class="altColor">
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/utils/Random.html" title="class in com.usp.corrida.utils">Random</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#rand">rand</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<tr class="altColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/Resources.html" title="class in com.usp.corrida">Resources</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#res">res</a></span></code>&nbsp;</td>
</tr>
<tr class="altColor">
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/utils/Save.html" title="class in com.usp.corrida.utils">Save</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#save">save</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<tr class="altColor">
<td class="colFirst"><code>private static java.lang.Boolean</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#showFPS">showFPS</a></span></code>&nbsp;</td>
</tr>
<tr class="altColor">
<tr class="rowColor">
<td class="colFirst"><code><a href="../../../com/usp/corrida/screens/TitleScreen.html" title="class in com.usp.corrida.screens">TitleScreen</a></code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#titleScreen">titleScreen</a></span></code>&nbsp;</td>
</tr>
<tr class="rowColor">
<tr class="altColor">
<td class="colFirst"><code>float</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#width">width</a></span></code>&nbsp;</td>
</tr>
Expand Down Expand Up @@ -229,11 +233,23 @@ <h3>Method Summary</h3>
</td>
</tr>
<tr id="i3" class="rowColor">
<td class="colFirst"><code>void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#resize-int-int-">resize</a></span>(int&nbsp;width,
int&nbsp;height)</code>&nbsp;</td>
</tr>
<tr id="i4" class="altColor">
<td class="colFirst"><code>private void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#setupPlayer--">setupPlayer</a></span>()</code>
<div class="block">Faz a primeira configuração do jogador</div>
</td>
</tr>
<tr id="i5" class="rowColor">
<td class="colFirst"><code>private void</code></td>
<td class="colLast"><code><span class="memberNameLink"><a href="../../../com/usp/corrida/Core.html#updateScale-int-int-">updateScale</a></span>(int&nbsp;width,
int&nbsp;height)</code>
<div class="block">Atualiza a escala da resolução do jogo</div>
</td>
</tr>
</table>
<ul class="blockList">
<li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
Expand Down Expand Up @@ -280,7 +296,7 @@ <h4>batch</h4>
<ul class="blockList">
<li class="blockList">
<h4>camera</h4>
<pre>private&nbsp;OrthographicCamera camera</pre>
<pre>public&nbsp;OrthographicCamera camera</pre>
</li>
</ul>
<a name="charPlayer">
Expand All @@ -292,6 +308,19 @@ <h4>charPlayer</h4>
<pre>public&nbsp;<a href="../../../com/usp/corrida/logic/Character.html" title="class in com.usp.corrida.logic">Character</a> charPlayer</pre>
</li>
</ul>
<a name="FIXED_WIDTH">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>FIXED_WIDTH</h4>
<pre>private static final&nbsp;float FIXED_WIDTH</pre>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="../../../constant-values.html#com.usp.corrida.Core.FIXED_WIDTH">Constant Field Values</a></dd>
</dl>
</li>
</ul>
<a name="gameScreen">
<!-- -->
</a>
Expand Down Expand Up @@ -419,16 +448,42 @@ <h4>render</h4>
<div class="block">Renderiza todo o programa</div>
</li>
</ul>
<a name="resize-int-int-">
<!-- -->
</a>
<ul class="blockList">
<li class="blockList">
<h4>resize</h4>
<pre>public&nbsp;void&nbsp;resize(int&nbsp;width,
int&nbsp;height)</pre>
</li>
</ul>
<a name="setupPlayer--">
<!-- -->
</a>
<ul class="blockListLast">
<ul class="blockList">
<li class="blockList">
<h4>setupPlayer</h4>
<pre>private&nbsp;void&nbsp;setupPlayer()</pre>
<div class="block">Faz a primeira configuração do jogador</div>
</li>
</ul>
<a name="updateScale-int-int-">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>updateScale</h4>
<pre>private&nbsp;void&nbsp;updateScale(int&nbsp;width,
int&nbsp;height)</pre>
<div class="block">Atualiza a escala da resolução do jogo</div>
<dl>
<dt><span class="paramLabel">Parameters:</span></dt>
<dd><code>width</code> - Largura da tela</dd>
<dd><code>height</code> - Altura da tela</dd>
</dl>
</li>
</ul>
</li>
</ul>
</li>
Expand Down

0 comments on commit 7a37c80

Please sign in to comment.