summaryrefslogtreecommitdiff
path: root/src/pt.h
diff options
context:
space:
mode:
authorSimponic <loganthebean222@gmail.com>2020-08-04 23:36:21 -0600
committerSimponic <loganthebean222@gmail.com>2020-08-04 23:36:21 -0600
commitebd81999b71ada201a316060fa47a7a66a277935 (patch)
tree930be8337e1144ba227bedb3e72e4473309c28e8 /src/pt.h
parentb323ae0ca067deb0a48e3d9088160383d698a28f (diff)
downloadsimple3dengine-ebd81999b71ada201a316060fa47a7a66a277935.tar.gz
simple3dengine-ebd81999b71ada201a316060fa47a7a66a277935.zip
Added files
Diffstat (limited to 'src/pt.h')
-rw-r--r--src/pt.h36
1 files changed, 36 insertions, 0 deletions
diff --git a/src/pt.h b/src/pt.h
new file mode 100644
index 0000000..b9f8841
--- /dev/null
+++ b/src/pt.h
@@ -0,0 +1,36 @@
+#include "defs.h"
+#include "fixed.h"
+
+#ifndef PT_H
+#define PT_H
+
+typedef struct POINT {
+ FIXED x;
+ FIXED y;
+} POINT;
+
+static inline void convertPointToScreen(POINT *point) {
+ // Convert point where (SCREEN_WIDTH / 2 * x,
+ // SCREEN_HEIGHT / 2 - y - 1)
+ // is the origin (0,0)
+ point->x += (WINDOW_WIDTH / 2) << FIX_SHIFT;
+ point->y = (WINDOW_HEIGHT / 2 - (point->y >> FIX_SHIFT) - 1) << FIX_SHIFT;
+}
+
+static inline POINT createPoint(FIXED x, FIXED y) {
+ // Create a point from data
+ POINT temp;
+ temp.x = x;
+ temp.y = y;
+ return temp;
+}
+
+
+static inline void swapPoint(POINT *p1, POINT *p2) {
+ POINT temp;
+ temp = *p1;
+ *p1 = *p2;
+ *p2 = temp;
+}
+
+#endif // PT_H