[Gag] PinBalls

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

[Gag] PinBalls

Post by newdep »

Cormullion wanted collisions, Curmullion got collisions ;-)

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

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

cormullion
Posts: 2038
Joined: Tue Nov 29, 2005 8:28 pm
Location: latiitude 50N longitude 3W
Contact:

Post by cormullion »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

fantastic! better than TV

Lutz

rickyboy
Posts: 607
Joined: Fri Apr 08, 2005 7:13 pm
Location: Front Royal, Virginia

Post by rickyboy »

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
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

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:

Code: Select all

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

Code: Select all

(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

newdep
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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
Posts: 2038
Joined: Mon Feb 23, 2004 7:40 pm
Location: Netherlands

Post by newdep »

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
Posts: 733
Joined: Thu Feb 26, 2004 10:19 pm
Location: The Hague, The Netherlands
Contact:

Post by pjot »

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

Locked