6/29/2009

Redoing battle system from scratch...?

I might have to redo the programming for the battle system from ground up. It turns out that my initial approach to doing this wasn't so good, I pretty much knew that it wasn't a great way to begin with, but as the battle gets more complicated, the harder it is to add more features. It feels too clunky as it is now, so it might be a good time to commit this.

もしかしたらそろそろバトルシステムのプログラミングを書き直さないとだめかもしれん。最初からあんまりよくないのはわかってたけどどういうふうになるかとかさっぱりわからなかったので「とりあえず」的なやりかたでやってたらやっぱり壁にぶち当たった。動きもダラダラやし、やっぱり1から書き直したほうがよさげなおさげ。しくしく。。

6/24/2009

Poison attack!

Now I got some poison attacks going on. There will be items and weapon that will do poison damage. Some monsters will have these too. I'm also drawing art as always. It's so much fun to do the art... Only when I can do it right really quick.

毒攻撃を導入。アイテムや武器で毒のダメージを与えることができる。モンスターも同様。
絵も同時進行で描いてます。絵描くのがめっちゃ楽しい。。。早くできればの話やけど。

6/23/2009

Excel data..

I tried to export the Excel spreadsheet of items and monsters to a text format I wanted. I couldn't seem to figure it out. Do I use macros or is there any better way... Does anybody know?

エクセルのアイテムやモンスターのデータを自分の好きなテキストフォーマットに出力する方法をリサーチ。残念ながらいい方法見つからず。マクロを使うか、何か他に方法はあるのか。。誰か知ってたらぜひ教えてください。

6/22/2009

Carried away with painting..



I've spend all day drawing today. It is quite fun. The good thing about drawing and painting is that it is possible to get better at it, to a certain degree, even if you don't paint. By observing the everyday life and how light hits the surface and think about the bouncing of the light rays, you'll understand why it emits certain colors. Maybe it is the same for programming too.

今日は一日中バックグランドを描いた。意外とはまってしまい、3つほどバックグラウンドを描いた。絵を描くということのいいことは、ある程度まで絵を描かなくても上達できるということである。日常生活で見る物の光の反射や形を観察していれば勝手に脳がそれを記憶していく。次絵をかくときはこうすればいい、という情報を得る。プログラミングも同じでデザインパターンなど思い浮かぶのかな。

6/21/2009

#pragma mark



This little tip will help you organize your code. It creates sections with bold fonts in your method pop ups like in the screenshot.

コードを整理するのに役に立つティップです。スクリーンショット参照。


#pragma mark Whatever you want to say

Background art



Painted my first original background in Photoshop. I think I'm go for the quick and easy way for these although they don't look quite as nice.. Maybe I'll touch it up later. Basically I draw a rough sketch using Wacom tablet, then I start painting with opacity set to about 50% for the brushes, this way, it'll give me the watercolor look and feel to it. I haven't done this in years...

このゲーム初のダンジョンのバックグランドをフォトショップで描いた。早く簡単に仕上げたいのとりあえずこのクオリティでやってみる。後で時間があればリタッチしようかなと。フォトショップではまず最初にラフスケッチをブラッシュで描いて、色は50%透明度ぐらいにしてからペイントしていく。これで水彩画のようなタッチになる。あとはペイント、undoの繰り返し。もともと背景画は中学、高校のころに描くのが好きでこの方法で描いていた時期もあったけど、最近は全然描いてなかったなぁ。

6/17/2009

if([myObject isKindOfClass:[UIView class]])

This gets pretty handy, the isKindOfClass: method. It's self explanatory, it gives you a boolean of whether if it is a certain class or not. I usually use it when I have random classes in an array and wants to do something with a specific class.

けっこうよく使うメソッドがこれ、isKindOfClass。配列にいろんなクラスをいれていて例えばUIViewのクラスならば、というふうな命令が下せる。


NSMutableArray *anArray = [[NSMutableArray alloc] init];
UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)];
[anArray addObject: [NSNumber numberWithInt:284]];
[anArray addObject: aView];
[anArray addObject: [NSString stringWithFormat:@"a string"]];

for (id aObject in anArray){
if([aObject isKindOfClass:[UIView class]]){
NSLog(@"aObject is a UIView: %@", aObject);
}
}

6/15/2009

More battle stuff

Back on track again. (hopefully) I think the game is playable now even though it is a bit slow still. I had to compromise the blinking animation when the monsters get hit.
So I got the attribute attacks working now. Monsters are put to sleep when they get hit with weapon that have sleeping attribute to it. But for some reason, the other monsters that didn't get hit are put to sleep. Nooo..

また波に乗ってきた、ような気がする、でもないこともない。とりあえずiPhone上でもなんとかプレイできるぐらいのスピードになったので開発を進める。
眠りの属性を持った武器で攻撃するとモンスターが眠るようになった。でもなぜか他の攻撃されてないモンスターまで眠ってしまう。なぜに。。でもたったこれだけでやたら戦闘に楽しみが増えた。

Hit the first wall

Weird bugs and technical difficulty slowed my development process for a couple of days. It works fine on the simulator, but the movement is a bit sluggish on the iPhone. I should have any problem with speed since my game is not based on action. Arghh..

開発スピードがこの二日間ほどちょっと下がった。バグやら技術的なことで悩まされる。シミュレーターではうまく動くけどいざiPhoneに入れて動作を確認すると1匹以上のモンスターを攻撃したときに少し動作が遅くなる。少し90年代のパソコンの動作の動きの鈍さを思い出させる感じ。こらいかんなぁ。

6/13/2009

NSSelectorFromString

I can pass in some strings as a parameter and then have it perform the selector method in the passed in method.

メソッドの名前をNSStringのパラメーターでうけとってそれを後でselectorとして扱う方法を発見。


- (void)performThis:(NSString *)aString {
SEL aSelector = NSSelectorFromString(aString);
[self performSelector:aSelector withObject:nil afterDelay:2];
}

6/12/2009

performSelectorOnMainThread

For some reason, I had the code below when I can just do [self addToBattleTextView:aString].
This was causing the thread to redraw the battle text in an arbitrary order. I don't need multiple threads for my game, bad idea for me to use it! It might have been ok if I had the waitUntilDone:YES, but I'm still novice to use multiple threads. Plus there's no good reason for me to use multiple threads at this point.

下記のコードを使っていたため戦闘メッセージがぐちゃぐちゃになってた。複数のスレッド使わなくていいのになんでこんなことになってたのか。。2時間ぐらい悩んでたyo、うぉにぃちゃん。大体スレッドの使い方把握してないし。

[self performSelectorOnMainThread:@selector(addToBattleTextView:) withObject:aString waitUntilDone:NO];

6/11/2009

Attribute attack and some problem with array

I'm starting to implement the attribute attacks, like attacking with a weapon to put enemies into sleep, which is going well. But I think I got a problem with something different here.. I'm having hard time putting the A, B, C after the enemies names when they are the same kind of monsters. It should be easy! The challenge comes from the fact that the monsters are displayed in a arbitrary order. Pulling my hair out in a graceful way.

属性攻撃を導入しはじめた。「まどろみの剣」で攻撃したらモンスターが寝る、とか。これはうまくいってるけどもう一つ違うとこで苦戦。モンスターの種類が同じ場合、A,B,Cとかで区別をつけるために名前の後に付け足したいのにこれがなかなかうまくいかず。簡単と思ってたのに。。なんで難しいかというと7匹のモンスターがランダムで表示されるためかな。優しく頭をかかえる数時間。

6/10/2009

Fixing things..

Always fixing things... bugs, but not even bugs maybe.
Side slash, diagonal slash, crush, are implemented. They do different damage and stuff.

バグとはいえないほどのバグなど細かいところを修正。
戦闘の横切り、縦切り、斜め切りなど導入。

6/09/2009

Swipe slash

Implemented the first swipe slash attack. These swipe gestures will do different attacking style like slash, hack, pound, etc.

スワイプすることで攻撃のバリエーションを追加。横へスワイプすると横切り、盾は兜割り、など。

6/08/2009

Damage number animation, scroll attack

Implemented damage number animation on top of enemies. For now, the more damage you do, the bigger the number it gets.
Also, the scroll attack to all enemies actually does damage and kills them. Attacking multiple enemies is the best thing!

モンスターの上にダメージ数値を表示。FFスタイルかな。クリティカルヒットの場合はちょっとスタイルを変えた表示も設置する予定。
あと、巻物で複数の敵を攻撃できるようになった。べりぃないす。

Xcode tips

Command + double clicking on it shows the header file.

コマンド+ダブルクリックでヘダーファイルを表示。

6/07/2009

Attack multiple enemies at once



Starting to implement the ways to attack more than one enemy at a time. I already have this set up with the dragging the finger across the screen to "slash" the monsters from different directions. Now I need to actually make it attack. Thinking about displaying the damage number above monsters instead of just having it in the scroll view.

多数のモンスターを同時に攻撃するコードを導入しはじめた。今はとりあえず画面をスワイプすることで剣のさばきを再現してるけど、まだ攻撃自体は作ってない。あと、モンスターの上にダメージ数値を表示しようかと考え中。たぶんやる。よし、やろう。
さてこれから本気モードで作っていくぞ。

6/06/2009

Level up, player death

Player actually gains level, and they now die. I had a hard time adjusting the size of the xp bar as they are collected. Be careful of the UIIView's clipsToBounds, they should be set to YES if you want to resize its bounds and frame. Wasted about 1 hour why my view wasn't changing its size.

レベルアップ設置とプレイヤーのHPが0になったときに死んで店に0階へ飛ばされるようにした。経験値バーの幅を設定するときにUIViewのプロパティであるclipsToBoundsがNOになってたため幅がどうしても100%のままだった。1時間無駄にしてもうた。みなさん気をつけてください。

6/05/2009

Xcode keyboard shortcut tips

Here are three simple Xcode keyboard short cut tips.
Xcodeの便利なショートカットを連載。

1) The Escape key for bringing up suggestion commands for specific class.
ESCキーでクラスのメソッドやプロパティのリストを表示。


2) Command + Shift + D lets you quickly view the header file of highlighted class.
コマンド+シフト+Dで選択したヘダーファイルを表示。


3) Command + Option + Shift + ? opens up the Documentation. This Documentation gets very very handy.
コマンド+オプション+シフト+?でドキュメンテーションを開く。

6/04/2009

Critical hit

Implemented critical hit for both player and monsters. Tweaking little detail as always.

プレイヤーとモンスターのクリティカルヒットを導入。細かいところを直していってる。

6/03/2009

MVC, Singleton, Delegate, NSNotificationCenter

It's hard to come up with a correct design pattern for you program. One of the useful one is NSNotificationCenter where you can access a selector from anywhere in your code.

プログラミングのデザインパターンをうまく構成するのはなかなか難しい。そこで一つ使えるのがNSNotificationCenter。使い過ぎは要注意。

Create a notification:


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(myMethod) name:@"myNotification" object:nil];


Call it from anywhere in your code:


[[NSNotificationCenter defaultCenter] postNotificationName:@"myNotification" object:nil userInfo:nil];

6/01/2009

Sell items

I finally implemented selling items at the shop. Added in info button for the items so that will will display detailed view of each items. It's an little property called accessoryView in UITableViewCell.

ショップでアイテムが売れるようになった。自分のアイテムのinfoも見れるようなった。UITableViewCellでaccessoryViewというのにボタンを指定するだけ。


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

....

UIButton *anAccessory = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *aImage = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"icon_info" ofType:@"png"]];
[anAccessory setBackgroundImage:aImage forState:UIControlStateNormal];
anAccessory.frame = CGRectMake(0, 0, 24, 24);
anAccessory.showsTouchWhenHighlighted = YES;
[anAccessory addTarget:self action:@selector(tappedAccessory:withEvent:) forControlEvents:UIControlEventTouchUpInside];
anAccessory.userInteractionEnabled = YES;
cell.accessoryView = anAccessory;



- (void)tappedAccessory:(UIControl *)button withEvent:(UIEvent *)event{
NSIndexPath *indexPath = [self.theTableView indexPathForRowAtPoint: [[[event touchesForView: button] anyObject] locationInView: self.theTableView]];
NSLog(@"%i", indexPath.row);
}