A package that makes it possible to make a game in steam with flutter! It combines steamworks and flame.
The goal of this library is to provide complete coverage possible over steam api. We can split functionality provided with the steam api into three categories:
- Initilization, common apis
- Asynchronous callbacks
- Asynchronous call results
You can get detailed information about these from the steam docs
You need to steam_api.dll and steam_api.lib to be able to use this package. You can either download from here by signing in or you can use the files under the example. If you chose to download from steam, the files are under redistributable_bin
.
First we need a game right! Lets make it.
class GameInstance extends FlameGame with KeyboardEvents, HasSteamClient {
GameInstance() {
init(); // it is important to call this to initialize steam api
}
}
HasSteamClient
mixin provides a simple api to register a callback. You can register a callback in any place in the code
class GameInstance extends FlameGame with KeyboardEvents, HasSteamClient {
GameInstance() {
init();
registerCallback<UnreadChatMessagesChanged>((data) => /*do what you want*/);
}
}
There are many callbacks in steam api, you check all of them on steam docs.
HasSteamClient
mixin provides a simple api to register a call result. Call results are a little different from callbacks. Before you subscribe to call result, you need to make a request and subscribe to result of that request.
class GameInstance extends FlameGame with KeyboardEvents, HasSteamClient {
// We wait for space key to be pressed and if it is then we make a request for UserStatsReceived an subscribe to its result
@override
KeyEventResult onKeyEvent(
RawKeyEvent event,
Set<LogicalKeyboardKey> keysPressed,
) {
bool isKeyDown = event is RawKeyDownEvent;
bool isSpace = keysPressed.contains(LogicalKeyboardKey.space);
if (isSpace && isKeyDown) {
CSteamId steamId = steamClient.steamUser.getSteamId();
SteamApiCall callId =
steamClient.steamUserStats.requestUserStats(steamId);
registerCallResult<UserStatsReceived>(
callId,
(ptrUserStatus, hasFailed) {
print("User stats received");
print("GameId: ${ptrUserStatus.gameId}");
print("SteamIdUser: ${ptrUserStatus.steamIdUser}");
},
);
return KeyEventResult.handled;
}
return KeyEventResult.ignored;
}
}
There are many call results in steam api, you check all of them on steam docs.
Here are a list of games that have been published on Steam that utilise this package:
- Omnichess - https://store.steampowered.com/app/2009510
Well, steam is the limit!