Tuesday, February 10, 2015

JS Test

hello

Friday, October 19, 2012

Reluctant Rogue - HTML5 and leaving C#

I've wanted to get back to the Roguelike game that I spent time working on a couple of years ago. The working title for the game is "Reluctant Rogue". Since then, I have stopped coding for my day job, and have picked up much more JavaScript knowledge. I never wanted to make the game platform dependent, so I decided to start over and rewrite the game in HTML5/JavaScript.

Why HTML5/JavaScript? For one, I really like the way JavaScript and jQuery interact with elements on a page. I recently worked on digitizing a board game that some friends of mine created some time ago (You can find it at here). I wrote it entirely in HTML and JavaScript/jQuery - and it was a very cool experience. Nothing to compile, cross-browser compatible, etc. Making a game in JavaScript also has an awesome "blending of the worlds" between "drawing" and "logic". I don't have to store a separate array of the game pieces, with their locations and rotations. Instead, I use jQuery to move the pieces around on the board. This literally updates their onscreen position, rotation, etc. Want to know where a piece is? Just look it up on the board - The data is all within the pieces themselves! This way of coding flows well with functional programming and is honestly way more fun to write.

RR is a little more complicated though, involving AI, a camera, etc. I don't want to rely on CSS to space out the dungeons, so I decided to use HTML5. The canvas allows you full control of the position of the art elements.

Plus, there are some kickass JavaScript libraries out there, such as processing.js and of course, jQuery!

Finally, I don't know any HTML5. It seems like the perfect time to learn it. I also need to improve my JavaScript knowledge beyond the level of "script kiddie" - making full use of advanced JavaScript functions.

My Visual Studio license also expired recently... totally unrelated!

Saturday, February 11, 2012

Lessons from using JSIL to convert C# to JavaScript

So I big reason I am still considering using C# is that there is a tool out there to convert C#/XNA games to JavaScript. This seems like the best of both worlds - game can be maintained in readable JS and I can update code in the language I am most comfortable with. However, JSIL is open-source with zero documentation. Recording my lessons learned here:

Getting Started

Assumptions:

  • You have Visual Studio 2010 and understand how to make .exe files for your programs
  • You have a basic understanding of SCM systems
  • You have programmed before, and are somewhat technical

Getting the source code:

  • Download Git here. Don't worry - we just need the full source
    • On installing, be sure to opt-in for the Command Line client (Windows)
    • Open the command line client. create a folder for the project and navigate there (Linux commands 'cd', 'mkdir' etc. work here)
    • Clone the JSIL repo recursively, including sub-modules:
    • Congratulations! You have the source!

Generating the JSIL .exe file

  • Open the JSIL.sln solution file
  • Rght-click on the solution file in the Solution Explorer
    • Select "build all"
  • the JSILc.exe file will be placed in the bin directory of the project

Using the .exe file to convert C# to JavaScript

  • The JSILc.exe file needs to be run from the bin directory - i.e. you can't move it around (seemingly)
  • Open a command window in this directory
    • Go back one directory, hold shift and right click the folder. You should see an option to open a command window there
    • You will have to run this .exe from the command window.
  • Bring your .exe file that you want to convert into the bin directory
  • "apply" JSILc.exe to your .exe. In the command prompt, type the following (remove the <> signs):
    • JSILc.exe <yourexe.exe> --out=<destination directory>
  • Congrats! You have converted source.

This is where I'm stuck - I get errors when I try to run the .js files that I can't resolve:
'JSIL is undefined'
I also don't really know which .js file to "run" - manifest.js? There isn't much help here.

Things to avoid

  • Do not assume you can download the source from GitHub - you need to do a full recursive clone using Git to get all the right references for JSIL
  • Do not move JSILc.exe around - it seems to fail outside of the build output directory.

Thursday, June 9, 2011

Opening Super Comrade Oriam's casket

He is badly decomposed, but we can rebuild him!

A Redditor recently announced that he developed a C# to JavaScript compiler, and the demo was the tutorial XNA game! This is perfect as JavaScript is cross-platform and easily portable.

In the end, though, if the JavaScript can't work, at least I'll have updated SCO to XNA 4.0, Visual Studio 2010, and Farseer Physics 3.2. There is a great tutorial for converting from Farseer 2.x to 3.2 here.

Monday, April 25, 2011

Regular Expression Search/Replace with IntelliJ

I recently got tasked with reviewing some HTML documentation for my company's product. In the documentation, many instances of the abbreviation "ID" were used. Except, they were being used inconsistently. Sometimes it was "ID", sometimes it was "Id", and sometimes it was "id". Luckily, IntelliJ supports find/replace with regular expressions.

find: id([ .,;!])
replace with: ID$1

The capture group (in the parenthesis) preserves the punctuation if there is any with the "$1" part of the replace.

Sunday, July 18, 2010

Dream Journal

I have had vivid dreams for the last two nights. I used to keep a dream journal and write all my dreams down. They say it helps you remember dreams more easily in the future. I stopped because it was a hassle.

The dream last night started somewhere and had some stuff happen that I don't really remember. One part I was on an island in the sky with others, and we would travel by thrusting ourselves into these long gray dirt tunnels. One of these lead to the Netherlands, and that was one of my companions homelands. This is probably due to a line from Gettysburg, which I watched last night.

I was working for someone who told me to spread around these dangerous, poison capsules. I remember objecting and being told that it didn't matter. There was a lot of small trains on a lot of small tracks around this countryside. There were lanterns on the back hitch of these trains, and I remember a contest to get one. I tried and failed. At one point a train went by and put gravestones down in-between the tracks it was on. apparently, the train could still move over them. The part I remember vividly is an abandoned house. I went into the house alone, and remember it being quite frightening. I then had a companion, though, who I think was a friend of mine named Laura. She told me this is the house she grew up in, and we thought it was haunted. She told me to lay the capsules, which looked like small, wax, orange-syrup filled scimitars, on the table in the dining room. I also had small , round, capsules of butter that I laid around the house. I guess the goal was to get someone to pick them up, one of the haunters.
There was also a small shack across the road from this abandoned house. The house was a three-story house on a hill, will a full basement. We left that place and came back later, and went through the kitchen and the dining room where the table was. The capsules were gone, and instead there were small blue squirt guns in various positions pointing at us. They started firing, but Laura remembered doing this as a child and the way to make them stop was to simply yell "stop!" and point at the gun. We did that and they stopped, and then magically a small girl appeared behind each one and laughed and scurried away.
We then all sat at the dining room table, and then Laura's mother appear with great duress to Laura. she noticed my presence, but not Laura's. She offered me cereal and began talking to me like I was one of her daughter's friends. I remember her telling me she had five daughters and five sons, but the sons never appeared. She seemed to be stuck in a time past. I had a magazine with me, and she commented, "how come I can see your feet through the table?" The magazine was dated 2010. I then realized she could not see anything that was "out of her time," which was about 1996. She seemed troubled by this, and I asked her if she knew anything about mental diseases, or slow degrading of the brain. She said no, but I pointed out the hole in the table which wasn't there, and she started to break down. I told her to follow me. I took her out of the house and across the street, which was now a large, three-story house build around the shack that was once there. Laura's mother told me how her husband lived here, and they were getting separated. I took her to a room upstairs and turned on the light and told her to look around. She seemed to vaguely understand what was happening. I told her to look at the magazine, and asked if she could read the date. "2010..." she said. I told her that that was the current year and time, and she has been stuck in the mental state of fifteen years ago. Slowly she changed and looked around, and fully realized where she was and what was happening. I was very excited to show Laura. I went out into the main living room on the third story of the shack-house. there was a lot of people here, but not Laura. I yelled for Laura, thought I saw her, but it was only someone who looked like her. I then yelled for any Williams sister, and could find none. I panicked and ran back to the mother's room. She was emulating some sort of martial art move that someone was showing her, and she lost her balance and fell on the ground, hitting her head. I then saw a computer diagram that showed an image she had not recognized. There was a date in the corner of this image -- 2010. The image started to disintegrate, starting from the lower right. I yelled "No!" at increasing volumes. The image disappeared and was replaced by one that simply stated, "1996." I was heartbroken, and full of anguish.

The dream ended here, and I awoke with a start. It was a very painful dream, and very interesting to me. I often dream, but the last two nights have been very vivid. They involved doing things under a lot of duress, but were not nightmares. This one in particular is very interesting to me because it contains two things that are not supposed to occur in dreams -- color and being able to turn lights off and on. I don't know what this means or if it is significant. I have had color before in my dreams -- the orange I know very well.