Recent

Author Topic: magician's maze (inc)  (Read 1837 times)

speter

  • Hero Member
  • *****
  • Posts: 522
magician's maze (inc)
« on: September 15, 2025, 06:04:33 am »
G'Day Folks,

Here is another game from Tim Hartnell's book "The Big Fat Book of Computer Games".
As before, I am posting:
  • the original BASIC source;
  • a simple translation to pascal; and
  • an "improved" game. :)


The original game is basically a text "adventure" - the user needs to collect 6 "magic objects" from a "maze" of 8 rooms. Unfortunately, the maze is limited and fixed...

My "improved" game (still) isn't very interesting. :) The user needs to collect 3 specific "magic objects" from a magician's mansion (23 rooms). The "large" number of rooms increases interest; also the mansion is randomly created each time the game begins. The mansion's plan is drawn as the user explores the building (use CTRL-mouse-down to pan the view; or CTRL-mouse-wheel to zoom the view). Because of the CTRL-mouse action, the code will (presumably) need tweaking for other OS's.

Finally, the game includes lots of text - all in (Australian) English. :'( :) So, I apologise in advance to all the non-english speakers.

Enjoy.
S.

EDIT: I can't post both projects, so I'll need a 2nd post...
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Hero Member
  • *****
  • Posts: 522
Re: magician's maze (inc)
« Reply #1 on: September 15, 2025, 06:05:36 am »
Here is the "improved" game.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

speter

  • Hero Member
  • *****
  • Posts: 522
Re: magician's maze (inc)
« Reply #2 on: September 26, 2025, 03:02:09 am »
One random question...

In my "improved" game, I implemented zooming using CTRL-mouse-wheel (which seems to work fine in windows, if you have a mouse & wheel).

How would you implement zooming without a mouse wheel, eg if using a laptop track pad or using a mouse without a "wheel"?

A related question, a single button mouses still common with Macs?

To 'port' my project to mac-os, I assume it would be necessary to replace the CTRL detection with detection of some other key...?

Apologies for these very simple questions, I haven't used a Mac since 1984.  :-[

cheers
S.
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

Handoko

  • Hero Member
  • *****
  • Posts: 5530
  • My goal: build my own game engine using Lazarus
Re: magician's maze (inc)
« Reply #3 on: September 26, 2025, 03:53:51 am »
My quick solution is to use Shift + y_move to zoom:

Code: Pascal  [Select][+][-]
  1. procedure TForm_main.Panel_drawing_areaMouseMove(Sender: TObject;
  2.   Shift: TShiftState; X, Y: Integer);
  3. //-------------------------------------------------------------------------
  4. const
  5.   previousY: Integer = 0;
  6. var
  7.   diff : tpoint;
  8. begin
  9.   if ctrl_down and   // pan
  10.      ((pan_start.x <> x) or (pan_start.y <> y)) and
  11.      ((pan_start.x <> 0) or (pan_start.y <> 0)) then
  12.     begin
  13.       diff := point(x - pan_start.x, y - pan_start.y);
  14.       mid := point(mid.x + diff.x, mid.y + diff.y);
  15.       refresh;
  16.       pan_start := point(x,y);
  17.     end;
  18.   if ssShift in Shift then   // zoom
  19.     begin
  20.       case Y < previousY of
  21.         True:  scale := scale / 1.03;
  22.         False: scale := scale * 1.03;
  23.       end;
  24.       refresh;
  25.       previousY := Y;
  26.     end;
  27. end;

- Line #5 is for storing previous mouse Y position.
- Lines #18 .. #26 are for detecting and processing the zoom.

Note, you need set the limits for the zoom.

speter

  • Hero Member
  • *****
  • Posts: 522
Re: magician's maze (inc)
« Reply #4 on: September 27, 2025, 01:15:56 am »
Thanks for the reply Handoko. :)
I climbed mighty mountains, and saw that they were actually tiny foothills. :)

 

TinyPortal © 2005-2018