Monday, April 10, 2006


The Dentist

 Hehe, been awhile since I posted. I've been busy hacking away at some special projects and experincing other interesting stuff about Japan. And watching Battlestar Galactica, Stargate, Lost, etc etc. :)

Well I went to the dentist here; since its been a year since I went back in Texas I thought it would be a good idea to go. Also, perhaps more importantly, I wanted my girlfriend to go, since its been a looooooooooooooooooooong time since she had gone.

The thing is, she is not so keen on drills, and the dental technology (as well as technology in other fields of medicine) is well behind the US (10 years or more). So she was kinda scared to go. But I pushed her, and she eventually found a University affiliated Dentist thing here (like a big ole dentist super complex) that we had newer technology and would probably be safer, and I promised to go with her.

So we went, and really, she made out pretty freaking well considering the amount of time it had been since she had gone. Of course that might be related to the fact she doesn't down a few liters of coke a day like I used to ;)

I also made out well, and just needed a cleaning. One interesting thing about the way they did business there was they made you come in the first time for just a checkup, then you had to make a second appointment to come back for the work you needed. Kinda different than what we expected. ;)

For the cleaning the technology wasn't too different, but yeah it was definitly older than what I was used to in the US. Also, I found it very suprising that the dentist actually told me to close my mouth some at times ;) I have grown quite acustomed to having the dentist frequently tell me to "open your mouth a little wider" you know, so it just struck me a little funny at first.

But you know, aside from the technology, things were pretty similar. Luckily my dentists also spoke English. Otherwise, that woulda been pretty pretty tough ;)

Friday, February 24, 2006


TQ on a bigger screen

 We took my laptop to Kamakura a couple weeks ago to watch that gay cowboy movie (well, I always take my laptop there so I can work on stuff) and found out that the TV there had a monitor input connection. So we plugged in my laptop and it worked like a champ. I bought and brought an S-video cable to try too, but it turns out that the monitor cable was noticably better in terms of resolution (I think the S-video supported about 1024x768, but the TV could do around 1600x1000).

After about an hour of watching the movie, which I had "found", it ended abruptly in mid-scene. Whoops ;) Turns out I had only "found" half of the movie. So, it was a really long preview I guess. :)

But I realized there was an important oppritunity here, and took advantage of the situation to try something really cool. Playing Texas Quest on a big wide-screen TV:



Thursday, February 09, 2006


Land of Legends

 One thing that bugged me about Texas Quest after I finished development was how terribly AWEFUL it looks on certain machines or graphics cards. I *think* I know why now, but its really crazy how badly the sprite class works on some machines cause you totally dont expect it. So if you are making a 2D game (or heck even 3D) make sure you test it on multiple graphics cards and stuff.

Anyways I downloaded a demo for Land of Legends after reading about it on some independent game websites. It looks pretty cool, and it turns out they used Managed DirectX. Just like me right? Well looks like they had the same problem I did. There 2D stuff has trouble on my girlfriend's mom's computer just like Texas Quest did. So, even though that kinda sucks for the game makers, I think it just goes to show you that making games with Managed DirectX is still not as easy as the APIs make it seem like, even for real games. :)

Tuesday, January 31, 2006


How about some numbers

 In my continuing struggles to learn Japanese I have learned that numbers are hard: counting always messes me up in Japanese because there are just a ton of ways to say the same numbers. Well its not when you are saying the same number exactly, but its like when you want to say 4 days or 4 months. The "days" or "months" part becomes a suffix like thing on the number (called a counter AFAICT), and the writing looks the same (aside from the counter) but the pronunciation of the number part varies WIDELY depending on the suffix/counter/subject (and sometimes the counter part changes too).

So the normal numbers, written and pronunced are:
1 ichi いち 一
2 ni に 二
3 san さん 三
4 yon/shi よん/し 四
5 go ご 五
6 roku ろく 六
7 shichi/nana しち/なな 七
8 hachi はち 八
9 kyuu きゅう 九(though this bugger changes to kuu all the freakin time!)
10 juu じゅう 十

And from there it just works normally. For example 14 is juu yon (10 4).

(Keep in mind that usually you see Arabic numerals, not Chinese Kanji for numbers. Which is sweet ;) )

So for examples of what I am talking about...

1. Months
Months are not given fancy names like in English, but are just a number + month suffix:

ichi gatsu
ni gatsu
san gatshu
shi gatsu
go gatsu
roku gatsu
shichi gatsu
hachi gatsu
kuu gatsu
juu gatsu
juu-ichi gatsu
juu-ni gatsu

Thats January threw December right there. Thats not so bad. Months kinda make sense.

2. Days of the Month

But days of the month, this one always freaks me out...

tsuitachi
futsuka
mika
yo ka
itsuka
muika
nanoka
youka
kokonoka
touka
ju-ichi-nichi
ju-ni-nichi
ju-san-nichi
ju-yo ka
Then the rest are normal up till up till 24 again

Well thats just a small example. Theres no reason for me to go into deeper detail at this point. And thats mainly because I am quite tired since we went to bed early last night and I have been up since (gasp!) 8 am!. Anyways though, I have learned that while this is hard its not as hard as Hindi, or some other regional Indian langauges. They apparently have a unique name for EVERY number between 1 and 100. Can you imagine having to memorize all that just to do arithmatic? WOW!

Friday, January 20, 2006


Thursday Night Lessons

 We took a break from lessons Wednesday night because of my company's long quarterly meeting and dinner at the Pink Cow in Shibuya. But we had some more time last night so I thought we would do those today. It’s a little shorter than last time, but just as important:

1.
Statement In Kana:
そのレストランはおもちかえりをできませんでした。
Probably how it is written:
そのレストランはお持ち帰りを出来ませんでした。
In semi-English:
That(sono) Restaurant(resutoran) (topic marker wa) takeout(mochikaeri w/ honorable prefix o) (subject marker o) could-not(dekimasen deshita).
In English:
That restaurant couldn’t do takeout.

Keywords:
お持ち帰り Take out
できます Can (or to be able to)

2.
Statement in Kana:
いつかアーちゃんはそのレストランをつれて行くつもり。
In semi-English:
Sometime(itsuka) Aa-chan(me ;) ) (topic marker) that restaurant to(direction maker e written へ) to-take-with(tsurete-iku) plan-to(tsumori).
In English:
Sometime I plan to take Aa-chan with me to that restaurant.

Keywords:
いつか Sometime (however, the same word, spelled the same way, can mean the 5th day, I am not sure if it is pronounced the same too, because my sweetie kept on telling me to put emphasis on different parts to make them sound like two different words, but either I can’t pronounce it or something cause I couldn’t hear or pronounce the difference between itsuka some-time and itsuka 5th day)
つれていく To-take-with-you (hmmmm the dictionary online says this means the other person is of lower status… I wonder what she meant when she said that to me!?)
つもり I kinda remember this from lessons I tried to do awhile ago. It means to-plan-to.

Wednesday, January 18, 2006


Tuesday Night Lessons

 Some more lessons, courtesy of my sweetie:

Obviously you have to at least know the kana systems to make sense of this, and some kanji helps too. This is a great reference for looking up words, and this is pretty good at translation, but doesn't do well if you don't use Kanji. But if you are curious and need help, ask :)


1.
Question in Kana:
けさはなんじにおきましたか?
Question how its probably written:
今朝はなんじに起きましたか?
In semi-English
This-morning (topic marker) What time (at) wake-up(past-tense) (question marker).
In English:
What time did you wake up this morning?

Keywords to remember:
けさ / 今朝 This morning
おきる / 起きる To wake up

1.5.
Answer in Kana:
くじはんぐらいでした。
Answer how its probably written:
9時半ぐらいでした。
In semi-English:
9 o’clock half about was
In English
About 9:30.

(Note I think you can use the present tense of desu (です) here instead of the past-tense deshita (でした)).

Keywords to remember:
はん / 半 Half

2.
Statement in Kana:
明日はもうちょと早く起きたいです。
In semi-English:
Tomorrow (topic marker) a-little-more early to-wake-up
In English:
I want to wake up a little earlier tomorrow.

Keywords to remember:
はやく / 早く Earlier (adverb)

2.5.
Response:
それはいいことですね。
In semi-English:
That (topic marker) good thing is (emphasis marker)
In English:
That’s a good thing (isn’t it)

3.
Statement:
お昼は韓国料理をたべました。
In semi-English:
Lunch (topic marker) Korea cuisine (object) ate.
In English
For lunch I ate Korean food.

Keywords to remember:
料理 / りょうり  Cuisine (following a country word it is like "(that countries) food")

3.5.
Response:
おいしかったですか?
In semi-English:
Delicious(past-tense) is (question marker)
In English:
Was it delicious?

4.
Question:
あなたの会社はどこですか?
In semi-English
You (‘s) Company (topic) where is (question)
In English:
Where is your company?

4.3333...。
Answer:
田町です。
In English:
Tamachi

4.6666...。
Response:
おいしいラーメン屋(や)さんがありますか?
In semi-English:
Delicious ramen shop (subject) are (question)?
Are there delicious ramen resturants there?

Keywords:
や(さん) Shop of a certain type. (Note: men don't say the SAN)

Tuesday, January 17, 2006


3D Game Alt+Tabbing Update

 After finding some excellent code on: The Drunken Hyena (great name BTW) I figured out that I wasn't doing anything specifically wrong, I was just donig tooooooo much crap. I took out my windows OnResize handler that was calling reset, change my Render a bit (though I don't believe that was having an effect), and finally put the OnDeviceResize event handler back in there to cancel the device's automatic resize. And now it works like a CHIZAMP! I can't believe how simple it is ;) I think I will post a decent update on it, with the code and instructions. That would make a good third tutorial probably ;)

In other news I am only 24 minutes away from episode 12 of Battlestar Galactica season 2. SWEEEEEEEEET!!! God willing that my Virtual-PC for downloading doesn't crash of course ;)

Some Lessons

 One of the things I really want to do here in Japan is learn Japanese. Not much of a surprise huh? So I have been slacking off on my learnings lately, but am trying to get back on the path. I've considered going to a class, and may do that eventually, but right now I got a book and a Japanese girlfriend, and I am hoping that suffices. I have actually been studying for awhile now off and on. Actually, almost a year ago really! Wow, thats hard to believe... cause I haven't made that much progress ;)

The funny thing is I still think I can understand more Mandarin Chinese from that single class I took in college than Japanese. I don't know why, but for some reason Mandarin makes sense to me... aside from that crazy pronunciation that I can't get ;)

Anywells, time for some Japanese lessons:
1.
Question in Kana:
おひるはなにをたのみましたか? 
Probably how it is really written:
お昼は何をたのみましたか?
In Romanji:
Ohiru wa(written ha) nani o tanomi mashita ka?
In semi-english:
Lunch (topic marker) what (object marker) request(as noun) (past tense) (question marker)
In English:
As for lunch, what did you order?

The keywords to learn here are:
おひる / お昼 Lunch
たのみました Order (past-tense)

1.5.
Answer in Kana (note, I am not 100% sure about the spelling of some of the words here):
ぺペロンチーノのAセットでした。
In Romanji:
Peperonchiino no A setto deshita
In semi-english:
Pepperoncini (‘s) A set was
In English:
I had the pepperoncini spaghetti (that’s kinda implied) A-set.

2.
Question in Kana:
渋谷から品川までどのぐらいかかりますか。
In Romanji:
Shibuya kara Shinagawa made dono gurai kakarimasu ka
In semi-english:
Shibuya (city in Tokyo) from Shinagawa (city in Tokyo) until how-long takes (question marker)
In English:
How long does it take (to go) from Shibuya to Shinagawa?

The keywords to learn here are:
かかります To take (verb)
どのぐらい How long

2.5.
Answer in Kana:
じゅうご ふん ぐらい かかります。
Answer how it is probably written:
十五分ぐらいかかります。
In Romanji:
Juu go fun gurai kakarimasu.
In semi-English:
10 5 minutes about takes
In English:
It takes about 15 minutes.

The keywords to learn here are:
ふん/分 Minute (it’s a counter, more on that next time)

Update: January 18th 2006:
Fixed some spelling ;) Thank you sweetie :)

Monday, January 16, 2006


Still not dead ;)

 I have had some time to delve a bit more into some graphics programming as of late, and have realized how much I don't know. But the great thing is I know I am making progress. Looking back six months ago, I can see how far I have come. I can't believe I got away with how simple some of the graphics stuff I did in Texas Quest was.

But learning this stuff is a slow process without a book ;) Hmmmmm, perhaps I should invest in one of those... nahhh I will just bang my head up against the wall :) The web sure has a bunch of great tutorials out there... but ahh, none that are perfect. I think the best I have found are here: C-Unit. Though I have to disagree with the design of his framework in some ways, namely that it seems to be growing in the same direction as the seemingly-bloated, reportedly slow, and massive Microsoft sample framework. But still its nice.

The current problem I am trying to surmount is how to freakin handle alt-tab correctly ;) I got it working fine in Windowed mode, and my full-screen app doesn't crash when switching, but after coming back from the alt-tab it never redraws itself and apparently goes into some kind of device lost/reset loop or something. Greeeeat ;)

However, I am proud to say I can do:Device.IsUsingEventHandlers = false; in my code with no fear of troubles.

Wednesday, January 04, 2006


Happy Holidays

 Well its been a two week vacation for me here, most of which I have been busy not doing much, so as I catch up with real life again here I'll be posting more. I'm not dead ;)

Wednesday, December 21, 2005


Meanings...

Its really funny. Sometimes you go through a huge part of your life thinking something means something, when in fact it means something totally different. Well, in this case its not totally different, but realtivly so. So I am sure everyone knows "69" and what that means, right? Well not me apparently ;) I always thought it meant one certain act performed by one person of a party of two, whereas it is actually two complimentary acts performed by both persons of the part at the same time (hows that for PC?) ;)

I found out last night while my sweetie and I were surfing the web and came across a "Delivory Health" site, which is the Japanese English phrase for prostitutes that come to your home. Prostitution seems to be technically illegal here, but I cannot believe it is really enforced well. Like I said, this is a prostitution website, that was easily found, and you could easily order from ;) And you goooooooooooooottttta love that name!

Anyways on that site they list all the girls you can order with their pictures and stats, and the things that they will and will not do in a nice organized little 6x6 grid ;) Very easy to use. They had several categories for different things, and my sweeite had to translate most of them for me, but of course some, like "69", have no need to be trasnlated (or so I thought). When going through them she told me what one set of Kanji meant (or it coulda been Katakana)... but then I thought, isn't that the same as this "69" over here...... and well then she tells me all about it, so now I know ;) (One other interesting thing about that site, that I'd just like to add, was that it was selling its girls as all married women in sexless situations, which is interesting in a way. I guess its a good way to make some extra cash if you have the free time --- which apparently you would ;).)

Then the really weird part is, on the way into work today I was thinking about this and how I should write about it, and I saw someone wearing a shirt with a big ole "69" on it. I thought how weird! Then I saw above the "69" the word "God" and I thought... what the heck does that mean? After thinking about it a bit more, I came to the conclusion that I, thankfully, was not the only person left on the Earth who didn't know what "69" really meant ;)

Update: Wednesday the 4th of January 2006:
My sweetie reviewed this entry and informed me that this is not technically a prostitution service, though it really is. The thing is the law is very clear and distinct about what sex is, and some of the things we might consider sex are not legally sex because they can't ever make babies, and thus if its not legally defined as sex, it can't legally be defined as prostitution.

And for that act that can make babies, as long as the man and woman from the service establish a relationship before commencing then its not really for money, right? That money pays for the other services ;) Thus, its still not prostitution. :)

Monday, December 19, 2005


Java is soooo 90s, part 3

OK... again where was I ;) Well we never made it to the gym, but we did have a nice weekend in Kamakura, where we will probably also be spending new years too.

So as I was saying, it seems like a lot of the really nice programming constructs that Java could have had to make things easier, they decided to go without. It always seems like I write more, and harder to understand code in Java than C++ or C#. Of course Java lends itself to the most object-oriented coding I ever do so I'll give it that. Ahhhhh well my point seems to be getting muddled here. What I am trying to say is that in Java, it seems like they wanted you to write more code. And I don't know why. Longer for-loops, tooooons of class casts, toooons of exception handling, pseudo enumerations, tons of null checks, boxing and unboxing native types... it just seems to be a big pain to code sometimes. I suppose that is my biggest compaint against the language. I really do like some things like declared exceptions and ... well I guess thats it ;) The class library I guess. Which is probably Java's biggest boone.

Of course... then again the class library is hard to get a handle on sometimes (i.e. Swing)... For the most part I like it, but it seems so incomplete for what I need to do. I always have to import jar's for xml processing, servlets, MySql... I don't understand why this huge class library doesn't include these important things... but anyways thats probably no big deal. I don't get upset at C++ for lacking those things, just Java because .NET does it so much better. I suppose thats the benefit of coming in second.

Though .NET did come in second, it really does feel ages ahead of working with Java. Signifigantly so when it comes to the class library, but extremely so when it comes ot the development tools. Eclipse is really cool and I like it alot, but it still lacks some of the refinement of Visual Studio (and it isnt until recently that I think Eclipse has been better than Visual Studio in many ways, that whole decade Java had to itself was kinda lost doing something other than IDEs... what, I dont know). Then when you get to Apache vs. IIS you gotta say: what the Frell? What an absolute dinosaur. Config file upon config file upon config file. And god do not mess up the order things are loaded. Geeze. MySql is nice though, and from what I have used with it so far I like it just as much as SQL Server.

So I should probably end this 5 day long mini-rant by saying Java started good, ended poorly. It had so much promise... but that was squandared in tons of config files, mundane coding tasks, and frankly poor performance. Changes that rectify these problems are occuring today it seems (not the config files thing though), but its too late. They are lost on most programmers. Java just dropped the ball basically. It is so 90's.

Friday, December 16, 2005


Java is soooo 90s, part 2

OK, where was I... ahh yes ;) I had to do some work yesterday, and more work today :( I also got my first taste of testing a handset with BREW. I guess thats a story for a different time though, today we are talking about Java.

Again, let me state that these are just my opinions, I make no claims to be complete valid with everything stated. So like I was saying Java feels much different to use than C++ its easier, shinyer, and facistic. Writing something in Java feels wrong to me in the way that I think things should be easier. When Java came out there were no generics, no enumerations, no pointers to functions, and no for-each statement. Each of which vastly reduces the code you need to write. Some still arent around in Java. It felt like the designers had one way for you to use the language, and there way was the best way so do it that way. Generics, I can kind of understand their abscence. They are quite complicated, and C# and Java today have them, but nothing as cool or hard to use as C++ templates. Maybe thats a good thing, but the total abscene of them totally sucks. At least C# had a for each to get rid of some of the crappy mundane casting and Iterator.next, Iterator.hasNext coding. Java on the other hand in each way held to the theory of: write more code! We love casts! I mean, why did it take 10 years for them to add enumerations? Its something EVERY part of the language uses... And I forgot about boxing/unboxing of native types. What a novel idea! Its a little more complicated, but Im sure anyone with half an IQ point can figure it out ;) Nope Java elected for the easier method of ... typing! Yeaa! Well, I'll continue this rant another time :)

Ok gotta go, sweetie is coming home and we are going to the gym tonight (probably) and the beach tomorrow. Sweeeeeet!

Thursday, December 15, 2005


Java is soooo 90s

I read this article yesterday about how the Java language is loosing ground to newer languages and technologies. Its an interesting article, so I suggest giving it a read. Since I work in Java now, again, after having working mostly with .NET (and doing a decent sized .NET project), and having used Python, it is very interesting to hear other people's opinions on Java.

Now since this is my soap box here I thought I would sound off on my personal opinion of Java. Java was a great idea in some ways, it filled a niche that needed filling back in the day. It wasn't near as complicated as C++, nor was it as exotic as functional languages. It was also easy to get small neat things done like in VB. So in a way I see Java as a middle point between VB and C++. Its great for those programmers who can't be burdened by the details of memory management or pointers or, you know, real programming stuff :P Joking. Seriously though, Java feels very distant from C++, though its so similar. It really feels less powerful. I guess thats good in a way... oh wait, I gotta go do some work now. I'll finish this later ;)

(On another note, whats up with my pictures. Imageshak must be goofing around...)

Monday, December 12, 2005


A Very Peanutty Xmas

Its going to be a very special Christmas this year for my family and best friend. A very special, peanutty Christmas. Since most of 'em can not think of anything they want rather than money, and I am really not sure what to get them in general, I decided and sent a good load of Peanut Butter home from here (Tokyo). Now that might seem strange, because it is strange, but keep in mind that it is really freaking good peanut butter. On the order of the stuff from inside a Reese's Peanut Butter Cup mixed with some butter and sugar. Its really quiiite good :) Hope my family likes it, cause after Twelve thousand yen two small boxes of this stuff is on its way back to Dallas. Merry Christmas ;)

Wednesday, December 07, 2005


Isometric Game Screenshots

 And just as an update for the world, some new screenshots of the Isometric graphics engine I am working on for a pet-project-game (WITH that darn graphics problem I wrote about awhile ago very much fixed):


World at Standard Zoom:



World's Zones at decent Zoom Out:


For the MOST part the graphics part is doooooooooooone for this stage of the game. With the exception of a few minor bugs and enhancements I want to do. This might be it, but I am thinking now that GUI controls and widgets might make sense inside the display, whereas previously I had thought they would surround the display. If I do decide to put those inside the display that means more graphics work :( And I am leaning that way... hopefully it wont be so bad ;)

Greasy Fish

God I love ramen! Cod is really greasy! I grilled... or I guess more accurately fried maybe some last night... or actually, you know what, I am not sure what to call what I did to the fish. I didn't do anything exotic, but just put the darn thing in a pan, spiced it up some, and then turned the stove on and let it cook there. I guess thats frying, but usually when I think of frying I think of something like fried chicken, with that crispy and delicious batter ;)

Anyways it turned out good for my not having any experience cooking it before. But man was it greasy. All sort of yellowish fish grease leaked out and started splattering. Man I hate it when grease splatters. I have no idea how to handle that yet. So I just take the pan off the stove and let it cool down.. and turn the temperature down. I guess most people don't get worried when they see splatter like that, but it kinda freaks me out. :) Like I said, the fish was good, so all in all, it was a success :)

Tuesday, December 06, 2005


Soybutter

 Ugggh. Why do people try to make normal foods out of soy beans? I mean what the heck are they doing trying to make peanut butter out of soy beans!? I was at the store last night picking up some peanut butter to send back home for Xmas. Which I guess sounds kind of weird, but this Japanese peanut butter is really awesome. Its like the peanut butter inside a Reeses Peanut Butter Cup minus the choclate but plus butter and extra cream. Seriously its so light and creamy and delicious! So I figure, since back home we only have JIF, Peter Pan, and (unfortunitly) Skippy, I thought this awesome peanut butter would make a nice present. So I went to the store and bought 3 little tubs of it. Went home, showed it to my sweetie, who promptly told me Kinako, which I thought was the brand name, means Soybean :(

So we tried it, and well it wasn't aweful, but it wasn't as good as the normal stuff. Not in any way shape or form. So now I gotta go by more tubs of the real stuff tonight, and gotta eat three tubs of that soy butter stuff... I contemplated throwing it away but it costs so much and there are three tubs of it. Plus I threw away some Skippy once and my sweetie still reminds me of that lapse in sound judgment (maybe because Skippy is her favorite for some reason ;) ).

Which brings to mind that weed juice I bought once from Dean and Deluca (which is like a cross between Eatzi's in Dallas and Starbucks). Instead of milk they had Vanilla flavored soy milk, so I figured that must be similar right? They call it "milk"... it says Vanilla... well, nope they lied big time. It sucks. In fact it tastes like weeds. I am not joking. (Of course I have never eatin weeds, so I technically mean it tastes like how weeds smell after you have been doing some yardwork). It was the most aweful crap I have ever drinking. And I have even drank Diet Coke.

Monday, December 05, 2005


Banking

 One thing about working in Japan that you notice quickly, is that Japanese banks are than American ones. In fact, banking in general is quite a bit different. There are no checking accounts, no monthly statements, and no intrest here. At least as far as I can tell. The ATMs are free at your bank just like in the US, but transfering money electronically isn't, which is, again as far as I can tell, the preferred method of exchange between people since there aren't checks here. So when I wanted to pay my sweetie for rent, since we are sharing that, it actually costed money. Had I just withdrawn cash though, it would be free. Its weird... something like an electronic transfer should be quite inexpensive for the bank to process... especially since we both have accounts at the bank.

But I guess you gotta deal with it. Also it seems common to only get paid monthly here. I am thinking the cost associated with transfering money is why.

Thursday, December 01, 2005


Living

I've been quite busy over here as of late in the land of Dai-chan. But my sweetie makes me seem like a NEET (interesting Japanese term for people of younger generations who are Not in Education, Employeement, or Training, i.e. bum people who live off the government and are outside the culture in a weird way). Seriously, my sweetie works like 14 hours a day some days. That means even with a day off she will still work more than me in one week. Hard to believe. Japanese work hours are crazy. I'm quite lucky I am working for a fellow expat Texan here. :)

Thanks Kurt!

Kurt has graceously provided a new place to host Texas Quest, so from now on you can find the game and source and everything at: http://coinop.org/KB.aspx/KB/ZZ-Hosted/!

Thanks Kurt!

Thursday, November 24, 2005


More than a week...

Well its been over a week since I posted, but thats mostly cause I was working on the next part of the tutorial and working on trying to fix that stupid incredibly frustrating graphics problem I was having. I eventually figured that out and will post it sometime. It was sooooo frustrating... graphics programming is the pits for me. I don't know how people love it so much. I love to see those great nice looking results, but I am just so much more into architecture and design.

Well, if any graphics programmers out there read this I don't mean this as an attack or anything. I am just saying WOW. I spent one week on a problem and was completely frustrated by it. I mean I made progress but every step I made it seemend like there was something else going wrong. And I was using Managed DirectX which seems to be orders of magnitude easier to use than straight DirectX. I just cannot see graphics work as something I could do, even though I love a challenge it borders on a game against the grand master of Go rather than a game of Civ 2 at deity level. That is to say the learning curve sucks cause I love and know Civ 2 so well and don't know Go at all. OK, enough blathering for me for one day.

Texas Quest Tutorial Part 2: Design Part 1


Part 2: Design of Texas Quest Part 1

I am writing this document as part of the very infrequently updated Texas Quest tutorial series. I suppose I should put “series” in scare quotes there because at this point there is only one entry in the series until now. ;) If you can ignore that, then what I am trying to do here is describe the overall architecture of a side scroller game before getting into more details of the rendering, which was going to be next. The architecture is usually the really fun part anyways, as graphics are, to me at least, quite frustrating (see the previous blog entry, which I did actually figure out eventually).

I am going to assume the reader is familiar with my side scroller game Texas Quest or at the very least games like it such as Mario World, so I am not going to detail their features. Also this guide, while based on Texas Quest and my experience making that game, may of course be used for other side scrollers and maybe even other types of games. In fact that’s why I am writing it, so that someone else making a game will have a good head start. But realize that there are always many many ways to do things in programming, what I detail is one way, not necessarily the best or even quickest either.

I should also mention that Texas Quest is kinda my second side scrolling game. I did another one back in the Winter of 2001 and got pretty far with it until giving up. I developed a lot of the concepts for Texas Quest there, so no one should think I came up with this whole design on a first pass or anything.

Levels

Levels are perhaps the easiest part of a game to design because it is really quite obvious what is needed from them. The reason for that is when you know everything required you can just put something together that does exactly what you need. The design flows from the requirements, especially with the case of levels since they are not too complex. So we start with levels for that reason and for another reason we will detail in a bit.

The level architecture goes as follows: A level has one or more level areas, one of which is the primary or starting area. Other than that a level doesn’t have anything else… except what I like to call a starting script. This is optional, and dependant on how you want to do scripting in your game. But this is the kinda thing that lets you play a little scene when the level starts. So it is neat and adds something special to a game that people expect nowadays. Oh, and when I say scripting I don’t mean a scripting language either, just a script in that it’s a series of predefined instructions. In Texas Quest I just had a few pre-built script classes (e.g. Level3StartScript, Level5StartScript, etc, etc).

Now for level areas. These objects are the maps or areas that you visit and explore in a game. The reason we separate out the maps from the level is that we want a level to have many relatively independent areas to explore, such as in Mario Brothers when you go down a tube you are no just taken to a different part of the level, but a whole new area with its own map. That’s what we are modeling here. A level area has the following components:

I call all active game objects (e.g. not tiles) Characters. So a level area has to maintain a list of Characters and where they start at. Characters can be enemies or items, or neutral things like blocks or really anything else you want, and we will discuss them in much more detail later. What I want to make clear now is that you need a list of them in your level areas that at a minimum includes what the character types, starting locations, and starting information (e.g. for a Question Mark Box character, what it contains). I will detail the way I did this later. Entry points are one end of the links between level areas. They are the exiting end, and the entering end is characters such as pipes or doors. There should also be some way of telling which entry point is the starting one for this area if this is the primary level area for the level. I just use the first entry point in an array but something more elegant could be done as well.

So… next are tiles. Let me say the way I did this in Texas Quest is wrong. I didn’t use a Tile class (actually a Tile struct would be more appropriate anyways if you are using C#). I used three matrixes of tiles. Each matrix is of integers. The integers are indexes into one of three different pseudo-arrays of tiles images. The matrixes are used to draw the map. So one matrix is for the foreground, another for what I call the mainground, and the final is for the background. There is another matrix containing movement information. Its cells are of an enumeration type with three possible values: Freely, StopsAll, JumpThrough, meaning respectively, this tile can always be moved through, this tile can never be moved through, and finally this tile can be moved through when traveling horizontally, or moving up (e.g. jumping).

What you should do is have a Tile class (again struct if you are using C# like I did). It should have an integral type (probably byte or ushort depending on how many tile types you have… byte if you have 256 or less, ushort otherwise (unless you have more than 65 thousand, which is very unlikely I think)) for the background, mainground, and foreground (and other layers if you want them). Each of these should index the same tile image array. Do not use three different tile image arrays like I did in Texas Quest. That’s silly and is bad design ;) Then you should have the same enumeration type I had in Texas Quest, with those three possible values effecting movement through the tile (Freely, StopsAll, JumpThrough). This will make things more clean.

Interlude

Now that you have gotten your level design down, now comes the first hurdle I like to cross: getting a map editor working. This has been a really great way for me to go about games, because I get the first and main round of graphics work done without getting into Character animations or anything, and I can make sure the level architecture works and looks good. I highly recommend doing this before getting into the core Engine part of the game. That may seem more appealing and rewarding, and it probably is, but getting this core work done will help you in the long run.

Characters

OK, now for characters. We are going to cover what attributes make up a character here, without getting into event handling for character interaction toooooo much. But we will touch on some of the basics for it as we detail what makes up a character. As I stated above, characters are all active objects in the game. Pretty much every game object aside from tiles is a character. You (as in me in Texas Quest, or Mario in Super Mario World), enemies, blocks that might break, blocks that interact with the user in any way, coins, other items, and even special effects (like the sparkles that appear after you collect a coin). I am going to list the attributes of characters in three sets: type based, instance based, and a small set describing how a character is added to the map in the level editor.

All characters have a class, such as Tutrle, and that has some attributes with are pretty much constants, such as maximum speed. These are type based character attributes. Characters also have some attributes like location, which changes. Those are instance based character attributes. Pretty simple really. What I did in Texas Quest is create an abstract class called Character that has both sets of attributes defined but not implemented (since they are abstract). That means ever Character subclass has to implement these attributes, and the difference between the two is that the type attributes can be gotten but not set so they should be more like constants. In a previous game I wrote I created a class called CharacterType and a class called Character. The CharacterType class had the type attributes, and the Character class had the instance attributes (plus a reference to the CharacterType class). Then I was even so bold as to make a small scripting language that defined the character types via a rule script file. Such that all the important stuff about the characters was dynamic and built at runtime instead of in the code. It sounds great. But it was toooooooooooo much work. And I got bored with it and let it die eventually. It is muuuuuch easier to build your Character classes at compile-time than at run-time, especially when you get to event handling. So just take my advice here, and if you are working on your first game, do not be too ambitious!

OK, so back on track here are character attributes:

Character Type Attributes

Character Instance Attributes

Character Level Editor Attributes

Wow that’s quite huge huh? I think they are all pretty straight forward and its pretty obvious why they were needed. How I implemented my character classes was to have this base abstract Character class whose attributes I just listed, and then have a ton of concrete subclasses like Turtle, Coin, and Aaron (the main character ;) ). There are some classes between the two (StandardCharacter, Enemy, Item) that are also abstract but provide some common functionality for their subclasses. The line between type and instance attributes is blurred a bit because of this, since the concrete subclasses do not have to return constants from the type attributes. But they for the most part do. Almost all type attributes return constants in all concrete character classes. Instance attributes depend on the character state, so naturally should not.

In addition to these attributes, the Character class also has several abstract methods that I am going to detail here. I want this to be complete so that’s why I am putting these all here, but a large number of the methods relate to event handling and will really be examined better later.

Character Methods

Now like I was saying about the characters and the level editor, the way I did the level architecture, specifically level areas, has each level area containing a list of characters. What I do is add an actual honest to goodness entire character to this list. That entire character is saved with the level. Most games probably use a character-stub for this, and as I said above you could probably get away with just putting a (type, location) into the list for your characters. Until you wanted to do things like set the item in a Question Box. Or set the number of coins in a Coin Bag. Or set the number of hit points of a Turtle. Or a million other things. I found it was just easier to put the whole character into the map so that all attributes can be modified. Then when the map is serialized and deserialzied the character comes with it (in .NET you have to set every character class with the SerializableAttribute before you serialize).

However this leads to the need for the Duplicate method. Once we have loaded a map with its level area’s and characters, we need to create an active set of characters running in the game. But if we use the same characters that came with the map, then when the player die’s and has to restart the level the map has to be reloaded again. To get around that silliness we can just clone every character from the map that should be in the running game when it is started, then if the character die’s or the level otherwise restarts we just trash the running character set and create it again, without having to reload the map.

Interlude 2

That’s quite a lot to digest so before I get any further I am going to take a break. If you have any questions, post them! Ill write the next part of the design soon (soon my time = a month or so probably, sorry :P)


Fish Head Day

God I love ramen! You can't say much about Japan if you can't say that they love their fish! This past holiday (the 23rd is some kind of labor day: translation weird middle of the week day off) we went to a fish market near Akihabara (the famour electronics town) and picked up a tuna head. Thats right, they head of a tuna ;) Sweetie grilled it and made quite a good dinner out of it, especially when combined with watching Battlestar Galactica. Mmmmmm Mmmmmmmmmmmmmm. Never had fish head before, but honestly its not bad, and is not really that different from fish... body I guess ;)

Sunday, November 13, 2005


Arrrrrrrrrg!

In my spare time I have (among other things) been trying to get a relativly small (at this point) isometric tile based map program running using Managed DirectX. And I got it working:



Until I started to try zooming in and out of the map. Then it looks like (with just a bit of zoom):



And I can not figure out how to get rid of those darn lines! Basically all I do is use a DirectX Sprite object to draw everything, tile by tile, and before I do any drawing I set up the transformation like so:
sprite.Transform = Matrix.RotationZ(0f) * Matrix.Scaling(viewZoom, viewZoom, 1.0f) * Matrix.Translation(0f);


And it almost works, but like we see in the pick I get those weirds lines around ever tile that I draw (I'm not even sure what to call them!). I have considered making an offscreen render target texture, then drawing to it and then finally updaing the screen with that (and doing the scaling there), but that is more complicated in a way since I can't create a texture big enough for doing zoom outs (zoom ins seem to be fine) and I might have to draw sections of the screen one at a time and then scale and draw them. I am not sure what else I can do...

Does anyone have any ideas as to what might be causing this? Or a way around it?

Friday, November 11, 2005


Past Four Day Weekend

 Aside from my afformentioned beef adventure this past weekend, my girlfriend and I also enjoyed the quite rural nature of Tochigi in her parents house. We were by ourselves for the first two nights, and then her mom came to join us (and I subsequently had that great beef).

The thing that suprised me the most, is that Tochigi reminded me of home a lot. Its weird, but the fact that everybody needed to have a car and you have to drive everywhere, and the fact that there is open space, seems to me to be a lot like Texas. Now of course there are mountains and more trees, and there are a lot more Japanese people, but had you switched those things out, man it would seem a whole lot like rural Texas.

This also leads me to the conclusion that Japanese cities are denseser than they have to be, because there is still open land out there. Granted I don't recommend blasting the life out of it and erecting more nameless chaotic dirty concrete human colonies there, but I am just wondering if there are reasons other than lack of land that make Japanese cities so dense.

Anyways other than the fact that it was a vacation with my sweetie and the beef, the best thing about the weekend was that her parent's house comes equiped with a built in onsen. And its big enough for a few people! (BTW, an onsen is a hot spring)

Man that thing was so cool. Every morning you take a shower, then take a bath. After a hard day of walking around rural Japan or eating beer rasied beef, you come back, and take another soak. Its very relaxing. :) The only bad parts are that you get tired of how hot it is (at least I did), and the effects don't last that long after you are there. Well maybe they would last longer if you weren't coming back to bustling Tokyo, but thats not pertinant to my situation huh.

Again, quite a good weekend. Had a great time :) Also I am learning a bit more Japanese, and have recently acquired a book to help with this endevor. I may have to take classes eventually too:

(What did you do for lunch today?)

私は今日マクドナルドでチーズバーガーを食べました。
Watashi wa kyou makudonarudo de chiizubaagaa o tabemashita.
Today I ate a cheeseburger at McDonalds.

(How much did it cost?)

私の昼食は250円かかりました。
Watashi no chuushoku wa 250 en kakarimashita.
My lunch took/cost 250 yen.

(Wow, you must be starving!)

いいえ、私はマクドナルドに行きました。:)
Iie, watashi wa makudonarudo ni ikimashita. :)
No, I went to McDonalds. :)

(Special thanks to my girlfriend for helping with these ;) )

I am pretty sure you can leave off the 私は/watashi wa from the first and third sentence because the subject (yourself) is implied by the context of the conversation. Though maybe in the third it helps to drive the point home? Ida know, Im still learning here.

BTW McDonalds destroys every Japanese burger joints burgers and fries I have tried so far. God Bless America ;)

Thursday, November 10, 2005


Beer Raised Beef

God I love ramen! Now I am not sure what the general concensus is on Japanese beef. Some people I have talked to think its supposed to be really good, while others can't imagine it being good since they don't have room for cows. However, as I spent this past weekend in a rural prefecture known for its beef, let me put this issue to rest once and for all: It Rocks!

I had the BEST steak I have ever had in my entire life here! And I am from Texas! Let me tell you, it was so juciy and flavorful and perfectly seasoned that I couldn't believe how good it was. Seriously I was blown away. Of course it cost upwards of $120 so you payed for what you got. The resturant even brought out the sirloin raw for me to evaluate before they cooked it. How awesome is that?!

My girlfriend and her mom (who treated me to this great beef) tell me that the reason this beef tasted so good was that the cow was raised on beer. Beer. Thats right, beer. Mmmmmmmmmmm Mmmmmmmmmmm. I am not much of a beer drinker but this has convinced me that is has an important part of any diet. While, in my opinion, nothing can top the fact that the cow was raised on beer there are two other reasons it was so good: the cow was given daily massages and was forced to listen to relaxation music.

Now thats life: beer, massages, and sitting around listening to music. Though the getting killed to make someone else's dinner sucks ;)

Simple C++ Kernel

 I was just informed by that file hosting service that since no one has downloaded that simple C++ kernel I uploaded for 2 weeks they were deleting it. I can probably upload the file again, but I can't believe people have been downloading it since September when I uploaded it! Wow thats at least a month ;)

If anyone is interested I could put it back up there :)

Wednesday, November 02, 2005


Tochigi (Gazunetight)

 Tomorrow (Thursday) is a holiday so we took Friday off together and are going up to north of Tokyo on a little 4-day weekend to an area called Tochigi. This place is supposed to have an onsen river that you can swim in!

I love hot springs so I am looking forward to going, and its supposed to be quite rural so it will be a change of pace from being in the city for the past month. One thing I don't like about the onsens, which I think is pretty natural, is the nakedness. Its hard for me to not find a bunch of naked guys bathing together more than a little heterosexually questionable. When I went to an onsen for the first time about five years ago (on my first trip here) with my best friend we were stuned that everyone was naked (since no one told us). We walked through the place uncomfertably drawing attention because of our pale whiteness and clothed bottoms before agreeing that this is the gayest thing we had ever been to. We left in a hurry and waiting out in the parking lot for the people who dropped us off to come back ;) Now though I can take solace in the fact that its a different culture than mine and that since I am not wearing my glasses I can't see anything I don't want to see. That lets me enjoy being there in peace. ;)

Its nice having weird holidays all the time too ;) And its been a loooooooooooong time since I've had a 4 day weekend.

Tuesday, November 01, 2005


Fishy

God I love ramen! Oh and I made some salmon last night with my favorite Cajun seasoning. Mmmmmm Mmmmmmmm. And she loved it too. Its really great to be able to just buy a small piece of fish, for two dollars, on the way home from work. Walking on the way home from work I mean. Its really nice not having to drive car to work here.

Now I have to figure out what else I can make with fish. I have the rice part down. And the fish part I am pretty competent with. But, at least with salmon, I don't know what else goes with it. It has such a strong taste you know.

Hmmmmmmmmmmmmmm...

Mmmmmmmmmmmmmmmm

On a much different note, ohhhhhhhhhhhhhhhhhhhhhhh my gawd, stockings ROCK!

Cheetos

Sometimes its the really small differences that highlight the bigger ones. Take cheetos. A nice crunchy cheesy tasty snack food back home. In fact, along with cheese pringles and doritos, part of the top cheesy-snack-trifecta. Now come to Japan. They have cheetos, but they aren't really cheetos. Can you believe they are sweet and not very cheesy? Its like "what the frak" the first time you try them. Things like that really get to you. Your expecting a super cheese flavor, and you get minor-cheesy-sweet flavor. It just ain't right. No other way to say it.

Monday, October 31, 2005


Happy Halloween

Believe it or not Halloween is actually kinda celebrated here in Japan. I am not sure how or why it started, but several places we have been have sold costumes and other Halloween stuff, and even promoted festivities. Last night when we were coming home from the beach in Kamakura there was even a relativly large pack of tricker-treating youngsters roaming around. They were all dressed up and everything. This is even more intersting if you consider that (I think) Kamakura is more of a retirement community and has few young kids.

I do love how they celebrate all sorts of holidays here though. Actually this week is a 3 day work week because of some holiday on the 3rd and the natural take-a-work-day off on the 4th. Its neat how they have adopted a bunch of American holidays here. Kinda like we adopt holidays from whomever is immigrating in large numbers to us (Cinco de Mayo anyone). Its been awhile since I've had a honest to goodness 4-day weekend too so I am looking forward to it.

Wednesday, October 26, 2005


The Return to Java

This is now my third week at the new job and I think I am settling in with what I will actually be doing around here. I was going to be working on BREW cell phone apps, but now it looks like I will be doing Java servlet based cell phone apps for the next month or so (at least ;) ). Which is fine, but there is one thing: the guys here have years of work invested in their architecture, which they use for multiple carriers. Literally years.

Which is good... but its hacked in many ways, and subsequently is quite big and confusing. Which is something I don't like to see. My saving grace is that I don't really have to work with the bowels of it, but I certainly have to touch it at times. Hopefully the BREW app will become a higher priority so I can say sayonara to Java once again.

Its not that Java is that bad. In some ways its nice. But after having used .NET, and the tools that come with it, coding in Java feels antiquated to me. All these configuration files have to be set up to just get a single servlet to load, the classpath's have to be pristine, and gosh darn there are like a billion class files and folders litered around my new work folders.

Then their is the IDE... its good I guess, but nothing like Visual Studio. I am using Gel for the Java stuff which is what everyone uses here... but its just so rough around the edges in places that were so smooth before that it bugs me. Like I tend to hold shift or control when tying lots of string. Well thats fine, until you get to the end of one string and are about to concatinate something ("message: " + var) then the IDE pops up with this funky code template insertion that always trys to put a nasty try/catch block there after my string. I really hate that.

So I am thinking of moving to Eclipse which I have some experince with and wasn't as rough on my conventions. Its only problem was that it was the biggest piece of memory bloat I have ever seen. Seriously, Java is 10 years old, thats a decade, and they still haven't managed to solve this memory consumption issue. I think this is what makes Java so slow in Desktop apps. All that wasted memory being paged in and out is crazy. I think .NET really has an advantage here, because even if Java solves this, the damage to its rep has already been done.

Tuesday, October 25, 2005


Gaijin Card

Last week my official gaijin card arrived at the Mintao city hall. Hmmmmmmm, to sidetrack for a bit: even though I am in Tokyo I am not in the city of Tokyo. This is because there is no actual city of Tokyo. Tokyo is more of a county or state type of government entity than a city, and it is divided into, among other things, wards, called ku, of which Mintao is one. Of course the metropolis of Tokyo exists and I am in that too, but that is not a well-defined government entity.

Anyways, the card makes me an official resident and has given me the honor of being able to open a no-intrest no-checking deposit account at the local branch of your friendly giant faceless buearacratic corporate bank. The weird thing, being an American here, is that no one uses checks, ever. And no one gets intrest on their bank accounts it seems like. Its all just deposit stuff. So the banks are getting your money and investing it and making money off of it, without the usual small benefit to you in the form of intrest.

I read an article once about this phenomena. It was old so I am not sure its still accurate. Even though your average Japanese family saves much more than your American family, the American family will come out ahead over time because our banks give out intrest. And to kick them while they are down, the American family will have spent more money and ultimately, have more junk. Kinda interesting.

My co-workers tell me I have to keep the card with me because the cops will occasionally do gaijin sweeps. Hmmmmmm sounds familiar to me, having worked at Wal-mart, just I am on the wrong side now ;)

Saturday, October 22, 2005


Texas Quest Tutorial Part 1


Part 1: 2D Rendering in Managed DirectX

Hi there. Due to some requests I have had regarding my game, Texas Quest, I am going to post a simple but hopefully informative set of tutorials covering the main aspects of getting a 2D side scrolling game to work. The general principles herein could be applied to many types of games though, be they 2D strategy games, 2D overhead adventures, 2D puzzles, or more 2D strategy games. ;) I am not sure about the utility of this for 3D games, except that it will be completely useless for graphics.

I have never done a tutorial before, but here is what I am thinking as I write this: First in this part we will cover how to get the rendering part of your game up and running using Managed DirectX. Second we will talk about images and how to draw them. After that you should be knowlegable enough to actually put a game together. Then in the third installment we will cover level architecture and how to draw a level (and by level architecture I mean what structures define a level, not an individual level's contents). Next up would probably be the basics of display characters and objects in levels. That's pretty easy actually. Then we should probably cover the current endeavor a character is undertaking and action they are executing if any. Next we will do hit detection and one of the most complicated to get right topics: event handling. That is, when A jumps on B X happens, but when B jumps on A Y happens. You gotta handle all that stuff. That is tough to get right, and to be honest, my game still doesn't get it right all the time ;) That flows right into changing a character's goal or endeavor in response to events or what I will call thinking. Actually user input would be covered there to. And that there is a decently complete overview of a game :)


Getting Started

Man let me tell you that I am not the guy to be writing a tutorial about DirectX that will impart the kind of wisdom you need to solve any problem. I can summarize it: it does graphics. I can also write a tutorial about how to get it to work. This in my experience is what tutorials usually do anyways, so all I am saying is just check your expectations at the door. This tutorial will teach you how to get it to work, but will not explain why it works (very well at least) ;) Speaking of tutorials, I initially learned how to use Managed DirectX through some decent tutorials on the web that I am going to link here:

http://geekswithblogs.net/jolson/articles/2176.aspx
http://www.gamedev.net/reference/articles/article1434.asp
http://pluralsight.com/wiki/default.aspx/Craig.DirectX.Direct3DTutorialIndex

You don't have to read those guys since you are already here. But if you are more interested in the why instead of just the how, or if the how isn't really working for you, then those would be good places to check.

Obviously from this point forward you are gonna need Visual Studio ... or maybe the #develop IDE ... or something that compile C# code, and the DirectX SDK. I am going to assume you are more than a novice with C# as well. It isn't hard to learn, but I really don't want to write a tutorial for that yet. I will however impart some programming tips and good-practices (e.g. I will force feed you things you should do anyways, so just do them). I am using the December 2004 one for Texas Quest and this tutorial, and is has worked pretty good. I used the Summer 2005 but I had trouble deploying that on computers where the SDK wasn't installed. I didn't really look into it though, but since I already had the 2004 SDK working I just used that. And since that is what I have working on my box that is what I will show. I recommend getting the latest though, and if anything I say in this tutorial doesn't sync up with it let me know.

Baby Steps

DirectX renders to a target of some sort, which in .NET is either a Form or a Control (technically since a Form is a Control its always to a Control). So first you have to have a Window, and optionally you can have a Control on that window to render to (this lets you surround the DirectX rendering with other controls, like buttons or list boxes). Simple enough right? Well lets write a Main function that does this. So start your IDE and create a C# Windows Application project.

Before we write any code you have to add references to the Microsoft.DirectX assemblies that should have been installed with the SDK.You need to add at a minimum Microsoft.DirectX, Microsoft.DirectX.Direct3D, and Microsoft.DirectX.Direct3DX. Now that we have done that, feel free to delete the default Form1.cs class generated for you. I hate the generated code they give you. Then add a new class (plain old class) with the name you want. I called my MainWindow because that succulently describes what it does. It is the main window. Naming is a very important and often misused concept in programming. Names are important, remember that.

Now we are ready to write some code. In the MainWindow class file write a using statement for System.Windows.Forms and make your MainWindow class inherit from the Form class (i.e. public class MainWindow : Form ).

Write your new Main function:
public static void Main (string [] args) {
   MainWindow mw = new MainWindow ();
   mw.Show();

   while (mw.Created) {
     Application.DoEvents();
   }
}

This goes in your MainWindow class. It should be pretty straight forward what we are doing. Cause we aren’t doing much, or anything related to DirectX at this point. All we are doing is creating a window, showing it, then saying while it is created process its events repeatedly (when you click the Close box the Created property of the Form becomes false).

Now compile, build and run. Should work like a champ.

Controller

Now we are ready to get to the good stuff. Borrowing a good point from the tutorials I listed and read myself above, I like to separate the rendering from the internals required to set up the rendering, and separate that from the game engine as well as the code to start and stop the app as best as possible. This leads to a few more classes which can be confusing at first but once you figure it out it works quite nicely. Basically the structure I have grown to like is to have a Controller class that handles everything related to getting rendering ready to go, but doesn't render anything. The rendering is actually done through a Renderer class of which the Controller object has an instance. The reason being is that you can toss out and plug in Renderer objects for different tasks on the fly without much work. In my game I have a Renderer for the main part of the game, that displays the map and everything, and then several for Menus. Its not that hard really, and it keeps your code cleaner.

Now what I said about the engine being separate from the rendering is very important too. All the Renderer does is display the current state of the game. It does not effect game state at all, ever. The engine does this. While they usually run in tandem that is not required. Meaning you can pause the engine and still render, or you can play 1000 turns of the game without rendering any of them. This is basic, but important.

So lets go ahead and create the Controller class I was talking about. Add a new class called Controller to your project. Add the following using statements:
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

Now add the following private variables to this class:
private Control target;
private Device device;
private PresentParameters presentParameters;
private bool deviceLost;
private Renderer renderer;

That first variable is the target we talked about earlier, it is where all the rendering goes. The second is the DirectX device interface that does the rendering and stuff to the target. The third is some information we setup to create the device. The reason we keep this is that occasionally the device could be lost, and we might need to recreate it without having to restart the app. Which is related to the fourth, which is a flag that is set when the device is lost. The fifth and final variable is the Renderer we talked about earlier.

Now change your constructor to be like this:
public Controller (Control target, Renderer renderer) {
   this.target = target;
   this.renderer = renderer;
   deviceLost = false;

   presentParameters = new PresentParameters ();

   InitializeGraphics();
}

Pretty simple, just sets up the private members and calls IntializeGraphics, which should look like:
protected void InitializeGraphics () {
   presentParameters.Windowed = true;
  /* If you want to use Full Screen mode (this assumes the target is a Form not just a Control), delete the previous line and add:
   presentParameters.Windowed = false;

   ((Form)target).FormBorderStyle = FormBorderStyle.None;
   ((Form)target).Size = new Size (800,600); //I forget if this can be removed ;)
   ((Form)target).ClientSize = new Size (800,600); //this is your resolution
   presentParameters.BackBufferFormat = Format.X8R8G8B8; //maybe needs to be changed...
   presentParameters.BackBufferHeight = this.target.Size.Height;
   presentParameters.BackBufferWidth = this.target.Size.Width;
   presentParameters.PresentationInterval = PresentInterval.Default;
   */


   presentParameters.SwapEffect = SwapEffect.Discard;
   presentParameters.AutoDepthStencilFormat = DepthFormat.D16;
   presentParameters.EnableAutoDepthStencil = true;

   // store our default adapter
   int adapterOrdinal = Manager.Adapters.Default.Adapter;

   // get our device capabilities so we can check stuff
   Caps caps = Manager.GetDeviceCaps(adapterOrdinal,DeviceType.Hardware);

   CreateFlags createFlags;
   if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
     createFlags = CreateFlags.HardwareVertexProcessing;
   else
     createFlags = CreateFlags.SoftwareVertexProcessing;

   if (caps.DeviceCaps.SupportsPureDevice)
     createFlags |= CreateFlags.PureDevice;

   // create our device
   device = new Device(
     adapterOrdinal,
     DeviceType.Hardware,
     target,
     createFlags,
     presentParameters
     );

   // Hook the DeviceReset event so OnDeviceReset will get called every
   // time we call device.Reset()
   device.DeviceReset += new EventHandler(this.OnDeviceReset);

   SetupDevice();
}

Pretty complicated. And heck if I know all of what its doing. Like I said, read the other tutorials or buy a book. Basically most of what this does is get ready to create the device and then it creates it. Telling DirectX a whole lot of information about how to create it. It also does two things at the end, add a handler for DeviceReset and call SetupDevice. The device reset handler calls setup device too because that is supposed to handle when the device has been lost and can hopefully be recovered. SetupDevice does the camera, lighting, and view setup:
protected void SetupDevice () {
   device.RenderState.AlphaBlendEnable = true;

   device.SetSamplerState( 0, SamplerStageStates.MinFilter, (int)TextureFilter.Linear);
   device.SetSamplerState( 0, SamplerStageStates.MagFilter, (int)TextureFilter.Linear);
   device.SetSamplerState( 0, SamplerStageStates.MipFilter, (int)TextureFilter.Linear);

   device.RenderState.Lighting = false;

   // get camera vectors
   float width = (float)target.Size.Width;
   float height = (float)target.Size.Height;
   float centerX = width / 2.0f;
   float centerY = height / 2.0f;

   Vector3 cameraPosition = new Vector3(centerX, centerY, -5.0f);
   Vector3 cameraTarget = new Vector3(centerX, centerY, 0.0f);

   // create our transforms
   device.Transform.View =
   Matrix.LookAtLH(
     cameraPosition,
     cameraTarget,
     new Vector3(0.0f, 1.0f, 0.0f)
     );

   device.Transform.Projection = Matrix.OrthoLH(width, height, 1.0f, 10.0f);
}

protected void OnDeviceReset (object sender, EventArgs e) {
   // We use the same setup code to reset as we do for initial creation
   SetupDevice();
}

This basically gets the device (camera, view, lighting) ready to draw 2D stuff normally. That’s about it ;)

Now lets add the all important Render method:
public void Render () {
   if (deviceLost) {
     // Try to get the device back
     AttemptRecovery();
   }

   // If we couldn't get the device back, don't try to render