From 58266627bf3ea66dfc6f8434c32304758d1d9e98 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Fri, 15 Oct 2021 23:29:49 -0400 Subject: Day 1 check-in. --- bonnie-bee/player.scm | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 bonnie-bee/player.scm (limited to 'bonnie-bee/player.scm') diff --git a/bonnie-bee/player.scm b/bonnie-bee/player.scm new file mode 100644 index 0000000..6e8f7fb --- /dev/null +++ b/bonnie-bee/player.scm @@ -0,0 +1,44 @@ +(define-module (bonnie-bee player) + #:use-module (bonnie-bee actor) + #:use-module (bonnie-bee assets) + #:use-module (chickadee math vector) + #:use-module (oop goops) + #:use-module (starling node) + #:use-module (starling node-2d) + #:export ( + move-left? + move-right? + move-down? + move-up? + shoot? + speed + lives + pollen)) + +(define-class () + (move-left? #:accessor move-left? #:init-value #f) + (move-right? #:accessor move-right? #:init-value #f) + (move-down? #:accessor move-down? #:init-value #f) + (move-up? #:accessor move-up? #:init-value #f) + (shoot? #:accessor shoot? #:init-value #f) + (speed #:accessor speed #:init-value 2.0) + (lives #:accessor lives #:init-value 3) + (pollen #:accessor pollen #:init-value 0)) + +(define-method (on-boot (player )) + (attach-to player + (make + #:atlas bee-atlas + #:index 12 + #:origin (vec2 16.0 16.0)))) + +(define-method (update (player ) dt) + (let ((v (velocity player))) + (set-vec2! v + (+ (if (move-left? player) -1.0 0.0) + (if (move-right? player) 1.0 0.0)) + (+ (if (move-down? player) -1.0 0.0) + (if (move-up? player) 1.0 0.0))) + (vec2-normalize! v) + (vec2-mult! v (speed player))) + (next-method)) -- cgit v1.2.3