Skip to content

Commit 39425de

Browse files
committed
Murk 1998 DirectX 1.0
1 parent 386b298 commit 39425de

2 files changed

Lines changed: 30 additions & 31 deletions

File tree

bin/Murk.exe

0 Bytes
Binary file not shown.

src/MurkControls.cpp

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -629,34 +629,6 @@ void handle_mouse(int x, int y) {
629629
}
630630
}
631631

632-
// Adjust mouse coordinates for isometric projection
633-
// mx,my = mouse position
634-
// px,py = reference point (e.g., tile origin)
635-
// type = axis selector (0 = slope +0.5, 1 = slope -0.5)
636-
637-
void mouse_adjust_shear(int mx, int my, int px, int py, int type) {
638-
// Relative mouse offset
639-
int dx = mx - px;
640-
int dy = my - py;
641-
642-
// Use integer-safe math (avoid truncation surprises)
643-
int val;
644-
645-
if (type == 1) {
646-
// Project onto axis with slope -0.5
647-
// v = dy - dx/2
648-
val = dy - (dx >> 1); // use bitshift for exact /2
649-
calcmousex = px - val;
650-
calcmousey = py + (val >> 1);
651-
} else {
652-
// Project onto axis with slope +0.5
653-
// u = dy + dx/2
654-
val = dy + (dx >> 1);
655-
calcmousex = px + val;
656-
calcmousey = py + (val >> 1);
657-
}
658-
}
659-
660632
///////////////////////////////////////////////////////////
661633
//
662634
///////////////////////////////////////////////////////////
@@ -670,11 +642,10 @@ void mouse_adjust(int mx, int my, int px, int py, int type) {
670642
// find the intsersction of two lines to adjust the mouse
671643
// to work on the 3d grid ... holy moly
672644

645+
// intersection of y = -1/2x + b and y = x/2, x=b
646+
673647
newmx = mx - px;
674648
newmy = my - py;
675-
b = (int)(newmy + (.5 * newmx));
676-
calcmousex = (b) + px;
677-
calcmousey = (b / 2) + py;
678649

679650
if (type == 1) {
680651
// new one
@@ -694,6 +665,34 @@ void mouse_adjust(int mx, int my, int px, int py, int type) {
694665
//
695666
///////////////////////////////////////////////////////////
696667

668+
// Adjust mouse coordinates for isometric projection
669+
// mx,my = mouse position
670+
// px,py = reference point (e.g., tile origin)
671+
// type = axis selector (0 = slope +0.5, 1 = slope -0.5)
672+
673+
void mouse_adjust_shear(int mx, int my, int px, int py, int type) {
674+
// Relative mouse offset
675+
int dx = mx - px;
676+
int dy = my - py;
677+
678+
// Use integer-safe math (avoid truncation surprises)
679+
int val;
680+
681+
if (type == 1) {
682+
// Project onto axis with slope -0.5
683+
// v = dy - dx/2
684+
val = dy - (dx >> 1); // use bitshift for exact /2
685+
calcmousex = px - val;
686+
calcmousey = py + (val >> 1);
687+
} else {
688+
// Project onto axis with slope +0.5
689+
// u = dy + dx/2
690+
val = dy + (dx >> 1);
691+
calcmousex = px + val;
692+
calcmousey = py + (val >> 1);
693+
}
694+
}
695+
697696
void OnRButtonDown(LPARAM lParam) {
698697

699698
UINT x1 = LOWORD(lParam);

0 commit comments

Comments
 (0)