Openfeint extension for Marmalade

We wanted to integrate Openfeint in our game BLAZ3D but there was no extension in Marmalade, the game engine we used. We decided to create an Openfeint extension for ourselves.
The extension and relevant documentation is available on Marmalade Github Community repo at[highlight type=”two”]https://github.com/marmalade/openfeint[/highlight]

The extension supports following API
[list style=”arrow” color=”blue”]

  • User login/approval
  • Display of Main dashboard
  • Display of dashboard directly to specific page like Challenges, Acheivements, Leaderoards (iOS Only)
  • Sending of challenges (iOS Only)
  • Highscore submission to leaderboards
  • Acheivement unlock
  • iOS Push Notifications for Openfeint (iOS Only)
[/list]  

Some sample code snippets (Not all API is available on Android as OpenFeint doesn’t support them either)

 

Initialising OpenFeint


s3eNOFSettingVal *settings = (s3eNOFSettingVal*)s3eMalloc(sizeof(s3eNOFSettingVal) * 6);
// Fill settings
// UIOrientation value
strncpy(settings[0].m_varName,
"OpenFeintSettingDashboardOrientation",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
settings[0].m_intVal = s3eNOFUIInterfaceOrientationPortrait;
//
// Shortdisplay name
strncpy(settings[1].m_varName,
"OpenFeintSettingShortDisplayName",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
strncpy(settings[1].m_stringVal,
"FunkyRacers",
S3E_NOPENFEINT_STRING_MAX);
// Push Notification Setting
strncpy(settings[2].m_varName,
"OpenFeintSettingEnablePushNotifications",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
settings[2].m_intVal = 1; // TRUE/YES
//
// Sandbox Notification Mode
strncpy(settings[3].m_varName,
"OpenFeintSettingUseSandboxPushNotificationServer",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
settings[3].m_intVal = 1;
//
// Disable User generated content
strncpy(settings[4].m_varName,
"OpenFeintSettingDisableUserGeneratedContent",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
settings[4].m_intVal = 0;
//
// Disable ask for approval in debug mode
strncpy(settings[5].m_varName,
"OpenFeintSettingAlwaysAskForApprovalInDebug",
S3E_NOPENFEINT_SETTINGS_STRING_MAX);
settings[5].m_intVal = 0;
//
s3eNOFArray array;
array.m_count = 6;
array.m_items = settings;
s3eNOFinitializeWithProductKey("PRODUCT_KEY_HERE",
"APP_ID_HERE",
"RacingGame",
&array);
s3eFree(settings);

Launch Main Dashboard after login


// Open Main Dashboard
// s3eNOFlaunchDashboard();

Pull Information about all achievements for user


const unsigned int max_achievements = 20; // whatever we think is max we need
void* data = s3eMalloc(sizeof(s3eNOFAchievement) * max_achievements);
if (data == NULL) {
AppendMessageColour(RED, ("Couldn't allocate data"));
return false;
}
//
s3eNOFArray achArray;
achArray.m_items = data;
achArray.m_count = max_achievements;
s3eNOFachievements(&achArray);
// AppendMessage("Size of achievement %d and double %d",
// sizeof(s3eNOFAchievement),
// sizeof(double));
for (uint i=0; i < achArray.m_count && i < max_achievements; i++) {
// s3eNOFAchievement* ach = &((s3eNOFAchievement*)achArray.m_items[i]);
// AppendMessage("Ach at %p", &((s3eNOFAchievement*)achArray.m_items)[i]);
AppendMessage("Acheivement title %s", ((s3eNOFAchievement*)achArray.m_items)[i].title);

Update December 30, 2011

The extension now supports both Android and iOS. Android API is extremely limited by OpenFeint itself and thus most APIs in extension just return -1 and do nothing.

26 Comments

Leave a Reply