A presentation on making games with Common Lisp. Intended for people who do not currently program in Common Lisp, so includes some general Common Lisp knowledge/propaganda. Written in LaTex, exported as pdf.

presentation.lisp 664B

123456789101112131415161718192021222324252627
  1. (declaim (ftype (function (number number) number) add))
  2. (defun add (x y)
  3. (declare (number x y))
  4. (the number (+ x y)))
  5. (defun add2 (x y)
  6. (+ x y))
  7. (defclass dog ()
  8. ((name :reader name :initarg :name :type string)
  9. (age :accessor age :type fixnum :initarg :age)))
  10. (defgeneric speak (thing))
  11. (defmethod speak ((rover dog))
  12. (dotimes (times (age rover))
  13. (format t "~A SPEAK!~%" (name rover))
  14. (format t "WOOF!~%")))
  15. (let ((our-dog
  16. (make-instance 'dog :name "Stupid dog!" :age 1)))
  17. (speak our-dog)
  18. ; Stupid dog! SPEAK!
  19. ; WOOF!
  20. (incf (age our-dog))
  21. (speak our-dog)
  22. ; Stupid dog! Speak!
  23. ; WOOF!
  24. ; Stupid dog! Speak!
  25. ; WOOF!
  26. )