[Gag] PinBalls

Started by newdep, October 05, 2007, 02:30:37 AM

Previous topic - Next topic

newdep

Cormullion wanted collisions, Curmullion got collisions ;-)



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



Enjoy! ;-)
-- (define? (Cornflakes))

cormullion

#1
And they're great! Such a small amount of code too - really clever!



I'd much rather watch a few balls slapping together than loads of balls ignoring each other...



Thanks!

Lutz

#2
fantastic! better than TV



Lutz

rickyboy

#3
My daughter and I agree with Lutz -- it's better than TV.  But, Norman, you are doing nothing to help her get her homework done.  :-)
(λx. x x) (λx. x x)

Lutz

#4
Norman, with your permission I would like to include your wonderful pinballs.lsp in the set of demo apps in the newLISP distribution? It is a great example for doing animations and how to use the 'gs:check-event' function. I made some minor modifications/simplifications:


(sym (string "C" t))

; changed to

(string "C" t)


when using tags, strings and symbols work equally well. The reason that most of the time symbols are handier is, that there is less typing. But when creating composite tags, as is the case in pinballs.lsp, there is no need to convert the strings back to symbols.


(first (randomize M ))

; changed to

(apply amb M)


The 'amb' function picks/evaluates one of its arguments at random. The function 'randomize' is relatively expensive and your case you need only one value from the list, so applying 'amb' to the list will save CPU cycles but gives you the same result of picking from a list a number by random.



Lutz



ps: I also eliminated the changing of the background color which could give the impression that the animation is not flicker free. Here is the modified version: http://newlisp.org/code/pinballs.lsp">http://newlisp.org/code/pinballs.lsp

newdep

#5
Sure no problem..I like the applet a lot, its so simple it does keep me stuck

to the screen looking at it (its like a Jerry Springer show) ;-)



The amb is a good solution, I never used it befor.. I do though use

the (sleep 1) (which is iniitial usefull for the first ball drawing, without the

(sleep 1) the start is too quick on linux.. but you can leaf it out...)..



yes the (sym (string... I forgot to remove that because I first had

a different update-circle function..



The code can be written even shorter when i move the BOUNDS into

the CIRCLE list, but that makes it a little harder to read/understand.





Regards, Norman.
-- (define? (Cornflakes))

pjot

#6
Just some knowledge sharing on newLisp and the Java GUI.



Today I reinstalled my computer with Linux and I also installed the latest newLisp version (9.2.3).



The pinballs demo did not work! Why not?



It appears that Java uses the system-wide DBUS daemon which did not run on my system. Once activated the pinballs demo ran fine.



So in the future, if Linux users have problems with the Java Guiserver, verify if the DBUS daemon is running.



Peter

newdep

#7
Thanks for the info, but ist it the other way around?



D-Bus is an IPC mechanism which at a low level uses message passing over Unix Sockets or IP. D-Bus models its messages as either function calls on remote objects, or signals emitted from them.



As i understand it, D-bus (dbus) is not part of Java but an extention on your linux system. (probably used together with your Desktop type).



I use KDE and xfce and dont have anything on my system regarding dbus.

(i dont have any dbus deamon running nor a dbus library nor any IPC sockets pointing to dbus names when running java...I do have UNIX and

pipes open when running java but nothing pointing to dbus..)



I installed java manualy btw..



Norman.
-- (define? (Cornflakes))

pjot

#8
DBUS is not part of Java but of my Linux installation. Somehow Java seems to be using it.



I disabled DBUS and tried again, with the same result: if it is not activated your demo does not run properly.



Peter