minor control tweaks and fixes
authorJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 16 Mar 2021 19:18:35 +0000 (21:18 +0200)
committerJohn Tsiombikas <nuclear@member.fsf.org>
Tue, 16 Mar 2021 19:18:35 +0000 (21:18 +0200)
src/main.c

index b5648d0..8a0df39 100644 (file)
@@ -249,6 +249,8 @@ int main(void)
 }
 
 #define PAN_SPEED      0x4000
+#define MAX_XPAN       0x50000
+#define MAX_YPAN       0x1c000
 
 static void handle_keys(void)
 {
@@ -257,7 +259,7 @@ static void handle_keys(void)
        if(KEYPRESS(KEY_UP)) {
                if(pan_mode) {
                        cam_pan_y += PAN_SPEED;
-                       if(cam_pan_y > 0x1c000) cam_pan_y = 0x1c000;
+                       if(cam_pan_y > MAX_YPAN) cam_pan_y = MAX_YPAN;
                } else {
                        cam_phi += 0x2000;
                        if(cam_phi > X_HPI) cam_phi = X_HPI;
@@ -267,7 +269,7 @@ static void handle_keys(void)
        if(KEYPRESS(KEY_DOWN)) {
                if(pan_mode) {
                        cam_pan_y -= PAN_SPEED;
-                       if(cam_pan_y < -0x1c000) cam_pan_y = -0x1c000;
+                       if(cam_pan_y < -MAX_YPAN) cam_pan_y = -MAX_YPAN;
                } else {
                        cam_phi -= 0x2000;
                        if(cam_phi < -X_HPI) cam_phi = -X_HPI;
@@ -277,7 +279,7 @@ static void handle_keys(void)
        if(KEYPRESS(KEY_LEFT)) {
                if(pan_mode) {
                        cam_pan_x -= PAN_SPEED;
-                       if(cam_pan_x < -0x50000) cam_pan_x = -0x50000;
+                       if(cam_pan_x < -MAX_XPAN) cam_pan_x = -MAX_XPAN;
                } else {
                        cam_theta += 0x2000;
                        if(cam_theta > X_2PI) cam_theta -= X_2PI;
@@ -287,7 +289,7 @@ static void handle_keys(void)
        if(KEYPRESS(KEY_RIGHT)) {
                if(pan_mode) {
                        cam_pan_x += PAN_SPEED;
-                       if(cam_pan_x > 0x50000) cam_pan_x = 0x50000;
+                       if(cam_pan_x > MAX_XPAN) cam_pan_x = MAX_XPAN;
                } else {
                        cam_theta -= 0x2000;
                        if(cam_theta < 0) cam_theta += X_2PI;
@@ -308,14 +310,20 @@ static void handle_keys(void)
 
        if(KEYPRESS(KEY_RT)) {
                cam_pan_x += PAN_SPEED;
+               if(cam_pan_x > 0x50000) cam_pan_x = 0x50000;
        }
        if(KEYPRESS(KEY_LT)) {
                cam_pan_x -= PAN_SPEED;
+               if(cam_pan_x < -0x50000) cam_pan_x = -0x50000;
        }
 
        if(KEYPRESS(KEY_A)) {
                if(!show_del) {
-                       if(show_obj) show_del = 1;
+                       if(show_obj) {
+                               show_del = 1;
+                       } else {
+                               show_obj = 1;
+                       }
                } else {
                        show_del = 0;
                }