Neither one nor Many

 
October 21 2012

Smash Battle is a really cool game made by Bert Hekman and Jeroen Groeneweg. Of which Jeroen is now a collegue of mine at Tweakers.net. It supports up to four players, you can use gamepads and the multiplayer is best out of five. You can get powerups in the game like extra damage, health pack, armor etc. :) (I see that in the codebase also a single player is under development!)

Network version

I decided to add a network multiplayer gametype to it, and I develop that in a separate branch. It supports more than four players.

Currently the network multiplayer supports only bullets and mines (your default equipment). Powerups do not yet appear. All damage to players or tiles is determined on the server. The clients are trusted though, to send their correct player positions, shots fired etc. You could theoretically cheat (up to a certain level) by modifying and compiling your own client, but it is far easier to implement a network multiplayer if I can trust clients somewhat. This can easily be rewritten though, and if you play with low lags you will probably not notice any difference. But I think you will notice if someone is cheating.

Pre-alpha test release

My fork is https://bitbucket.org/rayburgemeestre/smashbattle

It's a pre-alpha because the gametype is not completely finished yet, if there are more than two players a normal best out of five multiplayer starts. Once the game has started, you cannot join the server anymore. You can already test it out simply install the current release of Smashbattle.

On Windows:

  • It will default install to C:\Program Files\Smash Battle\
  • Extract the contents of smashbattle-pre-alpha.zip into your installation dir. (Use BattleXP.exe if you're running Windows XP)
  • If you changed the install location of it, modify the path in register_server.reg.
  • Double click the .reg file, now smashbattle:// protocol should be available.

On Ubuntu:

  • Put this line in your /etc/apt/sources.list: deb http://repository.condor.tv lucid main

  • apt-get update

  • apt-get install battle
  • cd /usr/share/games/smashbattle/ <<<<< important! the game expects level data in ".".
  • ./battle

Note that the update command might give you this if you are running 64 bit:

Ign http://us.archive.ubuntu.com quantal-backports/universe Translation-en_US
Fetched 1,032 kB in 30s (33.7 kB/s)
W: Failed to fetch http://repository.condor.tv/dists/lucid/main/binary-amd64/Packages  404  Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.

You can ignore this error and continue installing the 32 bit version.

The game should now run, but to use the pre-alpha, you have to replace the 'battle' binary with mine:

  • rm -f battle && wget http://blog.cppse.nl/battle && chmod +x battle
  • Edit: you may need to: apt-get install libsdl-net1.2

Server usage

You can start your server with these parameters:

Battle.exe -s 
Example: Battle.exe -s

Battle.exe -s <listen port>
Example: Battle.exe -s 1100

Battle.exe -s <levelname> <listen port>
Example: Battle.exe -s "TRAINING DOJO" 1100

In case no level is given as a parameter, the server will start with level selector. In case no port is given, default will be used (1100).

Client usage

To connect to a client, you need to have registered the .reg file. You can click links like:

smashbattle://<domain.tld>:<port>
Example: smashbattle://cppse.nl:1100

You could type such an url in your WINDOWS+R (Run command) or in command prompt start <url>.

If you do not like to register the .reg file, you can also give it to Battle.exe as a parameter:

Battle.exe <url>
Example: Battle.exe smashbattle://cppse.nl:1100

After you have set a server on your machine, you should be able to connect using ---> smashbattle://localhost:1100

The level names are

"TRAINING DOJO"
"PLATFORM ALLEY"
"PITTFALL"
"DUCK'N'HUNT"
"COMMON GROUNDS"
"POGOSTICK"
"LA MOUSTACHE"
"THE FUNNEL"
"BLAST BOWL"
"PIT OF DEATH"
"RABBIT HOLE"
"STAY HIGH"
"PIE PIT"
"SLIP'N'SLIDE"
"BOULDERDASH"
"SNOW FIGHT"

In game controls

  • F1 - toggle console (for debugging)
  • F10 - toggle fullscreen
  • F11 - toggle FPS
  • ESCAPE - pause menu

Default your keyboard controls are

  • a, s, d, w - left, duck, right, jump.
  • CONTROL - shoot
  • ALT - mine
  • SHIFT - run

Roadmap

  • Link gameloop to time
  • Create client and server class
  • Design efficient protocol
  • Create solution for lag
  • Introduce nicknames
  • Introduce ingame chat
  • Support powerups
  • Introduce more gametypes?
    • Red team vs Blue team
    • King of the Hill
    • Capture the flag
  • Refactor*
  • Merge with master

Refactoring:

While developing I sometimes put #include's above the function where I use stuff from it. This is when I feel like I might refactor the code, I can easily remove the #include again. Works for me, but it results in some stray #include's. Also I'm not sure about my design choice of making server and client singleton's (basically global classes). It was easy so I could weave the client/server code into the game rapidly, but I think it may need to integrate with the existing classes better, and use polymorphism a bit more here and there. Example: I have a few places in the code where I do different stuff based on Main::runmode static global, for server do this, for client do this..

Blog Comments (2)

Smithc717

website: http://bdbcbcdkedaeggee.blogspot.com/ @

2014-08-11 09:19:04

Hi there! Would you mind if I share your blog with my myspace group? There's a lot of people that I think would really appreciate your content. Please let me know. Many thanks bdbcbcdkedaeggee

Smitha907

website: http://ccbbfaebgafegege.blogspot.com/ @

2015-02-27 06:31:15

Appreciating the time and energy you put into your blog and in depth information you provide. It's good to come across a blog every once in a while that isn't the same unwanted rehashed information. Excellent read! I've saved your site and I'm adding your RSS feeds to my Google account. ccbbfaebgafegege


Leave a Reply

Comment may not be visible immediately, because I process everything manually.**

**) I plan to automate this.., but it's on my ToDo since for ever..


Author:
Ray Burgemeestre
february 23th, 1984

Topics:
C++, Linux, Webdev

Other interests:
Music, Art, Zen