-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBall.java
More file actions
50 lines (43 loc) · 1.19 KB
/
Ball.java
File metadata and controls
50 lines (43 loc) · 1.19 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
package com.example.mygame;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.opengl.GLSurfaceView;
import android.view.MotionEvent;
import android.view.View;
public class Ball {
public float x, y;
private Bitmap color, white;
private boolean red;
public Ball(float x, float y, Bitmap color1, Bitmap whit) {
this.x = x;
this.y = y;
this.color = color1;
this.white = whit;
this.red = true;
}
public boolean contains(float l, float m){
if(x - 100 + 125 <= l && l <= x + 100 + 125){
if(y - 100 + 120 <= m && m <= y + 100 + 120)
return true;
}
return false;
}
public boolean getRed(){
return red;
}
public void draw(Canvas c, int t){
if(t < 100){
c.drawBitmap(color, x, y, null);
}
else {
c.drawBitmap(white, x + 35, y + 15, null);
}
}
public void setRed(boolean red) {
this.red = red;
}
}