Skip to content

Commit

Permalink
Refactor tutorial 14
Browse files Browse the repository at this point in the history
  • Loading branch information
Yan committed Jan 8, 2022
1 parent 865902d commit 2bf5b6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions 14/tutorial-14.lisp → 14-animated-sprites-and-vsync.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(defpackage #:sdl2-tutorial-14
(:use :common-lisp)
(:export :main))
(defpackage #:sdl2-tutorial-14-animated-sprites-and-vsync
(:use :cl)
(:export :run)
(:import-from :sdl2-tutorial-utils :asset-pathname))

(in-package :sdl2-tutorial-14)
(in-package #:sdl2-tutorial-14-animated-sprites-and-vsync)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down Expand Up @@ -54,7 +55,7 @@
(defmacro with-window-renderer ((window renderer) &body body)
`(sdl2:with-init (:video)
(sdl2:with-window (,window
:title "SDL2 Tutorial"
:title "SDL2 Tutorial 14"
:w *screen-width*
:h *screen-height*
:flags '(:shown))
Expand All @@ -70,10 +71,10 @@
(defmacro clamp-decf (x delta)
`(setf ,x (clamp (- ,x ,delta))))

(defun main()
(defun run ()
(with-window-renderer (window renderer)
(sdl2-image:init '(:png))
(let ((spritesheet-tex (load-texture-from-file renderer "14/character.png"))
(let ((spritesheet-tex (load-texture-from-file renderer (asset-pathname "assets/14/character.png")))
(clip (sdl2:make-rect 0 0 64 96))
(sprite-frames 4)
(current-sprite-frame 0)
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion sdl2-tutorial.asd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
(:file "11-clip-rendering-and-sprite-sheets")
(:file "12-color-modulation")
(:file "13-alpha-blending")
(:file "14/tutorial-14")
(:file "14-animated-sprites-and-vsync")
(:file "15/tutorial-15")
(:file "16/tutorial-16"))
:in-order-to ((test-op (test-op "sdl2-tutorial/tests"))))
Expand Down

0 comments on commit 2bf5b6c

Please sign in to comment.