diff --git a/ueforth/common/grf_test.fs b/ueforth/common/grf_test.fs index d795ebf..e517c2f 100755 --- a/ueforth/common/grf_test.fs +++ b/ueforth/common/grf_test.fs @@ -30,8 +30,8 @@ grf ." CHAR: " last-char . cr then ) - 0 color! 0 0 width height box - LEFT-BUTTON pressed? if $ccccff else $ffccff then color! + 0 to color 0 0 width height box + LEFT-BUTTON pressed? if $ccccff else $ffccff then to color mouse-x mouse-y height heart flip event FINISHED = until diff --git a/ueforth/common/grf_utils.fs b/ueforth/common/grf_utils.fs index a80487f..0ab8a55 100644 --- a/ueforth/common/grf_utils.fs +++ b/ueforth/common/grf_utils.fs @@ -14,35 +14,33 @@ ( Graphics Utilities ) \ Pen: -\ color! ( col -- ) +\ ( $rrggbb ) to color \ Drawing: \ box ( x y w h -- ) also internals grf definitions + +0 value color + internals definitions -variable color - ( Scale to be divided by $10000 ) -variable sx variable sy -$10000 sx ! $10000 sy ! +$10000 value sx $10000 value sy ( Translation ) -variable tx variable ty +0 value tx 0 value ty : hline { x y w } - \ x y pixel w 1- for color @ over l! 4 + next drop ; - x y pixel w color @ fill32 ; + \ x y pixel w 1- for color over l! 4 + next drop ; + x y pixel w color fill32 ; grf definitions also internals -: color! ( col -- ) color ! ; - : box { left top w h } - left sx @ * tx @ + 16 rshift to left - top sy @ * ty @ + 16 rshift to top - w sx @ * 16 rshift to w - h sy @ * 16 rshift to h + left sx * tx + 16 rshift to left + top sy * ty + 16 rshift to top + w sx * 16 rshift to w + h sy * 16 rshift to h left w + top h + { right bottom } left 0 max to left diff --git a/ueforth/examples/heart_game.fs b/ueforth/examples/heart_game.fs index 81bbc0f..ff82246 100755 --- a/ueforth/examples/heart_game.fs +++ b/ueforth/examples/heart_game.fs @@ -72,22 +72,22 @@ create arrow-table : draw-one { e } e ->kind @ { kind } HEART-GOAL kind = if - $ff0000 128 random dup 8 lshift + + color! + $ff0000 128 random dup 8 lshift + + to color e ->x @ 100 / e ->y @ 100 / e ->step @ heart exit then FIRE kind = if - $222222 color! + $222222 to color e ->x @ 100 / 4 - e ->y @ 100 / 4 - 8 8 box exit then SPARK kind = if - $ff7700 128 random 8 lshift + color! + $ff7700 128 random 8 lshift + to color e ->x @ 100 / 4 - e ->y @ 100 / 4 - 8 8 box exit then ARROW kind = if - $ffff00 256 random + color! + $ffff00 256 random + to color 39 for e ->x @ 100 / e ->vx @ i 200 */ + i arrow-- 2/ - e ->y @ 100 / e ->vy @ i 200 */ + i arrow-- 2/ - @@ -99,16 +99,16 @@ create arrow-table : volcano height 2/ for - $334400 i 100 height */ + color! + $334400 i 100 height */ + to color width 2/ i 2/ - i height 2/ + i height 8 / + 1 box next - 0 color! + 0 to color width 2/ height 2/ height 8 / 20 box ; : draw - $003300 color! 0 0 width height box + $003300 to color 0 0 width height box volcano entity-count 0 ?do i entity draw-one loop flip