Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

2-browser interactive (2D) tankbattle game written in perl

by hackmare (Pilgrim)
on Feb 09, 2002 at 23:15 UTC ( #144413=CUFP: print w/replies, xml ) Need Help??

100% served in perl.

Warning, it is rendered in SVG and requires javascript & uses frames. NS and IE do fine with it on windows. Not sure if it works on NS6.X, or Mac OS.

What it is:

It's a nettrek-inspired prototype of a 2-player game (a currently non-shooting version of tank battle) that demonstrates browser-browser interaction without special software (I am using SVG but this could be dhtml too).

How you play...

Two people on 2 PCs can play this game: Each person goes to the game starting page, and one person starts player 1, sends the passkey to player 2, and waits for player 2 to start.

Player 2 starts. Uses the key passed on to register into the game session, and gets going. (caution: There is no error-catching for typos on the keys right now)

The game: click here

The concept:

Each invocation of the game writes a set of lockfiles (1 per browser,hence the passkey) on the server, which stores the last command uttered by either side through a cgi-based GUI (the think that kind of looks like a tank on the top-left window).

When client browser is launched, a single frameset is generated showing the tanks. The frameset contains two frames:

  1. the visible SVG-rendered game
  2. a hidden frame containing some control javascript.

The hidden frame refreshes every 30 seconds, and is a perl-driven cgi which reads the content of each lock file and transmits the commands back to the frameset. The visible frame has access capability to the hidden frame and reads the changed values, giving changes in motion of the vehcles and their gun turrets.

The source code is available here (zipped format).

As I said above, this is a prototype. Please don't forget that :)

A single person can test this by themeselves by first taking the role of player 1 and initiating a session, and then taking the role of player 2 and joining the game. NB: The player-2 control window opens exactly above the payer 1 control window.


  • Comment on 2-browser interactive (2D) tankbattle game written in perl

Replies are listed 'Best First'.
Re: 2-browser interactive (2D) tankbattle game written in perl
by cmilfo (Hermit) on Feb 11, 2002 at 06:37 UTC
    Excellent! It reminds me of the old Atari game (name escapes me now). Next add some walls, etc. or maybe airplanes and clouds. :-)

    I am excited to see some SVG development going on. I've been using Scalable Vector Graphics for about four months now. It's a lot of fun. Have an open standard is nice, and it's even nicer that SVG is XML based. We use it to display wave approximations in our math research. The coolest thing is to right click, view SVG source, and there are all the data points!

    These guys have *excellent* examples.


      If anyone is interested, I am presenting a paper on this at the SVG:Open converence in Zurich in July, and holding a workshop on SVG-Browse-Database interaction.

      If I can find the time, I'll also present something at YAPC::Europe

      Andreas Newmann from is putting the SVG conference together.


Re: 2-browser interactive (2D) tankbattle game written in perl
by kwoff (Friar) on Feb 10, 2002 at 11:36 UTC
    Cool. I didn't know about SVG. The roasp site seems to have some nice tutorials, though.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://144413]
Approved by root
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2023-01-29 18:49 GMT
Find Nodes?
    Voting Booth?

    No recent polls found