2010年10月28日 星期四

[IPhone] Fight Bingo Lite V1.0

Category top free 100 in 15 countries.
In Taiwan, Fight Bingo Lite got top 7.
Thank you very much.^^



The Fight Bingo Lite was on sales.
Simple AI with Lite version.

http://itunes.apple.com/us/app/fight-bingo-lite/id399638337?mt=8



2010年10月18日 星期一

[iPhone] Bingo Fight v1.1 update

V1.1.1 will fix this bug.
V1.1.1 was already in review.
Bug report:
Found a bug, when palyer won then click new game.
Touch board could not response.
Click new game again will fix it.
I will fix thisbug at next version.
Thanks very much.

Bingo Fight update to v1.1
1. Add fighter's fighting animation.
2. You can see two people fight with fire ball.

download link

Promotional Codes:
A6RWM3MHJNTR
69W36JX3MPM6
EAM3W9WJ93LL
ENNFXJ4PMH67
JL7MP3R3N4J6
JR673LW63L7W
9EA3EW3KXR33
9ENKF3XAE4FY
TWK6WXX9RHKN
LNAF6EKKMFEM







2010年10月6日 星期三

[IPhone] My first iphone app(Bingo Fight)

It's my first one Iphone Game (Bingo Fight) on sale now. The idea is from an Bingo Game that I made,
just simple rules that just get five lines to win.
Download with the link if interested as a treat to me for drinking.

Thanks Page Huang to support.

How to Play:
You must touch Left Board with number, then computer will cohice a number.
Five numbers to get a line.
If you get five lines first, you will win the game.

Promotional Codes:
X3KPAT9R4HA7
PH9KT3L4LEAY
TEMMW94ML4MA
NF7FHRYJ4YXJ
7ETX9TJ6RXHK

download link










2010年9月7日 星期二

[C++] Hex string convert to integer with stringstream

Sometimes we need to convert hex string to integer.
Usually we will use this alrorithm.
char xtod(char c) {
if (c>='0' && c<='9') return c-'0';
if (c>='A' && c<='F') return c-'A'+10;
if (c>='a' && c<='f') return c-'a'+10;
return c=0; // not Hex digit
}
This is a conventional usage.
Tonight I found a question in CSDN, then I try to found a better solution.
In stackoverflow, I found this answer.
It is very nice.
#include <sstream>
#include <iostream>

int main() {
unsigned int x;
std::stringstream ss;
ss << std::hex << "FF";
ss >> x;
// output it as a signed type
std::cout << static_cast<int>(x) << std::endl;
}

2010年8月20日 星期五

[C] OOP in C sample

Because I got a job, it was a C project.
So I am learning how to implement OOP in C now.
This is a example searched form google.
I use Xcode 3.2.3 with gcc4.2 to implement and test it.


#include <stdio.h>
#include <stdlib.h>

typedef void (*Walk_Fun)(struct Animal *a_This);
typedef struct Animal * (*Dtor_Fun)(struct Animal *a_This);

typedef struct _Animal_Vtable{
Walk_Fun Walk;
Dtor_Fun Dtor;
}Animal_Vtable;

typedef struct _Animal{
Animal_Vtable vtable;

char *Name;
}Animal;

typedef struct _Dog{
Animal_Vtable vtable;

char *Name; // mirror member variables for easy access
char *Type;
}Dog;

void Animal_Walk(Animal *a_This){
printf("Animal (%s) walking\n", a_This->Name);
}

struct Animal* Animal_Dtor(struct Animal *a_This){
printf("animal::dtor\n");
return a_This;
}

Animal *Animal_Alloc(){
return (Animal*)malloc(sizeof(Animal));
}

Animal *Animal_New(Animal *a_Animal){
a_Animal->vtable.Walk = Animal_Walk;
a_Animal->vtable.Dtor = Animal_Dtor;
a_Animal->Name = "Anonymous";
return a_Animal;
}

void Animal_Free(Animal *a_This){
a_This->vtable.Dtor(a_This);

free(a_This);
}

void Dog_Walk(Dog *a_This){
printf("Dog walking %s (%s)\n", a_This->Type, a_This->Name);
}

Dog* Dog_Dtor(Dog *a_This){
// explicit call to parent destructor
Animal_Dtor((Animal*)a_This);

printf("dog::dtor\n");

return a_This;
}

Dog *Dog_Alloc(){
return (Dog*)malloc(sizeof(Dog));
}

Dog *Dog_New(Dog *a_Dog){
// explict call to parent constructor
Animal_New((Animal*)a_Dog);

a_Dog->Type = "Dog type";
a_Dog->vtable.Walk = (Walk_Fun) Dog_Walk;
a_Dog->vtable.Dtor = (Dtor_Fun) Dog_Dtor;

return a_Dog;
}


int main (int argc, const char * argv[]) {
/*
base class:
Animal *a_Animal = Animal_New(Animal_Alloc());
*/
Animal *a_Animal = (Animal*)Dog_New(Dog_Alloc());

a_Animal->vtable.Walk(a_Animal);

Animal_Free(a_Animal);

return 0;
}

2010年8月5日 星期四

[IPhone] How to make iphone automatically distinguish 640 * 960 and 320 * 640 resolution






Using two images named a.png for 480*320 and named a@2x.png for 960*480.
Then use this code.
UIImage* anImage = [UIImage imageNamed:@"a"];