Liking cljdoc? Tell your friends :D

clunk.sprite


animated-spriteclj

(animated-sprite sprite-group
                 pos
                 size
                 spritesheet-texture-key
                 spritesheet-size
                 &
                 {:keys [rotation vel update-fn draw-fn points bounds-fn offsets
                         animations current-animation debug? debug-color extra]
                  :or {vel [0 0]
                       offsets [:center]
                       current-animation :none
                       draw-fn draw-animated-sprite!
                       animations {:none
                                     {:frames 1 :y-offset 0 :frame-delay 100}}
                       rotation 0
                       debug-color p/red
                       extra {}
                       update-fn update-animated-sprite
                       debug? false}})
source

capture-gl-stateclj

(capture-gl-state)

Capture the current blending state of GL so we can draw NanoVG text (which blats the config) before restoring the original state for drawing images/shapes.

Capture the current blending state of GL so we can draw NanoVG
text (which blats the config) before restoring the original state
for drawing images/shapes.
sourceraw docstring

default-bounding-polyclj

(default-bounding-poly {[w h] :size})

Generates a bounding polygon based on the :size rectangle of a sprite.

Generates a bounding polygon based on the `:size` rectangle of a
sprite.
sourceraw docstring

draw-animated-sprite!clj

(draw-animated-sprite! {:keys [pos spritesheet-texture spritesheet-size
                               current-animation animation-frame rotation]
                        [w h :as size] :size
                        :as s})
source

draw-boundsclj

(draw-bounds {:keys [pos debug-color bounds-fn] :as s})
source

draw-centerclj

(draw-center {[x y] :pos color :debug-color})
source

draw-default-sprite!clj

(draw-default-sprite! {:keys [pos size color] :as s})

Draw a green square as a sprite placeholder.

Draw a green square as a sprite placeholder.
sourceraw docstring

draw-image-sprite!clj

(draw-image-sprite! {:keys [pos size image-texture rotation] :as s})
source

draw-scene-sprites!clj

(draw-scene-sprites! {:keys [current-scene] global-debug? :debug? :as state})

Draw each sprite in the current scene using its :draw-fn.

Draw each sprite in the current scene using its `:draw-fn`.
sourceraw docstring

draw-text-sprite!clj

(draw-text-sprite! {:keys [window vg vg-color default-font] :as state}
                   {:keys [pos content font font-size color rotation] :as s})
source

has-groupclj

(has-group sprite-group)

Creates a predicate function for filtering sprites based on their :sprite-group.

Takes either a single :sprite-group keyword, or a collection of them.

Commonly used alongside update-sprites:

(sprite/update-sprites state (sprite/has-group :asteroids) sprite-update-fn)

(sprite/update-sprites state (sprite/has-group [:asteroids :ships]) sprite-update-fn)

Creates a predicate function for filtering sprites based on their
`:sprite-group.`

Takes either a single `:sprite-group` keyword, or a collection of
them.

Commonly used alongside `update-sprites`:

(sprite/update-sprites
  state
  (sprite/has-group :asteroids)
  sprite-update-fn)

(sprite/update-sprites
  state
  (sprite/has-group [:asteroids :ships])
  sprite-update-fn)
sourceraw docstring

image-spriteclj

(image-sprite sprite-group
              pos
              size
              image-texture-key
              &
              {:keys [rotation vel update-fn draw-fn points bounds-fn offsets
                      debug? debug-color extra]
               :or {rotation 0
                    vel [0 0]
                    update-fn update-pos
                    draw-fn draw-image-sprite!
                    offsets [:center]
                    debug? false
                    debug-color p/red
                    extra {}}})
source

is-spriteclj

(is-sprite {:keys [uuid]})
source

pos-offsetsclj

(pos-offsets {[x-off y-off] :offsets [w h] :size})

Determine the x and y offsets for a sprite based on it's :w, :h and :offsets configuration.

Defaults to [:center :center].

Determine the x and y offsets for a sprite based on it's `:w`, `:h`
and `:offsets` configuration.

Defaults to `[:center :center]`.
sourceraw docstring

restore-gl-stateclj

(restore-gl-state {:keys [src-rgb src-alpha dst-rgb dst-alpha blend-enabled?]})

Restore the original blending state of GL for drawing images/shapes.

Restore the original blending state of GL for drawing images/shapes.
sourceraw docstring

set-animationclj

(set-animation s animation)
source

spriteclj

(sprite sprite-group
        pos
        &
        {:keys [size vel color update-fn draw-fn points bounds-fn offsets debug?
                debug-color extra]
         :or {vel [0 0]
              offsets [:center]
              draw-fn draw-default-sprite!
              color p/white
              debug-color p/red
              extra {}
              size [20 20]
              update-fn update-pos
              debug? false}})

The simplest sensible sprite.

Takes a sprite-group (a label for sprites of this type) and a pos (an [x y] position vector).

Can be enriched with any custom fields by providing an :extra kwarg map.

The simplest sensible sprite.

Takes a `sprite-group` (a label for sprites of this type) and a
`pos` (an `[x y]` position vector).

Can be enriched with any custom fields by providing an `:extra`
kwarg map.
sourceraw docstring

text-spriteclj

(text-sprite sprite-group
             pos
             content
             &
             {:keys [rotation vel update-fn draw-fn points bounds-fn offsets
                     font font-size color debug? debug-color extra]
              :or {vel [0 0]
                   offsets [:left :bottom]
                   draw-fn draw-text-sprite!
                   rotation 0
                   color p/white
                   font-size 32
                   debug-color p/red
                   font "sans"
                   update-fn identity
                   debug? false}})
source

update-animated-spriteclj

(update-animated-sprite s)

Update the animation of a sprite in addition to it's position.

Update the animation of a sprite in addition to it's position.
sourceraw docstring

update-animationclj

(update-animation {:keys [current-animation delay-count] :as s})

If the :delay-count is zero, move to the next animation frame.

If the `:delay-count` is zero, move to the next animation frame.
sourceraw docstring

update-frame-delayclj

(update-frame-delay {:keys [current-animation] :as s})

Increment the :delay-count (wrapping to zero at :frame-delay).

The animation frame will change at 0.

Increment the `:delay-count` (wrapping to zero at `:frame-delay`).

The animation frame will change at 0.
sourceraw docstring

update-posclj

(update-pos {[x y] :pos [vx vy] :vel :as s})

Update the sprite position based on its velocity.

Update the sprite position based on its velocity.
sourceraw docstring

update-spritesclj

(update-sprites state f)
(update-sprites {:keys [current-scene] :as state} pred f)

Update sprites in the current scene with the update function f.

Optionally takes a filtering function pred.

Update sprites in the current scene with the update function `f`.

Optionally takes a filtering function `pred`.
sourceraw docstring

update-stateclj

(update-state {:keys [current-scene] :as state})

Update each sprite in the current scene using its :update-fn.

Update each sprite in the current scene using its `:update-fn`.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close