The very beginning of my forever game project, starting as a "simple" roguelike.

forever-game-roguelike.lisp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ;;;; forever-game-roguelike.lisp
  2. ;;;; Copyright (C) 2015 Lily Carpenter
  3. ;;;; This program is free software: you can redistribute it and/or modify
  4. ;;;; it under the terms of the GNU Affero General Public License as published by
  5. ;;;; the Free Software Foundation, either version 3 of the License, or
  6. ;;;; (at your option) any later version.
  7. ;;;; This program is distributed in the hope that it will be useful,
  8. ;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. ;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. ;;;; GNU Affero General Public License for more details.
  11. ;;;; You should have received a copy of the GNU Affero General Public License
  12. ;;;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. (in-package #:forever-game-roguelike)
  14. (defun start ()
  15. (sdl2:with-init (:everything)
  16. (sdl2:with-window (win :flags '(:shown :opengl))
  17. (sdl2:with-gl-context (gl-context win)
  18. (let ((controllers ())
  19. (haptic ()))
  20. (sdl2:gl-make-current win gl-context)
  21. (gl:viewport 0 0 800 600)
  22. (gl:matrix-mode :projection)
  23. (gl:ortho -2 2 -2 2 -2 2)
  24. (gl:matrix-mode :modelview)
  25. (gl:load-identity)
  26. (gl:clear-color 0.0 0.0 1.0 1.0)
  27. (gl:clear :color-buffer)
  28. (sdl2:with-event-loop (:method :poll)
  29. (:idle
  30. ()
  31. (gl:clear :color-buffer)
  32. (gl:begin :triangles)
  33. (gl:color 1.0 0.0 0.0)
  34. (gl:vertex 0.0 1.0)
  35. (gl:vertex -1.0 -1.0)
  36. (gl:vertex 1.0 -1.0)
  37. (gl:end)
  38. (gl:flush)
  39. (sdl2:gl-swap-window win))
  40. (:keyup
  41. (:keysym keysym)
  42. (when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape)
  43. (sdl2:push-event :quit)))
  44. (:quit () t)))))))