Skip to content

Commit 101710f

Browse files
committed
the game now exits and returns to the main page, I'll be working on making it a bit prettier
1 parent 32da214 commit 101710f

File tree

8 files changed

+719
-302
lines changed

8 files changed

+719
-302
lines changed

.idea/libraries/support_v4_21_0_3.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 653 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AndroidGameDev.iml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
</configuration>
88
</facet>
99
</component>
10-
<component name="NewModuleRootManager" inherit-compiler-output="true">
10+
<component name="NewModuleRootManager" inherit-compiler-output="false">
11+
<output url="file://$MODULE_DIR$/build/classes/main" />
12+
<output-test url="file://$MODULE_DIR$/build/classes/test" />
1113
<exclude-output />
1214
<content url="file://$MODULE_DIR$">
1315
<excludeFolder url="file://$MODULE_DIR$/.gradle" />

app/app.iml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<facet type="android" name="Android">
1010
<configuration>
1111
<option name="SELECTED_BUILD_VARIANT" value="debug" />
12-
<option name="SELECTED_TEST_ARTIFACT" value="_android_test_" />
1312
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
1413
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
1514
<option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<category android:name="android.intent.category.LAUNCHER" />
1717
</intent-filter>
1818
</activity>
19+
<activity android:name = ".GameActivity"></activity>
1920
</application>
2021

2122
</manifest>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.omkarmoghe.androidgamedev;
2+
3+
import android.os.Bundle;
4+
import android.support.v7.app.ActionBarActivity;
5+
import android.view.Menu;
6+
import android.view.MenuItem;
7+
import android.view.View;
8+
import android.widget.Button;
9+
10+
11+
public class GameActivity extends ActionBarActivity {
12+
13+
@Override
14+
protected void onCreate(Bundle savedInstanceState) {
15+
super.onCreate(savedInstanceState);
16+
getSupportActionBar().hide();// Hides the action bar
17+
setContentView(new GameView(GameActivity.this));
18+
}
19+
20+
@Override
21+
public boolean onCreateOptionsMenu(Menu menu) {
22+
// Inflate the menu; this adds items to the action bar if it is present.
23+
getMenuInflater().inflate(R.menu.menu_main, menu);
24+
return true;
25+
}
26+
27+
@Override
28+
public boolean onOptionsItemSelected(MenuItem item) {
29+
// Handle action bar item clicks here. The action bar will
30+
// automatically handle clicks on the Home/Up button, so long
31+
// as you specify a parent activity in AndroidManifest.xml.
32+
int id = item.getItemId();
33+
34+
//noinspection SimplifiableIfStatement
35+
if (id == R.id.action_settings) {
36+
return true;
37+
}
38+
39+
return super.onOptionsItemSelected(item);
40+
}
41+
}

app/src/main/java/com/omkarmoghe/androidgamedev/GameView.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.omkarmoghe.androidgamedev;
22

33
import android.annotation.SuppressLint;
4+
import android.app.Activity;
45
import android.content.Context;
56
import android.content.Intent;
67
import android.graphics.Canvas;
@@ -9,6 +10,8 @@
910
import android.view.MotionEvent;
1011
import android.view.SurfaceHolder;
1112
import android.view.SurfaceView;
13+
import android.view.View;
14+
import android.widget.Button;
1215
import android.widget.TextView;
1316
import android.widget.Toast;
1417

@@ -65,19 +68,20 @@ public void surfaceCreated (SurfaceHolder holder) {
6568

6669
@Override
6770
public void surfaceChanged (SurfaceHolder holder, int format, int width, int height) {
68-
}
71+
if(rectFP.get_right()-rectFP.get_left()<10) {
72+
73+
}
74+
}
6975
});
7076

7177
makePaints(); // Adds our paints to the arraylist.
7278
rectFP.setPaint(paints.get(random.nextInt(4)));
7379
}
7480

81+
7582
@Override
7683
public void onDraw(Canvas canvas) {
7784
canvas.drawColor(Color.BLACK); // Black background
78-
TextView tv = new TextView(getContext());
79-
tv.setText("Circles Clicked: " + Integer.toString(count));
80-
tv.setVisibility(VISIBLE);
8185
//canAdd = false;
8286
//for (RectFP r : circles) {
8387
rectFP.set_right((float) (rectFP.get_right() - (count+1)));
@@ -87,10 +91,12 @@ public void onDraw(Canvas canvas) {
8791
canvas.drawOval(rectFP, rectFP.getPaint());
8892
//}
8993
if(rectFP.get_right()-rectFP.get_left()<10){
90-
System.out.println("YOU LOSE");
9194
rectFP.set_left(0);
9295
rectFP.set_right(0);
9396
gameLoopThread.setRunning(false);
97+
//setVisibility(this.INVISIBLE);
98+
((Activity)this.getContext()).finish();
99+
94100
//Intent intent = new Intent(this, MainActivity.class);
95101
//rectFP.set_top(rectFP.get_bottom());
96102
}

app/src/main/java/com/omkarmoghe/androidgamedev/MainActivity.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.omkarmoghe.androidgamedev;
22

3+
import android.content.Intent;
34
import android.os.Bundle;
45
import android.support.v7.app.ActionBarActivity;
56
import android.view.Menu;
@@ -15,20 +16,21 @@ protected void onCreate(Bundle savedInstanceState) {
1516
super.onCreate(savedInstanceState);
1617
getSupportActionBar().hide();// Hides the action bar
1718
setContentView(R.layout.activity_main);
19+
}
1820

21+
@Override
22+
public boolean onCreateOptionsMenu(Menu menu) {
23+
// Inflate the menu; this adds items to the action bar if it is present.
24+
getMenuInflater().inflate(R.menu.menu_main, menu);
1925
Button b = (Button) findViewById(R.id.button_id);
2026

2127
b.setOnClickListener(new View.OnClickListener() {
2228
public void onClick (View v) {
23-
setContentView(new GameView(MainActivity.this));
29+
Intent gameScreen = new Intent(getApplicationContext(), GameActivity.class);
30+
startActivity(gameScreen);
31+
2432
}
2533
});
26-
}
27-
28-
@Override
29-
public boolean onCreateOptionsMenu(Menu menu) {
30-
// Inflate the menu; this adds items to the action bar if it is present.
31-
getMenuInflater().inflate(R.menu.menu_main, menu);
3234
return true;
3335
}
3436

0 commit comments

Comments
 (0)