Vaadin Java Framework

Through the PacktPub 2014 Advent Calendar, I recently became aware of a Java framework called Vaadin.  It’s essentially a Java framework with focus on HTML5 on the frontend, it does some fancy stuff by compiling some of the frontend Java code into Javascript for presentation purposes, does all fancy data-binding between the Javascript and the backend server (compiled into a WAR for Tomcat/Glassfish, or even running on Google AppEngine) through AJAX, etc.

There’s a Vaadin Book, that I started browsing through, and the one very nice thing that I noticed about Vaadin, is that it feels very, very famliar.  The more I read and watch some of the tutorial videos, the more it feels like I’m coding an Android app.  I mean, look at this simple code snippit for creating a button, and adding an event listener to that button’s Click event:

Look familiar?

So if you are familiar with Android app development, Vaadin becomes a very small jump to creating great and rich web applications too, all totally in Java, with no need to hack around in the frontend code much, or at all.  There is an Eclipse IDE plugin that adds the typical Text/Design tabs when creating new components, allowing you to drag/drop new web components onto the a canvas, with lots of versatility.

For a step-by-step 10 minute tutorial of creating your first Vaadin app, watch their video.

Unity courses discounts at Udemy.com

I just came across Udemy.com’s Black Friday deals, where almost all of their courses are discounted to ridiculous prices, the prices for all of them started at $10, and increase (so far) by $1 once a day.

They have a ton of Unity courses available, all for currently $11.  The discounts end on 28 November 2014.

Go quick and see and get your Unity education on.  https://www.udemy.com/courses/search/?q=unity

This is not a referral link, it’s merely me sharing the love. 🙂

Adventures in Unity: How to change the default New Unity Project path in Windows

UPDATE: This was for Unity 4.x, and no longer applies to Unity 5.x

I just re-installed my computer, and installed Unity again, aaah, a clean slate. Upon starting Unity up, I realised that it had the rather daft default New Unity Project path set to something silly like C:\Users\aubrey\Documents\New Unity Project\ – but I gather all my Unity projects in my C:\Development\ folder, so I wanted to change that default path.

A quick Google search found only questions, and no answers, on the Unity forums, as well as StackExchange etc. So I went a digging.

Luckily, it did not take me long to find exactly what I was looking for, which was a single registry entry that needed to be changed.

So here it is:

In there, you will see a String with a name starting with kProjectBasePath.

At least, that’s what it is on my computer. I merely searched for “kProjectBasePath” in the registry, and the above came up. It’s a simple registry string, so once you find it, double click it and you can edit it to whatever you want.

If you store your Unity Projects in a folder under your Documents folder like I used to, then the following value will do perfectly:

Just make sure you’ve created this folder first.

Happy Unity’ing.

Disclaimer:
I do this for the fun of it, and ask nothing in return. If you care to donate to see more, please visit my TipJar page.

Adventures in Unity: Making an object move one step at a time – Tetris-style

I hit a small mental block with Project X (codename for my RealGame™ that I am trying to build in Unity), so decided to try to do something a bit simpler first, and see how that goes, purely as a learning experience, getting used to Unity and its quirks.  I decided to make a Tetris clone.

At first I thought “Hey, Unity has a physics engine, Tetris blocks drop down, I can use the physics engine!” – but alas, no, that’s not the greatest idea, as you essentially need to switch off everything about the physics engine, except for gravity really, to make it work.   Too much work, and too much randomness that could creep in.   Especially if you’re using the 3D engine but presenting it in 2D, as I had intended initially.  I figured the final game could present the blocks in 3D as they drop down, maybe move the camera around a bit depending on which side of game grid the object is, etc.  So I am sticking to 3D for now.

Ah, but the reason you’re here, you want to make an object move on “step” at a time, like a tetris block moves, over time.  I just created a script for that, see it at my GitHub repo: StepObject.cs

Here’s how it works:

Here is just the beginning of the script, we make our four public variables available and initialise a couple of private variables.  Our Start() method merely checks that we have the required variables to be able start moving at startup, if so required, so if we have SecondsPerStep and a MoveDirection is set, we make the Moving private variable equal to whatever you chose in the Inspector for the StartMoving tickbox.

Here is the meat of the script, quite small actually, not very meaty at all.  In every Update, we increase the value of the Timer variable by Time.deltaTime.  We use the Timer variable to count how much time has passed since the last time the object moved.

Et voila.  Done.  Very simple actually.  To use this in a Tetris-like game, you would adjust the SecondsPerStep variable over time as the difficulty increases, lowering that value for each level gained.  You would probably start with a number of 2 seconds per step at level one.  If you create your game grid to be one unit per square, then your MoveDirection Vector would be equal to (0,-1,0).

Please give me feedback if you use this script, and let me know how things go.

Here’s the full script code: