Tutorial 3 was pretty long-winded, so if you made it through that it’s time for something simpler. Today we’re gonna write our very first mini-game.
Make sure you’ve done Tutorial 1 so you know how to issue commands to the game and Tutorial 3 so you know where to put game scripts.
This mini-game we’ll be making doesn’t actually do anything; it just ends after 5 seconds and gives all teams a score of 0, so the game comes out a draw. That’s ok though; the point is to show what a bare-bones mini-game looks like; we’ll make it fancier in a later tutorial.
When BombSquad gathers its list of mini-games, it simply scans through all modules in its user and system scripts directories looking for ones that define a ‘getGames()’ function.. so to add a game we simply have to write a module that provides that function.
Create a file named HelloWorldGame.py (or whatever you want to call it), paste the following code in, and drop it into BombSquad’s user-scripts directory. You can use the ‘Show Mods Folder’ button in Settings->Advanced if you’ve forgotten where this is. (‘mods folder’ is just another term for the user scripts directory).
import bs # scripts specify an API-version they were written against # so the game knows to ignore out-of-date ones. def bsGetAPIVersion(): return 3 # how BombSquad asks us what games we provide def bsGetGames(): return [HelloWorldGame] class HelloWorldGame(bs.TeamGameActivity): @classmethod def getName(cls): return 'Hello World Game' @classmethod def getDescription(cls,sessionType): return 'Just a test game.' def onBegin(self): bs.TeamGameActivity.onBegin(self) # game's starting - let's just set a timer to end it in 5 seconds bs.screenMessage("Hello World! Ending in 5 seconds...") self._endGameTimer = bs.Timer(5000,bs.WeakCall(self.endGame)) def endGame(self): # game's over - set a score for each team and tell our activity to finish ourResults = bs.TeamGameResults() for team in self.teams: ourResults.setTeamScore(team,0) self.end(results=ourResults)
Now, to try out your shiny new mini-game, launch BombSquad, create a new game list, and add a game to it. You should see ‘Hello World Game’ in the list of available game types. When you run the game you should just see it print its message and end.
If you’d like documentation on any of these classes or methods, take a look at the BombSquad Python API Docs.
Well, that’s it for this tutorial.. next time we’ll start to add logic to our game to make it actually worth playing… stay tuned. (or if you’re impatient, you can look through BombSquad’s system scripts directory at all the built-in mini-games as reference)
5 thoughts on “BombSquad Modding Guide Episode 4: Writing Your First Mini-Game”
I own Bombsquad on OUYA. Funny as heck!
But a question is: Will there be a PC port for Steam?
This script starts the game, but doesn’t end it.
I have using the following code : http://pastebin.com/mmCMf3SB
I made some changes in the Python API for version 1.3.24 and the code in the tutorial was out of date, so it was probably spitting some errors.. I’ve updated it now so it will work if you’d like to try again. Sorry ’bout that; I’m aiming to have the API nice and cleaned up (and hopefully stable) by version 1.3.26 or so..
Hola creador de bomb squad ehhh este estaba pensanda en que si pudieses agrerar personajes nuevos a la lista o mapas nuevos seria maravillóso
Pst el juego es increíble hasta el momento te damos entre yo y mis compañeros una 100 estrellas es lo mejor para pasar el rato
how to used this syntax??