Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon
25. November 2015

 

With the upcoming LibGDX jam, it dawned on me I hadn’t done anything with LibGDX in a while.  I decided to look into doing a mini game series in advance of the Jam and decided it was a good opportunity for me to look into the Kotlin programming language.  Ironically a day later, RoboVM and IntelliJ announce a Kotlin code competition… stars aligning I suppose.

 

So I decided to start with Kotlin-afying a LibGDX project and see how the process went.  This tutorial is the result of that experience, although to be honest calling it a tutorial is a bit of a joke as the process was amazingly simple.

 

Before we begin there are a couple of things you are going to need:

 

Open the project in IntelliJ just like normal with a Java application.

In your project, in core create a new Kotlin file beside your main class like so:

image

 

That’s one of the cool things about Kotlin, it can exist along side existing java sources.  Once you create the Kotlin file, this popup will be shown:

image

 

Click the link and let it configure as a Kotlin module. Defaults are good, click OK.

image

 

Now this part is impressive and I discovered it by accident.  Open your existing .java file and copy the contents, then paste them into your newly created kt file.  When prompted, let it convert the Java to Kotlin code:

image

 

Now the default project will be converted to Kotlin, but there will be a pair of errors:

image

 

Kotlin does not appear to like unallocated variables.  There are a few options here.  You can move the initialization of batch and img to the KotlinDemo constructor, you can default initialize them to null (this will however cause LibGDX to explode, so not recommended ;) ) or you can add the lateinit modifer, which is the route I went.  Here is the resulting code:

package com.gamefromscratch

import com.badlogic.gdx.ApplicationAdapter
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.GL20
import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.SpriteBatch

class KotlinDemo : ApplicationAdapter() {
    internal lateinit var batch: SpriteBatch
    internal lateinit var img: Texture

    override fun create() {
        batch = SpriteBatch()
        img = Texture("badlogic.jpg")
    }

    override fun render() {
        Gdx.gl.glClearColor(1f, 0f, 0f, 1f)
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
        batch.begin()
        batch.draw(img, 0f, 0f)
        batch.end()
    }
}

Congratulations, you’ve just created your first Kotlin application!  The mix and match nature enables you to slowly port your code over to Kotlin making the transition exceedingly easy.

Now there is one last very important step, we need to delete the original .java class. 

image

 

When you delete it, you want to make sure you don’t do a smart delete, as we want the existing references to this class to remain (as our Kotlin class is replacing it):

image

 

I’m going to continue to play around with Kotlin, so expect more coverage over the next few days/weeks.  Let me know what you think of Kotlin… any interest?

Programming


25. November 2015

 

Phaser, the popular open source HTML5 game engine, are having a 50% off Black Friday sale (*cough* It’s Wednesday btw… *cough*) with all of their items half price.  I'm a huge fan of Phaser, in fact did a complete tutorial series on using it, so love to see them get the support they deserve. 

 

Items on sale include:

  • Phaser Mega Bundle
  • Particle Storm particle system plugin
  • Virtual Joystick Plugin
  • Box2D Plugin (Premium/Standard)
  • Waveforms (pathing)
  • Interphase book

Click here to head on over to the sales page.  Also stay tuned for the real Black Friday, where I will attempt to gather all the game dev related deals together in one place.

GameDev News


25. November 2015

 

This one has to be about the most ironic timing of a contest ever, as just last night I started working with Kotlin and IntelliJ (expect a post later today)… anyways, on to the competition.  The nutshell version, you create a Kotlin app using IntelliJ or Android Studio, submit it on Github and you could win a Mac Mini or other prize from RoboVM and JetBrains.

 

Just a bit of quick back story here.  RoboVM are the makers of technology the allows you t run JavaVM applications on iOS devices.  JetBrains make the popular IntelliJ IDE (along with WebStorm, CLion, etc) and somewhat recently released a new JVM based programming language called Kotlin.  Kotlin I will look at in more detail shortly.

 

The complete announcement is available here, but the rules and prize bits are included below:

How to Enter

  1. Create an app using Kotlin and RoboVM for iOS and/or Android
  2. Publish your app on GitHub
  3. Tweet your entry using this link:
    “I just submitted my app <GitHub URL> for the @robovm @jetbrains Kotlin Contest:https://robovm.com/kotlin-contest

Don’t have a Mac for iOS development? No problem – we’re accepting Android-only apps as well! IntelliJ IDEA Ultimate and Community edition both have great support for building Android apps with Kotlin on Windows and Linux!

How to win

Want to give your entry the extra edge? Here are some tips:

  • Include a screenshot of your app in your tweet
  • Blog about how you built your app in Kotlin and include a link in your tweet
  • Use Kotlin everywhere – bonus points for shipping a cross-platform app or building your backend in Kotlin, too!

Prizes

All apps must be submitted by end of day PST December 14th 2015! The teams at RoboVM and JetBrains will pick the winners from all submissions. A valid entry consists of your tweet pointing to your app’s GitHub repository. Only one prize will be awarded per participant, and per GitHub repository. Bonus points for cross-platform apps, development logs in form of tweets or blog posts which we’ll happily promote, as well as code quality! Winners will be announced on the RoboVM and JetBrains blogs as well as on Twitter, and will be contacted via GitHub.

 

Also, stay tuned to GameFromScratch.com for some Kotlin specific content in the very near future.

GameDev News


24. November 2015

 

I don’t often announce Kickstarter campaigns unless they are specifically about the creation of game development tools but for this one I am making an exception as this project looks high quality, is game developer focused and Krita itself deserves a great deal more exposure.  The campaign is called Create Professional 2D Game Art: Krita Video Training and it walks the user through the process of creating 2D art using Krita, a completely free cross platform 2D painting tool.  Depending on the level of success with the campaign it will result in tutorials on side view painted style art, isometric view cel shaded art and top down pixel style art if all goals are met.  The ultimate outcome will create a course hosted on Udemy.

 

At the end of the day, there really aren’t a ton of 2D art tutorials available, I can personally only think of a handful, most of which I linked in my getting started in game art guide.  There are even less focusing around using Krita itself.  Finally, I like the guys art style, so I would like to see this go somewhere.

 

Anyways, here is the Kickstarter pitch video.  If you are looking for 2D art instruction, check it out.

Art GameDev News


24. November 2015

 

Over on the Construct2 blog there is this announcement of a new free e-book Level Zero about programming games from scratch using Construct2.

 

This recently published book "Level 0" is a resource designed for the absolute beginner. You'll learn how to set up characters and backgrounds, apply in-game mechanics and implement if – then functions and end up with five fully functional mini-games. The book will also show you how to publish your games to app stores and make them available to millions of potential customers around the world. The goal of Level 0 is to give aspiring game developers the basic building blocks to apply their creativity and bring their vision to life. For example, one of the mini-games you’ll learn to build is a simple sound board app where you click on an image and the corresponding sound will play. Through this exercise, not only do you pick up the skills to build a virtual keyboard or maybe an educational app that teaches kids the sounds farm animals make but also learn how to use sound, music and touch functions that can be used for subsequent arcade and action games. Each of the 5 mini-games covered in the book has already been used by thousands of Construct 2 users to build their first game on Construct 2.

This book uses Construct 2 in all the featured tutorials. According to the authors,"Construct 2 is as easy as it gets for making a game". Spot on!

C'mon, gimme the download link!

It's available on Amazon.com for a little over $3 USD, however we've managed to get permission to distribute it for free on Scirra for now!

Download for Free

(Right click and "Save Link As")

And good news, Ankur tells us that there's a second book in development detailing how to build 3 classic arcade games. Keep your eye out!

 

So head on over to the Scirra blog to download a free copy, or support the authors by purchasing it on Amazon.

GameDev News


GFS On YouTube

See More Tutorials on DevGa.me!

Month List