Skip to content

Commit 0cdbb76

Browse files
committed
Removing camera shake
1 parent e03f1ed commit 0cdbb76

File tree

4 files changed

+1972
-2049
lines changed

4 files changed

+1972
-2049
lines changed

camera.h

-25
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,6 @@ struct Camera
33
float x = 0;
44
float y = 0;
55

6-
float xShake = 0;
7-
float yShake = 0;
8-
9-
// initiate screen shake
10-
void shake(uint8_t power = 15)
11-
{
12-
float angle = random(100) / 100; // a value between -1 and 1
13-
14-
xShake = power * cos(angle);
15-
yShake = power * sin(angle);
16-
}
17-
18-
// apply screen shake
19-
void update()
20-
{
21-
if ((abs(xShake) > 0.5) || (abs(yShake) > 0.5))
22-
{
23-
xShake *= -0.7 - random(20) / 100;
24-
yShake *= -0.7 - random(20) / 100;
25-
26-
x += xShake;
27-
y += yShake;
28-
}
29-
}
30-
316
bool canSee(float xTarget, float yTarget, uint8_t width, uint8_t height)
327
{
338
if (xTarget + width > x && xTarget < x + 128)

crates.ino

-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ void loop()
8484
{
8585
// erase cops if they have no health
8686
if (cops[i].health == 0) {
87-
camera.shake();
8887
dust.add(Dust(cops[i].x + cops[i].width / 2 - 4, cops[i].y + cops[i].height / 2 - 4, cops[i].angle, cops[i].speed / 2));
8988
cops.erase(i);
9089
i--;
@@ -108,7 +107,6 @@ void loop()
108107
drawLocator(crate.x, crate.y, crate.width, crate.height, 2);
109108

110109
camera.follow(player.x+player.width/2, player.y+player.height/2, 54, 27); // make the camera follow the player
111-
camera.update(); // apply camera shake
112110

113111
arduboy.display(CLEAR_BUFFER); // draw everything to the screen
114112
}

0 commit comments

Comments
 (0)