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.
123456789101112131415161718192021222324252627 |
- (declaim (ftype (function (number number) number) add))
- (defun add (x y)
- (declare (number x y))
- (the number (+ x y)))
- (defun add2 (x y)
- (+ x y))
- (defclass dog ()
- ((name :reader name :initarg :name :type string)
- (age :accessor age :type fixnum :initarg :age)))
- (defgeneric speak (thing))
- (defmethod speak ((rover dog))
- (dotimes (times (age rover))
- (format t "~A SPEAK!~%" (name rover))
- (format t "WOOF!~%")))
- (let ((our-dog
- (make-instance 'dog :name "Stupid dog!" :age 1)))
- (speak our-dog)
- ; Stupid dog! SPEAK!
- ; WOOF!
- (incf (age our-dog))
- (speak our-dog)
- ; Stupid dog! Speak!
- ; WOOF!
- ; Stupid dog! Speak!
- ; WOOF!
- )
|