Game
Smacklings
5 years ago

Java, but not Java. What makes Smacklings development awesome?


As mentioned in game's description, the development tool for Smackings is Java. Kind of. It was the closest one to match what is happening here.

It indeed is Java's JVM running Java bytecode (or Dalvik on Android) but the code we write is not Java. The language used to make Smacklings is called Kotlin. Kotlin is a programming language created by JetBrains. You might know the company better from tools like IntelliJ IDEA or a variant of it, Android Studio. Essentially Kotlin is an independent laguage that compiles into Java bytecode an therefore is runnable wherever Java programs are.

"Why?" you might ask. Well, for two seasons. First, Google announced last year that Kotlin is the preferred language for Android development. It is pretty good reason itself but wouldn't write this post just to tell that.

Second reason is that I found Kotlin to be awesome. There are ton on cool features but I won't go through them all here. You can always go and check the official documentation

No forced semicolons! It is a small and simple thing but it makes us happy. You can still use semicolons if you really want and in cases where you really need to. Think about it, how often do you write multiple expressions on same line and need to split them up with semicolon?

Another nifty feature is string interpolation.

Instead of writing "time remaining: " + minutes + ":" + seconds you can write "time remaining: ${minutes}:${seconds}" neat, huh?

Here is another example what Kotlin can do. Code here is from character controller class:

		
			private fun act(dir:Int) {  
  if (!alive) {    
    return  
  }  

  when (state) {    
    CharacterState.IDLING -> jump(dir)    
    CharacterState.JUMPING -> attack(dir)
  }
}
		
	

CharacterState is an enum and state-variable is field of the class. This is kind of Kotlin version of switch-case flow but way cleaner and cooler. That when-expression could easily return a value too but that was not need for this functionality.

We might post more neat stuff from the game's sources so stay tuned for the next one!



1 comment

Loading...

Next up

Smacklings announces here on Game Jolt! Go check our development progress https://gamejolt.com/games/smacklings/477866

Here is a fresh screenshot from two-player mode.

Here is one of the chracters, Dan, being photographed. The small paper roll behind his head was used as a support. After that it was edited in Photoshop and exported to the game as a png file.

Short intro of us 💕✌️

We're an eletro duo based in Seoul 🇰🇷 Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era 💽 CD listenin 📟 beeper beepin 💾 floppy disks floppin days 😎

Stream now! 🎧

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqU…

"Thanks guys for endless hours of fun." 👍

(My first fan art. Read the article, please.)

#sonic #mario #photoshop

Here's a peaceful little forest scene for this #screenshotsaturday, from the beginning of the game.

Successful landing

#screenshotsaturday

Sometimes the suction cup get sticky. Small animation I made in Blender after doing my tutorial on picking up/dropping objects in animations. Crate model by jQueary (https://sketchfab.com/3d-models/game-ready-sci-fi-crate-d98deca6…).

Back in my art school days I used to ride the 710 COPSA line from Parque Del Plata to Montevideo almost everyday. This is the Marcopolo Viaggio G4 Mercedes Benz model from the late 80s, one of the older bus models that was running on the line.

Demonstration of the spells and their effects :)!