integrate jiles into the game engine, draw with left & right click

This commit is contained in:
Jeremy Penner 2019-07-28 18:40:13 -04:00
parent e630e20d46
commit ba62a080e9
8 changed files with 53 additions and 36 deletions

BIN
game.exe

Binary file not shown.

View file

@ -129,7 +129,7 @@ player :tick
: mode-move
entities each EVTICK entity>do more
party each EVTICK entity>do more
tick-mapedit
tick-mapedit jiles
tick-debounce
q-level @ dup if
0 q-level !

BIN
game.prj

Binary file not shown.

View file

@ -21,6 +21,7 @@ s" timer.jor" loadfile
s" entity.jor" loadfile
s" footer.jor" loadfile
s" map.jor" loadfile
s" jiles.jor" loadfile
s" state.jor" loadfile
s" game.jor" loadfile
; execute

View file

@ -1,5 +1,6 @@
( K E Y B O A R D )
1 const ^ESC
15 const ^TAB
28 const ^ENTER
29 const ^CTRL
51 const ^<

View file

@ -1,62 +1,70 @@
: blah ' seremit task-emit ! ;
blah
s" game.log" open seekend fdeactivate const LOGFILE
: emit-log ' fputc LOGFILE withfp ;
: atexit LOGFILE factivate close ;
: start-repl activate blah ' emit-log task-echo !
s" .:: J O R T H ( jean forth) ::." type cr
begin receive loadstring s" ok" type cr again ;
task const REPL
REPL start-repl
intern input.jor
input.jor loadfile
var color
var lcolor 0x0f lcolor !
var rcolor 0x10 rcolor !
var spriteindex
var refresh-needed
: refresh 1 refresh-needed ! ;
: color! dup color @ = if drop else color ! refresh then ;
: color! >r dup r@ @ = if drop else r@ ! refresh then rdrop ;
: +sprite! spriteindex spritecount +!cycle refresh ;
: draw-palette 0 0x11 for i 79 i 3 << drawfatbox next ;
: mousepos>sprpos 3 >> swap 3 >> swap ;
: mousexys mousepos mousepos>sprpos spriteindex @ ;
: tick
: mousepixel! ( color -- )
>r mousexys getpixel r@ != if
r@ mousexys putpixel refresh
then rdrop ;
var jiles-old-tick
var jiles-old-draw
44 const ^Z
45 const ^X
31 const ^S
: jiles-tick
mousepos 128 < swap 128 < and if
MOUSEL mousedown if
mousexys getpixel color @ != if
color @ mousexys putpixel
refresh
then
then
MOUSER clicked if
mousexys getpixel color!
then
MOUSEL mousedown if lcolor @ mousepixel! then
MOUSER mousedown if rcolor @ mousepixel! then
then
mousepos 136 < swap 312 >= and if
mousepos swap drop 3 >>
MOUSEL mousedown if color! else drop then
mousepos swap drop 3 >> dup
MOUSEL mousedown if lcolor color! else drop then
MOUSER mousedown if rcolor color! else drop then
then
^LEFT key-pressed if -1 +sprite! then
^RIGHT key-pressed if 1 +sprite! then
^Z key-pressed if mousexys getpixel lcolor color! then
^X key-pressed if mousexys getpixel rcolor color! then
^S key-pressed if s" SAVING" type cr savegfx then
^TAB key-pressed if
jiles-old-draw @ ' draw redefine
jiles-old-tick @ ' tick redefine
mousehide unfuck invalidate-map
then
tick-debounce
;
: draw
: jiles-draw
refresh-needed @ if
mousehide
spriteindex @ drawfatsprite
color @ 78 0 drawfatbox
lcolor @ 77 0 drawfatbox
rcolor @ 78 0 drawfatbox
draw-palette
mouseshow
0 refresh-needed !
then ;
mouseshow
refresh
: jiles
^TAB key-pressed if
' draw definition jiles-old-draw !
' tick definition jiles-old-tick !
' jiles-draw ' draw redefine
' jiles-tick ' tick redefine
fuck mouseshow refresh
then ;

Binary file not shown.

View file

@ -369,12 +369,18 @@ void f_savegfx() {
void f_mousehide() {
mouse_hide();
}
void f_mouseshow() {
mouse_show();
}
void f_resetvideo() {
setLogicalWidth(SCREEN_STRIDE >> 1);
setResetEnabledCached(0);
setWriteMode(0);
setAllPlanes();
mouse_show();
setDisplayOffset(0);
setHorizontalPan(0);
}
void f_putpixel() {
@ -441,6 +447,7 @@ void game_f_init(char *exe, char *bootjor) {
CDEF("loadtiles", f_loadtiles);
CDEF("glitch", f_glitch);
CDEF("unfuck", tile_init);
CDEF("fuck", f_resetvideo);
CDEF("mouseshow", f_mouseshow);
CDEF("mousehide", f_mousehide);