Space Invaders

From awesome
Jump to: navigation, search

Awesome Invaders[edit]

Introduction[edit]

Screenshot of Awesome Invaders

Awesome Invaders is, as the name says, an implementation of Space Invaders using Awesome 3's Lua interface. Everything is displayed using the new WiBox from Awesome 3 GIT, which allows arbitrary placement of widgets anywhere on the screen. On this page, I will walk you through setting it up and running.

Setting it up[edit]

Prerequisites[edit]

  • Awesome 3 GIT, get this from git with the following command:
 git clone git://git.naquadah.org/awesome.git

Editing the config file[edit]

Open up ~/.config/awesome/rc.lua with your favourite editor. The top of the file should look like this (or similar):

 require('awful')
 require('beautiful')

Add the following line below the last line containing a require, in this case, you would add it after require('beautiful'):

 require('invaders')

The result should look similar to this:

 require('awful')
 require('beautiful')
 require('invaders')

Then, find the section of your configuration file where keybindings are set. It may look something like this:

 [...]
 keybinding({ modkey, "Mod1" }, "c", function () client.focus:kill() end):add()
 keybinding({ modkey }, "Up", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
 keybinding({ modkey }, "Down", function () awful.client.focus.byidx(1);  client.focus:raise() end):add()
 keybinding({ modkey }, "Left", function () awful.client.swap(1) end):add()
 [...]

Add a keybinding to start invaders like this:

 keybinding({ modkey, "Mod1" }, "i", invaders.run):add()

Running the game with awesome-client / the lua prompt[edit]

You can also run the game without the need to edit your config file. Simply run awesome-client in a terminal, then run the following two commands:

 require('invaders')
 invaders.run()

The same can be done with the lua prompt if you are running Awesome from the next branch of the git repository.

Running the game without awesome-client[edit]

To start the game, press the keybinding you just specified. If you copied the above one, hit Modkey+Alt+i. Pressing left and right moves your spaceship, space fires. If you want to quit the game, press Q. Pressing S will create a screenshot in ~/.cache/awesome. For creating screenshots, you need ImageMagick installed.

Note #1: On some systems, X and awesome might eat a lot of ressources while running Space Invaders. This performance impact should vanish once you quit the game. If not, let me know about it.

Note #2: If you run the game on top of other windows, you will notice squares around the player and enemies. Through these squares, the screens background is shining through, therefore, it is the best if you run the game on a free tag with no windows behind it.

Running the game from the awesome menu[edit]

After requiring invaders from either your rc.lua file or awesome-client, you can launch the game from your awesome menu with this entry:

  { "Invaders", invaders.run }

Acknowledgements[edit]

I wrote the code for the game, while Garoth made the sprites. If you want to comment, complain, compliment on this piece of code, please keep in mind that this is more of a proof-of-concept than of a completely functioning game, and drop me a line in #awesome.

Also, if you are having problems, please make sure to grab the latest GIT checkout.

Have fun playing :)