Saturday, December 27, 2008

MMORPG Day 6

Merry Christmas Again!

The MMORPG became interactive on day 6 of it's development. I made it possible to move around the map and change the camera angle.

To move around the map I either had to move the Map itself or the Character and the Camera. I decided to move only the Map since it was harder to move the Camera and the Character. Every time the character "moves" a tile, the map gets translated by the TileSize to make it look like the character moved.

The camera angle can be moved freely which isn't so great yet. I'm going to have to find some proper camera restrictions so that the player can't rotate the map 180 degrees and look below it.

The MMORPG of day 6 can be found Here. You can move around by using the arrow keys. You can change the camera angle by holding down the control key and pressing an arrow key. Unfortunately you have to press the arrow key each time you want to change the camera angle by 0.5. I'm probably going to change that.

To finish the Map I need to be able to load Objects and add them on top of the height map. Then I need to be able to display everything in color, not in grey tones. Then I need to put the character class into the map at the proper height. Then I'm finished with a lot of the MMORPG and I will be happy.

Monday, December 22, 2008

MMORPG Day 5

I got a lot done on Day 5. I started working on a Height Map loader which can load a 3D map from a 2D height map. It looks really good although I don't have any great maps yet.

First I had to create a height map to test the loader. I wasn't sure if I should use a picture or a text file. I decided on a text file since it's easier to store additional information about the map this way. I decided on a really simple format:


// A random 5*5 Sized Map
1,-2,4,1,4
-2,8,5,6,2
1,0,0,2,3
4,6,2,5,7
-1,0,4,3,2



To load that height map I first created a grid of 5*5 Vertices and connected them together with triangles so that they would form a Square pattern like so:


After that I simply assigned a number to each vertex so that they would be the height they should be in. A resulting height map of the Loader looked something like this in my 3D Engine:


Now I just would have to find the perfect size of the squares and the Height Map loader would be finished. I though of 32 times 32 pixels because most 2D video games use this tile size. I found 32 pixels too small to fit a 3D human into so I set it to 50 pixels. 50 Pixels is quite good and I'll probably stay at that size but I'm not sure yet.

Now to finish the Map loader I need to find a way to load objects (ex. trees, houses, chairs) into the map and place them at the appropriate position. Then I need to find a way to add colour to the whole thing, grey is kind of boring. After that I should find a way to make the Camera focus on a certain tile (probably the one with the player on it). I'm not quite sure how much more time I have before Christmas so I'm saying that the next MMORPG Day might be more than 3 days from now.

Merry Christmas!

Sunday, December 21, 2008

MMORPG Day 4

On day 4 I ran into many things I hadn't even thought about.

One of the many problems is Animating the Characters model. I think I might group together many polygons and bond them with a "bone" point and when I do anything to that point it impacts all the polygons tied to it. That way by moving one vertex I can be able to move an entire part of a character (ex. Left Leg, Right Arm). I will also have to find some way to record the movement of the "bone" points in a simple text file. As stated before I'm kind of stuck there.

I also hadn't considered the Item class properly. I forgot to add any way the Item could interact with another thing. When I realised I added 3 new methods to the Item class; useonCharacter, useonItem, and useonTile. This way the Item can interact with players, other items, and the surrounding area. I have to create some kind of scripting language to create the results of an interaction. This Scripting language could also be useful with map related events. The scripting language would have to be simple, something like this:


(item)Fish+(character)Player
> Player is less hungry
> Fish Disappears
(tile)Tree+(item)Axe
> Tree dissapears
> Player gains (item)Wood
> 50% chance axe may brake


I also forgot about any kind of Levels the character may have. I think a simple array of numbers will do but I'm still thinking about it.

The thing I mainly worked on on Day 4 is This Applet. It took quite some tweaking to get the Applet to load files from the server it was stored on. I may write an Article about it later on. When you view the applet you should see a green cube rotating representing the character. It's loaded from a file and treated as a character would be. I will improve the characters visual appearance later on so don't panic =). On the top of the applet it says "3D Engine (ZBuffer: False)" which means that ZBuffering is disabled in the 3D Engine (as you may have guessed). On the bottom of the Applet is a series of letters harder to decipher. They basically represent the players character.

I'm kind of stuck on all fronts with the Character so if I don't solve the problems I'll continue on to the Map class and return later.

Saturday, December 20, 2008

MMORPG Day 3

I finished the Character class on Day 3 of my MMORPG developing experience. It was pretty simple to create a method which would piece together a character from various 3D files. First I had to find a good way to save 3D models into files. I got myself a copy of K-3D and Blender to look at common file formats. I wanted it to be really simple so I wouldn't have any trouble with the data, I decided that maybe later I could think about using a proper file format. I picked the K-3D raw format since I as a human could understand it easily. It looks something like this:


# comments.. bla bla bla

# points
-1 2 3
6 -3 6
9 3 -5
1 5 8
-4 2 6
# polygons
1 2 3
3 4 1
1 3 2
1 3 4
1 2 4
1 2 3
1 2 3

First of all I loaded the file using the Java method I had created for loading text files. Then I excluded all lines starting with "#" except "# points" and "# polygons". I used those two comments as references as to what I was loading right now. I simply loaded all the points into a List using each of the three numbers as a coordinate (x,y,z). When I got to loading the polygons, triangles in this case, I picked the points out of the list with the corresponding index (ex. List Item number 1, 2, and 3) and created a Triangle with them which I then added to my Model.

I created a Model.merge method so I could load another model and merge it into the first model. This allowed for loading each part of a model separately, as was needed for my Character class.

Next I created a folder layout to save all my Character parts in. It would bring some more order into all the files I would need to create so that players could customise their character as they wanted. The folder layout looked something like this:

+CParts (character parts)
--Body
--Hat
--Gloves
--Shoes
--etc.

Each folder would have files in it with names ranging from the number 1 to something hopefully below 100. So to generate my players model I could simply load the corresponding file to the corresponding number in his Look Array from the correct folder. The number 0 in a players Look Array means that he isn't wearing that right now (ex. hat=0; not wearing a hat).

Once I finished that I started thinking about the Item class I would hopefully create on the next day. I didn't come up with anything but since my current speed is pretty good I hope I'll think of something tomorrow. If I don't, I'll start working on the Map class.

Friday, December 19, 2008

MMORPG Day 2

On day two of my MMORPG development I got bored of the working on the 3D engine so I started working on the character class. I thought it would be something easy and useful to do. I will go back to the 3D Engine later, for now it displays only one model in a relativity slow speed.

The character class started out easy, I just created variables which would store the characters data. These variables where:

- Name (of character)
- Position (Map Name)
- Position (X & Y)
- Action (ex. Walking, Sleeping...)
- Frame Number (frame of action)
- Logged On (yes/no)
- Chat (what the player is saying right now)
- Look (how he looks, what the player is wearing)
- Inventory (items the player is carrying)

I ran into some problems with the Look and Inventory. For the Inventory I decided an array of the class Item would do just fine. I will work on the Item class later on but for now it doesn't even exist. For the look I decided an array of numbers would do. Each number would represent one aspect of the characters look. For example:

1. Hair Style (1=Bald, 2=Punk, 3=Mohawk, 4=Normal)
2. Hair Colour (1=Blue, 2=Red, 3=Green)
3. Skin Colour (1=Blue, 2=Normal, 3=White)
4. Hat/Helmet (1= none, 2=gold helmet)
5. etc. etc. etc.

After creating the variables I went to work on the methods. The first and simplest method I created was toString. This method simply took all the variable and turned them into one string. The second method was fromString. This method took all the variables from a String. These two methods will hopefully help me later with the networking of the game.

The method I'm currently working on is the createModel method. It's supposed to take all the numbers from the number array Look and turn them into a 3D model for the 3D engine to display. I'm thinking about having a 3D file for each number of an aspect (ex. hair, skin, hat) and then just simply loading them and piecing them together. I'm not sure yet if that will work but I hope so.

Once I have that method finished I just need to create the item class and my character class will be finished.

Thursday, December 18, 2008

MMORPG Day 1

I decided that a MMORPG (Mini Multyplayer Online Role Playing Game) would be something fun to work on. I hope I can finish it in the 19 days I have left of Christmas Break because afterwards I have exams and I won't be able to focus on programming. It's probably a world wonder if I do finish a MMORPG in 20 days but it won't be very big, that part comes later (I hope).

I'll write a daily Blog post so you guys know what's going on. I have decided that I will only dedicate full days to my MMORPG, nothing less. This way it will be easier for me to focus. If I take a break of working on my MMORPG (for whatever reasons) I will simply skip that day and continue on the next (If possible).

So on Day 1 of my MMORPG I made an outline of all the things I would need to program in Java. That way I will hopefully be able to tell exactly how much progress I have made and how much I still need to do. Here's the simplified outline:

- 3D Engine
- Map
- Character
- Networking
- Sound
- HUD / Menu

The 3D Engine is going to be the first thing I will work on. It will "simply" take 3D Models and display them on the screen. I have decided to use the 3D Engine I developed earlier on due to portability reasons. If I would take a 3D engine depending on graphic cards there certainly would be problems. I choose Java because of portability and I'll choose the 3D Software Rendering Engine out of portability too. Maybe later I'll add the option for people with good graphic cards to use them. I decided to work on this first so you people out there can see results quickly.

The Map will load a 2D tile based map and convert it into a 3D model which will be displayed by the 3D Engine. It will also store all the data of the players surroundings.

The Character will load a Characters DNA and make a 3D model out of it which will also be displayed by the 3D Engine. A Characters "DNA" includes all the characters Information in one short line of text. The Character stores everything about the player and what he's doing right now.

The Networking will probably be the hardest since I have no experience in that area at all. I'll just have to try this and that and hope it works. Wish me Luck!

The Sound and HUD are very low priority and will be the last thing I'm going to work on. The HUD may come a long as I work on my MMORPG and it may not, it depends on how much I need it.

I had some time left after making a good outline so I imported my old 3D engine and familiarised myself with it as it has been a long time since I last looked at it. It's working nicely and I'll just have to tweak some small things here and there to make it fit into a MMORPG. The biggest concern will probably be the speed but I'll find a way (hopefully).

Wednesday, December 17, 2008

Christmas Break

I have just entered Christmas break!

I have given up on the Hardest Logic Puzzle on Earth for now. My friend has told me that the answer can be found at Wikipedia so if you are curious take a look. I myself won't look until I think I found the correct answer, I'll keep trying every few weeks to see how much my brain has grown.



As I stated above Christmas break has just begin for me and I know have exactly 20 days of free time on my hands. Maybe take away one or two days for Christmas and after. I'm currently trying to think of a big project to start and finish during these days but I haven't thought of anything fun and exciting yet.



I have optimised the website layout further and my "Games and Applications" section is starting to take shape. It's still pretty bland but I have already uploaded my very first Java game. As you may have guessed, it's a Pong game. It's not the best game but it's certainly fun to play for 5 minutes or so (I hope). The sound magically vanished when I uploaded and I'm trying to fix it.



Have a Nice Christmas Break!

Sunday, November 23, 2008

The Hardest Logic Puzzle on Earth

Well first of you may have noticed (if you use I.E.) that the layout has changed drastically and is almost completely free of bugs. I have also lost all respect for Microsoft and am considering to create a website just to combat them. I am just so sick of them...

On a happier note I was being bored again and surfing through the net I found this: http://philosophy.hku.hk/think/logic/hardest.php. It's a very interesting website and I advise you to read through it if you haven't finished a course on Psychology and Critical Thinking yet. The website states that George Boolos states that this is the most difficult logical puzzle on earth:

Three gods A , B , and C are called, in some order, True, False, and Random. True always speaks truly, False always speaks falsely, but whether Random speaks truly or falsely is a completely random matter. Your task is to determine the identities of A , B , and C by asking three yes-no questions; each question must be put to exactly one god. The gods understand English, but will answer in their own language, in which the words for yes and no are “da” and “ja”, in some order. You do not know which word means which.
I thought I might give it a try.

First of I Organised My Data:
  • 3 Gods: A,B,C
  • True Names of 3 Gods: True, False, Random
  • I can ask 3 true and false questions.
  • The response is either da/ja which means either yes/no.

After that I used one of my favorite computer algorithms; Brute Force =)
I calculated all of the possible answers to the puzzle:


So once I knew the 6 different answers I couldn't do anything more on that part of the puzzle but wonder if it was even something useful I had done.

I moved on to another part of the puzzle: The Questions.
I would have to ask 3 true and false questions to find out which of the 6 answers was the correct one. Not only would I have to consider the questions I would ask but also to which God I would ask them to.

Lets look closer at "True and False Questions". The question would have to be answered by yes or no (da/ja). The types of "True and False Questions" I could think of are listed below:
  1. Asks weather dogs are animals (true)
  2. Asks weather dogs are stones (false)
Upon further thinking I also thought of these more personal questions:
  1. Asks: Are you True/False/Random
  2. Asks opposite of 1-3
  3. Asks: Are you "Insert a Double Combination of Questions 1-3"
  4. Asks opposite of 5
I wasn't really sure if the first pair of questions or the latter bunch of questions would help me more so I just wrote both down. I would probably have to ask a correct combination of the above questions to find out what da/ja meant. Once I know what da/ja means I probably could find out with ease which god lied and which one didn't, I'm not sure about the Random god yet.

Lets apply the Brute Force Method Again:
  • The different Questions I could ask is: 2+3+3+3+3=14
  • The amount of Questions I could ask is: 3 (given)
  • The number of Responses I could get is: 2 (da/ja)
The Total Different Routes I Could Take or be Chosen to Take: 14*3*2=84
I'm pretty much stuck there. I will analyse the routes more carefully in the Next Post and I hope I'll get a result.

Monday, November 17, 2008

Fighting Boredom

I'm not getting anything done lately since I'm very bored. I'm not so sure yet why I feel like doing nothing all day lately but I'm sure it's a severe case of boredom. I don't think it's laziness since I don't feel like doing fun stuff either, things like programming or writing random stuff are normally things I like to do but lately I just don't feel like doing them. I think I got bored by these things because they don't provide a challenge any more. Of course programming takes a lot of time and is something hard to do but I have the blueprints of how I'm going to do everything I want to do in my mind and there are no obstacles standing in my way. Except time of course, but that's not really an obstacle since I have more than enough of it. I hope I'll get over this total lack of enthusiasm soon.

Since I'm not going to get anything done due to boredom I've decided to make a list which I have to follow. Excuses about boredom are not accepted.

List:
- Make website Internet Explorer Capable
- Finish of Website Layout
- Create Help Files for my Website
- Add my E-Mail address and the likes under "Contact"
- Add one Game under "Games"
- Finish of Current Content
- Think of more ways to use up time:
- Maybe get Traffic?
- Put on more games?
- Create an Article Section?

Monday, November 3, 2008

Finally Website!

I have finally gotten a website: http://www.zirconcode.com/
This Blog will be integrated into that site but will still be available under: http://devediary.blogspot.com/

I'm currently just trying to get this site to work. For best results view it in Firefox (3 or above?). I'll get this site to look good for funnier browsers like IE too but that has to wait until I got everything set up.

The Site currently has the following categories:
Home = A Welcome Message + News Blog (this one)
Applications & Games = Anything Java for Computer Illiterate (it's also longer)
Help! = ...
Contact = a non-private e-mail and maybe comments?

I may be adding a forum later once I get more than about 350 hits a year =).
Also I'm not quite sure if I should add an "Articles" section (with polished blogposts, ex. Triangle Interpolation) but it would probably boost my hit counter.

On a more Boring note (location,location,location...):
Let me explain in a monotonous voice how I stumbled on the name ZirconCode because I know that you are just burning to know =/.
Well first I thought something with "Source" or "Code" or similar would be nice. Then I thought that maybe I could add some colour prefix like "red" or "blue" but for various reasons it didn't sound so good... (really, trust me)
Then I thought instead of colours I could add a precious metal like "diamond" or "ruby" or "gold" or "titanium" or...
Well I somehow ended up at ZirconCode and as it was the first name I came up with which wasn't taken I took it =).