Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Stupid, Clever, or Both?

Name: Anonymous 2007-10-24 2:02

I'm doing some expert programming of a tile-based game in which tile classes have references to anonymous functions that return the proper image for that tile. I figure I might as well not duplicate these. Should I make these functions onymous or just have a picture function manager that lets me get at them easily? It would be dead simple to create onymous functions for them at runtime, but it makes me feel funny to do it.

Name: Anonymous 2009-11-25 4:04

I know this is pointless to post, but >>9 would be nicer to be done using some accessor (SETF and normal), or at least something like:

(let ((pictures))
  (defun init-pics ()
    (setf pictures (make-hash-table)))
  (defun get-pic (image-name)
    (symbol-macrolet ((pic (gethash image-name pictures)))
      (or pic
          ;; provide lookup-image somewhere if you need it,
          ;; otherwise replace game-file with image-name
          (let ((game-file (lookup-image image-name)))
            (setf pic (sdl-image:load (game-file game-file))))))))

Which would make loading transparent.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List