screwlisp proposes kittens

Hurkling Onwards - Fancying up our Common lisp McCLIM Hurkle game GUI app

Aside from burning out during yesterday’s article, I am very satisfied with our

  1. Intro on Making Common lisp ASDF systems
  2. New Common lisp Hurkle system, Hurkle class package & the console game
  3. Hurkle frame package (GUI) & commands package (GUI buttons)

now, while my friend Vassil promises me

there is never any such thing as the final coat of paint

in this penultimate article, we will derive an application-frame with multiple panes and a layout from our single-pane hurkle-frame to make it a bit more complete-game-y and show off some of McCLIM’s convenient features.

Next article, we will put the common lisp app on the steam-software-store-alternative itch.io so we can kind of see turning a lisp repl app into a gui, a more advanced gui, and then distributing it via itch.io (lispgames homed steam software store alternative).

Updated git also I had to add some exports to hurkle/class.lisp from before since the new frame uses them.

Multipane application-frame package

In the new #P"~/common-lisp/hurkle/multipane.lisp"

#|
 (eepitch-sbcl)
 (eepitch-kill)
 (eepitch-sbcl)
|#
(uiop:define-package :hurkle/multipane
    (:mix :hurkle/commands :hurkle/frame :hurkle/class
     :clim :clim-lisp :cl)
  (:export #:hurkle-game #:define-hurkle-game-command #:status-message))

(in-package :hurkle/multipane)

(define-application-frame hurkle-game
    (hurkle-frame)
  ((status-message :initform "commence hurkling" :accessor status-message))
  (:panes
   (app :application :incremental-redisplay t
		     :display-function 'display-hurkles)
   (title :title :title-string (format nil "McCLIM~%Hurkle Game"))
   (int :interactor)
   (status :application
	   :display-function
	   (lambda (f p) (princ (status-message f) p))))
  (:layouts (default (horizontally ()
		       (1/2 (vertically () title app))
		       (vertically ()
			 status
			 (1/2 int)))))
  (:command-table (hurkle-frame)))

(defmethod investigate :before ((obj hurkle-game) row col
				&key &allow-other-keys)
  (with-slots
	(active hurkle-row-col turn)
      obj
    (when active
      (cond
	((equal hurkle-row-col `(,row ,col))
	 (setf (status-message obj)
	       (format nil "You found the hurkle on turn ~d!"
		       turn)))))))

If you are from a non secret-alien-technology language, that :before common lisp object system method qualifier lets me add a side effect before a method runs (defined on a class that is one of the frame’s grandparents)).

A few more notes

Okay, I will add those last two in part 4/4: Releasing the game.

Fin.

See you on the Mastodon thread to talk about this everyone.

It is my intent to help share some computer science and software engineering knowledge that got closely tied up with lisp’s cultural history which, as Kay pointed out, makes it a bit unaccessible - for example, when I was at university, there was a lisp-shaped gaping void in computer science’s historical record, with lame java apps ostensibly appearing ex nihilo in the late 90s. For this reason, please do share this and share your secret alien technology knowledge with me (on the show and otherwise) and everyone else. It improves the health of the lisp community: Other languages who want to be our replacement certainly aren’t going to do it for us.

By the way, check out mdhughes’ scheme hurkle

Miscellany: We got a few articles in Sacha’s emacsnews!:

screwlisp proposes kittens