Syntensity, however, is focused on games (at least for the near future), and it will launch with insta ctf as its main gameplay mode. So, over the last 4 days I wrote an insta ctf 'activity' for the Intensity Engine entirely from scratch. This ended up taking about 650 lines of code, split up into several components:
- GameManager: Keeps score, assigns players to teams, and in general manages the game. Plugins for the GameManager let you control things like what determines when the game is over (a high enough score, for example).
- Health: A plugin for the player class that adds a 'health' attribute ('state variable' in Intensity Engine terminology) to players, and manages player death and respawning.
- Firing: Handles guns and their behavior (including delays after firing, etc.). A SniperRifle example gun gives the 'insta' gameplay element - one shot and you're dead.
- CTF: A plugin for the GameManager that handles the flags and their behavior.
(All the code is already in the repo, if anyone wants to take a look.)
So, after eliminating all the hardcoded insta ctf stuff in Sauerbraten, we have come full circle to implementing an insta ctf game mode, but this time written in JavaScript, and it's just one example of an activity which the Intensity Engine can run. Amusingly, insta ctf in Sauerbraten and in the Intensity Engine look quite similar from the outside (well, they would if we used the same models), but the internals are entirely different.
Interesting idea you've done here, though, wouldn't Javascript be too slow to be adequate in this situation?
ReplyDelete@Alex:
ReplyDeleteJavaScript is only used for the high-level game logic. It wouldn't be fast enough for rendering or physics, but for what we use it it should be sufficient. And we use Google V8, which is quite fast for a dynamic language engine (and also getting faster all the time).
However, yes, this does mean the frame rate is lower than Sauerbraten would get on the same map.