diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-10-28 11:42:38 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-10-28 11:42:38 -0400 |
| commit | 35a094792d28eaf31bcf0502746e211685d7573e (patch) | |
| tree | 5911d9803109b75e098ae0860ced47fc02d0dd60 /balls.c | |
| parent | e27211417ab0538096e773bd9afa585651500839 (diff) | |
| download | balls-35a094792d28eaf31bcf0502746e211685d7573e.zip | |
press q to quit
Diffstat (limited to 'balls.c')
| -rw-r--r-- | balls.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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; |