I don't understand why you came 63rd for graphics. The minimal style that you used was beautiful, particularly the star background. My wife won't shut up about "how elegant and beautiful that star background is". She keeps saying that "the effect was a revelation" to her.
Badly Drawn Rod
Creator of
Recent community posts
You might want to change the instructions to say "click" rather than "tap". I spent a fruitless few minutes wondering just how hard I had to nudge the materials to collect them before realising that I should use the mouse. That being said, I thought the graphics were beautiful. The star background was a welcome pleasant change from the usual pixels and dots.
With the exception of the issue with the tethering, it was a cracking little game.
I really liked this. I haven't seen 3d with the Thrust mechanic before and it worked really well. The only issue I had was the lighting - everything seemed a bit dark (I know, it's a cave). The aliens and their voices were excellent - they really don't want deliveries do they? I was half expecting to hear "get off my lawn!"
I think I found a way of putting it on autopilot. If you surround the inner earth with 50 point towers (the ones that shoot at the bottom of the toolbar) then you run out of money, but then you don't have to press anything or buy anything to survive as it provides enough coverage to shoot everything. I've been locked in a stalemate with the boss for ages now.
Great music and love the alien graphics.
I enjoyed that. Good premise, and I like the particle effects when the asteroids explode. The only problem that I had was that the text scrolling across the screen made it a little difficult to see what was going on, but otherwise it's a fun game. My wife enjoyed acting as my wingman, controlling the astronaut.
I'm glad to say that it has been a fairly smooth transition, although some of my code has more than a hint of "let's try this Kotlin feature" as I'm still learning. I regularly use Java, C#, Python and JavaScript for my day job, so many of the ideas in it are familiar.
What I like about it is:
- it's succinct, which is a refreshing change from Java's verbosity
- it's expressive - some of it is reminiscent of LINQ
- it has batteries included, as it can use any Java library
- it doesn't enforce any particular programming paradigm - if all you want is a function then that's fine
- it has new ideas that work well, such as its approach to delegation
If you want to learn it, start with the tutorials, browse the reference and definitely, definitely do the Kotlin koans (I've been doing these on my lunch breaks and they're very good).
Update: this is a very good overview of Kotlin (video + transcript)
Kotlin, Kotlin and Kotlin
Kotlin is excellent. Did I mention that? It has all of the benefits of Java such as the rich libraries, LibGDX, with none of the downsides. It's also incredibly succinct.
Lambdas
If I want to run something after a few seconds, I use a Timer class with a method after() that takes () -> Unit as its last parameter.
Here's the signature…
fun after(seconds: Float, run: () -> Unit)
That lets me call it with a lambda as follows…
timer.after(5f) { resetWave() }
For what it's worth, the implementation of after() is incredible short…
fun after(seconds: Float, run: () -> Unit) = q.add(Task(run, now + seconds))
Extension Methods
Another thing that works rather well is Kotlin's implementation of extension methods. C# also has extension methods, but Kotlin's go further. Let's say I want to run all the eligible tasks in the timer's update() method. I could write it all inline in the update() method, checking that the LibGDX BinaryHeap backing the timer isn't empty, peeking the head to see if it's eligible, popping it and invoking it if it is, but that would be rather verbose and would hide my intent.
Or I could do this…
var task = q.nextTask() while (task != null) { task.run() task = q.nextTask() }
Here, q.nextTask() is an extension method on BinaryHeap<Task> that returns null if there isn't an eligible task or the next eligible task if there is. It's implemented as a private method inside Timer, so it has access to its properties, including the all-important now property.
private fun BinaryHeap<Task>.nextTask(): Task? { if (size > 0) { val task = peek() if (task.value <= now) { q.pop() return task } } return null }
Extension Properties
Kotlin also has extension properties. I have an interface Transformable that has properties worldX and worldY. When I use objects that implement Transformable in the renderer, I want to know where they are in relation to its camera. To do that, I add a couple of extension properties on Transformable in the renderer, called cameraX and cameraY. The implementation of cameraX is shown below.
val Transformable.cameraX: Float get() = toCameraX(worldX)
That allows the renderer to do things like this…
batch.draw(image, t.cameraX, t.cameraY)
Delegation
Also, Kotlin's implementation of delegation is something that I haven't seen before. In the following example, class Animal implements Transformable, but the implementation of Transformable is handled by t which by default is of type Transform. That means any call to a method or property on Animal that implements the Transformable interface is automatically delegated to t, without the need to delegate it yourself.
class Animal(x: Float, y: Float, t: Transformable = Transform()) : Transformable by t {
For example, in the following code, the property worldX is implemented by a Transform, without the need for me to write anything more.
var a = Animal(100f, 200f) var x = a.worldX
Conclusion
I am not going to claim to be an expert at Kotlin. I only started using it when I began this project, and have been working my way through the Kotlin koans (found here) on my lunch breaks. But I am very pleased with what I've found so far and I think that I will use it instead of Java in circumstances where that's practical.
I'm trying to figure out the best way of getting Box2D to play well with Ashley. Fortunately there are existing examples, such as those found in Overlap2D, so I don't have to do too much thinking – just as well as I'm shattered! My daughter wanted to see in the New Year, not realizing just how exhausted my wife and I are having had to cater to her relatives.
Much of today - at least once I got up - was taken up with spending time with my wife and daughter, playing Yoshi's Woolly World on the Wii-U, and Avian Attorney and Shovel Knight on the PC. For what it's worth, Shovel Knight is my favourite as it has very precise controls and a great retro feel. I think I may be putting in more than a few hours.
Eventually, when everyone else had gone to bed and the house was quiet, I managed to squeeze in a couple of hours programming. I'm impressed with Kotlin's when expression and smart casts. By the way, createFixture() is a nested function. Nice.
when (shapedComponent.shape) {
is CircleShaped -> {
val circle = CircleShape().apply { radius = shapedComponent.shape.radius } createFixture(circle) circle.dispose() }
is BoxShaped -> { val polygon = PolygonShape().apply {
setAsBox(shapedComponent.shape.halfWidth, shapedComponent.shape.halfHeight)
}
createFixture(polygon)
polygon.dispose();
}
}
Today's progress:
- Added Box2D physics and implemented a PhysicsSystem. It still needs some work, but the rudiments are there.
- Created a BodyComponent to represent Box2D bodies in Ashley.
- Created a ShapedComponent, which can currently be either circle shaped or box shaped.
- Learned about Kotlin's smart casts and when expression.