Development

Thursday, January 17, 2013

Galaxy map and screenshots

The galaxy map is the first screen I develop to show the generated galaxy data in game. I had some distress regarding the Ogre integration's functionality, because I didn't used the scenenode, camera and light system yet, but it turned out to be seamless, and easy to make. Thanks to SWIG!

I've made and uploaded some screenshots and video about the actual game startup, new single player screen functionality, galaxy generation progress and the first display of galaxy map into the media section.


In YASTACS the galaxy is divided into sectors, where the user visitable planetary systems, clouds, asteroid belts, etc. reside. The galaxy map shows the entire galaxy in miniature, where the player can fly around and get information about the sector.  Blue cubes image the sectors in 3D space (at the moment), that the user can sense the distance and relative position of them.

The next steps are to implement mouse look and sector info display. And of course the gui needs a skin change desperately too! :)

Thursday, January 10, 2013

Embed ECL and run swank on Windows (Part 1)


aka how to get a lisp console to your (running) game?

There aren't many choices if you want a Common Lisp interpreter embedded in your application. In fact, I only found ECL, thats made and suitable for this. Its only downloadable in source code form, but its very easy to compile - even under Windows.

Ok, we found a suitable Lisp, time to think about the script development. Wouldn't be nice if we had an environment to develop, load and test the game scripts, alter parameters, etc while running the game? Well, there is THE free Lisp development environment: Emacs + Slime. And you can use it to connect to remote lisps to work with them! Thats my solution.

In this article I explain the necessary steps to get an Emacs Slime session to a separatelly running Lisp instance. In the next article I'll explain how to embed ECL into D applications.

Building ECL

You have to edit a Makefile to enable some features, and fire away nmake at the Visual Studio command prompt in msvc directory. Not in the docs, but you'll need the yasm assembler installed somewhere on path too. After this, an nmake install creates a package directory with ECL executables, libs and other system components.

Slime/swank

If your a lisper, you know what to do to get, install and use Slime. For the game console we need only the lisp engine side parts of it, named swank. The other part is run by Emacs, when you M-x slime-connect.

Swank is the *.lisp and the ChangeLog files from the Slime package in the root and contrib directories. The listing to the rigth shows them.

Running swank

First, we have to load and run swank in our ECL instance. This is accomplished in a fairly standard way. The only problem is, that ECL (under Windows) only supports the NIL communication style, and this doesn't work very good with Emacs Slime interactive mode.

For a seamless cooperation you need to run swank in a separate thread (process in ECL/Lisp terms) from top level. The solution is in this ecl user mail list post.

Here comes the procedure to run swank in ECL:

1. Make sure, we have our swank on ASDF load path:
>ecl
ECL (Embeddable Common-Lisp) 12.12.1 (git:UNKNOWN)
Copyright (C) 1984 Taiichi Yuasa and Masami Hagiya
Copyright (C) 1993 Giuseppe Attardi
Copyright (C) 2000 Juan J. Garcia-Ripoll
ECL is free software, and you are welcome to redistribute it
under certain conditions; see file 'Copyright' for details.
Type :h for Help.  Top level in: #.
> (require "asdf")
;;; Loading #P"c:/zzzz/asdf.fas"
("ASDF")
> (push #p"zzz/swank/" asdf:*central-registry*)
(#P"zzz/swank/")
> (push #p"zzz/swank/contrib/" asdf:*central-registry*)
(#P"zzz/swank/contrib/" #P"zzz/scripts/swank/")
2. Load swank:

> (require "swank")
;;; Loading "zzz/swank/swank.asd"
;;; Loading "zzz/swank/swank-loader.lisp"
...
;;; Warning: These Swank interfaces are unimplemented:
 (ACTIVATE-STEPPING ADD-FD-HANDLER ADD-SIGIO-HANDLER BACKGROUND-SAVE-IMAGE DUP  EXEC-IMAGE FRAME-CALL LIST-CALLEES LIST-CALLERS MACROEXPAND-ALL MAKE-FD-STREAM  REMOVE-FD-HANDLERS REMOVE-SIGIO-HANDLERS RESTART-FRAME RETURN-FROM-FRAME  SAVE-IMAGE SLDB-BREAK-AT-START SLDB-BREAK-ON-RETURN SLDB-STEP-INTO  SLDB-STEP-NEXT SLDB-STEP-OUT TOGGLE-TRACE) ("SB-BSD-SOCKETS" "SOCKETS")
 3. Start swank server in separate thread, on port 55555:
 >   (mp:process-run-function "swank"
                  #'(lambda ()
                      (swank:create-server :dont-close t :port 55555)))
#
> ;; Swank started at port: 55555.
 Swank is running, our Lisp is waiting for connections and hack. Jump over to Emacs, and try to meet!

Connecting from Emacs/Slime

In Emacs we must run M-x slime-connect, and give Slime the host name and port, where swank is listening. After this M-x eval expression, (slime-setup '(slime-fancy)) and voila!