[Game] worm

Started by newdep, September 30, 2007, 09:26:34 AM

Previous topic - Next topic

newdep

Here a Sunday afternoon game ;-)



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



Norman.
-- (define? (Cornflakes))

newdep

#1
version 2 is updated, some tweaking done, added a new worm ;-)...
-- (define? (Cornflakes))

newdep

#2
version 3 is posted... thats it for today ;-)



enjoy..
-- (define? (Cornflakes))

cormullion

#3
Good stuff! Tomorrow, PacMan, perhaps?



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


(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)

newdep

#4
Quote from: "cormullion"Good stuff! Tomorrow, PacMan, perhaps?



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


(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...
-- (define? (Cornflakes))

newdep

#5
new version v0.5 ..lots of changes!!!
-- (define? (Cornflakes))

pjot

#6
First run in Linux delivers this


Quote
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:


Quote
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

cormullion

#7
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.

newdep

#8
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)
-- (define? (Cornflakes))

newdep

#9
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.
-- (define? (Cornflakes))

cormullion

#10
Focus is fine. It's very fast but choppy.



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

newdep

#11
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 ;-)
-- (define? (Cornflakes))

Lutz

#12
newdep:


QuoteAlso, 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:


(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:


Quotearray, 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


(load (append (env "NEWLISPDIR") "/guiserver.lsp"))

and this should work on all platforms since 9.2.1



Lutz

newdep

#13
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.
-- (define? (Cornflakes))

Lutz

#14
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