Showing posts with label CODES. Show all posts
Showing posts with label CODES. Show all posts

Friday, January 20, 2012

Cocos2D/Orientation: How to get the orientation you want.


Yo, dudes,

How's it going? Kind of shitty, hun? No Megaupload, no FBI, no WhiteHouse.
What else to do? Well, here goes a fast topic for orientation issues.
Know when you have that real cool game that you're using Cocos2D but want to use Portrait Orientation?
Just do This:


1) Go to "RootViewController.m";
2) Find this piece of code:



#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
return ( UIInterfaceOrientationIsLandscape( interfaceOrientation ) );

3)Change the "UIInterfaceOrientationIsLandscape" to "UIInterfaceOrientationIsPortrait", or any other that you would like. (Just try not using "PortraitUpSideDown" if would be kind of awkward.

Now your code should be something like this:

#elif GAME_AUTOROTATION == kGameAutorotationUIViewController
//
// EAGLView will be rotated by the UIViewController
//
// Sample: Autorotate only in landscpe mode
//
// return YES for the supported orientations
return ( UIInterfaceOrientationIsPortrait( interfaceOrientation ) );


Any problems, get in contact.
Cheers.

Thursday, October 6, 2011

Cocos2D: Press&Hold button

Hey, sports!


Today the time is really really short, so I made an example and uploaded it.
It's no a virus or anything, it's a project that can help you when you need to make action like this:


1)Press button;
2)Wish that it would increase/decrease a "number label";
3)Release button;
4)Action stop right after releasing




                                           here's the link:
                   Project: Button Press&Hold


Hasta la vista, dudes.

Saturday, September 24, 2011

App4U/Work: TwistMemory, SecretBalls, HungryFrog

*GREEN for English
*AMARELO para Português


Hi!


Here are the links for some of our apps:
Aqui estão os links para alguns dos nossos aplicativos:


#1 :  TWIST MEMORY:


http://itunes.apple.com/br/app/twist-memory/id457878965?mt=8




This is a memory twisting, psychedelic memory game. You just need to put up the pairs together as fast as you can in less then 5 minutes. Fun to spend you time and difficult stopping to play it.


Jogo que vai psicodelicamente pirar a sua memoria. Você só precisa juntar os pares o mais rápido possível, em menos de 5 minutos. Divertido para passar o tempo e difícil de parar de jogar.


*This was made with 100% legit code by Felipe Gringo(me) and Sergio Furlaneto Filho.


*Esse foi um código 100% feito por Felipe Gringo(eu) e o Sergio Furlaneto Filho.
        
#2: SECRET BALLS:


http://itunes.apple.com/br/app/secret-balls/id392074246?mt=8



This was the first app I put my hands on, so we worked like camels to do a new interface and bring some new stuff on it. It's just incredible. If you like a intelligent and nerdy game, this is the one for you. You just need to find out the right sequence and go to the next code, over and over!

Esse foi o primeiro aplicativo que me veio em mãos, então nós camelamos para fazer uma nova interface e trazer novas funcionalidades. Simplesmente incrível. Se você se interessa por jogos inteligentes e meio nerds, esse é pra você. Você só precisa acertar a sequência de cores e ir para o próximo código!

#3: HUNGRY FROG:



Wow, this kid here drove us crazy, it gave lot of work but the animations are spectacular, the game is fun and not so hard to play. You'll have to help this little green dude eat as many flies he can before the flies counter attack.

Wow, esse quase nos fez ir para em um sanatório, deu trabalho mas as animações ficaram espetaculares, o jogo é divertido e não é complicado. Você terá que ajudar esse carinha verde comer quantas moscas forem possíveis antes que as moscas contra-ataquem.


For more App4U apps go to: http://www.app4u.com.br/
Para mais aplicativos da App4U:  http://www.app4u.com.br/

If you want to get in contact with me go to CONTACT section.
Se quiser entrar em contato comigo clique na aba CONTACT. 

Friday, August 19, 2011

Google Developer Day / Objective-C: String Handling

Hi!

Here's the code i used for the Google Developer Day 2011, i wasn't able to come up with the 4th task, but it came to me a few hours later at home, so as soon as i code it, i'll update the post.

No way i can paint special words.
Sorry.

CODE:


#import <Foundation/Foundation.h>

@interface MyClass : UIViewController {
    
    IBOutlet UIButton* hitItButton;
    IBOutlet UITextField* TEXT;
    
    int VEZES_QUE_ENTROU;
    int VEZES_QUE_SAIU_SEM_SUCESSO;
    
    NSMutableString* POSITION_1;
    NSMutableString* POSITION_2;
    NSMutableString* POSITION_3;
    NSMutableString* POSITION_4;
    NSMutableString* POSITION_5;
    NSMutableString* POSITION_6;
    NSMutableString* POSITION_7;
    NSMutableString* POSITION_8;
    NSMutableString* POSITION_9;
    NSMutableString* POSITION_10;
    NSMutableString* POSITION_11;
    NSMutableString* POSITION_12;
    NSMutableString* POSITION_13;
    NSMutableString* POSITION_14;
    NSMutableString* POSITION_15;
    NSMutableString* POSITION_16;
    NSMutableString* POSITION_17;
    NSMutableString* POSITION_18;
    NSMutableString* POSITION_19;
    NSMutableString* POSITION_20;
    NSMutableString* POSITION_21;
}


@property(nonatomic, retain)NSUserDefaults* defaultz;

-(void)doIt:(id)sender;


@end


#import "MyClass.h"

@implementation MyClass

@synthesize defaultz;

-(int)intergerForTheString:(NSMutableString*)SINGLE_LETTER{
    
    int switcher;
    
    if ([SINGLE_LETTER isEqualToString:@"l"]){
        switcher = 0;
    }
    if ([SINGLE_LETTER isEqualToString:@"v"]){
        switcher = 1;
    }
    if ([SINGLE_LETTER isEqualToString:@"z"]){
        switcher = 2;
    }
    if ([SINGLE_LETTER isEqualToString:@"t"]){
        switcher = 3;
    }
    if ([SINGLE_LETTER isEqualToString:@"r"]){
        switcher = 4;
    }
    if ([SINGLE_LETTER isEqualToString:@"n"]){
        switcher = 5;
    }
    if ([SINGLE_LETTER isEqualToString:@"h"]){
        switcher = 6;
    }
    if ([SINGLE_LETTER isEqualToString:@"f"]){
        switcher = 7;
    }
    if ([SINGLE_LETTER isEqualToString:@"x"]){
        switcher = 8;
    }
    if ([SINGLE_LETTER isEqualToString:@"d"]){
        switcher = 9;
    }
    if ([SINGLE_LETTER isEqualToString:@"g"]){
        switcher = 10;
    }
    if ([SINGLE_LETTER isEqualToString:@"p"]){
        switcher = 11;
    }
    if ([SINGLE_LETTER isEqualToString:@"b"]){
        switcher = 12;
    }
    if ([SINGLE_LETTER isEqualToString:@"j"]){
        switcher = 13;
    }
    if ([SINGLE_LETTER isEqualToString:@"m"]){
        switcher = 14;
    }
    if ([SINGLE_LETTER isEqualToString:@"w"]){
        switcher = 15;
    }
    if ([SINGLE_LETTER isEqualToString:@"q"]){
        switcher = 16;
    }
    if ([SINGLE_LETTER isEqualToString: @"s"]){
        switcher = 17;
    }
    if ([SINGLE_LETTER isEqualToString:@"k"]){
        switcher = 18;
    }
    if ([SINGLE_LETTER isEqualToString:@"c"]){
        switcher = 19;
    }
    
    return switcher;
}


-(double)potenciacao:(double)X onTheTurn:(int)Z{
    
    double Y=0;
    
    if (Z==0){
        return 1;
    } else {
        Y=X*20;
    }
    
    return Y;
    
}

-(double)calculateIt:(NSString *)X{
    
    
    int TOTAL = [X length];
    int switcher=0;
    double TOTAL_A_ENTREGAR=0;
    double POTENCIACAO=20;
    NSMutableString* SINGLE_LETTER;
    
    for (int i=0; i<[X length]; i++){
        SINGLE_LETTER = [NSMutableString stringWithString:[X substringWithRange:NSMakeRange(i, 1)]];
        switcher = [self intergerForTheString:SINGLE_LETTER];
        
        POTENCIACAO = [self potenciacao:POTENCIACAO onTheTurn:i];
        
        TOTAL_A_ENTREGAR = TOTAL_A_ENTREGAR + switcher*POTENCIACAO; 
        TOTAL--;
    }
    return TOTAL_A_ENTREGAR;
}

-(BOOL)isItBonito:(double)X{
    
    BOOL RETURNER;
    
    if ((X > 865641) && (((int)X%3) == 0)){
        RETURNER = TRUE;
    } else {
        RETURNER = FALSE;
    }
    
    return RETURNER;
    
}

-(BOOL)isItAlreadyStocked:(NSMutableString *)X withLoopNumber:(int)Y{
    
    NSString* RECOVERED_STRING;
    BOOL COISA;
    int zzz;
    VEZES_QUE_ENTROU++;
    
    for (int i=1; i<=Y; i++){
        RECOVERED_STRING = [defaultz stringForKey:[NSString stringWithFormat:@"iz%d", i]];
        if ([X isEqualToString:RECOVERED_STRING ]){
            VEZES_QUE_SAIU_SEM_SUCESSO++;
            COISA = TRUE;
        }
        
    }
    
    if (COISA == TRUE) {
        return COISA;
    } else {
        
        zzz = VEZES_QUE_ENTROU-VEZES_QUE_SAIU_SEM_SUCESSO;
        [defaultz setObject:X forKey:[NSString stringWithFormat:@"iz%d", zzz]];
        return FALSE;
    }
}


-(BOOL)firstLette:(NSMutableString*)X{
    
    BOOL RETURNER;
    
    if ([X isEqualToString:@"x"]){
        RETURNER = TRUE;
    } else if ([X isEqualToString:@"q"]){
        RETURNER = TRUE;
    } else if ([X isEqualToString:@"g"]){
        RETURNER = TRUE;
    } else if ([X isEqualToString:@"p"]){
        RETURNER = TRUE;
    } else if ([X isEqualToString:@"r"]){
        RETURNER = TRUE;
    } else {
        RETURNER = FALSE;
    }
    
    return RETURNER;
    
}

-(IBAction)doIt:(id)sender{
    //NAO ESQUECE DE COLOCAR UM ESPAÇO NO FINAL
    NSString* ENTERING_STRING = @"THE STRING GOOGLE GAVE YOU TO FIND OUT STUFF";
    
    int WORD__COUNTER=0, SAVED_COUNTER=0, WHAT_LETTER_WE_ARE = 0, PREPOSITION_COUNTER=0, NORMAL_VERB_CONTER=0, FP_VERB_CONTER=0, D_LETTER=0, BONITO_COUNTER=0, OUTRO_BONITO_COUNTER=0;
    NSMutableString* SINGLE_LETTER, *WORD, *SINGLE_LETER_FOR_FIRST_PERSON;
    BOOL TIME_TO_SAVE_CONTER = YES, IS_IT_FOO = NO;
    NSMutableArray* array = [[NSMutableArray alloc]initWithCapacity:110];
    
    
    for (int x=0; x<[ENTERING_STRING length]; x++) {
        
        if(TIME_TO_SAVE_CONTER == YES){
            TIME_TO_SAVE_CONTER = NO;
            SAVED_COUNTER = x;
        }
        
        SINGLE_LETTER = [NSMutableString stringWithString:[ENTERING_STRING substringWithRange:NSMakeRange(x, 1)]];
        
        
        if ([SINGLE_LETTER isEqualToString:@" "]){
            WORD = [NSMutableString stringWithString:[ENTERING_STRING substringWithRange:NSMakeRange(SAVED_COUNTER, WHAT_LETTER_WE_ARE)]];            
            //NSLog(@"%@", WORD);
            int OCORRENCIA_FOO=0;
            
            WORD__COUNTER++;
            if (WORD__COUNTER == 1){
                [defaultz setObject:WORD forKey:[NSString stringWithFormat:@"iz%d", WORD__COUNTER]];
            }
            
            NSString* WORD_FOR_CAL = WORD;
            //NSLog(@"%@", WORD_FOR_CAL);
            
            if ([WORD_FOR_CAL isEqualToString:@" "]){
                NSLog(@"branco");
            } else {
                //NSLog(@"wordc: %d", WORD__COUNTER);
                BOOL REPETIDO = [self isItAlreadyStocked:WORD withLoopNumber:WORD__COUNTER];
                //NSLog(@"repetido: %d", REPETIDO);
                
                BOOL BONITO = [self isItBonito:[self calculateIt:WORD_FOR_CAL]];
                if (BONITO == TRUE && REPETIDO == FALSE){
                    BONITO_COUNTER++;
                    [defaultz setObject:WORD_FOR_CAL forKey:[NSString stringWithFormat:@"BONITO%d", BONITO_COUNTER]];
                    [array addObject:[defaultz stringForKey:[NSString stringWithFormat:@"BONITO%d", BONITO_COUNTER]]];
                }
            }
            
            [array sortUsingSelector:@selector(compare:)];
            
            for (int y=0; y<[WORD length]; y++){
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"x"]){
                    //NSLog(@"SOMOOU FOO");
                    OCORRENCIA_FOO++;
                }
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"q"]){
                    //NSLog(@"SOMOOU FOO");
                    OCORRENCIA_FOO++;
                }
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"g"]){
                    //NSLog(@"SOMOOU FOO");
                    OCORRENCIA_FOO++;
                }
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"p"]){
                    //NSLog(@"SOMOOU FOO");
                    OCORRENCIA_FOO++;
                }
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"r"]){
                    //NSLog(@"SOMOOU FOO");
                    OCORRENCIA_FOO++;
                }
                if ([[WORD substringWithRange:NSMakeRange(y, 1)] isEqualToString:@"d"]){
                    //NSLog(@"entrou");
                    D_LETTER++;
                }
            }
            
            //VERIFICA SE TEM FOO
            if (OCORRENCIA_FOO > 0){
                //NSLog(@"SIM ELE É FOO");
                IS_IT_FOO = YES;
                if (OCORRENCIA_FOO > 1){
                    //NSLog(@"%@ TEM %d LETRAS", WORD, [WORD length]);
                    //NSLog(@"FOO: %d OCORRENCIAS", OCORRENCIA_FOO);
                }
                else{
                    //NSLog(@"%@ TEM %d LETRAS", WORD, [WORD length]);
                    //NSLog(@"FOO: %d OCORRENCIA", OCORRENCIA_FOO);
                }
            } else {
                //NSLog(@"NAO É FOO");
                IS_IT_FOO = NO;
                //NSLog(@"%@ TEM %d LETRAS", WORD, [WORD length]);
                //NSLog(@"FOO: %d OCORRENCIA", OCORRENCIA_FOO);
            }
            
            
            if ([WORD length] == 3 && IS_IT_FOO == YES && D_LETTER <= 0){
                //NSLog(@"ESSA É UMA PREPOSIÇÃO");
                PREPOSITION_COUNTER++;
                IS_IT_FOO = NO;
                
            } else { 
                D_LETTER=0;
                //NSLog(@"ESSA NÃO É UMA PREPOSIÇÃO");
            }
            
            
            
            if ([WORD length] >= 8){
                SINGLE_LETTER = [NSMutableString stringWithString:[ENTERING_STRING substringWithRange:NSMakeRange(x-1, 1)]];
                SINGLE_LETER_FOR_FIRST_PERSON = [NSMutableString stringWithString:[ENTERING_STRING substringWithRange:NSMakeRange(SAVED_COUNTER, 1)]];
                
                if ([SINGLE_LETTER isEqualToString:@"x"]){
                    NORMAL_VERB_CONTER++;
                    if ([self firstLette:SINGLE_LETER_FOR_FIRST_PERSON] == TRUE){
                        FP_VERB_CONTER++;
                    }
                }
                if ([SINGLE_LETTER isEqualToString:@"q"]){
                    NORMAL_VERB_CONTER++;
                    if ([self firstLette:SINGLE_LETER_FOR_FIRST_PERSON] == TRUE){
                        FP_VERB_CONTER++;
                    }
                }
                if ([SINGLE_LETTER isEqualToString:@"g"]){
                    NORMAL_VERB_CONTER++;
                    if ([self firstLette:SINGLE_LETER_FOR_FIRST_PERSON] == TRUE){
                        FP_VERB_CONTER++;
                    }
                }
                if ([SINGLE_LETTER isEqualToString:@"p"]){
                    NORMAL_VERB_CONTER++;
                    if ([self firstLette:SINGLE_LETER_FOR_FIRST_PERSON] == TRUE){
                        FP_VERB_CONTER++;
                    }
                }
                if ([SINGLE_LETTER isEqualToString:@"r"]){
                    NORMAL_VERB_CONTER++;
                    if ([self firstLette:SINGLE_LETER_FOR_FIRST_PERSON] == TRUE){
                        FP_VERB_CONTER++;
                    }
                }
                
            }
            
            
            TIME_TO_SAVE_CONTER = YES;
            WHAT_LETTER_WE_ARE =0;
        } else {
            //NSLog(@"%@", SINGLE_LETTER);
            WHAT_LETTER_WE_ARE++;
        }
        
        
    }
    NSLog(@"VERBOS: %d", NORMAL_VERB_CONTER);
    NSLog(@"VERBOS EM 1P: %d", FP_VERB_CONTER);
    NSLog(@"PREPOSIÇOES: %d", PREPOSITION_COUNTER);
    NSLog(@"NUM. BONITOS: %d", BONITO_COUNTER);
    NSLog(@"TOTAL DE PALAVRAS = %d", WORD__COUNTER);
    
    NSString* string_De_retorno = [[NSString alloc]init];
    for (NSString* WWW in array) {
        NSLog(@"%@", WWW);
        [string_De_retorno stringByAppendingString:WWW];
    }
    
    TEXT.text = string_De_retorno;
    NSLog(@"%@", string_De_retorno);
    
}

-(int)count:(NSString*)String{
    int x = 0;
    for ( x=0; x <= [String length]; x++)
        NSLog(@"x");
    
    return x;
}

-(void)startMutableStrings{
    
    POSITION_1 = [NSMutableString string];
    POSITION_2 = [NSMutableString string];
    POSITION_3 = [NSMutableString string];
    POSITION_4 = [NSMutableString string];
    POSITION_5 = [NSMutableString string];
    POSITION_6 = [NSMutableString string];
    POSITION_7 = [NSMutableString string];
    POSITION_8 = [NSMutableString string];
    POSITION_9 = [NSMutableString string];
    POSITION_10 = [NSMutableString string];
    POSITION_11 = [NSMutableString string];
    POSITION_12 = [NSMutableString string];
    POSITION_13 = [NSMutableString string];
    POSITION_14 = [NSMutableString string];
    POSITION_15 = [NSMutableString string];
    POSITION_16 = [NSMutableString string];
    POSITION_17 = [NSMutableString string];
    POSITION_18 = [NSMutableString string];
    POSITION_19 = [NSMutableString string];
    POSITION_20 = [NSMutableString string];
    
}

-(void)stockString:(NSMutableString*)X withIndex:(int)Y{
    
    switch (Y){
        case 1: POSITION_1 = X; break;
        case 2: POSITION_2 = X; break;
        case 3: POSITION_3 = X; break;
        case 4: POSITION_4 = X; break;
        case 5: POSITION_5 = X; break;
        case 6: POSITION_6 = X; break;
        case 7: POSITION_7 = X; break;
        case 8: POSITION_8 = X; break;
        case 9: POSITION_9 = X; break;
        case 10: POSITION_10 = X; break;
        case 11: POSITION_11 = X; break;
        case 12: POSITION_12 = X; break;
        case 13: POSITION_13 = X; break;
        case 14: POSITION_14 = X; break;
        case 15: POSITION_15 = X; break;
        case 16: POSITION_16 = X; break;
        case 17: POSITION_17 = X; break;
        case 18: POSITION_18 = X; break;
        case 19: POSITION_19 = X; break;
        case 20: POSITION_20 = X; break;
    }
    
}


-(void)viewDidLoad{
    
    [self startMutableStrings];
    defaultz = [NSUserDefaults standardUserDefaults];
    VEZES_QUE_ENTROU=1;
    VEZES_QUE_SAIU_SEM_SUCESSO=0;
    [super viewDidLoad];
    
}


-(void)viewDidUnload{
    [super viewDidUnload];
 }

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{   
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end

Tweet