diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-10-02 11:44:15 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-10-02 11:44:15 -0400 |
| commit | 5c89b3615c067c51e0076f5433ccbdbee5022f70 (patch) | |
| tree | 8dbcc06c32aefe2cbdba572138fa181e03149be7 | |
| parent | 49751d69498c265cb46f6cce5033367ae39c5e91 (diff) | |
| download | balls-5c89b3615c067c51e0076f5433ccbdbee5022f70.zip | |
refactor
| -rw-r--r-- | Makefile | 7 | ||||
| -rw-r--r-- | balls.cpp | 16 | ||||
| -rw-r--r-- | geometry.cpp | 17 |
3 files changed, 22 insertions, 18 deletions
@@ -2,9 +2,12 @@ CC = g++ CFLAGS = -Wall -pedantic LDFLAGS = -ltbb -lglut -lGLU -lGL -balls: balls.o collision.o +balls: balls.o collision.o geometry.o ${CC} -o $@ $^ ${LDFLAGS} @echo done %.o: %.cpp balls.h - ${CC} -c ${CFLAGS} $<
\ No newline at end of file + ${CC} -c ${CFLAGS} $< + +clean: + rm -f ./*.o balls
\ No newline at end of file @@ -116,19 +116,3 @@ animate(int v) { display(); glutTimerFunc(FRAME_TIME_MS, animate, 0); } - -Point -ptAddVec(Point p, Vector v) { - p.x += v.x; - p.y += v.y; - return p; -} - -Rectangle -insetRect(Rectangle r, double n) { - r.min.x += n; - r.min.y += n; - r.max.x -= n; - r.max.y -= n; - return r; -} diff --git a/geometry.cpp b/geometry.cpp new file mode 100644 index 0000000..ae2c8ae --- /dev/null +++ b/geometry.cpp @@ -0,0 +1,17 @@ +#include "balls.h" + +Point +ptAddVec(Point p, Vector v) { + p.x += v.x; + p.y += v.y; + return p; +} + +Rectangle +insetRect(Rectangle r, double n) { + r.min.x += n; + r.min.y += n; + r.max.x -= n; + r.max.y -= n; + return r; +} |