|
|
@ -21,7 +21,7 @@ |
|
|
|
(var x float 0.f) |
|
|
|
(var y float 0.f) |
|
|
|
(var z float 0.f) |
|
|
|
(var move-speed float 0.3f) |
|
|
|
(var move-speed float 10.f) |
|
|
|
|
|
|
|
(var counter-num-ticks-per-second (const Uint64) (SDL_GetPerformanceFrequency)) |
|
|
|
(var last-frame-perf-count Uint64 (* 0.016f counter-num-ticks-per-second)) |
|
|
@ -37,22 +37,27 @@ |
|
|
|
(var currentKeyStates (* (const Uint8)) (SDL_GetKeyboardState nullptr)) |
|
|
|
(when (at SDL_SCANCODE_ESCAPE currentKeyStates) |
|
|
|
(set exit-reason "Escape pressed")) |
|
|
|
|
|
|
|
(var delta-position ([] 3 float) (array 0)) |
|
|
|
(when (at SDL_SCANCODE_RIGHT currentKeyStates) |
|
|
|
(set x (+ x move-speed))) |
|
|
|
(set (at 0 delta-position) (+ (at 0 delta-position) move-speed))) |
|
|
|
(when (at SDL_SCANCODE_LEFT currentKeyStates) |
|
|
|
(set x (- x move-speed))) |
|
|
|
(set (at 0 delta-position) (- (at 0 delta-position) move-speed))) |
|
|
|
(when (at SDL_SCANCODE_UP currentKeyStates) |
|
|
|
(set y (+ y move-speed))) |
|
|
|
(set (at 1 delta-position) (+ (at 1 delta-position) move-speed))) |
|
|
|
(when (at SDL_SCANCODE_DOWN currentKeyStates) |
|
|
|
(set y (- y move-speed))) |
|
|
|
|
|
|
|
(ogre-node-set-position (addr monkey-node) x y z) |
|
|
|
(set (at 1 delta-position) (- (at 1 delta-position) move-speed))) |
|
|
|
|
|
|
|
(var current-counter-ticks Uint64 (SDL_GetPerformanceCounter)) |
|
|
|
(var frame-diff-ticks Uint64 (- current-counter-ticks last-frame-perf-count)) |
|
|
|
(printf "%lu %f\n" frame-diff-ticks |
|
|
|
(/ frame-diff-ticks |
|
|
|
(type-cast counter-num-ticks-per-second float))) |
|
|
|
(var delta-time float (/ frame-diff-ticks |
|
|
|
(type-cast counter-num-ticks-per-second float))) |
|
|
|
(printf "%lu %f\n" frame-diff-ticks delta-time) |
|
|
|
|
|
|
|
(set x (+ x (* delta-time (at 0 delta-position)))) |
|
|
|
(set y (+ y (* delta-time (at 1 delta-position)))) |
|
|
|
(set z (+ z (* delta-time (at 2 delta-position)))) |
|
|
|
(ogre-node-set-position (addr monkey-node) x y z) |
|
|
|
|
|
|
|
(set last-frame-perf-count (SDL_GetPerformanceCounter)) |
|
|
|
|
|
|
@ -61,16 +66,12 @@ |
|
|
|
(break))) |
|
|
|
|
|
|
|
(ogre-shutdown) |
|
|
|
(sdl-shutdown window) |
|
|
|
(when exit-reason |
|
|
|
(printf "Exit reason: %s\n" exit-reason)) |
|
|
|
(return 0)) |
|
|
|
|
|
|
|
(set-cakelisp-option executable-output "test/ogreSDLApp") |
|
|
|
(set-cakelisp-option executable-output "test/SDLOgreApp") |
|
|
|
|
|
|
|
;; TODO: Somehow inherit this from SDL.cake? |
|
|
|
(set-module-option build-time-compiler "/usr/bin/clang++") |
|
|
|
;; Include cakelisp source for DynamicLoader.hpp |
|
|
|
(set-module-option build-time-compile-arguments |
|
|
|
"-Werror" "-Wall" "-Wextra" "-Wno-unused-parameter" |
|
|
|
"-g" "-c" 'source-input "-o" 'object-output "-fPIC" |
|
|
|
"-IDependencies/SDL/buildSDLBuild/include/SDL2") |
|
|
|
(module-use-sdl-build-options) |
|
|
|