ref: 05ca30481c0857c673a4341a1550b8216028fd83
parent: af89f884a13a8ee2cc7d9d09cc88a3fbb145f177
author: rodri <[email protected]>
date: Thu Apr 11 08:21:30 EDT 2024
add a way to control zoom with the keyboard.
--- a/dat.h
+++ b/dat.h
@@ -11,6 +11,8 @@
KR→,
KR↺,
KR↻,
+ Kzoomin,
+ Kzoomout,
Kcam0,
Kcam1,
Kcam2,
--- a/main.c
+++ b/main.c
@@ -32,6 +32,8 @@
[KR→] = 'd',
[KR↺] = 'q',
[KR↻] = 'e',
+ [Kzoomin] = 'z',
+ [Kzoomout] = 'x',
[Kcam0] = KF|1,
[Kcam1] = KF|2,
[Kcam2] = KF|3,
@@ -435,6 +437,20 @@
}
void
+zoomin(void)
+{
+ maincam->fov = fclamp(maincam->fov - 1*DEG, 1*DEG, 359*DEG);
+ reloadcamera(maincam);
+}
+
+void
+zoomout(void)
+{
+ maincam->fov = fclamp(maincam->fov + 1*DEG, 1*DEG, 359*DEG);
+ reloadcamera(maincam);
+}
+
+void
drawstats(void)
{
int i;
@@ -576,14 +592,10 @@
mmb();
if((mctl->buttons & 4) != 0)
rmb();
- if((mctl->buttons & 8) != 0){
- maincam->fov = fclamp(maincam->fov - 1*DEG, 1*DEG, 359*DEG);
- reloadcamera(maincam);
- }
- if((mctl->buttons & 16) != 0){
- maincam->fov = fclamp(maincam->fov + 1*DEG, 1*DEG, 359*DEG);
- reloadcamera(maincam);
- }
+ if((mctl->buttons & 8) != 0)
+ zoomin();
+ if((mctl->buttons & 16) != 0)
+ zoomout();
}
void
@@ -673,6 +685,10 @@
placecamera(maincam, maincam->p, maincam->bz, qrotate(maincam->by, maincam->bz, 1*DEG));
if(kdown & 1<<KR↻)
placecamera(maincam, maincam->p, maincam->bz, qrotate(maincam->by, maincam->bz, -1*DEG));
+ if(kdown & 1<<Kzoomin)
+ zoomin();
+ if(kdown & 1<<Kzoomout)
+ zoomout();
if(kdown & 1<<Kcam0)
maincam = &cams[0];
if(kdown & 1<<Kcam1)