Skip to content

Commit

Permalink
tutorial
Browse files Browse the repository at this point in the history
  • Loading branch information
David O'Toole committed Dec 8, 2009
1 parent 5c44709 commit 19dfa9d
Show file tree
Hide file tree
Showing 42 changed files with 498 additions and 39 deletions.
8 changes: 5 additions & 3 deletions cells.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ You must provide at least a :base value."
(define-method draw cell (x y image)
"Use XE2 drawing commands to render a presentation of this cell at
X, Y to the offscreen image IMAGE. This method is invoked to draw a
cell when no :tile field is present. See also viewport.lisp."
cell when its TILE field is nil, or when it is in the
category :drawn. See also viewport.lisp."
nil)

;;; Cell categories
Expand All @@ -244,6 +245,7 @@ interpretation:
cells participate in the Action Points system.
- :target --- This cell is susceptible to targeting.
- :proxy --- This cell is a proxy for another cell.
- :drawn --- This cell has a [draw] method used for custom drawing.
- :proxied --- This cell is an occupant of a proxy.
- :dead --- This cell is no longer receiving run messages.
- :player --- Only one cell (your player avatar) has this category.
Expand Down Expand Up @@ -501,9 +503,9 @@ is in the way."
(unless (eq cell self)
[step cell self]))))

(define-method drop cell (cell)
(define-method drop cell (cell &key loadout)
"Add CELL to the world at the current location."
[drop-cell *world* cell <row> <column>])
[drop-cell *world* cell <row> <column> :loadout loadout])

(define-method drop-sprite cell (sprite x y)
"Add SPRITE to the world at location X,Y."
Expand Down
41 changes: 21 additions & 20 deletions viewport.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -102,25 +102,26 @@
(dotimes (i origin-height)
(dotimes (j origin-width)
;; is this square lit?
(if (and (array-in-bounds-p grid (+ i origin-y) (+ j origin-x))
(or (eq :total ambient-light)
(= 1 (aref light-grid (+ i origin-y) (+ j origin-x)))))
(progn
(setf objects (aref grid
(+ i origin-y)
(+ j origin-x)))
(dotimes (k (fill-pointer objects))
(setf cell (aref objects k))
(when (object-p cell)
(let ((j0 (* j tile-size))
(i0 (* i tile-size)))
(if (and (array-in-bounds-p grid (+ i origin-y) (+ j origin-x))
(or (eq :total ambient-light)
(= 1 (aref light-grid (+ i origin-y) (+ j origin-x)))))
(progn
(setf objects (aref grid
(+ i origin-y)
(+ j origin-x)))
(dotimes (k (fill-pointer objects))
(setf cell (aref objects k))
(when (object-p cell)
(let ((j0 (* j tile-size))
(i0 (* i tile-size)))
(setf tile (field-value :tile cell))
(if tile (draw-resource-image tile j0 i0 :destination image)
;; no tile; save it as a pending draw op
(vector-push-extend cell pending-draws))))))
;; not in bounds, or not lit; draw blackness
(draw-resource-image ".blackness" (* j tile-size) (* i tile-size)
:destination image))))
(when tile (draw-resource-image tile j0 i0 :destination image))
(when (or (member :drawn (field-value :categories cell))
(null tile))
(vector-push-extend cell pending-draws))))))
;; not in bounds, or not lit; draw blackness
(draw-resource-image ".blackness" (* j tile-size) (* i tile-size)
:destination image))))
;; draw the sprites
(dolist (sprite sprites)
;; pull image and calculate screen coordinates
Expand All @@ -129,12 +130,12 @@
(x1 (- x0 (* tile-size origin-x)))
(y0 (field-value :y sprite))
(y1 (- y0 (* tile-size origin-y))))
(draw-resource-image graphics x1 y1 :destination image)))
(draw-resource-image graphics x1 y1 :destination image)))
;; draw the pending ops
(map nil #'(lambda (cell)
(multiple-value-bind (x y) [viewport-coordinates cell]
[draw cell x y image]))
pending-draws)
pending-draws)
;; update geometry
(let ((width (* tile-size origin-width))
(height (* tile-size origin-height)))
Expand Down
5 changes: 5 additions & 0 deletions worlds.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,11 @@ narrator, and VIEWPORT as the viewport."
(categories :initform '(:gateway :exclusive))
(address :initform nil))

(define-method initialize gateway (&key address tile name)
(when tile (setf <tile> tile))
(when address (setf <address> address))
(when name (setf <name> name)))

(define-method activate gateway ()
[play *universe* :address <address> :player [get-player *world*]])

Expand Down
Binary file added xong/enemy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified xong/floor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/npc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/objects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/plasma1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/plasma2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/plasma3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/plasma4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-black-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-blue-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-green-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-orange-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-other-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-purple-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-red-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-white-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/player-yellow-svg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/portal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/puckup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezblur1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezblur2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezblur3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezblur4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezblur5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezlight1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added xong/rezlight2.png
Binary file added xong/rezlight3.png
Binary file added xong/rezlight4.png
Binary file added xong/rezlight5.png
Binary file added xong/talk.wav
Binary file not shown.
Loading

0 comments on commit 19dfa9d

Please sign in to comment.