1. Tools

    May 10 2012

    As a programmer, I’m always interested in the latest tools to make my life and my job a little easier. This post will be a small advertisement to those services that have made my days simpler.

    First is Dropbox. If you haven’t heard of this, you need to. This awesome tool allows you to store your files for free online. Now you’re probably thinking, ‘So what? I can do that with anything.’ Well, maybe, but not like this. If you download it (Windows, Mac & Linux), you can have it operate just like a folder on your computer. Not just that, it updates with all of your other computers. Don’t have any other computers? Not a problem. Dropbox works with your smartphone, too. On top of all of that, you can share your uploaded files with anybody, and even share whole folders with a group. This is great for classes and group projects, and it really keeps you up to date. I personally use it to upload my .apks for Android to my phone to test them without annoying wires. How much is it? Free. Yeah, you heard me. Free for the first two gigs, with options to get more by saving photos and spreading the word. Trust me, this is a tool you need.

    Second is one I’m currently working with called Wix. Wix is a website… that makes websites. Simple drag-and-drop Flash or HTML5 goodness. Wix is a bit limited - they assume you don’t want any user input, and that’s a bit of a drawback, but you can easily add your own HTML, Javascript, and CSS by using a quick embed tool. On top of that, Wix will help you make a mobile website and a Facebook page. How much for this one? Well, it’s free too. I KNOW RIGHT?! This is great. Even if you don’t try it, give it a look. It deserves your attention.

    Another one I’m working with is called Zoho. I’m not too knowledgeable with databases, and it also requires me learning PHP, so it’s a great alternative. It makes easy forms that you can fill out and automatically populates a database for you. It’s great if you want to get up and running with some dynamic content but don’t have the skills or the time to make a database. If you want to make it look your own, Zoho even releases your database as a JSON or XML object for you to do your own parsing. Not for everybody, but cool if you’re into that sort of thing (if you’re reading this blog, chances are you just might be).

    Another one I’ve worked with recently is called Cacoo. I don’t like to use it often, but that’s because it’s a diagramming tool, and I really hate diagramming. It’s great for classes, though, and it has some pretty neat wireframing features good for pre-code web design.

    Back to web design, there’s a really neat tool called Handcraft. It’s not so much drag and drop, but it gives you tools for making streamlined HTML and Javascript, and really takes a lot of the legwork out of it.

    Hmm. That’s probably it for the design tools. If you think of any tools you want to share or let me know about, feel free to let me know!

  1. Combo Practice

    May 1 2012

    So, I’m working on another app (Master Sword 3.0 is still on my list). This one basically a practice mechanism for fighting games like Mortal Kombat and Tekken. It’s in its early stages now, but as it develops, I think it’ll be pretty cool. A good friend of mine says I shouldn’t have ads or anything and make it entirely free. While I like that in principle, I really need to start making money (college is expensive). I’m a bit conflicted about not having any ads or anything, seeing as how ads are my only source of income.

    Anyway, that’ll all be decided later. I wanted to upload a screenshot so I can give you an idea of what I’m working with.

    Combo Practice App

    As you can see, pretty standard controls. D-Pad and 4 button layout. I’m trying to accomodate most games, and the ones that have bumpers and such typically just use the bumpers to be A+B or something, so hopefully this layout will suffice. Right now I’m just having trouble with the onTouch() — I had an onTouch for each ImageView, but that didn’t work out because you couldn’t touch multiple buttons at once. To solve this, I created a generic onTouch, but the buttons aren’t where they say they are (they’re all the way at the top for some reason). I’m considering using a different layout (instead of Relative) to try to solve this, but with the other layouts, it can be so difficult to get things in order.

    Wish me luck!

  1. ImageBuffer subImages!

    May 1 2012

    Just ‘cause I haven’t done any code in a while, I thought I’d upload some information about subImages that I wish I’d known before I started the fighter project. This is mostly used for manipulating sprite sheets.

    Well, first of all, if your sprite sheet doesn’t have backward sprites, you might want to make an inverted sprite sheet (easy using a program like GIMP - Don’t use MS Paint, since you need transparency). In any case, let’s get down to code.

    ImageBuffer spriteBox = ImageIO.read(new File("img/hiei.png"));
    ImageBuffer sprite = spriteBox.getSubimage(x, y, width, height); 

    So sprite is basically a smaller version of spriteBox, using the getSubimage method. Sprite is going to be variable, changing whenever you need to change the sprite (hopefully you have a well-arranged sprite sheet).

    Hiei sprites

    As you can see here, my sprite sheet is on the right and the program is on the left. The spriteBox itself is the entire right image, whereas the small pixelized sprite on the left side is just the sprite. I hope this image helps out.

    The way I’ve had to change the images so far is using HashMaps. If you haven’t used HashMaps yet, they’re really quite cool. It’s basically an array that maps a value to another value instead of an index. So if I have a HashMap for storing addresses, I could have ‘Robert’ correspond to ‘1234 Example Lane’.

    HashMap<String, int[]> hm = new HashMap<String, int[]>(); /** Length - 1, OffsetX, OffsetY, Width, Height **/ hm.put("idle", new int[] { 3, 5,  10, 40, 65 }); hm.put("walk", new int[] { 5, 220, 7, 42, 65 }); hm.put("dash", new int[] { 2, 69, 91, 52, 65 }); hm.put("down", new int[] { 1, 475,10, 40, 65 });

    The above code basically puts 4 things into the HashMap hm which contains an integer array relative to a String. Okay, that sounded a bit complicated. So, if I call “idle”, I get that integer array. Pretty simple, right? The comment above it is just so I can remember what I’m using the images for, and I’ll get into that next.

    Each sprite is actually a series of images, right? You never see a guy in a game just… frozen. Well, hopefully not, anyway. So the first value I have in the array is the number of images in that sprite (minus one, but that’s for some logic). So basically, idle is comprised of 4 images. The next is the X offset in pixels. This means my first image in the spriteBox is 5 pixels away from the edge. The next is the Y offset in the same way. The next are the widths and the heights (and remember, graphics in programming are in the 4th quadrant - 0,0 is the top-left!)

    Alright. So we have an array of images, and we know what sprites we need. We have those in a HashMap. All that’s left is traversal.

    for (int i = 0; i < arr[0] * 2; i++) { if (i % 2 == 0) j++; if (!dirRight) sprite = invertedBox.getSubimage(invertedBox.getWidth() - (arr[3] * j) - arr[1], arr[2], arr[3], arr[4]); else sprite = spriteBox.getSubimage((arr[3] * j) + arr[1], arr[2], arr[3], arr[4]); checkMove(); try { Thread.sleep(40); } catch (InterruptedException e) { }

    And I bet this sounds pretty complicated, too. Well, I’ll go through step-by-step. I personally hate it when people don’t explain a huge chunk of code and just assume I know something, so I’ll try my best not to do that.

    As you see, I multiply the length by 2. I do this because I want to have the sprites go slower without losing computer response time by ‘sleeping’ (I’m using Threads. If you don’t know those, try to look them up - they’re a lifesaver!). Anyway, I then use that doubled i to mod j, which I’m using as my counter (it only gets incremented every other pass, thanks to our good friend mod) 

    If we aren’t facing right, we get an image called invertedBox (a backward spriteBox), and we get the sprite using subImage. If we ARE facing right, we just get an image into sprite from the original spriteBox. As you can see, I’m using the values from the HashMap, and incrementing which image by that j I made earlier. 

    I then call checkMove(), which just sets some booleans and junk. No big deal, just some logic.

    I hope I’ve been some help, and if you have any questions, let me know and I’ll see what I can do!

  1. AAAAAAAAAAAAAAAAAAGGGH

    Apr 24 2012

    That’s a terrible wail of pain. I don’t want another project to go uselessly down the drain, but it just might happen. My partner, Clifton, has too much of a workload to help too much (not his fault, I have bad timing), and HitodamaKyrie hasn’t drawn anything for it, so we won’t have the images by our deadline. We still don’t even have jumping implemented.

    After talking to a fan of my Android apps, I’m really thinking about going back and making Master Sword 3.0 like I had wanted. If I do, though, I really hope I can finish them. I need to do something to make money, and I also need to further my career. I WISH I HAD IDEAS, AGH.

    We’ll see how things go. Wish me luck on my finals in these coming weeks =P

  1. Sprites, Heads, Tails, and Fridays

    Apr 17 2012

    So, the sprite sheet I’ve been working with for the Fighter (currently Tails from Sonic) is a bit skewed, and it’s making me realize how difficult it is to work with improper sprites. I’m really hoping that the sprites we have in the end are organized. The ones I’m working with (though I’m likely to change soon) don’t even have static sizes, so each image will appear smaller than the last.

    In good news, HitodamaKyrie drew this for the main protagonist: http://24.media.tumblr.com/tumblr_m2etztVc2j1rs6ewpo1_1280.jpg

    I have an interview on Friday for an internship, so things are looking up. I really hope I get it, I need a job over the summer. Wish me luck!

  1. A game I’ll follow through on

    Apr 10 2012

    At heart, I’ve always been a game designer. I’ve always wanted to, but never got around to it. I keep starting these projects, and never finish them. So, I need to start small. I always go for such grand ideas, I need to shut up and climb the ladder just like everybody else.

    So, my friend and I thought about it. What’s the easiest type of game to make? Based on the number of variables, we landed on Fighter. Fighter games are basic and very little is dynamic, and should be pretty simple to code.

    We’ve had a bug already - the Canvas’s addNotify() method wasn’t called. To solve this, we ended up having to copy another Canvas class from the internet and modify it to look exactly like ours. I have no idea why this works, and our previous didn’t, but once it stops being broken you kinda stop asking questions and hope for the best.

    We’re about to add fighters and get some base functionality down. Oddly enough, the thing I’m worried about most is the HUD. I know we can have some rectangles for health, but I was hoping for a fluid slimming style. We’ll see how it goes, and I’ll post some pictures once they’re worth something.

    I’ll keep updated!

  1. Microsoft Interview

    Apr 4 2012

    So, this Monday I had an interview with Microsoft. I’ll try to be as descriptive as possible - I know that there are people interested in this, and if you’re reading this before an interview of your own, good luck!

    So, I was to meet in Building 111 (One-Eleven) with my coordinator for an SDET position interview. I’ll leave out names for privacy’s sake. After playing for about an hour with various interviewees on an awesome Microsoft Surface 2 in the lobby, the receptionist, another interviewer and I all rocked out on Rock Band 3. We ended up playing “Yoshimi Battles the Pink Robots Pt. 1”. Halfway through, a coordinator came out to meet our drummer, the last interviewee besides myself. The two of them left together, and the receptionist had to go do some business stuff. Since I was still waiting, I decided to sing “Everybody Wants to Rule The World”. Near the end, my coordinator showed up, and we went to his office.

    His office was pretty small and dark, and like all the offices I saw at Microsoft, was comprised of three solid walls and a fourth glass wall containing the door. He went over my resume a bit, asked me some pretty generic questions, and then got down to business: I was interviewing for the Windows Live team. The Live team was located in Building 88, I had an unknown number of interviewers because of their schedules, and after I was done interviewing he wanted to talk to me again. So he called a shuttle (A midsized Ford sedan) for me, and it took me to building 88.

    Surprise! At building 88, in the lobby, I met the drummer again. Turns out he was interviewing for Project Manager for the Windows Live team. Small world (big campus). I could wholeheartedly wish him luck, since he wasn’t applying for SDET. He left before me yet again, then my interviewer showed up. Hard questions time.

    So, this guy used to work on the Hotmail team. That’ll be important later. He asked me a programming question first, which I’ll describe down here:
    You have a tic-tac-toe program. Given this method header, solve for checkWin -

    public bool checkWin(int col, int row, char piece)

    So, I want to go ahead and say that I’ve done tic-tac-toe before, and that was my downfall. I was thinking back to my own generic method so much that I didn’t understand the simplicity of his. I feel I failed this horribly. This is the first solution I came up with:

    public bool checkWin(int col, int row, char piece)
    {   for(int i = 0; i < 2; i++)
      {
        for(int j = 0; j < 2; j++)
        {
         if(board[i] != piece)
           continue;
       }
        return true;
       }
      return false;
    }

    To be honest, I’m not sure that’s exactly what I had, but even that wouldn’t be done. I’d still need to check for vertical, then diags. I kept improving that while I worked on it, trying to reason my way to a better solution, but as long as I didn’t understand that col and row were being passed to me, it was no good. Thinking back makes me realize how stupid I was in that interview.

    So, here’s what I -should- have been doing:

    public bool checkWin(int col, int row, char piece)
    {
      if(board[col][0] == board[col][1] == board[col][2])
        return true;
      if(board[0][row] == board[1][row] == board[2][row])
        return true;
      if(board[0][0] == board[1][1] == board[2][2])
        return true;
      if(board[2][0] == board[1][1] == board[0][2])
        return true;
      return false;
    }

    I was trying not to brute-force it, but sometimes ya gotta. So after that coding question, he asked me to ‘test’ an elevator. So, I came up with some ways to test it. Test the capacity - load it up until it starts to mess up. Don’t go beyond that weight. Make sure it has a good speed, but that it doesn’t accelerate so much it kills you. Make sure the brakes are good. Pretty general stuff there.

    Then here was the last question he asked me. Say you’re on the Hotmail team (told you it was important). You have two bugs, but only time to fix one before release. These are the bugs: Messages sent to multiple recipients will only go to the first recipient. — If you have more than 500 messages in your inbox, your browser will crash.

    What to do? He said I was able to ask him anything, so I did. Here’s some info:
    Less than 5% of all users have over 500 messages in their inbox.
    Over 66% of all messages sent have multiple recipients.
    The time it would take to send a message to everyone apologizing for the multiple recipients issue is too long for us to solve the inbox issue and then the recipient issue because of localization (Hotmail has a large user base).
    And then I asked: Is there a right answer?

    He said no.
    I ended up going with the recipient issue. I hate it, but it’d impact less people.

    So. Back to the lobby (where I met drummer a final time) to wait for my next interviewer. After he arrived (I’ll be honest, it took a while), we went to lunch together in Building 86. The ‘weird’ cafeteria, because you have to pay for your food. I’m not sure if we went there as part of the plan or if it’s because it was closer than The Commons. We got Chinese (the line was short for that one, so I opted for it, but I shouldn’t have - it was actually pretty lousy. I saw plenty of other good food, so I know it isn’t the establishment, just my poor judgment), then got some (FREE) coke and sat down. He asked me about what I was interested in, and I asked him about what kind of work he did. He talked mostly about automating input to systems using C# and PowerShell. We went back to his office for a more official interview.

    Coding problem 2. Given an integer array, remove all adjacent repeating integers.

    There was a bit of miscommunication, so I was going to write the code for finding the integers and a method to solve it. I think it was just me misunderstanding him (he had a thick Indian accent, probably because he was from India), but I’m pretty sure I lost points for that. He corrected me, and I went to solving it again. I ended up with something like this:

    public void removeAdj(int[] intarr)
    {
      int[] list = new int[intarr.length];
      element = 0;
      for(int i = 0; i < intarr.length; i++)
      {
        if(intarr[i] != intarr[i + 1])
          list[element++] = intarr[i];
      }
    ...

    And then I ran into some problems. I was thinking we could just leave it at that, but then we’d have an excessively long array (assuming we did work) with no way to denote worthless values. I was much too nervous to remember we had ‘element’ for some reason. Oh, somebody hit me in the head with a hammer. He ended up reminding me by something he said that I could use element, but not after I made a fool of myself. I ended up adding this:

    ...
    int[] temp = new int[element];
    for(int i = 0; i < element; i++)
    {
      temp[i] = list[i];
    }
    intarr = temp;
    }

    which works fine, but for some reason he didn’t like it. Apparently, he wanted me to just do ‘intarr = list’ before that and do an int return of element to show where there was meaningful information. I have to say, that’s just silly.

    ON TO THE NEXT INTERVIEW.

    So, this guy and I got along fine, we had similar senses of humor, although I found his social awareness lacking (dude had never heard of Minecraft). He used to be on the Messenger team. For his programming question, I’ll skip ahead and tell you the answer instead of what I fiddled around with (which were all mostly terrible, I assure you).

    Say you have a char singly linked list. Remove all recurring nodes. (For instance, if you have AaBCAD, you should have AaBCD).

    Short answer - create a hashmap and check on every node if that hash value is filled. If it is, remove that node.

    He also had me run through some test cases, which I apparently didn’t supply enough of. It’s 1:22 and I’m getting tired, so I’m not going to go through those.

    So, we departed, and I went back to Building 111 via Shuttle. I met with my coordinator briefly (He had a meeting to get to), he asked me how it went, and told me he’d be in touch within a week. I hope to hear from him soon.

    Oh, quick tip: In the refrigerator in the lobby of 111, there’s this drink called ‘Kinect’. DONT DRINK IT. ITS BAD.

    At least, I didn’t like it. Ended up drinking some Welsh’s Cranberry Juice to get the flavor out. A couple more juices fell out of the fridge and got dented, so I ended up taking those too. Overall, I liked the experience. I was way too nervous to function, though.

    Like I said, if you’re reading this in prep for an interview, good luck! Well, so long as you’re not going for SDET on the Windows Live team. At least, not anytime soon.

  1. Databasing

    Jan 7 2012

    The main issue I’m having now is databasing. I need each contact to hold information such as what network feeds to look for and what image to use, et cetera. Unfortunately, I have absolutely no idea how to communicate with a database. Do I need to create one, and if so, what do I use? I’m finding the internet to be surprisingly unhelpful at this time. I shall seek aid from some associates who are more versed in the matter.

  1. Internet Explorer… again

    Jan 7 2012

    I come this time with a problem, and not a solution. In Internet Explorer, the Javascriptdoes not work. I forget if Tumblr supports HTML or not… if it does, the above will look kinda weird.

    el.innerHTML = "<b>" + contact[i].name + "</b><br> &nbsp;" + contact[i].status;

    Chrome, Firefox and Opera all display it fine, but IE will not show it. If I even just do ‘status’ (defined a few lines prior), it is blank. If I add random things in the quotes after ‘br’, they will display on the new line properly, but the status will not. The most peculiar thing though is that if I use contact[i].name, instead of status, it displays perfectly…

    I’ll need to put some work into this, even though it’s not certain that this will even make it to the final product. I simply feel that if I can resolve this issue, I’ll have a better understanding of HTML and Javascript… and IE… in general, and I’ll be better suited to tackling any challenges I’m sure to face.