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 ;)

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...

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
   if (deviceLost) {
     return;
   }

   device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.Blue, 1.0f, 0);
   device.BeginScene();

   renderer.Render(this);

   device.EndScene();

   try {
     // Copy the back buffer to the display
     device.Present();
   } catch (DeviceLostException) {
     // Indicate that the device has been lost
     deviceLost = true;

     // Spew a message into the output window of the debugger
     System.Diagnostics.Debug.WriteLine("Device was lost");
     }
}

I feel most of this is straight forward too. First we see if the device has been lost previously, and if so we try to recover it. If after that the device is still lost then we return from this method without doing anything. As a note the device can be lost when the screen saver comes on or things like that. If everything is OK then we clear the display, and do BeginScene. All rendering must occur between the calls to BeginScene and EndScene. That’s just how DirectX works. Between the two we call our Renderer’s Render method which should do all the drawing. Then after that we try to present the work we have done, and that is when we might notice we’ve lost the device, so we set that deviceLost flag to true in this case (so the next time Render is called we will attempt to get the device back).

Now AttemptRecovery:
protected void AttemptRecovery() {
   try {
     device.TestCooperativeLevel();
   }
   catch (DeviceLostException) {
   }
   catch (DeviceNotResetException) {
     try {
       device.Reset(presentParameters);
       deviceLost = false;


       // Spew a message into the output window of the debugger
       System.Diagnostics.Debug.WriteLine("Device successfully reset");
     }
     catch (DeviceLostException) {
       // If it's still lost or lost again, just do
       // nothing
     }
     }
}

Lets just assume this works ;) I copied it from somewhere and it seems to work, so that’s good enough for me. Next we have a DisposeGraphics method which should release all our resources:
public void DisposeGraphics () {
   device.Dispose();
}

Since we just have the device at this point we just release it. Technically I don’t think you have to have this because resources will be reclaimed anyway on exiting the program, but its nice to give people a way to free them isn’t it?

Finally we have a simple property to get and set the Renderer:
public Renderer Renderer {
   get { return renderer; }
   set { renderer = value; }
}

And that is all for the Controller class for now. You can’t built it or run it yet because we haven’t created the Renderer yet, so lets do that next.

A Renderer

Create a new class in your project called Renderer. Add the using directives:
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;

Then add the Render method:
public class Renderer {
   public Renderer() {
   }

   public virtual void Render (Controller controller) {

   }
}

And that’s it. Right now the Render class is going to be dirt simple because it doesn’t do anything yet. Actually the Render class itself will never really do anything, but its sub-classes will. In fact we will make it an abstract class in the next version because no one should ever need to use it as it is. For now though, if it was abstract we couldn't test our fledgling program so its better to make it concrete.

Wrap Up

The last part we have to do is rewrite the Main function a bit:
public static void Main (string [] args) {
   MainWindow mw = new MainWindow ();
   Renderer r = new Renderer ();
   Controller c = new Controller (mw, r);

   mw.Show();

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

Build it and run it. You should be the proud parent of a deeply blue window :) Congratulations.

OK that wraps up what I wanted to cover here. This has taken longer than I thought it would actually. I do have a newfound respect for tutorial writers now though, cause its not as easy at it seems. Mostly the next tutorial about images is more important because that will get you drawing stuff, and after that you might be ready to really start a game. It could be a little while before I have that one up though, but thanks for reading. Comments are very welcome, so please post them.




Update: Wednesday the 4th of January 2006:
I have a second part thats been up for awhile now:
Texas Quest Tutorial Part 2: Design Part 1
I forgot to link it earlier ;)

Thursday, October 20, 2005


Seriously, I didn't do it!

 I saw this on the way to work in someone's newspaper and it reminded me so much of an expression my old dog Stinky would have that I had to share it with the world:
Man, seriously, I didn't do it!

"Man, Seriously, I know what you are thinking but I didn't do it! You can trust me man!"

Wednesday, October 19, 2005


The Earthquake

 What a weird experince! I felt my first real earthquake this past Sunday. According to my girlfriend I have slept through at least two but since I wasn't conscious I don't count those. It was a small one and brief but quite freaky. I was sitting on the couch watching some English TV (the news I think) and she was doing the dishes. All of a sudden the couch started vibrating. My first thought was that, since it was her parent's couch and they have lots of nice stuff, that it was some sort of really nice relaxation couch that I had inadvertantly turned on. But after a couple seconds of that I realized slowly that is a horribly dumb explanation. So I jumped up and other things started shaking, I asked her what was going on and she said "Welcome to Japan!" :)

After that it died down, but it was quite a freaky experince to go through. I have used the word "freaky" alot here huh? Well even though it was a small Earthquake I think part of the reason it is freaky is that you don't know if its going to get worse or last longer. And there ain't much you can do about it really. So there you go, I've been here two weeks and have already had my welcome Earthquake :)

Monday, October 17, 2005


The Beach

 My girlfriend and I went to the beach Saturday to enjoy the sun and bake awhile. Its in a town called Kamakura which is south of Tokyo, kinda at the entrance to Tokyo bay actually. In the past it was also the capital of Japan, and its a pretty nice, albeit expensive area to live in. But my girlfriend is lucky enough to have parents that have a house there, so we went there to stay. And her parents are quite busy so we pretty much had the house to ourselves this weekend.

Anyways one thing I find a bit different here is that the beach is black sand and there are no palm trees! Its kinda weird. The beaches I am used to, from Florida, are vastly different and are what I tend to think of as a beach. No palm trees, black sand, and no seashells... is that a beach or just a coast?

We had a great time baking in the sun and napping there together irrespective of whether we were at an actual beach. The weather forecast has thankfully been wrong for every day uptill that Saturday evening. They always predict rain and its been quite sunny and rain-free. So its good to know that Japanese and American forecasters still have something in common: they get paid to be wrong ;) Makes it feel a bit more like home here, you know :)

We also tried this resturant called First Kitchen. The funny thing is, as my girlfriend tells me, in Japanese they pronounce it like Fusutu Kiichin I think, and then the shorten it, taking the first words Fu and the second works Kii~n. So the shortened common version of the resturant's name sounds an aweful lot like a certain word in English :) I'll leave it as an exercise to the reader to figure out what word that is :)

Sunday, October 16, 2005


Workin Life

 I have started the job here, and I am liking it. Most of the work I am doing is on BREW, which is a C/C++ API/Enviroment for writing Cell Phone apps. Its pretty fun actually. Tuesday I had to spend a few hours just getting the tools to compile and link a C++ program that could be run on the phones. Its not the easiest stuff and you have to do a lot of basic low level things... heck I even created my own string class cause you can't use the standard library. Its cool though. Its nice to be busy allll day too.

Its a little tiring as well actually. I have managed to start getting up at 8 though, and getting to work around 9:15. Which is a huge accomplishment compared to my last job :) As anyone there would probably tell you ;)

Also I was a little disapointed that I can't find the coke bottles with the micro machine cars anymore. There seems to be some pepsi with mech action figures, but I really don't like pepsi that much ;)

Oh and I am working in Shibuya which is a really cool part of town. Lots of shops and businesses. The office I am in is nice, but its in a kinda sleezy area and it seems very out of place. All around it are love hotels, and I will leave figuring out what they are used for as an exercise for the reader. :) But its an interesting area like I said... lots of gaijin too.

Oh I gotta go, I am here in Kamakura at my girlfriend's parnet's house and we are going to the beach.

Also, the weather is GREAT here!

Wednesday, October 05, 2005


Enjoying the Break

 Life in Tokyo is going well. The whole waking up at 6 am still throws me for a loop everyday, but I am starting to get used to it. Having almost no fridge and having to pretty much eat out or buy stuff from the local store for every meal is quite different though. I think that will take some time to get used to for me, cause I find it so weird to be without food or drink during most of the day. I got some snacks and drinks but still, its very limited compared to having a big pantry full of stuff and a freezer you can put hot pockets in ;)

Mostly I am here by myself while my girlfriend works her extra long kinda-overtime traditional Japanese schedule ;) Its tough working here I think, I mean she ends up working like 12 hours a lot of days. Or more! When I was ending my last job I could barely do 6 hours. And I don’t mean the last 2 weeks, I mean like the last 2 months! Well that’s what I call a real American style schedule. Come in late around 10:30, leave early around 5ish, and include a complimentary long lunch in the middle of the day ;) That’s some work!

Also I have been collecting these stupid coke cars ;) Every time I buy a 500ml bottle of coke (about 20oz I think...) from this one convenience store I get a free Micro-Machine like car with it :) So far I have three, but the one I got today was the same as the one I got Monday :( It does feel quite silly when you realize you are contemplating skipping a better deal (230 yean for a 1.5 liter of coke) just to get a toy. And you feel even sillier when you actually go get that little car.

Tuesday, October 04, 2005


Im In!

 Well, here is to my life in the biggest city in the world, Tokyo! After a grueling 13 hours flight and 2 hours in customs and baggage, and another hour or so on the train with my sweetie, I did finally make it to my new home. And let me tell you its kinda small for two people ;) But its great to be here.

I am taking this week off to adjust and finish some stuff, and next week I will start working. Monday is a holiday (national workout day or something according to my girlfriend, go figure) so Tuesday is the big day. I’m pretty stoked. I like the toolkit I am working on (BREW, a C/C++ API/environment for making cell phone applications). And I think I will have muuuuuuuuuuuuuch more fun doing that than sitting around with my thumb up my but and banging my ahead against the wall doing the support and debugging of crappy ass code that my old job entailed. Can you say good-riddance? :)

Well, I gotta go figure out what a cup is in milli-liters and see if I can pick up some butter from the local fancy grocery store. Hopefully they also have sticks of butter here.... I brought some Kraft Mac n Cheese for my honey since that’s a rare commodity here and was going to make that for her.

Oh, one thing I wanted to mention to anyone else who might come to Japan from the states: after you get your visa and Certificate of Eligibility from the consulate, KEEP BOTH! I guess keeping the visa is obvious, but the Certificate wasn't so obvious to me. I almost tossed it, but I brought it with me for memorabilia’s sake. Little did I know I NEEDED it! They don't let you in the first time with just the visa, you also have to have it. So anyways I am reeeeeeeeeeeeeealy lucky I had it, even though I packed it instead of keeping it in my carry on like I should have. (Also the visa is on your passport which I was surprised by, so that’s something else to expect.)

(You will also notice this post is now in JAPAN time!)

Friday, September 30, 2005


Almost There!

 About 24 hours from now I will be somewhere over that penninsula at the extreme South-Eastern end of Siberia heading towards the land of my sweetie. I am terribly excited. Can't wait in fact. Isn't it kinda crazy to just get up and go to the otherside of the world? But hey, you gotta do what you gotta do :D

So I am gonig to say 28 hours to go give or take a few till I see her :)

Thursday, September 29, 2005


FIVE ZERO

 I am wrapping things up here and it is now officially the fifty, five zero, half of a hundread hours mark! Man I am excited. Its almost go time.

Tuesday, September 27, 2005


Japan and Choclate

 One of the things about my sweetie is that she loves her choclate. But one of the odd things about Japan is Japanese choclate aren't that sweet. They are in fact almost plastic like. You'd have to try them to see what I mean, of course, because its hard for me to explain. (Actually I shouldn't have said its odd given some of the dishes (like natto :P), but its still a lot different than American or European choclates.) So to impress her nice and good I went with a traditional but very successful strategy of buying her choclates. I hit one of the fine markets here to get the more-or-less-finest-imported choclates available. The Belgian kind to be precise. The thing that I am curious about though, is why are there so many Swiss imported choclates? I mean, is it that great? Well could be. I supose I should try it before posting, but it struck me as strange.

Getting rid of Virtual Memory...?

 One other thing I am going to do tomorrow is talk to one of my old teachers about this great idea I had. Well... I guess it remains to be seen whether or not it is actually great, but it is intriguing.

Basically I was thinking of doing an OS that would only run what I like to call managed programs, which is to say those written in .NET or Java, or for any virtual machine that ensures many nice things. The cool thing about those is that with JIT you can compile the intermediary assembly code into native machine instructions and still get similar performance with respect to a typical C++ program. Especially .NET and not as much Java though. Since .NET is really a more well thought out and implemented platform in my humble opinion.

Anyways, so say you have this OS and on it you only run .NET programs. That is pretty neat already, but isn't much different in that respect than any other OS out there. But, since everything is managed, then maybe the intermediary code to native code compiler could verify and ensure the code produced isn't going to do bad things, like access invalid pointers and the like that regular programs can do. And if you can do that... maybe you could eliminate the need for virtual memory with respect to security. Why check to make sure a program is accessing only its own memory for every memory load or store for eternity, when you could guarantee it at native compilation time! :D If you could turn virtual memory off, then you are looking at what could potentially be a big performance boost, since every memory access has some indirection. Though modern hardware (the TLB) helps immensely in making this cost somewhat minimal, its still not as good, I don't think (one of the things I have to ask my teacher about tomorrow), as a straight access of memory (no indirection required).

Now that’s the beauty part. The hard part is re-implementing a paging system that doesn't rely on the virtual memory system and still making a process think it has more memory than what is available on the system and making performance still be better than the traditional way of doing things! Quite a task. Something very interesting to think about though.

96 Hours and counting down

 I've been really busy trying to tie up loose ends here before I move Friday. Thats right, I am moving Friday. To Japan! (If you couldn't it out from previous posts I mean ;) ) So pretty much in the past few days I have cancelled all services related to my apartment (phone, DSL, power), donated a TON of crap to goodwill that I don't need (namely clothes and food that I bought but never ate), tried to update all my banks and credit card and blah blah blahs to my Mom’s address, moved my bed and other stuff I don’t need but my family could use to my Mom’s condo in Uptown, and most importantly threw a bunch of other crap I didn’t need away. Sounds like I have tons of junk huh? Well to be honest I really don’t. Now I do usually buy more food than I need, but most of the stuff I had is stuff you need to live. Forks, plates, cheese-its, socks, etc… but when you are moving across the world (more or less) its surprising how little you actually need to bring. When you get down to the basics of things, you probably need clothes and bathroom stuff, and a laptop of course. Oh, and money, but that is a given ;) Which reminds me I gotta go withdraw some cash… we’ll I still got a lot to do in the next three days before I fly out at noon on Friday. Back to my point though, there is really no reason to keep all the stuff other people can use when you get back, unless it has sentimental value. And there isn’t much reason to bring said stuff, unless you have a taste for finer things and it costs a lot. I of course bought all my forks, knives, spoons, and the like at Wal-Mart for under $3, so that certainly doesn’t apply to me.

I am really anxious to get going, but the constant stream of stuff I have to take care of keeps me steady. And my girlee is terribly excited for me to get there. It’s a great feeling moving to start something new (in a few ways to boot).

On a side note, if you drive to a good will donation center... one of those trucks with the signs saying "Donation Center", can you just drop your stuff/crap off there in the middle of the night? Cause that’s what I have been doing, but I have a sneaking suspicion that I may not be doing the right thing there. I figure they can do what they want with my stuff, but I might inadvertently be pissing them off. Hmmmmm...

Friday, September 23, 2005


Lets go

 Well I have got tons of thing to take care of. I am thinking of flying out next Friday for a few different reasons. Mostly I want to get there and see my sweetie, but also I think it'd be easier to move in on Saturday there. And I think I can finish everything I need to do by then. I guess I dont really have thaaaaaaaat much to do, but I don't want to end up crazy rushing you know. And if something goes a little off with returning the keys to the apartment or canceling my DSL it would probably be better to not be leaving the next day. By the same token I am reaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaly ready to go!

Things are a little confused now because of the hurricane hitting Houston, and that might affect my plans but I dont think it will be too bad. Hopefully everything will be peachy :)

Wednesday, September 21, 2005


Re: I'M OUT!!!

 Uhhhhhhhhh well this is strange, I posted the I'M OUT entry yesterday cause I got my visa to enter Japan yesterday... but blogger dated it September 8th. Well, just so we are all clear: I got my visa to enter Japan!!!!

So to recap, I got my visa yesterday and am moving to Japan!!! I will start my new job on the 11th of October or so, so I have two weeks to get there and get settled, which should be no problem. My last day at my crap-o current job is this Friday, which is really several months to late, but getting a visa takes time, so I shouldn't complain.

Ohhhhhhhhhhhhh yeah I am excited and can't wait!

Edited Sep. 22nd:
Well I figured out how to fix the previous post, so most of this post doesn't make sense ;)

Tuesday, September 20, 2005


I'M OUT!!

 Alright, got the VISA!

Saturday, September 17, 2005


James Brings up a Good Point...

 ...About that GUI idea where the four corners of the screen are used for important operations, and perhaps as importantly, is the first person to add a substantive comment to my blog. :)

James says:

Perhaps there are reasons we've not seen corner usage become prevalent? I can think of three reason, the first you've already hit - what should they be used for. OSX is a good example that is flawed, IMO. Why would I want to move my mouse to the corner of the screen just to move it back to select an application, widget, window, etc? The corner's are furthest away from where the action is, the center of my screen.


I think you are spot on here. Corners should be used for important but rare operations. The main action and focus of your attention should be on your App's windows and their contents. Windows is a realtivly decent example of this design I think. One corner accesses all your programs and crap, the other (usually) closes the current program you are in. Of course the other two corners are used for date & time and a system menu that as far as I know no one uses. So what I was thinking was that those last two could be replaced with things that are more useful. But as you pointed out, I still can't figure out what those would be ;)

If we look at that Symphony OS that has implemented this idea by what sounds like breaking the Windows Start menu apart into a few pieces and putting those into the corners. I'm not sure thats the best approach, but their designer seems to have a thing against nested menus so maybe its necessary for them.

However one decent idea for at least two corners would be to have one bring up Apps Services and Operations, and the other link into your Documents. Then a third that closes the current app stays (provided you like running maximized apps).


The second issue relates laptops. As I type on my laptop the mouse cursor is inadvertently push around by constant jitter of the base of my thumb and the track pad. It eventually finds a corner to rest. For the most part it's always the same corner. This could be a design problem for the laptop in question, however unless you have a strangle hold on the HW any corner GUI solution must cope with this problem.


Really? I can't say I have this problem with my work or home laptop. That kinda kills the idea I had for automatically opening the menu or target associated with a corner when your mouse moves over it (so you don't even have to click ;) ).

So naturally, the auto-opening should probably be configurable ;)


Thirdly, how to define corners with multiple displays? It's quite easy to have six or more corners. How do you address these? This is probably the most illuminating issue to the corner idea - it's geometry specific.


Yeah thats a tough one. I would say we take a cue from windows and only have one primary window with the corners. But multiple windows really takes away from the motivation for having the four corners (in that they are really easy to hit). I don't know if much could be done here really. Maybe the same mechanism Windows uses today to handle multiple windows could be used: don't put the start bar on the second one. Similarly, the four corners could just be on the first one and on whichever side that the two monitors connect you just loose the ability to easily hit the corners.

Good points all around though. The most pressing in my opinion is the need to figure out what the heck to put on the corners, if they are indeed something that the OS should have. I am thinking that they might also be configurable. So you could as a user put your own operations in there. But I consider that to be up in the air too. It might be better to force the corners to behave the same for everyone, I mean how many Windows machines have you seen with the toolbar on the right side or top of the screen? Is that really useful?

Anyways as it stands for the four corners I think:

Thursday, September 15, 2005


Texas Quest Update

My thanks goes out to Tom Miller and Zman for noticing the game :) I have to say that was quick. Hope everyone has fun with it. I decided to post some screenshots so people don't have to download the whole 50 meg game to get an idea of what it is. I'll post some more instructions on how to use the level editor and engine tester, and give credit to the authors of the songs I used , among other things :P OK gotta go eat some Sushi :)

Sorry had to use slow free image hosting ;)Sorry had to use slow free image hosting ;)Sorry had to use slow free image hosting ;)

Sorry had to use slow free image hosting ;)Sorry had to use slow free image hosting ;)Sorry had to use slow free image hosting ;)

Sorry had to use slow free image hosting ;)Sorry had to use slow free image hosting ;)


Update: Friday the 21st of October 2005:
First part of a Tutorial on how I did Texas Quest

Update: Thursday the 1st of December 2005:
Now the game can be downloaded from this new link:
http://coinop.org/KB.aspx/KB/ZZ-Hosted/

Thanks Kurt!

Wednesday, September 14, 2005


Simple C++ Kernel

 
Obviously today I found a way to upload files today. Finally ;) You'd think it would be easier since there are files everywhere on the internet. But nope... I guess it makes sense if you are worried about abuses though. Anyways since I found this service (savefile.com) while was at work I decided to upload Texas Quest since I have been meaning to put that online for awhile. But I also wanted to put my C++ kernel out there in case anyone is interested in seeing the code I used, especially the make file, to build the kernel and get it to run.

So now that I am home and have uploaded it, here it is. All my code in there, as well as some other stuff that you probably don't need to be concerned with. But most importantly it has the make files and related stuff, so you can see how it builds. Since that took me some effort to get right, I figure thats the most worthwhile bit. If you actually want to see the kernel in action without building it, the dev.img file (its a floppy disk image, like an ISO is for CDs) can be mounted by Virtual PC (or you might be able to make a real floppy from it... but I am not sure about how to do that).

As for the whole thing, feel free to use it as you see fit, just let me know if you do. And comments are always welcome :)

Texas Quest

Ahhh video games. One of the main reasons I got into programming. Well I made one that is not too bad if I don't say so myself. I would have put it on the web sooner, but haven't been able to find a way to host it. Cause with all the files and everything its about 50 megs (including mp3 songs and the source).

So the backstory is that back in the winter of 2001 I was first learning Win32 GDI programming and decided to take what I knew and make a side scroller game. I actually got decently far before stopping, and had character interactions and some graphics working. But what got me was that I was trying to make the game waaaaaaaaaaaay to customizable. I got the idea from Civilization 2 (favorite game of all time) because it was so great to go in, and almost make your own game from the framework provided by the game engine. So I tired to do the same thing with my game... but that killed me. I almost had my own scripting language to control character interactions in the game done, but it just became such a bear to work with that I lost intrest, even though the engine part of the game was decently complete.

Now fast foward to May 2005. I have just returned from a trip to Japan to see my wonderful girlfriend. I know her birthday is coming up since she thankfully finally told me her birthdate ;) and I want to do something really special for her. I have been playing around with the idea of doing a game in C# and using managed DirectX when it hits me. I could use those technologies and redo the game I origionally did as me having to save her! Just like the good old Super Mario Brothers games, but with myself instead of Mario and her as the Princess. Add in some unique elements, like coke restoring health, and her annoyingly aweful co-worker Ito-san as the end boss and you have got yourself a great idea.

So I set out to make this game. Knowing I had three short months to do it so I had to work very fast. But I didn't really do to well with time managment ;) I spent too much time working on the level editor... and then playing Half Life 2 ;) By the start of July I was really rushing to get it finished, and the code kinda shows this, its definitly not my best work. But by the middle of July (deadline being the 21st) I pretty much had it done. I tested it for awhile, touched up some of the graphics, and sent it to her.

She really loved it too. Possibly cause I spent so much time working on it, but I think also because it is something unique that no one has (or very few guys have) done before for their girlfriends. Which is sweet, cause I was really hoping to wow her with it too. My only regrets are 1. not using my time properly, and 2. now I am not sure how to top this one on subsequent birthdays ;) But it was a great experince.

Anyways please try it out and let me know what you think. It is all in C# and uses Managed DirectX through and through. If you have any questions or whatever, again, send them to me and I'll try to answer them as best I can. Any suggestions or anything too. :)

The game, source, and managed DirectX runtime (can now be downloaded by using the link at the bottom of this post). All you need is DirectX 9.0c and the .NET 1.1 framework before you unzip the file. There are no real installation instructions (except for one minor ignorable thing), but glance over the readme.txt for info on how to play the game. Also I've found this site is kinda slow so if anyone else knows a good free place to host files let me know.

Update: Friday the 21st of October 2005:
Other blog entries regarding Texas Quest:
Screen shots of Texas Quest
First part of a Tutorial on how I did Texas Quest

Update: Thursday the 1st of December 2005:
Thanks to Kurt I have a new host for Texas Quest, please download it here:
http://coinop.org/KB.aspx/KB/ZZ-Hosted/

Monday, September 12, 2005


Cooking

I really like cooking. I'm not so good at following recipes yet, cause things in the food world are so new to me. For example, which number corresponds to low heat? Which is medium? How often is "stirring occasionally"? Maybe I am just used to having more exact instructions because of using computers and doing math for so long ;)

The thing I think I am decent at is making up new stuff. For example, my Asian+Western Fusion Chili Rice. Its really easy. Just take some left over rice (you know the kind you made but didn't eat, and is never as good), and microwave it with enough water to get it pretty wet again. Then drain the rice, and pour it into a bowl. Pop open a can of chili and pour that bad boy on top of the rice. Then microwave it a bit more until the chili is good and heated. Now finally add some peanuts and shredded cheese and you are good to go. Well, unless you are a very spicy type of person in which case I believe jalapeños could be added, though I've never done it myself.

Anyways, my girlfriend was telling me that cooking for girls really gets them going. More so than taking them to dinner. Which I can understand, but I think its something you just have to do for your girl, even though its not the easiest thing to do. Compared to dinning out anyways ;) And I think one of reasons I got my LL to be was a special breakfast I cooked for her one morning. Salmon omelets. Mmmmmmmmmmmmmmmmmmmm.

One thing I think my sweetie might be right about too, is that some programmers like cooking alot. Now I think this probably applies to every type of artist or creative person. Cause you can take your creativity in one area and apply it to others. And I think everyone can cook if they try too.

Thursday, September 08, 2005


Wario World

 One thing about me is that I love video games. Its really the main reason I wanted to be a programmer, and probably one of the reasons I am so into programming still. And I have to say Nintendo has always been one of my favorite video game companies. I can't even remember how many hours of my childhood and teen years I spent on their games. Well less so in the teens because of Square (or Square Soft or Enix Square or whatever it is now...). But basically I loved Nintendo's games, and got a Gamecube just so I could play their games. And I liked Super Mario Sunshine, Metroid Prime, and Zelda Wind Waker alot. Though Super Mario Sunshine only felt like a mario game a tiny bit, and Zelda was a bit short, especially just after having finished the Gamecube port of Ocarina of Time. But they were all great.

Then I borrowed Wario World from a friend. Whoa.... way to let someone down. Its way to short, the levels are incoherent as a group, and monotonous individually, and its really just not that fun to play. Of course I finished it just to beat it, but really, it was more of annoyance than anything else. I did like some of the red-diamond areas, which were like levels inside levels where you had to get to this red-diamond by jumping over blocks and stuff usually. Those were cool, and I am thinking they should have just made the whole game like that ;)

So word to the wise, avoid this title. $20 is still too much ;)

Tired Eyes, Huge Smile

 Guys, if you have never gotten some lingerie for your woman then you are missing out on a great experinence for the both of you. I was skeptical about how great it would be, and of course nervous about buying something that wasn't right. But let me tell you flat out: it is really great. And as long as you know the right size to get, and probably to avoid anything thats off limits for your girl, then anything you buy should be good. And because of the internet you don't have to feel pressured (or perverted ;) ) to get anything like you might in a store. And even better, when you think about it you get to browse online for hours and hours , which is rewarding in and of itself. And man, there are so many sexy items, its hard to just pick thing.

On the other side of the gender fence it seems to go over as an exceptional present. I think women can tell the time and effort you put into it somehow.

But trust me, if you shop online search around. Cause a bunch (and I mean a bunch) of the shops on the internet have the exact same items, but will still charge differently for them. Sometime the price differences are quite dumb-founding too. Happy hunting :) And take breaks cause your eyes get really tired from focusing on your monitor for so long ;)

Wednesday, September 07, 2005


More GUI Ideas

 After reading this article, and then this article on Fitts' law, I have to say I'd like to appropriate two of the GUI ideas found herein for my own OS. Noting of course that they are not origionally mine (nor are they origionally either authors).


Even Better Luck: Going to Japan!

 The Certificate of Eligibility from Japan I have been waiting for is on its way to Texas finally! And much sooner than I expected! I was thinking end of the week at the earliest, but probably towards the middle or end of September. This is great news!

So let me explain what this is by starting with a little back story. To get a visa allowing you to live and work in Japan you have to get a company to sponsor you (unless you are from certain countries that have good relations, and that don't seem to be overrun with criminals to your average Japanese person). I got that thankfully. Then after they have decided to hire you, they submit some paper work and applications on your behalf to the immigration bureau there. Then the bureau asks for your diploma since you have to be a college grad (you have to have a 4 year degree, but any field is fine) and some pictures to hang on their wall or something. Then they sit around for awhile. They send your diploma back, but then sit around for awhile again. All this sitting around takes at least 6 weeks they say, but maybe as many as 12. I think it actually took 6 weeks almost exactly for me. At the end of this sitting period is when they send the Certificate of Eligibility off (to your company which will naturally forward it to you).

OK, and getting that is basically the second to last step in the visa process as I understand it. They have pretty much said, hey come on it :) but you still have to go actually get the visa from a Japanese embassy, bringing the Certificate of Eligibility with you. The closest Japanese embassy to in Dallas is in Houston (why is it that most embassies in Texas are in Houston anyways? Dallas is the bigger city...), so I'll be making a little trek down there soon I think. :)

I'm totally excited! My job here sucks and my girlfriend is waiting for me there!

Monday, September 05, 2005


Running

 During the last week I have also made it a point to try and run every night. Just about 1.2 or so miles. Which translates to between 15-20 minutes of out-of-shape running/jogging ;) The reason I am doing this is probably the same reason anyone does it: to be healthier, to feel better about myself physically, and with my imminent move to Japan to be with my girlfriend I am hoping to be slightly more physically impressive for her :) Plus a slightly less certain side effect is an increased ... appetite :) Even though I know she loves me as I am, it never hurts to try and improve you know.

But you wouldn't believe how bad I felt after running that first day last Tuesday, or how good it felt afterwards to get in a hot bath and just relax. The first day I ran I felt like I was about to die, but then each subsequent day, until today, it has just gotten easier and less painful. Today was a B though, since I didn't run either yesterday or the day before.

I highly recommend this though. It really feels great and eases your mind.

Luck

 I thought I was going to be spending the weekend in East Texas. But somehow, astoundingly, I ended up not having to go to East Texas.

Now I should say that I originally wanted to go when I thought everyone was going on Saturday for the whole weekend, together. That meant more company, less money spent on gas, and all sorts of good stuff. Which is good.

But then, naturally, my sister decided she wanted to drive 3 hours on Sunday and then less than 24 hours later drive back on Monday, rather than go for the whole weekend. What can I say but the girl likes to drive ;) Its not really her fault, cause her boyfriend had to work Sunday morning (I think). But still, after I found out about that I wasn't too sure about going with them, but I thought OK if they are driving still I can ride with them and its no big deal. Then I found out she gave me the shaft and invited my brother Michael and his girlfriend to go with her instead of me. And that’s fine, you know, but then I am left with the option of driving by myself Saturday and being alone there for a day (plus my parents), or driving by myself Sunday and then coming right back the next day. To which I uniformly reply: screw that. I have much more interesting things to do here. And more important things, like talking to my girlfriend in Japan.

Anyways I told my dad Saturday I wasn't going to go, and he was totally cool with it. Which is one of the reasons I love my dad. But later on I guess he told my sister and she started frantically calling my house phone and the cell phone (that my dad conveniently gave to me last Thursday (I'm generally against cell phones and only took one "for emergencies" and since it was a free gift)). Luckily I wasn't here so couldn't return her calls. I say luckily cause I know she was pissed and you can't talk to her when she is that way. But Sunday I finally called her back, figuring the coast was clear. She laid a big guilt trip on me, but I heroically fought it off. Then my brother called me and laid another one on me, and started to cave. Because of another weird chain of events his girlfriend didn't actually go with them, but she was thinking about it. So they wanted me to go with her cause she really didn’t know how to get there. So things weren't looking good for my “I don’t feel like it” + “Don’t want to drive” + “Don’t want to go alone” defense, and I caved and said OK.

But holy of holies, she couldn't get an oil change and thus couldn't go! Which I think is a little screwy since tons of car shops are open on Sundays now, but whatever. I think maybe she didn't really want to go either. Which was fine with me at this point. I had a grand day talking to my girlfriend, programming, and running. Which in my book, is pretty good.

Friday, September 02, 2005


Excuses...

 Well after eating dinner with my folks, doing my nightly run, and working on an ISAPI redirect filter for a project with a guy from my work, I didnt really have time to find a good file hosting website. So the source code posting may take a bit longer than I thought.

And since I am heading out to East Texas this labor day weekend... where we don't have the internet, it will probably be next week.

Well since no one is reading this blog yet I imagine thats quite OK ;)

Thursday, September 01, 2005


Now we are talking on the same page

I got MinGW's LD to work, thanks to more information from that same page. Basically all you have to do is: do not create a binary kernel. Then LD seems happy. Just pass something like --oformat pei-i386 --file-alignment 0x1000 --section-alignment 0x1000 to LD to tell it to output a non binary but still binary like file, and if you are using GRUB as your bootloader like I am then will understand that file's format load it just fine. So there you have it, I can now get rid of DJGPP and the dumb 127 character on the command line limit in the favor of real, albeit still very buggy (for what I am doing) tools. I guess that's an improvement, right? ;)

Now I tried one other thing, which was to use MinGW's objcopy tool to covert my elf kernel to a binary kernel. And that didn't report any errors, but naturally failed miserably when I actually ran my kernel. Since I have a working all-MinGW-created kernel now though, I am just going to leave well enough alone.

Oh, and I had to add those dummy definitions of __main and _alloca back to my main cpp file too of course. ;) After getting all this working, I think Ill post my source tomorrow, since I am more than a little proud my accomplishment :)

Ahhh LD

 I found more information on the problem I was having with MinGW's LD. It seems that LD does have bugs writing binary output files. Such as my kernel ;) So it didnt matter what format of output I created with NASM, it ends up LD was just not going to take it.

There looks to be more things to try now, so I have more work to do...

Core GUI Ideas

 The main motivation for writing my own kernel is to create a platform for implementing some of my more advanced operating system ideas. Now, I should say most of my ideas apply to desktop OSes, particularly about the interfaces between the system and the users or programs. I am not very interested in how low-level things like networking and virtual memory could be improved or changed. Which is not to say I dont find understanding how they work rewarding, but they just dont seem to grab and hold onto my intrest.

So today I am going to post some of my OS ideas relating to GUIs:

Wednesday, August 31, 2005


Maybe it was LD

 Hmmmmmmmm... while thinking about the post I wrote last night, I realized that the problem with using MinGW may have been the fact that I was using its GCC but DJGPP's LD. I know that seems like an odd thing to do, but I couldn't get GCC's LD to understand the object file output by NASM for the tiny assembler part of my kernel. I didnt try every NASM output format, but of the ones I tried (ELF, AOUT, COFF) each got me either "File format not recognized" or "PE operation on non-PE file" errors from that LD.

So I switched back to using DJGPP's LD and that didn't have the same trouble... but maybe if I had solved that problem instead of avoiding it, then I wouldn't have had that horrible and strange kernel crashing problem later. I'll have to look into it tonight.

MinGW is BAD for C++ Kernels

 Well here we are at my first content post :) And its going to be a long one.

I have been toying around with a bunch of ideas for an OS lately, and I decided to go ahead play around with developing a tiny kernel, so that sometime in the future I could add on to it and implement my ideas. To that end I read some good tutorials, downloaded a bunch of tools (DJGPP, NASM, PartCopy, FileDisk, GRUB...), and tried a basic kernel I built on my virtual PC. It worked like a champ. :) Its a really cool feeling to know that you have written a real kernel, even though you dont understand how or why most of it works. ;)

Then I downloaded the FreeBSD and Linux kernel sources and gave them a look to see how they did some things, namely how they implemented the important C function malloc so that I might copy it. Now since malloc is responsible for allocating memory on the heap, and thus has to work with virtual memory and paging among other things, its not going to be a trivial task to understand it on these OSes. But DAMN! After looking through the code, I am left awe-struck that any mere mortal not only can maintain it, but would want to! That is a labor of love if I've ever seen it.

Maybe it's just me, having grown up with object oriented languages, but I was surprised how incomprehensible that code is. And its not just that its C code and is full of preprocessor directives, though those are certainly marks against it, but give me some comments! Some understanding imparted about how the pieces related would be nice you know, but Id settle for a couple of lines giving you an idea of what it does and why. Throw me a bone!

After that, and since I am not big on straight C anyways, I thought I would do my kernel in C++ and found a good introduction on that subject. Well its pretty good anyways. I figured at least this way, even though I cant use some of the better features of C++, I can at least have classes that are easier to understand to someone else reading my code.

I followed all the steps, taking my own approach to some things, and tried compiling my kernel. That almost worked. ;) But DJGPP doesn't like command lines greater than 127 characters (thank you MSDOS) so since that is very very gay I rashly downloaded MinGW and used its version of GCC instead. Well that also almost worked as well, but didn't because GCC adds calls at the beginning of your main function to ___main and __alloca for possibly valid but mostly frustrating reasons. And that seems to be the only darn behavior in GCC that their isn't a command line parameter to control. So basically these two guys, ___main and __alloca, are normally supplied by libgcc as I understand it, but of course a new-born kernel doesn't have fancy stuff like that so it took me awhile to figure out how to solve it by simply adding the following code to my main cpp file:

extern "C" int __main () {return 0;}
extern "C" void _alloca () {}


Problem solved.

I compiled the kernel again, and this time bingo, it worked. I wrote it to my boot disk image, loaded it in virtual PC and after GRUB loaded it I got a nasty "An unrecoverable processor error has been encountered. The virtual machine will resent now." Whaaaaaat!!!

How do you deal with something like that? Well the same way as anything else where you can't write debug messages: start ripping code out. Eventually I found out it was in my constructor for my Screen class. Which is in fact my only class at this point. My main functions just instantiates a Screen object, and calls Write to print "Hello World" on the screen. And as soon as the constructor is called, even though it does almost nothing, everything blows up. And believe it or not, when I removed the constructor out of the screen.cpp file where it was in and put in into the screen.hpp header file where the class was defined, that fixed it!

I couldnt believe it. And I played around with it for awhile longer, but kept coming back to the conclusion that I was right, and something was wrong in how the code was linked or how main was assembled by GCC. So on a hunch I went back to using DJGPP and worked around the 127 character command line limit. And equally unbelievably, it fixed everything. Now I have a minor kernel, written in C++, that works like a champ at its one and sole task: printing "Hello World" to the screen.

So the moral of this loooooooooooooooong story is, don't use MinGW to build a C++ kernel. Or maybe even a C kernel. At least not on Windows. Maybe GNU's GCC is better on UNIX or Linux though.

An Intro

 With my first real post let me give myself and this blog brief introductions:

Hi my name is Aaron, and I am a programmer living in Dallas, Texas. Im not just a programmer by trade though, I am one by birth. I love what I do... well almost. Its suprising how much of a job in software development has little to nothing to do with programming. Suprising and a little disappointing, but I love programming none-the-less.

Now related to that, I am not going to be in Dallas for much longer, God willing, because I am moving to Japan where I will start a new job and be with my love. And I will leave my old job, far, far, behind. And I will probably learn Japanese and possibly finish my Masters depending on how things go.

Now as for this blog, I am planning on writing down ideas I have on a variety of topics that intrest me, such as operating system design, programming languages, games, politics, and philosophy. Also I think I will write about my experience of moving to Japan for other to learn from.

The idea for the blog came from my girlfriend. She told me one night that I should do this, so that other people could read and comment on my ideas, and possibly my experinces in Japan. And I really do have lots of ideas. So here we are.

Tuesday, August 30, 2005


Welcome

 Welcome to my blog, I am trying to get it looking good right now. Come back later.

This page is powered by Blogger. Isn't yours?