Skip to content

Instantly share code, notes, and snippets.

View frostney's full-sized avatar
🐢

Johannes Stein frostney

🐢
View GitHub Profile
@frostney
frostney / SDL_uikitview.m
Created May 27, 2011 08:35
Add a simple function in SDL iOS 1.3 to detect if the current target has a retina display or not.
/*
Add this little function to a .m file of your choice. I chose SDL_uikitview.m as it already has the iPhone specific keyboard functions in it.
I'm pretty sure you can choose any *.m file in /Library Source/video/uikit from the Xcode project file.
Make sure this function is added after @implementation ... @end.
Admittedly this is not best solution as it forces you capsulate your asset loading into one or more if calls.
SDL unfortunately has no tie-ins to NSImage, so you can't use the usual @2x stuff by default. (I'm not sure about SDL_image for iOS though. This option here is also preferred if you want to include a third-party non-SDL image library such as Vampyre Imaging.)
*/
@frostney
frostney / BESENObject.pas
Created May 4, 2011 18:20
How to get BESEN (Revision: 145) to work with FreePascal 2.4.x: Replace line 1280 with the following in BESENObject.pas. Thanks to BeRo for the hint.
Hash:=((Hash-TBESENUINT32(Integer(Prop^.Attributes))) xor TBESENUINT32(Integer(Prop^.Presents)))*1664525;
@frostney
frostney / Baking.js
Created May 4, 2011 03:23
This is a code snippet which shows how to embed JavaScript (using BESEN, http://besen.sourceforge.net) in FreePascal/Delphi applications. I used FPC 2.5.1, compiled using "fpc -Mdelphi FPCScript.dpr" and tested under Ubuntu Linux 10.10 (32-bit).
//importScript("Test.js"); // Imports & executes Test.js
// Wohooo, JavaScript inside of JavaScript. That's meta.
execute("(function() { print('Hello world') })();");
print("--- Let's have a cake ---");
var myCake = new Cake();
myCake.Info();
print("--- I'm hungry ---");
@frostney
frostney / achievements.css
Created April 19, 2011 01:58
This is a code snippet on how to implement achievements (as seen on Steam or XBox Live) in JavaScript games using DOM. It utilizes jQuery, HTML5 LocalStorage and some CSS3. This runs completely client-side, but it could easily be integrated into a Node.js
/* You may want to style this to your personal need */
#status.achievement {
display: none;
position: absolute;
left: 50%;
bottom: -120px;
margin-left: -160px;
}