-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshake.c
More file actions
57 lines (49 loc) · 1.03 KB
/
shake.c
File metadata and controls
57 lines (49 loc) · 1.03 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
/*
* shake.c
*
* This is a very low down basic file that adds the shake effect to all the lines in the game.
* It also has the ability to show random colors.
* Author: Raphael BN
*/
#ifdef __APPLE__
#include <GLUT/glut.h> // Required on mac. Was working with GL/glut.h in 10.10.5, but not in 10.11.2
#else
#include <GL/glut.h> // Required elsewhere.
#endif
#include "util.h"
double MaxShake = 5;
double shakeX;
double shakeY;
int rc = 0;
void useRandomColor(int use)
{
rc = use;
}
int getRandomColor()
{
return rc;
}
void setShake()
{
if( MaxShake !=0 )
{
shakeX = myRandom(-MaxShake , MaxShake);
shakeY = myRandom(-MaxShake , MaxShake);
}
else
{
shakeX = shakeY = 0;
}
if(rc)
glColor3f(myRandom(0.1,1),myRandom(0.1,1),myRandom(0.1,1));
}
void setMaxShake(double newValue)
{
MaxShake = newValue;
}
void drawLineWithShake(double x1, double y1, double x2, double y2)
{
setShake();
glVertex2f( x1 + shakeX, y1 + shakeY);
glVertex2f( x2 + shakeX, y2 + shakeY);
}