Monday, August 27, 2012

Its almost 2 months and I have finish nothing?

Well, I first started this blog on June and hoping to at least finish some simple game and I am not too proud to say that I failed, due to my laziness and just gaming and playing with my free time and not enough concentration and effort put into this

Well, guess I will start doing something today, yes, since I started my simple forex game, so I guess I will study how to plot a simple chart first for today objective

Okay after a 5 minute searching I found that there are 2 library I can use to plot the char, one is the power plot and one is the core plot

After a quick view for both, I found that power plot is more simpler even though the feature might be less, I will go for power plot then

Hmmm, after one hour of trying and coding and I am still failing, and I already feel tired, I will continue tomorrow and hopefully by then I can at least finish plotting a graph

Tuesday, August 21, 2012

Xcode how to convert integer to String for Noob

Here is how to convert integer to String in Xcode


 NSString *temp = [NSString stringWithFormat:@"%d", price];



So let say you want to convert integer "price" into String temp, above is how you do it

Xcode how to convert String to Integer for Noob

Here is Xcode how to convert String to Integer


int temp2 = [temp1 intValue];


Let say your temp1 is a String with value "100" it will convert into integer 100 in temp2

Xcode how to substring for Noob

There are 3 way to substring in Xcode

Let say Your String is "HelloRabbit"

NSString *aString = @"HelloRabbit"

First Way 

NSString *substring = [aString substringToIndex:7];
You will get: "HelloRab"
It mean you take the first character until the 7th character
Second Way 
NSString *substring = [aString substringFromIndex:5];
You will get "Rabbit"

It mean you take from the 5th character until the end


Third Way NSString *substring = [aString substringWithRange:NSMakeRange(5, 3)];

You will get "Rab"

It mean you start from character 5 and take only 3 character

Xcode how to Concat string and integer together for Noob

Here is how to Concat string and integer together for Noob


NSString *temp = [NSString stringWithFormat:@"Your Money: $%d, Price now is: $%d", money, price];


So your String is "Your Money:$, Price now is:$ " and your integer is money and price


New Update for today

So Today I continue to work on my simple forex game

where a single number on the middle will up or down

then there is 2 button for you to press to long or short

and in the middle is the list of item showing the position you long or short

in below screenshot


It look simple but the skill I learned to do this is as below

1. how to concat two string together
2. how to substring
3. how to convert string to integer
4. how to convert integer to string

I will make 4 post of simple tutorial later


Monday, August 20, 2012

Start New Game Instead of Continue Old one?

Ok, Instead of pushing my self to continue to finish the boring ass game, maybe I should start a new one instead?

Better than not doing anything right?

So what is my interested?

well, i guess I like to gamble stock and forex maybe I can create some simple forex game?

whatever, just as long as I can move my lazy ass to do something

So what is the first step?

First step is the whole idea, how should my game goes?

- a graph that randomly up and down, and a few button to click buy and sell, and profit

Ok, i just need to finish my first goal

man, believe it or not, just 10 days no touch the code, I feel like a complete noob again, i spend a total of 30 minute just to get 2 button up for me to click , and below is the code, under the init i will call the create button function to create 2 button for me to click, i am lazy to draw the button, so i use the CCMenuItemFont to show the Font button


        [self createbutton];
        


-(void)createbutton
{

    
    
    // Font Item
    CCMenuItem *item1 = [CCMenuItemFont itemFromString: @"LONG" target: self selector:@selector(Level1:)];

    
    CCMenuItem *item2 = [CCMenuItemFont itemFromString: @"SHORT" target: self selector:@selector(Level1:)];

    CCMenu * myMenu = [CCMenu menuWithItems:item1,item2,  nil];
    
    // Arrange the menu items vertically
    [myMenu alignItemsVertically];
    
    myMenu.position=ccp(170,140);
    
    
    // add the menu to your scene
    [self addChild:myMenu];

}


- (void) Level1: (CCMenuItem  *) menuItem 
{
    
NSLog(@"resume game was called");
}


And Below is the screenshot after my 30 minutes effort, OH MY GOD!!!!! so slow

ok, I cannot just stop here right, the next thing is to add a timer that will slowly increase the price or randomly change the price


- (void) myTimer:(ccTime)dt 
{
    smalltimer+=1;
    
    if(smalltimer==100)
    {
        smalltimer=0;
    
    
    
        NSString *temp = [NSString stringWithFormat:@"Price now is: %d", price];
    
        [mylabel setString:temp];
        price +=1;
    }
}

Here I just increase the price slowly every 2 seconds increase by 1, but I took a fine 10 minute just to research how to Concat the String and Int together, there are no simple + for this


Its Sunday and again I feel very lazy

So I sleep, rest, play games, watch movie, watch olympic and just don't want to work.

Is this normal? probably most people also don't feel like working?

But I need to get my stuff done, ok, so first thing is to open my games, run it and see what else I can do about it

hmmm, why do i feel that my game suck so hard

it is not fun in any freaking way

i need to make this fun, but how

i think i know why , the graphics is too suck ass no body wanna play my stupid games

probably i need to spend some time drawing and make this look awesome


Saturday, August 11, 2012

Its Saturday and I am lazy

Yes, so here I am , no need to work today, I should have spend the entire day coding but I am lazy so I just spend all the time watching the Olympic, watching movie, playing games, and basically wasting time

I feel regret about it because I am supposed to work hard on my game, so what should I do next, well, let me play my own games and think about it

Ok, so I tested my games, the 5 ppl walking around and when I start to sing, they will float over and stop there, I want to make them move normally

Ok, so today goal is to try make those 5 people run to the main player and give money when the main character sing, and when non sing, they will go back to their original path

After 1 hour and 30 minutes, I done it


-(void)playerdonate:(int) x: (int) y
{
   
    [self stopAllActions  ];
    [self walk2picFunction];

    
    id action1 = [CCMoveTo actionWithDuration: 2 position:ccp(x-80, y)];
    

    
    id action2=[CCCallFuncN actionWithTarget:self 
                         selector:@selector(stopAllActions)];
   
    id action3=[CCCallFuncN actionWithTarget:self 
                                    selector:@selector(throw2picFunction)];
    
    
    
        [self runAction: [CCSequence actions:action1,action2,action3,nil]];
}

here is how it work

the moment my main character sing, i will stop all action, then the 5 player will start to walk to my main character, so i use a CCSequence to chain the 3 type of action

stop all action
walk 2 pic action

action1, move to my main character
action2, stop all action
action3, throw money action

Once release, then they should go back to their original routine
- (void)ccTouchEnded:(UITouch *)touch withEvent:(UIEvent *)event {

    
    [myplayer[0] playergo:5 :200];
    [myplayer[1] playergo:7 :220];
    [myplayer[2] playergo:9 :240];
    [myplayer[3] playergo:11 :260];
    [myplayer[4] playergo:13 :280];
    
    
}






Tuesday, August 7, 2012

Cocos2d This is How I make the player move back and forth


this is my function

-(void)playergo:(int) x: (int) y
{
    id action1 = [CCMoveTo actionWithDuration: x position:ccp(0, y)];
    
    id flip=[CCFlipX actionWithFlipX:YES];
    
    id action2 = [CCMoveTo actionWithDuration: x position:ccp(480, y)];
    
    id flipback=[CCFlipX actionWithFlipX:NO];
    
    

    
    
    
    id actionRepeatForever = [CCRepeatForever actionWithAction:
                  [CCSequence actions:action1,flip,action2,flipback, nil]
                  ];
    
   [self runAction: actionRepeatForever];
    
    //[self runAction: [CCSequence actions:action1,action2, nil]];

   
}

this is how i call the function
 [myplayer[0] playergo:5 :200];
 [myplayer[1] playergo:7 :220];
 [myplayer[2] playergo:9 :240];
 [myplayer[3] playergo:11 :260];
 [myplayer[4] playergo:13 :280];



below is the video, please enjoy, 

How to use array in Xcode for noob?

Well, I have successfully created my object, now i want to create let say 20 object but I don't want to create them one by one, so by using array , i can create one array that contain 20 object

Since I am a noob, I will use array in a noob way

let say my object is Player

this is how i declare my new variable

Player *myplayer[20]


this is how i use them

for( int i=0 ; i<20 ; i++)
{
    [myplayer[i]  walk]
}


this mean i will loop through 20 object of Player and ask them all to walk



14 days no update, what happen?

Well of course, I am busy, thats why I did not come back and update, I was still working with the same company and the working hour is almost 16 hour per day, 7 days a week thats why I did not managed to find time to update my blog and build my game

And also I got lost to what should I do next?

well, I guess I need to familiarize myself how to use the object to simulate like 100 people walking around my game, not just 1 or 2 dude

I will try my best