summaryrefslogtreecommitdiff
path: root/sly/game.scm
Commit message (Collapse)AuthorAgeFilesLines
* math: Rewrite vector math library to use packed f64 bytevectors.David Thompson2016-02-271-1/+3
| | | | | | | | | | | | | | | | | | | | The big consequence of this change to the rest of the codebase is that we can no longer use record destructuring when pattern matching, so I had to rewrite every place where pattern matching was used. It was probably a bad idea to expose the record type descriptors publicly in the first place. * sly/math/vector.scm: Reimplement everything in terms of an f64 packed bytevector record type. Do not expose record type descriptors. * sly/game.scm (run-game-loop): Convert viewport width/height to exact numbers. * sly/window.scm (open-window): Likewise. * sly/input/mouse.scm (mouse-position): Rewrite pattern matching. * sly/math/quaternion (make-quaternion, vector->quaternion): Likewise. * sly/math/rect.scm (rect-clamp): Likewise. * sly/math/transform.scm (translate!, translate, scale): Likewise. * sly/render/mesh.scm (vertices-bytevector): Likewise. * examples/mines/mines.scm: Likewise.
* Use a single foreign object guardian.David Thompson2016-02-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | Rather than each foreign resource type creating its own guardian, let's just use one instead so that there is only a single guardian to talk to each frame. * sly/guardian.scm: New file. * Makefile.am (SOURCES): Add it. * sly/game.scm (run-game-loop): Start guardian worker. * sly/render/mesh.scm (mesh-guardian): Delete. (free-mesh): New procedure. (make-mesh): Guard newly created meshes. * sly/render/shader.scm (shader-stage-guardian): Delete. (free-shader-stage): New procedure. (make-shader-stage): Guard newly created shader stages. (shader-guardian): Delete. (free-shader): New procedure. (make-shader): Guard newly created shaders. * sly/render/texture.scm (texture-guardian): Delete. (free-texture): New procedure. (make-texture): Guard newly created textures.
* game: Add on-start procedure.David Thompson2016-02-101-0/+11
| | | | * sly/game.scm (on-start): New procedure.
* game: Add game started hook.David Thompson2016-01-271-2/+16
| | | | | * sly/game.scm (game-start-hook, game-started?): New variables. (run-game-loop): Run game-start-hook before loop starts.
* game-loop: Process input events before each agenda tick.David Thompson2016-01-121-1/+1
| | | | | | | | In practice this wasn't very noticeable, but it is a bad idea to lock input event processing with the frame rate. * sly/game.scm (run-game-loop): Process input events before each call to 'agenda-tick!'.
* render: Add alpha value to render context.David Thompson2016-01-121-1/+3
| | | | | | | | | Necessary for interpolating moving objects to avoid temporal aliasing. * sly/render.scm (<graphics>)[alpha]: New field. (graphics-alpha, set-graphics-alpha!): New procedure. * sly/game.scm (run-game-loop): Set the frame's alpha value before each render call.
* Upgrade to SDL2!David Thompson2015-12-221-6/+7
| | | | | | This commit is massive and crazy and I'm not going to do the usual GNU ChangeLog thing because it's just too much. Let's just be happy that the port is completed!
* game: Stop the game loop upon SIGINT.David Thompson2015-11-121-0/+5
| | | | | | | Fixes a long standing annoyance that pressing C-c wouldn't kill the application. * sly/game.scm (run-game-loop): Catch SIGINT and call 'stop-game-loop'.
* render: Reimplement rendering engine using functional combinators.David Thompson2015-09-211-10/+8
| | | | | | | | | | | Warning: This is a huge commit. I completely gutted the old scene graph and replaced it with a somewhat monadic rendering combinator module instead. The interface remains purely functional, but replaces the <model> data type with procedures in the rendering monad instead. This opens the door for rendering *anything*, not just meshes. Now I can implement particle systems and other non-static things.
* render: Reimplement OpenGL state machine manager.David Thompson2015-08-261-7/+7
| | | | | | | | | | | | | The implementation is a bit cleaner, and it's a stepping stone towards render combinators. * sly/render/context.scm: Delete. * sly/render.scm: New file. * Makefile.am (SOURCES): Add it. Remove context.scm. * sly/game.scm (run-game-loop): Use new <graphics> type. * sly/render/model.scm (draw-model): Likewise. * sly/render/scene.scm (draw-scene): Likewise. * examples/2048/2048.scm: Remove (sly render context) import.
* Rename start-game-loop to run-game-loop.David Thompson2015-06-101-2/+2
| | | | | | | | | | | | | * doc/api/init.texi: s/start-game-loop/run-game-loop/ * examples/2048/2048.scm: Likewise. * examples/animation.scm: Likewise. * examples/font.scm: Likewise. * examples/joystick.scm: Likewise. * examples/mines/mines.scm: Likewise. * examples/simple.scm: Likewise. * examples/tilemap.scm: Likewise. * sandbox.in: Likewise. * sly/game.scm: Likewise.
* game: Add scene argument to start-game-loop.David Thompson2015-06-061-5/+12
| | | | * sly/game.scm (start-game-loop): Add 'scene' argument.
* agenda: Rename procedures.David Thompson2014-12-131-1/+1
| | | | | | | * sly/agenda.scm (tick-agenda!, clear-agenda!): Rename. (agenda-tick!, agenda-clear!): New procedures. * sly/game.scm (start-game-loop): Use agenda-tick!. * sly/repl.scm (start-sly-repl): Likewise.
* Remove unneeded (sly camera) imports.David Thompson2014-10-281-1/+0
| | | | | * sly/game.scm: Remove (sly camera) import. * sly/scene.scm: Likewise.
* game: Decouple the scene graph from the game loop.David Thompson2014-10-251-18/+9
| | | | | * sly/game.scm (start-game-loop): Just run the draw hook instead of rendering a scene graph.
* Rewrite vector math module.David Thompson2014-10-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * .gitignore: Ignore '*.log' files. * sly/vector.scm: Delete file. * sly/math/vector.scm: New file. * tests/math/vector.scm: New file. * Makefile.am: Add new file and remove the old one. * sly/font.scm: Remove import. * sly/game.scm: Change import. * sly/joystick.scm (make-directional-signal-raw, make-directional): Use 'vector2'. * sly/keyboard.scm (key-directions): Use 'vector2'. * sly/mesh.scm (vertices-bytevector): Use new vector procedures. * sly/mouse.scm (mouse-position): Use 'vector2'. * sly/quaternion.scm (axis-angle->quaternion, quaternion->vector, vector->quaternion): Use new vector procedures. * sly/rect.scm (rect-position, rect-top-right, rect-bottom-left, rect-bottom-right, rect-center, rect-size): Use 'vector2'. * sly/scene.scm (make-scene-node): Use 'vector2'. * sly/shader.scm: Change import. * sly/shape.scm (make-cube): Use new vector procedures. * sly/sprite.scm (make-sprite): Use new vector procedures. * sly/texture.scm (anchor-texture): Use 'vector2'. * sly/transform.scm (transform-vector2): Use 'vector2'. (translate, scale): Use new vector procedures. * sly/transition.scm (guess-interpolator): Use new vector procedures. * sly/window.scm (make-window, window-size, open-window): Use 'vector2'.
* scene: Remove messy interpolation/caching for now.David Thompson2014-09-301-4/+0
| | | | | | | | | | | | * sly/game.scm (run-game-loop): Remove scene updating step. * sly/scene.scm (scene-node-prev-position, set-scene-node-prev-position!, scene-node-prev-scale, set-scene-node-prev-scale!, scene-node-prev-rotation, set-scene-node-prev-rotation!, scene-node-transform, set-scene-node-transform!, scene-node-dirty?, update-scene-node, recompute-transform!): Delete procedures. (make-scene-node): Remove transform caching. (draw-scene-node): Re-calculate transforms every frame.
* scene: Decouple cameras from the scene they render.David Thompson2014-09-291-10/+9
| | | | | | | | | | | | * sly/camera.scm (make-camera, orthographic-camera): Remove 'scene' parameter. (draw-camera): Delete. (call-with-camera): New procedure. * sly/game.scm (start-game-loop): Replace 'camera' parameter with 'scene'. * sly/scene.scm (make-scene, scene?, update-scene, draw-scene): New procedures. (scene-root): Replace.
* game: Accept one camera object as well as a list in start-game-loop.David Thompson2014-09-011-14/+20
| | | | | * sly/game.scm (start-game-loop): Support rendering a single camera object instead of just a list of cameras.
* Run draw-hook each time a frame is drawn.David Thompson2014-08-251-0/+1
|
* Render using scenes and cameras.David Thompson2014-08-251-2/+12
| | | | * sly/game.scm (start-game-loop): Add cameras parameter.
* Deference one signal instead of two.David Thompson2014-08-251-3/+3
| | | | | * 2d/game.scm (draw): Use window-size instead of window-width and window-height.
* Add error handling hook to game loop.David Thompson2014-07-051-7/+47
| | | | | | * sly/game.scm (after-game-loop-error-hook): New variable (display-game-loop-error): New procedure. (start-game-loop): Add error handling.
* Remove global variables for controlling tick rate.David Thompson2014-07-031-57/+62
| | | | | | | | | * sly/game.scm (tick-interval, max-ticks-per-frame): Remove them. (draw, update, alpha, frame-sleep): Move within start-game-loop closure. (interval): New procedure. (start-game-loop): Add tick-rate, frame-rate, and max-ticks-per-frame keyword arguments.
* Rename guile-2d to Sly!David Thompson2014-06-281-0/+109
Massive find/replace job.