chewbranca.com

Check-in [e11c5f9a0c]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Don't use local in functions
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | lisp-game-jam-2020
Files: files | file ages | folders
SHA3-256: e11c5f9a0c7dc22e06251741d475e045035ec3a5cee9b211b49dc9eb65ef8674
User & Date: chewbranca 2020-04-11 22:32:09
Context
2020-04-11
22:49
Finish part1 and fix jumping check-in: d243b75468 user: chewbranca tags: lisp-game-jam-2020
22:32
Don't use local in functions check-in: e11c5f9a0c user: chewbranca tags: lisp-game-jam-2020
22:26
Add Fennel port of http://www.osmstudios.com/tutorials/love2d-platformer-tutorial-part-1-the-basics check-in: a607a0e86f user: chewbranca tags: lisp-game-jam-2020
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/fahombo/play-osms-part1.fnl.

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

(: world :add player player.x player.y (: player.img :getWidth) (: player.img :getHeight))
;;(: world :add ground-0 20 360 640 16) ; blog version
(: world :add ground-0 120 360 640 16) ; github version
(: world :add ground-1 0 448 640 32)

(fn update [dt set-mode]
  (local goal-x (+ player.x player.xVelocity))
  (local goal-y (+ player.y player.yVelocity))

  (let [(x y) (: world :move player goal-x goal-y)]
    (set player.x (lume.clamp x 5 1000))
    (set player.y y))

  ;; apply friction
  (let [df (- 1 (math.min 1 (* dt player.friction)))]
    (set player.xVelocity (* player.xVelocity df))
    (set player.yVelocity (* player.yVelocity df)))







|
|
<
|







30
31
32
33
34
35
36
37
38

39
40
41
42
43
44
45
46

(: world :add player player.x player.y (: player.img :getWidth) (: player.img :getHeight))
;;(: world :add ground-0 20 360 640 16) ; blog version
(: world :add ground-0 120 360 640 16) ; github version
(: world :add ground-1 0 448 640 32)

(fn update [dt set-mode]
  (let [goal-x (+ player.x player.xVelocity)
        goal-y (+ player.y player.yVelocity)

        (x y) (: world :move player goal-x goal-y)]
    (set player.x (lume.clamp x 5 1000))
    (set player.y y))

  ;; apply friction
  (let [df (- 1 (math.min 1 (* dt player.friction)))]
    (set player.xVelocity (* player.xVelocity df))
    (set player.yVelocity (* player.yVelocity df)))