Skip to content

Instantly share code, notes, and snippets.

@JulienRouse
Created September 19, 2016 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulienRouse/0ad1e262b80c4c809f1a19451316f295 to your computer and use it in GitHub Desktop.
Save JulienRouse/0ad1e262b80c4c809f1a19451316f295 to your computer and use it in GitHub Desktop.
xelf:draw-string
;;;; draw-string.asd
(asdf:defsystem #:draw-string
:description "Describe draw-string here"
:author "Your Name <your.name@example.com>"
:license "Specify license here"
:depends-on (#:xelf)
:serial t
:components ((:file "package")
(:file "draw-string")))
;;;; draw-string.lisp
(in-package #:draw-string)
(defparameter *width* 640)
(defparameter *height* 480)
(defclass foo (node)
((width :initform 16)
(height :initform 16)))
(defclass bar (buffer)
((width :initform *width*)
(height :initform *height*)
(foo :initform (make-instance 'foo))))
;; ctrl+r to quit
(defmethod initialize-instance :after ((bar bar) &key)
(bind-event bar '(:r :control) 'quit))
(defmethod start-game ((bar bar))
(with-buffer bar
(draw-string "Hello World" 50 50 :color "red")
(current-buffer)))
(defun launch ()
;; Configure the screen dimensions
(setf *screen-height* *height*)
(setf *screen-width* *width*)
;; Allow resizing of window and scaling
(setf *resizable* t)
(setf *scale-output-to-window* t)
(with-session
(open-project :plong)
;; this indexes everything defined with DEFRESOURCE
(index-pending-resources)
(let ((bar (make-instance 'bar)))
;; start the buffer running
(switch-to-buffer bar)
(start-game bar))))
;;;; package.lisp
(defpackage #:draw-string
(:use #:cl #:xelf)
(:export launch))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment