summaryrefslogtreecommitdiffstats
path: root/balls.c
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-10-28 11:42:38 -0400
committerSam Anthony <sam@samanthony.xyz>2024-10-28 11:42:38 -0400
commit35a094792d28eaf31bcf0502746e211685d7573e (patch)
tree5911d9803109b75e098ae0860ced47fc02d0dd60 /balls.c
parente27211417ab0538096e773bd9afa585651500839 (diff)
downloadballs-35a094792d28eaf31bcf0502746e211685d7573e.zip
press q to quit
Diffstat (limited to 'balls.c')
-rw-r--r--balls.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/balls.c b/balls.c
index 7594eb7..48fc430 100644
--- a/balls.c
+++ b/balls.c
@@ -24,6 +24,7 @@
#define VMAX_INIT 0.1 /* Maximum initial velocity. */
enum { WIDTH = 640, HEIGHT = 480 };
+enum { KEY_QUIT = 'q' };
enum {
NBALLS = 8,
CIRCLE_POINTS = 16+2, /* +2 for center point and last point which overlaps with first point. */
@@ -40,6 +41,7 @@ void configureSharedData(void);
void setKernelArgs(void);
void display(void);
void reshape(int w, int h);
+void keyboard(unsigned char key, int x, int y);
void move(void);
void collideWalls(void);
void genVertices(void);
@@ -71,6 +73,7 @@ main(int argc, char *argv[]) {
glutDisplayFunc(display);
glutReshapeFunc(reshape);
+ glutKeyboardFunc(keyboard);
glutMainLoop();
@@ -306,6 +309,12 @@ reshape(int w, int h) {
}
void
+keyboard(unsigned char key, int x, int y) {
+ if (key == KEY_QUIT)
+ glutDestroyWindow(glutGetWindow());
+}
+
+void
move(void) {
size_t size;
int err;