forked from StRobertCHSCS/ICS4U-PCP
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPaddle
More file actions
52 lines (38 loc) · 1.02 KB
/
Paddle
File metadata and controls
52 lines (38 loc) · 1.02 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
package com.example.luimi.breakout;
import android.graphics.RectF;
public class Paddle {
private RectF rect;
private float length;
private float height;
private float x;
private float y;
private float paddleSpeed;
public final int STOPPED = 0;
public final int LEFT = 1;
public final int RIGHT = 2;
private int paddleMoving = STOPPED;
public Paddle(int screenX, int screenY){
length = 130;
height = 20;
x = screenX / 2;
y = screenY - 20;
rect = new RectF(x, y, x + length, y + height);
paddleSpeed = 350;
}
public RectF getRect(){
return rect;
}
public void setMovementState(int state){
paddleMoving = state;
}
public void update(long fps){
if(paddleMoving == LEFT){
x = x - paddleSpeed / fps;
}
if(paddleMoving == RIGHT){
x = x + paddleSpeed / fps;
}
rect.left = x;
rect.right = x + length;
}
}