Skip to content

Commit

Permalink
Merge pull request #3 from ellisvelo/master
Browse files Browse the repository at this point in the history
Created sdl2-tutorial system and more documentation
  • Loading branch information
TatriX authored Nov 14, 2020
2 parents 983ac86 + 0e0dcb6 commit 8671ff1
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 36 deletions.
9 changes: 6 additions & 3 deletions 1/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-1
(defpackage #:sdl2-tutorial-1
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-1)
(in-package :sdl2-tutorial-1)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand All @@ -15,4 +15,7 @@
nil
(sdl2:map-rgb (sdl2:surface-format screen-surface) 255 255 255))
(sdl2:update-window window)
(sdl2:delay delay)))))
(sdl2:with-event-loop (:method :poll)
(:quit () t)
(:idle ()
(sdl2:delay delay)))))))
4 changes: 2 additions & 2 deletions 10/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-10
(defpackage #:sdl2-tutorial-10
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-10)
(in-package :sdl2-tutorial-10)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 11/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-11
(defpackage #:sdl2-tutorial-11
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-11)
(in-package :sdl2-tutorial-11)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 12/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-12
(defpackage #:sdl2-tutorial-12
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-12)
(in-package :sdl2-tutorial-12)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 13/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-13
(defpackage #:sdl2-tutorial-13
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-13)
(in-package :sdl2-tutorial-13)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 14/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-14
(defpackage #:sdl2-tutorial-14
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-14)
(in-package :sdl2-tutorial-14)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
6 changes: 3 additions & 3 deletions 15/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-15
(defpackage #:sdl2-tutorial-15
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-15)
(in-package :sdl2-tutorial-15)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down Expand Up @@ -62,7 +62,7 @@
(with-window-renderer (window renderer)
(sdl2-image:init '(:png))
(let ((texture (load-texture-from-file renderer "15/arrow.png"))
(flip :flip-none)
(flip :none)
(degrees 0)
(delta 60))
(sdl2:with-event-loop (:method :poll)
Expand Down
4 changes: 2 additions & 2 deletions 16/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-16
(defpackage #:sdl2-tutorial-16
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-16)
(in-package :sdl2-tutorial-16)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
10 changes: 6 additions & 4 deletions 2/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-2
(defpackage #:sdl2-tutorial-2
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-2)
(in-package :sdl2-tutorial-2)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand All @@ -24,5 +24,7 @@
screen-surface
nil)
(sdl2:update-window window)
(sdl2:delay delay)))

(sdl2:with-event-loop (:method :poll)
(:quit () t)
(:idle ()
(sdl2:delay delay)))))
4 changes: 2 additions & 2 deletions 3/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-3
(defpackage #:sdl2-tutorial-3
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-3)
(in-package :sdl2-tutorial-3)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 4/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-4
(defpackage #:sdl2-tutorial-4
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-4)
(in-package :sdl2-tutorial-4)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 5/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-5
(defpackage #:sdl2-tutorial-5
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-5)
(in-package :sdl2-tutorial-5)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 6/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-6
(defpackage #:sdl2-tutorial-6
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-6)
(in-package :sdl2-tutorial-6)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 7/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-7
(defpackage #:sdl2-tutorial-7
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-7)
(in-package :sdl2-tutorial-7)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 8/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-8
(defpackage #:sdl2-tutorial-8
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-8)
(in-package :sdl2-tutorial-8)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
4 changes: 2 additions & 2 deletions 9/main.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
(defpackage #:sdl-tutorial-9
(defpackage #:sdl2-tutorial-9
(:use :common-lisp)
(:export :main))

(in-package :sdl-tutorial-9)
(in-package :sdl2-tutorial-9)

(defparameter *screen-width* 640)
(defparameter *screen-height* 480)
Expand Down
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,54 @@
# Common Lisp SDL2 tutorials
Adapted from http://lazyfoo.net/tutorials/SDL/


## Installing the SDL2 Libraries

The tutorial requires that SDL2, SDL2 Image, and SDL2 TTF are installed before
running the examples.

### Mac OS X

Mac OS X requires each library to be downloaded and copied to
$HOME/Library/Frameworks or /Library/Frameworks.

Library Name | Download Link
------------ | -------------
SDL2 | https://www.libsdl.org/download-2.0.php
SDL2 Image | https://www.libsdl.org/projects/SDL_image
SDL2 TTF | https://www.libsdl.org/projects/SDL_ttf

Running the tutorials will cause Catalina to report that the framework cannot be
opened because the developer cannot be verified. The workaround for this problem
is the following:

1. Navigate to System Preferences -> Security & Privacy -> General on the Mac

2. Run repl.sh

3. When the dialog appears about the developer not being verified, click the
"Cancel" button.

4. Examine the Security & Privacy screen for a button called "Allow Anyway" for
the framework. Click the "Allow Anyway" button with the identified framework.

5. The verification dialog will now appear a second time, but there will be an
option to "Open" the framework. Click "Open".

6. Repeat steps 3 through 5 for the different frameworks.

### Linux

The SDL2 libraries can be installed on a Debian based system with the command
below.

apt install libsdl2-2.0 libsdl2-image-2.0 libsdl2-ttf-2.0


## Running the Examples

A repl.sh script is provided that loads SDL2-TUTORIAL with quicklisp and then
starts up a swank thread on port 4005 for repl connections.

1. ./repl.sh
2. (sdl2-tutorial:main #'sdl2-tutorial-1:main)
4 changes: 4 additions & 0 deletions repl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

sbcl --eval "(ql:quickload \"sdl2-tutorial\")" \
--eval "(sdl2-tutorial:create-swank-server)"
22 changes: 22 additions & 0 deletions sdl2-tutorial.asd
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(defsystem "sdl2-tutorial"
:description "SDL2 Tutorial based upon http://lazyfoo.net/tutorials/SDL"
:version "0.0.1"
:licence "Public Domain"
:depends-on ("bordeaux-threads" "sdl2" "sdl2-image" "sdl2-ttf" "swank")
:components ((:file "1/main")
(:file "2/main")
(:file "3/main")
(:file "4/main")
(:file "5/main")
(:file "6/main")
(:file "7/main")
(:file "8/main")
(:file "9/main")
(:file "10/main")
(:file "11/main")
(:file "12/main")
(:file "13/main")
(:file "14/main")
(:file "15/main")
(:file "16/main")
(:file "sdl2-tutorial")))
11 changes: 11 additions & 0 deletions sdl2-tutorial.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(defpackage :sdl2-tutorial
(:use cl bt)
(:export :main :create-swank-server))

(in-package :sdl2-tutorial)

(defun create-swank-server()
(bt:make-thread (lambda () (swank:create-server :port 4005 :dont-close t))))

(defun main(fn)
(sdl2:make-this-thread-main fn))

0 comments on commit 8671ff1

Please sign in to comment.