Skip to content

Instantly share code, notes, and snippets.

View alinradut's full-sized avatar

alinradut

  • Targu Mures, Romania
View GitHub Profile
- (void)updateCorrectKeysPressed {
correctKeysPressed_++;
correctKeysPressedThisGame_++;
// update the current score, 10 points for a correct key and 3 points for each consecutive correct key
score_ += 10 + (correctKeysPressedThisGame_ - 1) * 3;
if (correctKeysPressed_ && correctKeysPressed_ % 10 == 0) {
// compute the bonus based on consecutive correct keys
NSInteger bonus = score_ * ((float)correctKeysPressed_/200);
- (void)updateCorrectKeysPressed {
correctKeysPressed_++;
correctKeysPressedThisGame_++;
// update the current score, 10 points for a correct key and 3 points for each consecutive correct key
score_ += 10 + (correctKeysPressedThisGame_ - 1) * 3;
if (correctKeysPressed_ && correctKeysPressed_ % 10 == 0) {
// compute the bonus based on consecutive correct keys
NSInteger bonus = score_ * ((float)correctKeysPressed_/200);
@alinradut
alinradut / gameswon.m
Created April 17, 2011 18:35
Achievements - Games won
- (void)updateGamesWon {
gamesWonInARow_++;
if (gamesWonInARow_ && (gamesWonInARow_ % 10 == 0 || gamesWonInARow_ == 5)) {
NSInteger bonus = score_* ((float)gamesWonInARow_ / 100);
score_ += bonus;
NSString *achievement = [NSString stringWithFormat:@"%d games in a row! (+%d)", gamesWonInARow_, bonus];
[self achievementUnlocked:achievement];
}
- (void)achievementUnlocked:(NSString *)achievement {
[achievements_ addObject:achievement];
// lazy load the achievements layer
if (!achievementLayer_) {
CGSize winSize = [[CCDirector sharedDirector] winSize];
// instantiate the layer
achievementLayer_ = [[CCLayer alloc] init];
achievementLayer_.anchorPoint = ccp(0,0);
@alinradut
alinradut / CGRect helpers
Created May 26, 2011 08:40
Useful CGRect manipulation defines
#define CGRectSetPos( r, x, y ) CGRectMake( x, y, r.size.width, r.size.height )
#define CGRectSetX( r, x ) CGRectMake( x, r.origin.y, r.size.width, r.size.height )
#define CGRectSetY( r, y ) CGRectMake( r.origin.x, y, r.size.width, r.size.height )
#define CGRectSetSize( r, w, h ) CGRectMake( r.origin.x, r.origin.y, w, h )
#define CGRectSetWidth( r, w ) CGRectMake( r.origin.x, r.origin.y, w, r.size.height )
#define CGRectSetHeight( r, h ) CGRectMake( r.origin.x, r.origin.y, r.size.width, h )
@alinradut
alinradut / gist:1025002
Created June 14, 2011 14:27
Print all subviews with a certain type
- (NSString *)superviewPath:(UIView *)view
{
NSMutableArray *path = [NSMutableArray array];
while (view != nil)
{
[path insertObject:[NSString stringWithFormat:@"(%p) %@",view,NSStringFromClass([view class])] atIndex:0];
view = [view superview];
}
@alinradut
alinradut / gist:1025691
Created June 14, 2011 19:41
Check for iOS version
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
@alinradut
alinradut / version.sh
Last active June 30, 2016 13:06
Automatically bump up the version number when creating an iOS Release build
#
# License: Public domain
#
function bump_version() {
touch "$PROJECT_DIR/LASTVERSION"
typeset -i BUILD_VERSION=$(cat "$PROJECT_DIR/LASTVERSION")
BUILD_VERSION=$((BUILD_VERSION+1))
echo $BUILD_VERSION > "$PROJECT_DIR/LASTVERSION"
echo "Bumped up build version to $BUILD_VERSION"
@alinradut
alinradut / webrtc-callback-logger.diff
Created May 2, 2017 09:08
WebRTC patch for a callback logger for iOS
diff --git a/BUILD.gn b/BUILD.gn
index 4e6816fd8..d54fef764 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -12,7 +12,7 @@ group("default") {
testonly = true
deps = [
"//webrtc",
- "//webrtc/examples",
+# "//webrtc/examples",
@alinradut
alinradut / rotoscope.sh
Created May 3, 2017 08:45
A script that will convert a regular video to a rotoscoped video. Requires autotrace, ffmpeg, imagemagick.
#!/bin/bash
# rotoscope - auto rotoscope a video file with openSource Software on Linux
# needs ffmpeg, autotrace and ImageMagick
# usage: rotoscope videofile //will create videofile.rotoscoped.avi
# created by Honza Svasek : HonzaSvasek.nl
# edited by Joseph Riopelle finitelife[at]hotmail.com
set -x
export TMPDIR=/tmp/rotoscope$$
export FILM=$1