-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
67e3384
commit ce10e08
Showing
24 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* version 0.1 | ||
made by Kodiqi | ||
*/ | ||
|
||
function cmgAdStarted() { | ||
console.log("adStart gone and did it"); | ||
gml_Script_gmcallback_cmgAdStart(); | ||
} | ||
|
||
function cmgAdEnded() { | ||
console.log("adEnd went and occured, yo"); | ||
gml_Script_gmcallback_cmgAdEnd(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
console.log("Poki wrapper load"); | ||
///~ | ||
function poki_init_raw() { | ||
console.log("Poki wrapper init"); | ||
// fix GMS1 bug with iframes | ||
var ctr = document.getElementById("gm4html5_div_id"); | ||
if (ctr && !ctr.frames) ctr.frames = []; | ||
return 0; | ||
} | ||
///~ | ||
function poki_script_closure_raw(self, other, script, custom) { | ||
return function(result) { | ||
window.gml_Script_gmcallback_poki_closure(self, other, script, result, custom) | ||
} | ||
} | ||
|
||
function poki_is_blocked() { | ||
return !window.PokiSDK_OK; | ||
} | ||
|
||
function poki_gameplay_start() { | ||
if (PokiSDK) PokiSDK.gameplayStart(); | ||
} | ||
|
||
function poki_gameplay_stop() { | ||
if (PokiSDK) PokiSDK.gameplayStop(); | ||
} | ||
|
||
function poki_happy_time(magnitude) { | ||
if (PokiSDK) PokiSDK.happyTime(magnitude); | ||
} | ||
|
||
///~ | ||
function poki_commercial_break_raw(fn) { | ||
if (PokiSDK) { | ||
PokiSDK.commercialBreak().then(function() { fn(true); }); | ||
} else setTimeout(function() { fn(false); }, 0); | ||
} | ||
|
||
///~ | ||
function poki_rewarded_break_raw(fn) { | ||
if (PokiSDK) { | ||
PokiSDK.rewardedBreak().then(fn); | ||
} else setTimeout(function() { fn(false); }, 0); | ||
} | ||
|
||
/// https://yal.cc/gamemaker-html5-loading-bar-extended/ | ||
var inst = { }; | ||
///~ | ||
function poki_loadbar(ctx, width, height, total, current, image) { | ||
if (window.PokiSDK) { // if you have your own loadbar, just copy this block in there | ||
if (window.PokiSDK_loadState == 0) { | ||
window.PokiSDK_isLoading = 1; | ||
PokiSDK.gameLoadingStart(); | ||
} | ||
PokiSDK.gameLoadingProgress({ percentageDone: current/total }); | ||
if (current >= total && window.PokiSDK_loadState != 2) { | ||
window.PokiSDK_loadState = 2; | ||
PokiSDK.gameLoadingFinished(); | ||
} | ||
} | ||
|
||
function getv(s) { | ||
if (window.gml_Script_gmcallback_poki_loadbar) { | ||
return window.gml_Script_gmcallback_poki_loadbar(inst, null, | ||
s, current, total, | ||
width, height, image ? image.width : 0, image ? image.height : 0) | ||
} else return undefined; | ||
} | ||
function getf(s, d) { | ||
var r = getv(s); | ||
return typeof(r) == "number" ? r : d; | ||
} | ||
function getw(s, d) { | ||
var r = getv(s); | ||
return r && r.constructor == Array ? r : d; | ||
} | ||
function getc(s, d) { | ||
var r = getv(s); | ||
if (typeof(r) == "number") { | ||
r = r.toString(16); | ||
while (r.length < 6) r = "0" + r; | ||
return "#" + r; | ||
} else if (typeof(r) == "string") { | ||
return r; | ||
} else return d; | ||
} | ||
// get parameters: | ||
var backgroundColor = getc("background_color", "#FFFFFF"); | ||
var barBackgroundColor = getc("bar_background_color", "#FFFFFF"); | ||
var barForegroundColor = getc("bar_foreground_color", "#242238"); | ||
var barBorderColor = getc("bar_border_color", "#242238"); | ||
var barWidth = getf("bar_width", Math.round(width * 0.6)); | ||
var barHeight = getf("bar_height", 20); | ||
var barBorderWidth = getf("bar_border_width", 2); | ||
var barOffset = getf("bar_offset", 10); | ||
// background: | ||
ctx.fillStyle = backgroundColor; | ||
ctx.fillRect(0, 0, width, height); | ||
// image: | ||
var totalHeight, barTop; | ||
if (image != null) { | ||
var rect = getw("image_rect"); | ||
if (!rect) rect = [0, 0, image.width, image.height]; | ||
totalHeight = rect[3] + barOffset + barHeight; | ||
var image_y = (height - totalHeight) >> 1; | ||
ctx.drawImage(image, rect[0], rect[1], rect[2], rect[3], | ||
(width - rect[2]) >> 1, image_y, rect[2], rect[3]); | ||
barTop = image_y + rect[3] + barOffset; | ||
} else barTop = (height - barHeight) >> 1; | ||
// bar border: | ||
var barLeft = (width - barWidth) >> 1; | ||
ctx.fillStyle = barBorderColor; | ||
ctx.fillRect(barLeft, barTop, barWidth, barHeight); | ||
// | ||
var barInnerLeft = barLeft + barBorderWidth; | ||
var barInnerTop = barTop + barBorderWidth; | ||
var barInnerWidth = barWidth - barBorderWidth * 2; | ||
var barInnerHeight = barHeight - barBorderWidth * 2; | ||
// bar background: | ||
ctx.fillStyle = barBackgroundColor; | ||
ctx.fillRect(barInnerLeft, barInnerTop, barInnerWidth, barInnerHeight); | ||
// bar foreground: | ||
var barLoadedWidth = Math.round(barInnerWidth * current / total); | ||
ctx.fillStyle = barForegroundColor; | ||
ctx.fillRect(barInnerLeft, barInnerTop, barLoadedWidth, barInnerHeight); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,236 @@ | ||
/* version 1.1 | ||
KONGREGATE (C) API Extension for GameMaker:Studio | ||
-- Written by Dexter Friedman (July 15, 2012) | ||
-- Feel free to redistribute this extension, but don't | ||
violate Kongregate's terms of service, if they have any. | ||
I just made a Javascript wrapper. Please don't sue me! | ||
------ Version History ------- | ||
------ Version 1.1 | ||
(March 6, 2013) | ||
> Added kongGetUserID() | ||
> Made error console output print to console.error | ||
------ Version 1.0 > | ||
(July 15, 2012) | ||
> Created most of the wrapper functions for the Kongregate API | ||
> Ensured all function calls are surrounded by try-catch so that | ||
users can test locally without trouble. | ||
*/ | ||
|
||
var version = "1.1"; | ||
|
||
// Load the API | ||
// Define control functions | ||
|
||
function kongGetAPI() { | ||
// Returns the API object | ||
try { | ||
if (typeof parent.kongregate === 'undefined') { | ||
throw "APIUndefinedException"; | ||
} | ||
return (parent.kongregate); | ||
} catch (e) { | ||
if (e = "APIUndefinedException") { | ||
// Log this to the javascript console | ||
|
||
logError(); | ||
|
||
//console.error("GameMaker:Studio <KongAPI Extension by Afrodynamics> - Kongregate API not loaded!"); | ||
} | ||
return -1; | ||
} | ||
} | ||
|
||
function kongInit() { | ||
|
||
// Initialization Function for the whole extension | ||
try { | ||
parent.kongregate.services.connect(); | ||
console.log("GameMaker:Studio <KongAPI Extension "+version+" by Afrodynamics> - Kongregate API initialized!"); | ||
console.log("GameMaker:Studio <KongAPI Extension "+version+" by Afrodynamics> - Succesfully connected to Kongregate services!"); | ||
} catch(e) { | ||
console.error("GameMaker:Studio <KongAPI Extension "+version+" by Afrodynamics> - ERROR! Kongregate API not initialized!"); | ||
console.error("GameMaker:Studio <KongAPI Extension "+version+" by Afrodynamics> - You are not playing on kongregate.com!"); | ||
return -1; | ||
} | ||
}; | ||
|
||
function logError() { | ||
console.error("GameMaker:Studio <KongAPI Extension "+version+" by Afrodynamics> - Kongregate API not loaded!"); | ||
console.error("Play the game on Kongregate's website in a preview window to avoid this error."); | ||
}; | ||
|
||
/* | ||
* - API - FUNCTIONS - | ||
* | ||
* All functions will return String or Double to GameMaker:Studio | ||
* All functions are within try-catch statements so you can test locally. | ||
* If the game isn't hosted in the kongregate preview window, kongregate | ||
* API calls will throw execeptions. The try-catch prevents this. | ||
* | ||
* If exceptions are caught, functions returning double will return -1 | ||
* If exceptions are caught, functions returning strings will return "" | ||
* If exceptions are caught for void functions, -1 is returned as well. | ||
* | ||
*/ | ||
|
||
// -------------- GENERAL KONGREGATE FUNCTIONS -------------- | ||
|
||
function kongSubmitStat(argument0, argument1) { | ||
/* | ||
Submits a stat to the kongregate API, returns true if successful | ||
arg0 = String (stat name) | ||
arg1 = Number (stat) | ||
You define Kongregate stats on kongregate's website, and | ||
refer to them by their name strings (which you defined on | ||
their site.) | ||
*/ | ||
try { | ||
kongregate = kongGetAPI(); | ||
kongregate.stats.submit(argument0, argument1); | ||
return 1; | ||
} catch(e) { | ||
logError(); | ||
return -1; | ||
} | ||
}; | ||
|
||
function kongGetUsername() { | ||
|
||
// Returns a string of the username, or empty string if there's an exception | ||
|
||
try { | ||
return kongGetAPI().services.getUsername(); | ||
} catch(e) { | ||
logError(); | ||
return ""; | ||
} | ||
}; | ||
|
||
function kongGetUserID() { | ||
|
||
// Returns a String containing the unique user ID associated with the current player. | ||
// If the player is not signed in or you aren't viewing the game in a Kongregate preview | ||
// window, it'll return "" | ||
|
||
try { | ||
|
||
var id = kongGetAPI().services.getUserID(); | ||
console.log( id ); | ||
|
||
if ( id == 0 ) { | ||
return "" | ||
} else { | ||
return id; | ||
} | ||
|
||
} catch (e) { | ||
logError(); | ||
return ""; | ||
} | ||
|
||
} | ||
|
||
function kongIsGuest() { | ||
|
||
// returns true if user is guest, false if logged in | ||
// returns -1 if we aren't on kongregate | ||
try { | ||
if (kongGetAPI().services.isGuest()) { | ||
// If we are a Guest, return true to GM | ||
// In JS, there is a boolean object. This is to be precise. | ||
return 1; | ||
} | ||
else { | ||
return 0; | ||
} | ||
} catch(e) { | ||
// Remember, if we return -1, that means we aren't on kongregate at all! | ||
logError(); | ||
return -1; | ||
} | ||
|
||
}; | ||
|
||
function kongShowRegistrationBox() { | ||
|
||
// Shows a kongregate registration box | ||
|
||
try { | ||
if (kongIsGuest()) { | ||
kongGetAPI().services.showRegistrationBox(); | ||
return 1; | ||
} else { | ||
return 0; | ||
} | ||
} catch (e) { | ||
logError(); | ||
return -1; | ||
} | ||
|
||
} | ||
|
||
// ----------- KONGREGATE CHAT API FUNCTIONS ------------- | ||
|
||
function kongChatDisplayMessage(argument0, argument1) { | ||
// Displays chat message | ||
// arg0 = message, arg1 = username | ||
try { | ||
kongGetAPI().chat.displayMessage(argument0, argument1); | ||
} catch(e) { | ||
logError(); | ||
return -1; | ||
} | ||
|
||
} | ||
|
||
function kongChatClearMessages() { | ||
// Clears messages in Kongregate Chat Window, returns true | ||
try { | ||
kongGetAPI().chat.clearMessages(); | ||
return 1; | ||
} catch(e) { | ||
logError(); | ||
return -1; | ||
} | ||
} | ||
|
||
function kongChatShowTab(argument0, argument1, argument2) { | ||
/* | ||
arg0 - Name of the tab (word in tab itself) | ||
arg1 - Description of the tab | ||
arg2 - Relative size of the canvas, 0 being the smallest, 1 being the largest (default 0.5) | ||
*/ | ||
try { | ||
kongGetAPI().chat.showTab(argument0, argument1, {size:argument2}); | ||
return 1; | ||
} catch (e) { | ||
logError(); | ||
return -1; | ||
} | ||
} | ||
|
||
function kongChatCloseTab() { | ||
// Closes the tab opened by kongChatShowTab() | ||
try { | ||
kongGetAPI().chat.closeTab(); | ||
return 1; | ||
} catch (e) { | ||
logError(); | ||
return -1; | ||
} | ||
} | ||
|
||
// --------------- OTHER ----------------- |