Skip to content

Instantly share code, notes, and snippets.

View Sumolari's full-sized avatar

Lluís Ulzurrun de Asanza Sàez Sumolari

View GitHub Profile
@Sumolari
Sumolari / gist:4e0a5c6cdb4fa47b0cb2db8dafe5056a
Created January 17, 2017 16:25 — forked from rsattar/gist:b06060df7ea293b398d1
Convert CLLocation and CLHeading into GPS metadata
// Inspired by: http://stackoverflow.com/a/5314634/9849
// Simplified if-statements
// Updated to "modern" syntax
// Support optional CLHeading
// Support degree-of-precision
//
// This dictionary should then be added to the normal
// metadata using the kCGImagePropertyGPSDictionary key
- (NSDictionary *)GPSDictionaryForLocation:(CLLocation *)location heading:(CLHeading *)heading
{
@Sumolari
Sumolari / demo_device_language_mawkit.cpp
Created April 18, 2016 16:36
Custom translation with MawKit
#include "MawKit/Device.hpp"
std::map<std::string, std::map<std:string, std::string>> languages;
std::string translate( const std::string &key )
{
std::map<std::string, std::string> &translations = languages[MK::Device::language()];
if ( translations.find( key ) == translations.end() ) {
translations[key] = key;
@Sumolari
Sumolari / demo_finiteTimeActions_mawkit.cpp
Last active April 18, 2016 16:38
Custom FiniteTimeActions demo with MawKit
#include "MawKit/FiniteTimeActions.hpp"
void runPickupCoinAnimation( cocos2d::Node *coin, cocos2d::Node *chest ) {
// Move coin to chest.
auto moveCoinToChest = MK::Actions::MoveToNode::create( 0.25, chest );
// Bounces chest.
std::function<void( void )> bounceChest = [=]() { chest->bounce(); };
@Sumolari
Sumolari / demo_mawkit_random.cpp
Created April 18, 2016 16:29
Dice demo with MawKit
#include "MawKit/Range.hpp"
#include "MawKit/Random.hpp"
#include <vector>
long long throw20FacesDice() {
return MK::LLRange( 1, 20 ).randomInteger();
}
double getRandomNumberFrom0UpTo100() {
@Sumolari
Sumolari / demo_adkit.cpp
Created April 18, 2016 16:25
Interstitial demo with MawKit
#include "MawKit/AdKit.hpp"
constexpr const char*ADMOB_INTERSTITIAL_ID = "";
void prepareAds() {
MK::AdKit::init( ADMOB_INTERSTITIAL_ID );
}
void showMyInterstitial() {
MK::AdKit::showInterstitial( ADMOB_INTERSTITIAL_ID );
@Sumolari
Sumolari / demo_gamekit_2.cpp
Created April 18, 2016 16:19
Getting achievement progress
#include "MawKit/GameKit.hpp"
void getSecretAchievementInfo()
{
MK::GameKit::requestAchievement(
MK::GameKit::AchievementIndex::SECRET_ACHIEVEMENT,
[]( float progress, bool success ) {
if ( success ) {
if ( progress == 1 ) {
// Achievement unlocked!
@Sumolari
Sumolari / demo_gamekit.cpp
Created April 18, 2016 16:14
Submitting a score
#include "MawKit/GameKit.hpp"
MK::GameKit::submitScore( 42, MK::GameKit::LeaderboardIndex::SCORE );
@Sumolari
Sumolari / demo_kvdatabase.cpp
Created April 18, 2016 16:11
Checks if player has enough money to buy an item, and buys it if possible
#include "MawKit/KVDatabase.hpp"
bool buyIfPossible( long long price )
{
constexpr const char *moneyKey = "money";
if ( MK::KVDatabase::getLongValueForKey( moneyKey ) > price ) {
MK::KVDatabase::decreaseLongValueForKey( moneyKey, price );
return true;
}
@Sumolari
Sumolari / game.cpp
Last active May 2, 2019 22:13
Set texture wrap mode in Cocos2d-x
cocos2d::Texture2D::TexParams texParams = {
GL_NEAREST, // TextureMinFilter
GL_NEAREST, // TextureMagFilter
GL_CLAMP_TO_EDGE, // TextureWrapMode Horizontal
GL_CLAMP_TO_EDGE // TextureWrapMode Vertical
};
this->getTexture()->setTexParameters( texParams );
@Sumolari
Sumolari / increase-xcode-build-number.sh
Created February 8, 2016 08:49
Increases Xcode build number
#!/bin/bash
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"