Skip to content

Commit

Permalink
Score screen improvement, waypoint fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakakordez committed Apr 14, 2015
1 parent ddb8017 commit 9f1ef37
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 19 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
Air racing is a 3D Android game inspired by Red Bull Air Race. It is written in Java using OpenGL.
The project is created in Android studio IDE.

For some more information you can check out the [game design document!](docs/AirRacer.pdf) (in Slovene).
For some additional informations you can check out the [game design document](docs/AirRacer.pdf) (in Slovene).

Game size: 12.8 MB

#Requirements

Expand Down
3 changes: 1 addition & 2 deletions app/src/main/java/tk/jakakordez/airracer/Waypoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ public void Draw(MeshCollection collection, GL10 gl){
}

public int Check(Vector2 player, MediaPlayer waypointSound){
if(player.Distance(location) < 10 && stage != 2){
if(player.Distance(location) < 15 && stage != 2){
stage = 2;
waypointSound.start();
return 4;
}
if(player.Distance(location) < radius && stage == 0){
stage = 1;

return 1;
}

Expand Down
8 changes: 3 additions & 5 deletions app/src/main/java/tk/jakakordez/airracer/World.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ public World(AssetManager content, GL10 gl, MediaPlayer[] sounds, String path, F
appCont = finished;
GameMenu g;
meshCollector = new MeshCollection(content);
player = new Airplane("extra", meshCollector, gl);
scenery = meshCollector.Import("abudhabi/abudhabi", gl);

player = new Airplane("extra", meshCollector, gl);
InitWaypoints(gl, path, content);

InitTrees(content, gl);
viewMatrix = new float[16];
this.sounds = sounds;
Expand All @@ -71,7 +69,7 @@ private void InitWaypoints(GL10 gl, String path, AssetManager content){

while ((line = reader.readLine()) != null) {
String[] l = line.split(";");
wps.add(new Waypoint(wpMesh, new Vector2(Float.parseFloat(l[0]), Float.parseFloat(l[1])), 20));
wps.add(new Waypoint(wpMesh, new Vector2(Float.parseFloat(l[0]), Float.parseFloat(l[1])), 25));
}
waypoints = new Waypoint[wps.size()];
waypoints = wps.toArray(waypoints);
Expand Down Expand Up @@ -120,7 +118,7 @@ public void Draw(GL10 gl, float[] acc){
for (int i = 0; i < waypoints.length; i++){
int t = waypoints[i].Check(new Vector2(pos.X, pos.Z), sounds[1]);
score+=t;
if(t == 4 && i == 0){//waypoints.length-1){
if(t == 4 && i == waypoints.length-1){
sounds[0].stop();
appCont.finish(System.currentTimeMillis()-startTime, score);
}
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/java/tk/jakakordez/airracer/util/Scores.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ protected void onCreate(Bundle savedInstanceState) {
SharedPreferences scores = getSharedPreferences("Scores", 0);
long time = scores.getLong("time", 0);
int score = scores.getInt("score", 0);
TextView txt = (TextView)findViewById(R.id.textView3);
txt.setText("Best time: "+convertTime(time)+"\nBest score: "+score);
TextView txtTime = (TextView)findViewById(R.id.txtTime);
TextView txtScore = (TextView)findViewById(R.id.txtScore);
txtTime.setText(convertTime(time));
txtScore.setText(Integer.toString(score));

Button btnBack = (Button)findViewById(R.id.btnBack);
btnBack.setOnClickListener(new View.OnClickListener() {
Expand Down
73 changes: 64 additions & 9 deletions app/src/main/res/layout/activity_scores.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,73 @@
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="10"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt1"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:background="#A0FFFFFF"
android:textSize="18dp"
android:textStyle="italic"
android:padding="5dp"
android:text="Best time:"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txtTime"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:background="#A0FFFFFF"
android:textSize="18dp"
android:textStyle="bold"
android:padding="5dp"/>
</LinearLayout>

<TextView
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/textView3"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:background="#A0FFFFFF"
android:padding="5dp"/>
android:orientation="horizontal"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txt2"
android:textSize="18dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:background="#A0FFFFFF"
android:textStyle="italic"
android:padding="5dp"
android:text="High score:"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceSmall"
android:id="@+id/txtScore"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="15dp"
android:textColor="#000000"
android:background="#A0FFFFFF"
android:textSize="18dp"
android:textStyle="bold"
android:padding="5dp"/>
</LinearLayout>
<Button
android:layout_width="150dp"
android:layout_height="wrap_content"
Expand Down

0 comments on commit 9f1ef37

Please sign in to comment.