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 : mode-move
entities each EVTICK entity>do more entities each EVTICK entity>do more
party each EVTICK entity>do more party each EVTICK entity>do more
tick-mapedit tick-mapedit jiles
tick-debounce tick-debounce
q-level @ dup if q-level @ dup if
0 q-level ! 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" entity.jor" loadfile
s" footer.jor" loadfile s" footer.jor" loadfile
s" map.jor" loadfile s" map.jor" loadfile
s" jiles.jor" loadfile
s" state.jor" loadfile s" state.jor" loadfile
s" game.jor" loadfile s" game.jor" loadfile
; execute ; execute

View file

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

View file

@ -1,62 +1,70 @@
: blah ' seremit task-emit ! ; var lcolor 0x0f lcolor !
blah var rcolor 0x10 rcolor !
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 spriteindex var spriteindex
var refresh-needed var refresh-needed
: refresh 1 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 ; : +sprite! spriteindex spritecount +!cycle refresh ;
: draw-palette 0 0x11 for i 79 i 3 << drawfatbox next ; : draw-palette 0 0x11 for i 79 i 3 << drawfatbox next ;
: mousepos>sprpos 3 >> swap 3 >> swap ; : mousepos>sprpos 3 >> swap 3 >> swap ;
: mousexys mousepos mousepos>sprpos spriteindex @ ; : 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 mousepos 128 < swap 128 < and if
MOUSEL mousedown if MOUSEL mousedown if lcolor @ mousepixel! then
mousexys getpixel color @ != if MOUSER mousedown if rcolor @ mousepixel! then
color @ mousexys putpixel
refresh
then
then
MOUSER clicked if
mousexys getpixel color!
then
then then
mousepos 136 < swap 312 >= and if mousepos 136 < swap 312 >= and if
mousepos swap drop 3 >> mousepos swap drop 3 >> dup
MOUSEL mousedown if color! else drop then MOUSEL mousedown if lcolor color! else drop then
MOUSER mousedown if rcolor color! else drop then
then then
^LEFT key-pressed if -1 +sprite! then ^LEFT key-pressed if -1 +sprite! then
^RIGHT 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 tick-debounce
; ;
: draw : jiles-draw
refresh-needed @ if refresh-needed @ if
mousehide mousehide
spriteindex @ drawfatsprite spriteindex @ drawfatsprite
color @ 78 0 drawfatbox lcolor @ 77 0 drawfatbox
rcolor @ 78 0 drawfatbox
draw-palette draw-palette
mouseshow mouseshow
0 refresh-needed ! 0 refresh-needed !
then ; then ;
mouseshow : jiles
refresh ^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() { void f_mousehide() {
mouse_hide(); mouse_hide();
} }
void f_mouseshow() { void f_mouseshow() {
mouse_show();
}
void f_resetvideo() {
setLogicalWidth(SCREEN_STRIDE >> 1); setLogicalWidth(SCREEN_STRIDE >> 1);
setResetEnabledCached(0); setResetEnabledCached(0);
setWriteMode(0); setWriteMode(0);
setAllPlanes(); setAllPlanes();
mouse_show(); setDisplayOffset(0);
setHorizontalPan(0);
} }
void f_putpixel() { void f_putpixel() {
@ -441,6 +447,7 @@ void game_f_init(char *exe, char *bootjor) {
CDEF("loadtiles", f_loadtiles); CDEF("loadtiles", f_loadtiles);
CDEF("glitch", f_glitch); CDEF("glitch", f_glitch);
CDEF("unfuck", tile_init); CDEF("unfuck", tile_init);
CDEF("fuck", f_resetvideo);
CDEF("mouseshow", f_mouseshow); CDEF("mouseshow", f_mouseshow);
CDEF("mousehide", f_mousehide); CDEF("mousehide", f_mousehide);