Skip to content

Commit

Permalink
Refactor tutorial 13
Browse files Browse the repository at this point in the history
  • Loading branch information
TatriX committed Sep 20, 2021
1 parent 8041d52 commit 865902d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions 13/tutorial-13.lisp → 13-alpha-blending.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(defpackage #:sdl2-tutorial-13
(:use :common-lisp)
(:export :main))
(defpackage #:sdl2-tutorial-13-alpha-blending
(:use :cl)
(:export :run)
(:import-from :sdl2-tutorial-utils :asset-pathname))

(in-package :sdl2-tutorial-13)
(in-package #:sdl2-tutorial-13-alpha-blending)

(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 13"
:w *screen-width*
:h *screen-height*
:flags '(:shown))
Expand All @@ -70,11 +71,11 @@
(defmacro clamp-decf (x delta)
`(setf ,x (clamp (- ,x ,delta))))

(defun main()
(defun run ()
(with-window-renderer (window renderer)
(sdl2-image:init '(:png))
(let ((bg-texture (load-texture-from-file renderer "13/fadein.png"))
(modulated-texture (load-texture-from-file renderer "13/fadeout.png"))
(let ((bg-texture (load-texture-from-file renderer (asset-pathname "assets/13/fadein.png")))
(modulated-texture (load-texture-from-file renderer (asset-pathname "assets/13/fadeout.png")))
(alpha 255)
(delta 32))
(set-blend-mode modulated-texture :blend)
Expand Down
File renamed without changes
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 @@ -17,7 +17,7 @@
(:file "10-color-keying")
(:file "11-clip-rendering-and-sprite-sheets")
(:file "12-color-modulation")
(:file "13/tutorial-13")
(:file "13-alpha-blending")
(:file "14/tutorial-14")
(:file "15/tutorial-15")
(:file "16/tutorial-16"))
Expand Down

0 comments on commit 865902d

Please sign in to comment.