-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathSubHunter.java
More file actions
95 lines (78 loc) · 2.17 KB
/
SubHunter.java
File metadata and controls
95 lines (78 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// This is our package
// If you are copy & pasting the code then this line will probably be different to yours
// If so, keep YOUR line- not this one
package com.gamecodeschool.c2subhunter;
// These are all the classes of other people's
// (Android) code that we use in Sub Hunt
import android.app.Activity;
import android.os.Bundle;
import android.view.MotionEvent;
import android.util.Log;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Point;
import android.view.Display;
import android.widget.ImageView;
import java.util.Random;
public class SubHunter extends Activity {
/*
Android runs this code just before
the app is seen by the player.
This makes it a good place to add
the code that is needed for
the one-time setup.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d("Debugging", "In onCreate");
newGame();
draw();
}
/*
This code will execute when a new
game needs to be started. It will
happen when the app is first started
and after the player wins a game.
*/
void newGame(){
Log.d("Debugging", "In newGame");
}
/*
Here we will do all the drawing.
The grid lines, the HUD and
the touch indicator
*/
void draw() {
Log.d("Debugging", "In draw");
}
/*
This part of the code will
handle detecting that the player
has tapped the screen
*/
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
Log.d("Debugging", "In onTouchEvent");
takeShot();
return true;
}
/*
The code here will execute when
the player taps the screen It will
calculate distance from the sub'
and determine a hit or miss
*/
void takeShot(){
Log.d("Debugging", "In takeShot");
draw();
}
// This code says "BOOM!"
void boom(){
}
// This code prints the debugging text
void printDebuggingText(){
}
}