Live demo

Play a TV game with real SofAds ads.

Couch Stars runs the real SofAds SDK, the way a TV app does. At each level break it shows an ad, and when you run out of lives it offers an extra life for a rewarded ad: scan its QR code with your phone and the reward unlocks on the TV.

SofAds
Arrow keys move, Enter is OK, Escape or Backspace is BACK. Or use the remote, or tap the left or right half of the screen.
What the SDK is doingcalls, events and requests, live

Not loaded yet. The game loads the SDK when you press Play.

  1. Nothing yet. Press Play: the game loads the SDK and calls SofAds.init.

The code

Everything the game does with SofAds is in this one file, ads.js: the same three calls as the snippet on our homepage, plus the event hook that feeds this log.

// The SofAds part of the demo game: the same calls as the homepage snippet.
// The game loads the SDK's script-tag build (the global SofAds) before this file.

// At launch: start the SDK. It never throws and never blocks the game.
export function startAds(appId, bootstrapUrl) {
  return SofAds.init({
    appId: appId,
    platform: "web", // an explicit desktop/demo build
    bootstrapUrl: bootstrapUrl || undefined, // empty: the SofAds ad server
  });
}

// Between levels: one interstitial. The game waits for it, whatever happens.
export function levelBreak() {
  return SofAds.showInterstitial({ placement: "level_break" });
}

// After losing, when the player chose to watch an ad for an extra life.
export function extraLife(game) {
  return SofAds.showRewarded({
    placement: "extra_life",
    onReward: () => game.addLife(),
  });
}

// The panel next to the TV listens to the SDK's public events.
export function watchAds(log) {
  const events = ["ready", "request", "fill", "no_fill", "show", "impression", "quartile", "complete", "skip", "reward", "close", "error"];
  for (const name of events) {
    SofAds.on(name, (data) => log(name, data));
  }
}

What you are looking at

  • Test ads only. The demo is its own app on SofAds, and it only ever gets SofAds test ads: the test video between levels and the rewarded scan test ad. They are never billed, earn nothing and never count in anyone's stats.
  • The scan is real. Scan the QR code of the rewarded ad with your phone. Our ad server records the scan, the phone opens a "Scan worked!" page, and the SDK unlocks the reward on the TV.
  • Never blocks the game. Every SDK call resolves, ad or no ad. If the ad server can't be reached, or you have seen a lot of ads in a minute, the game simply carries on and the log says why.
  • The real screen size. The game and the ads render at 1920×1080, like on a TV, scaled down to fit your screen.