[Hive Game] Back to Hive P v. S this week

in Game Development2 years ago

Back at it

Lack of updates regarding TMoS for past two weeks has been due to getting a fling of the flu. This week it has been all good again and got back to development. Instead of working on TMoS, most of the week was spent on fixing post release issues and adding new functionality to Hive P v. S.

KILLEDTAIL_done.jpg
Achievement for killing part of the enemy tail. Image Jens Nilsson

Hive P v. S

When Hive P v. S was released on Steam, I used Greenworks to add support for the Steamworks SDK. I had not intended to make any use of it, except to know when the Steam overlay was opened so that I could pause the game.

While fixing some issues that have shown up as the game has been played on Steam, I decided to implement Steam Achievements. A look a the documentation showed that it was a simple process with few steps.

  1. Create an achievement in Steamworks by giving it an ID, name, description and one graphic for when you have achieved it and one for when you have not.
  2. Using Steamworks SDK (or Greenworks in my case), store the achievement completed when the player does so and when suitable send it to Steam servers for permanent storage.
  3. Update game code with the places you want to trigger completed achievements.

KILLEDBH_done.jpg
Achievement for main objective of the game. Image Jens Nilsson

As I use Electron to package my game as a native application, I had some additional issues to solve. The process that renders the game is separate from the process that runs the application, this to make the application safer, as in essence it is a browser with unlimited access to the computer. While player progress happens in the render, Greenworks runs in the application process, therefor I had to add means for the two of them to communicate. For a little while I thought I had to add electron as a dependency to the render code, which would have complicated the otherwise clean code that makes it possible to have same code for web, mobile devices and computers. Thankfully, after some searching I found an example of how to implement it in a way that added no new dependencies to the render code.

The original solution: https://stackoverflow.com/a/68581487

How I used it to send Steam achievement notices from Electron render to Electron main.

//preloads.ts file
import { ipcRenderer, contextBridge } from "electron";

// Setup sending notices about achievements.
contextBridge.exposeInMainWorld("electron", {
    notificationApi: {
        sendNotification(achievement: string) {
            ipcRenderer.send('SteamAchievement', achievement);
        }
    }
});

//index.ts file (main electron)
ipcMain.on('SteamAchievement', (event, achievement) => {
    // Greenworks code to check if achievement should be acheived or already is.
});


//app.ts file (render process)
globalThis.electron.notificationApi.sendNotification(achievement);

For sending the notices I created a simple helper method, that I could call in the appropriate places to trigger an achievement. To keep it nice and tidy I made an enum with the 40 achievements and used it with the helper method.

// Enum
export enum Achievement {
    HighScore = "HIGHSCORE",
    Tutorial = "TUTORIAL"
    // ... etc
}

// Helper method
steamAchievementTrigger = (achievement: Achievement) => {
    // ... Some additional code to only do when in electron, and only once.

    // Send notification to electron.
    globalThis.electron.notificationApi.sendNotification(achievement);
}

// ...In the high score check, trigger achievement for not good enough for high score table.
if (noHighScore) {
    // Achievement
    this.props.app.steamAchievementTrigger(Achievement.NoHighScore);
}

// Greenworks in the main process
// ... Some additional greenworks code to check if achievement not already achieved.
// Local set it achieved.
greenworks.activateAchievement(achievement,
    () => console.log(`Achieved: ${achievement} ok!`),
    (error: any) => console.log(`Failed: ${achievement}, error: ${error}`)
);

// Send it to Steam for permanent storage.
greenworks.storeStats(
    () => console.log(`Stored: ${achievement} ok!`),
    (error: any) => console.log(`Failed storing: ${achievement}, error: ${error}`)
);

That sums it all up for adding the achievements, only 39 more this.props.app.steamAchievementTrigger(Achievement.?); was added to the code... Or rather 9 more, as 20 are for levels and 10 are for power ups, which could be triggered in two places.

PUFREEZE_waiting.jpg
Power up achievement not yet achieved. Image Jens Nilsson

The achievements are not yet live on Steam, currently testing them in the beta before pushing them live.

Thanks for reading, next week it is back to TMoS!


Spelmakare is game development using web technologies.

Spelmakare.se
Discord
GitHub
Play Hive P v. S

Sort:  

Yes! Looking foward to this new addition. How was the publishing progress on Steam?

Hey! Out of the 5 stores I have released on, steam is the most work and also the one that (temporary) costs the most. You get the money back when/if you sell for 100 USD.

There is a lot of info and a lot of graphics to create for the steam store. I think it can be a bit confusing how it all goes together with what you have to configure and how to upload your game. But, there is a lot of documentation to follow, developer groups to ask and a support that actually answer any questions within 24h. Do it once and then it makes a lot more sense for the future.

Steam is far superior to the others that they actually have a system that works to give new titles exposure and get views to your game. I definitely think steam is by far the most important store to release on and one that is worth doing so on.

If you release there and need any help, I'd be happy to help you out.

Yeah I always felt that is the kind of the best store in that sense. Still I'm undecided to publish A wild sprite there. Thank you for these insight! Will try to look them deeper. Gonna try the new achiviement system of Hive PVS :D

Congratulations @smjn! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s):

You distributed more than 66000 upvotes.
Your next target is to reach 67000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Check out the last post from @hivebuzz:

The fourth edition of Hive Power Up Month started today. Don't miss it!
Hive Power Up Day - April 1st 2022
Support the HiveBuzz project. Vote for our proposal!