View Full Version : Jive and the Space Invaders
A friend of mine pointed me to this new mystery project.
Looks very interesting. Can't wait to see on what platform this will actually run in the end.
I started to play around with programming a new applet and this is what I came up with...
A simple Space Invaders clone. Coded and tested on SVN r167.
Some things I didn't figure out yet:
- Is it possible to have multiple applets use a single top level menu entry? ie. Games > Space Invaders, Breakout, Tetris etc.
- All the created Images and Surfaces are automatically Garbage Collected. Is it also possible to clean unused surfaces up from the Lua code?
- There are some applets to control the SlimServer which for some reason weren't loaded correctly on my build haven't figure out why yet. Didn't see any errors in the console. (Could be current SVN r167 has this problem?)
That's all for now. Back to try some other stuff. :-)
rtitmuss
2007-07-22, 08:41
A simple Space Invaders clone. Coded and tested on SVN r167.
This is very cool :-D
- Is it possible to have multiple applets use a single top level menu entry? ie. Games > Space Invaders, Breakout, Tetris etc.
Yes, I'll post an update version that adds a Game sub-menu, and a few other changes later.
- All the created Images and Surfaces are automatically Garbage Collected. Is it also possible to clean unused surfaces up from the Lua code?
Sorry I don't understand what you are trying to do? For a games applet it would be better to preallocate all the objects to minimize garbage collection while it's running.
- There are some applets to control the SlimServer which for some reason weren't loaded correctly on my build haven't figure out why yet. Didn't see any errors in the console. (Could be current SVN r167 has this problem?)
You need to be running slimserver 7.0 and have at least one Squeezebox/Softsqueeze connected, otherwise you won't see much.
That's all for now. Back to try some other stuff. :-)
Great :-)
rtitmuss
2007-07-22, 08:46
A screenshot for people how don't have Jive working yet.
rtitmuss
2007-07-22, 15:30
Attached is an updated Invaders, in three parts as the zip file was too big for the forum. The changes are:
- Added a Games sub-menu.
- Added support for scroll wheel and Go button.
- Added sounds.
- Fixed window transitions at the end of the game (you'll need svn r168).
I am not sure these are the right sounds for this version of the game, but it demonstrates what's possible. I just found them after a quick web search here: http://www.planetalia.com/cursos/Java-Invaders/JAVA-INVADERS-27.tutorial. At the moment Jive only supports two channels for sounds, but this might be limiting for games. Do you think more channels should be supported by the platform?
The game runs a little slow on the target platform, but it is still playable (my 8 year old son has been playing it this afternoon :) ). It also blocks on occasion. I have not checked why this is yet, but it may be related to the garbage collector. Preallocating the objects used would help here. It would be good if you could use the lua profiler (included in the jive application) to see what areas need optimization. If necessary we can add additional methods in C to the jive framework for specific functions that are slow, for example the collision detection.
Keep up the good work!
Wow.
Thanks for the feedback and improvements.
I played around a bit more and Slim Server integration works now.
I hopefully will have some time later today to look at some possible optimizations using luap.
I am also working on a Breakout/Arkanoid clone but it isn't nearly as polished as Space Invaders.
Very nice. Playing it brings back old memories :)
Re. optimization, be aware class:method() is about 2x slower than procedure and 4x slower than _local_procedure(). Try to use local functions as much as you can, potentially using closures.
Fred
Here is the updated Space Invaders with the suggestions from Fred.
I am using local functions for all functions which are called very often (Updating Positions / Movement, Collision Detection, Main Gameplay Tick)
It seems to be running slightly faster on my jive emulator. Profiler data has improved a bit as well.
What I also noticed is with the profiler activated I see the same short "blocks" you see on the target platform. This is when the profiler is writing a chunk of its data down to the hard disk.
rtitmuss
2007-07-27, 03:28
Thanks, that is an improvement. Updating the screen is working fine, but the problem seems to be controlling the blaster. If you only shoot or more occasionally it's ok, but with lots of movement/shooting I think the event queue is backing up.
I'll try to find some time to profile it on the target platform later, and see if I can spot areas for improvement.
whatisron
2009-01-02, 11:35
The sound effects don't work (they crash in the call to loadSound) and are the reason Invaders doesn't work presently. Here is an updated Invaders that works in 7.3.1
www.wellbaby.org/squeeze
Powered by vBulletin® Version 4.1.12 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.