Skip to content
Permalink
Browse files

raylib.demo: cleanup change-player-position.

  • Loading branch information...
mrjbq7 committed Jun 12, 2019
1 parent bc76809 commit 00a0edb1991b7b58088c68ff4a8f2553efeae471
Showing with 14 additions and 14 deletions.
  1. +14 −14 extra/raylib/demo/demo.factor
@@ -19,20 +19,21 @@ SYMBOL: player
: show-player-circle ( -- )
player get
25.0 RED draw-circle-v ;

: setup-game-vars ( -- )
get-screen-width 2 /
get-screen-height 2 /
Vector2 <struct-boa> player set ;

! Make this cleaner
: change-player-position ( -- )
{
{ [ KEY_RIGHT enum>number is-key-down ] [ player get x>> 2.0 + player get x<< ] }
{ [ KEY_LEFT enum>number is-key-down ] [ player get x>> -2.0 + player get x<< ] }
{ [ KEY_DOWN enum>number is-key-down ] [ player get y>> 2.0 + player get y<< ] }
{ [ KEY_UP enum>number is-key-down ] [ player get y>> -2.0 + player get y<< ] }
[ ] } cond ;
player get {
{ [ KEY_RIGHT enum>number is-key-down ] [ [ 2.0 + ] change-x ] }
{ [ KEY_LEFT enum>number is-key-down ] [ [ -2.0 + ] change-x ] }
{ [ KEY_DOWN enum>number is-key-down ] [ [ 2.0 + ] change-y ] }
{ [ KEY_UP enum>number is-key-down ] [ [ -2.0 + ] change-y ] }
[ ]
} cond drop ;

: render-loop ( -- )
begin-drawing
@@ -41,11 +42,10 @@ SYMBOL: player

: main ( -- )
make-window clear-window setup-game-vars
[ change-player-position
render-loop
window-should-close not ] loop
close-window
;
[
change-player-position
render-loop
window-should-close not
] loop close-window ;

MAIN: main

0 comments on commit 00a0edb

Please sign in to comment.
You can’t perform that action at this time.