Page 1 of 1

[Game] worm

Posted: Sun Sep 30, 2007 4:26 pm
by newdep
Here a Sunday afternoon game ;-)

(load "http://www.nodep.nl/downloads/newlisp/worm.lsp")

Norman.

Posted: Sun Sep 30, 2007 7:24 pm
by newdep
version 2 is updated, some tweaking done, added a new worm ;-)...

Posted: Sun Sep 30, 2007 10:07 pm
by newdep
version 3 is posted... thats it for today ;-)

enjoy..

Posted: Sun Sep 30, 2007 10:38 pm
by cormullion
Good stuff! Tomorrow, PacMan, perhaps?

I found that it didn't start reliable until I moved this line:

Code: Select all

(while (gs:check-event 2000)
   (gs:request-focus 'C)

Also, I tried to change the timings to get the movement smooth but fast. It's not easy! Sometimes I got:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 18 >= 14
at java.util.Vector.elementAt(Vector.java:432)
at CanvasWidget$MyCanvas.render(CanvasWidget.java:639)

Posted: Mon Oct 01, 2007 6:47 am
by newdep
cormullion wrote:Good stuff! Tomorrow, PacMan, perhaps?

I found that it didn't start reliable until I moved this line:

Code: Select all

(while (gs:check-event 2000)
   (gs:request-focus 'C)

Also, I tried to change the timings to get the movement smooth but fast. It's not easy! Sometimes I got:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 18 >= 14
at java.util.Vector.elementAt(Vector.java:432)
at CanvasWidget$MyCanvas.render(CanvasWidget.java:639)

thanks for the test...I thought about packman ;-) ..

Yes the speed is perhpas an issue, though I did not find any strange
behaviour bewtween my AMD64 3200+ and my Intel Dual Core..

the check-even I have left in 10000 and put in a (sleep 1) for the official delay.

I only need to use (gs:request-focus 'C) once on windows and Linux? I dont
know if macOS needs it inside the while loop..


But there is another problem ;-) that is flickering when the tail gets bigger
than 100.. On linux it realy starts flickering on windows its a little less bad..
But that is because I need to redraw the tags.. I did not find a good way
to "Append" tags actualy without deleting...

Posted: Mon Oct 01, 2007 10:36 am
by newdep
new version v0.5 ..lots of changes!!!

Posted: Mon Oct 01, 2007 10:50 am
by pjot
First run in Linux delivers this
peter[~]$ newlisp worm.lsp

array, list or string expected : (env "NEWLISPDIR")
If I put this variable to "/usr/bin" according to the example in the manual, I get this:
peter[~]$ newlisp worm.lsp

problem accessing file : "/usr/bin/guiserver.lsp"

However, in Linux the file 'guiserver.lsp' by default resides in "/usr/share/newlisp".

So after executing "export NEWLISPDIR=/usr/share/newlisp" in a Bash shell, your game runs fine, even on my Lifebook with a 700Mhz processor :-)

Peter

Posted: Mon Oct 01, 2007 10:52 am
by cormullion
I don't think request focus needs to be in the event loop. But worm wouldn't work for me unless I moved it to later in the script. Perhaps just before the event loop is OK.

Posted: Mon Oct 01, 2007 11:00 am
by newdep
Cormullion ->
The new version has het focus in the event loop, seems it needs to be there ;-)
better this way.. But is you speed oke on the Mac?


Peter ->
Is the speed fine on the 700 Mhz? (in version v0.5?, just uploaded)

Posted: Mon Oct 01, 2007 11:07 am
by newdep
Just found an issue.. v0.5

Seems that under Linux the speed it stable all the time..

But under windows the speed if full after playing it twice.. can find the problem.

Posted: Mon Oct 01, 2007 11:10 am
by cormullion
Focus is fine. It's very fast but choppy.

I get game over after five seconds or so. That's no fun... :(

Posted: Mon Oct 01, 2007 11:20 am
by newdep
Uploaded v0.7, which runs fine now on Windows and Linux.
Both have steady speed.

Its difficult to regulate the sloppyness, I dont see that here on window and
linux, could be specific MaC+java or even your fast CPU ;-)

Posted: Mon Oct 01, 2007 12:42 pm
by Lutz
newdep:
Also, I tried to change the timings to get the movement smooth but fast. It's not easy! Sometimes I got:

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 18 >= 14
at java.util.Vector.elementAt(Vector.java:432)
at CanvasWidget$MyCanvas.render(CanvasWidget.java:639)
The exception happens when Java is rendering the array of tagged objects and a tag is deleted at the same time. Try to use 'gs:hide-tag' and 'gs:show-tag' instead. Or do all 'gss:xxx-tag' operation with 'nil' as the last parameter, i.e:

Code: Select all

(gs:move-tag 'mytag x y nil) ; suppress screen update
Then after all tag operations do a 'gs:update' or any 'gs:xxx-tag' operation without the the 'nil' flag to force a re-rendering operation. If neither 'nil' or 'true' is given in a tag operation then guiserver.lsp assumes 'true'.


pjot:
array, list or string expected : (env "NEWLISPDIR")
Since version 9.2.1 NEWLISPDIR is automatically put in the environment when newlisp starts up. In /usr/share/newlisp on all UNIX and into %PROGRAMFILES%/newlisp on Win32.

Unfortunately the not-updated documentation for 'env' also uses NEWLISPDIR in an example but puts it in /usr/bin, this is where the confusion comes from ;). Since the last development version all demo files for guiserver are coded using

Code: Select all

(load (append (env "NEWLISPDIR") "/guiserver.lsp"))
and this should work on all platforms since 9.2.1

Lutz

Posted: Mon Oct 01, 2007 2:08 pm
by newdep
Okido, I changed towards your advice..

Lutz, I do have a sound problem though;-)

gs:play-sound does it 3 or 4 times and then its quiet nothing plays anymore...
Im wondering if that could be a timing issue in the event-loop or perhpas a
"sound close" inside java?

Norman.

Posted: Mon Oct 01, 2007 3:02 pm
by Lutz
Using sound-demo.lsp and a 11sec .wav file I could not repeat this on Mac OS X, loading the file 20 times.

Can you write a small routine to reproduce this? Did you see this on Linux or on Windows?

Lutz

Posted: Mon Oct 01, 2007 3:36 pm
by newdep
I think its a key-event or buffer update issue.. but not 100% sure..

here is the demo ->
(load "http://www.nodep.nl/downloads/newlisp/sound.lsp")
(it includes the wav file)

when you start it... press some random keys on the keyboard
and keep you ear on the sound...

Its also happens without pressing the keyboard checked now...


PS: only happens on Linux as it seems now..

Norman.

Posted: Mon Oct 01, 2007 3:55 pm
by Lutz
Perhaps a platform issue. On OS X this seems to run forever with or without keyboard input. When doing keyboard input the keyboard events are lined up, and the key doesn't display until the sound has finished. When presssing 1 to 9 in a row, they appear one by one after a plop. Sometimes the same number appears more than once, when 2 plops appear in-between serving the keyboard queue.

Lutz

Posted: Mon Oct 01, 2007 5:03 pm
by newdep
Yes could very well be a platform issue.. But i would expect Java to take
control of this..like tuning speed and threads in its VM.. But then again we have
the GS in between where we have an IO queue.. On windows its also different..odd ;-)

On linux, while NOT pressing keys its not constant a 1 second beep.. its
very random.. like a hickup in between.. then some silence..etc.. but the key-event
is here synchrone..though not inline with the beep..

well I think i have to live with it ;-)


PS: Could it behaps be related to the disk-read of the sound file? and buffering
related to that action?

Posted: Mon Oct 01, 2007 5:32 pm
by Lutz
In a later release gs:play-sound could be in an extra Java thread, so other events can be served during sound playing.

The choppiness (hickups) you are observing, is Java's carbage collection kicking in and absorbing cycles. For the time beeing the only thing you can do, is to make sounds as short as possible.

The IO queue will always be something, which has to be dealt with. Thats why real-world gaming software is interrupt driven. The moment you hit the button or move the stick, it gets served as a pirority.

Lutz

Posted: Mon Oct 01, 2007 6:21 pm
by newdep
Aha..yes i thought so... another java thread would be very welcom but
i think the GS should not have too many java threads running, but GS cant get around that..;-)

Is there a more direct way to communicate towards Java? I could emagine
that IPC's or pipe's are much quicker then network events for example... Or perhpas direct API calls or the whole guiserver.lsp in JAVA itself? ;-)

For now the networking speed is fine the only problem is indeed the Sync
of processes and the speed handling when building game-like applications
with GS... widgets do great and small canvas tools too..but i thing the "worm.lsp"
almost is on its limits regarding interaction of events..

Aaa its still a joy ;-)

regards, Norman.