📎 Webclip
Let’s Build a Simple Video Game with JRuby: A Tutorial
The article argues that JRuby lets Ruby use Java game libraries in a practical way, making it possible to build a simple game despite Ruby’s weaker game-development ecosystem. It introduces Slick and LWJGL, then walks through setup, a basic window, graphics, input handling, and a small bat-and-ball game.
Reading notes #
- JRuby is presented as a way to use Java libraries on the JVM from Ruby.
- Slick is described as a thin layer over LWJGL.
- LWJGL provides graphics, audio, controller input, and OpenCL.
- The setup uses RVM, Slick, and native libraries placed in the game directory.
- A basic JRuby game subclasses Slick’s
BasicGameand definesrender,init, andupdate. renderdraws the window contents,initloads resources, andupdatehandles input and game changes.- The sample game loads a background image, a ball image, and a paddle image.
- The paddle moves with the left and right arrow keys, using
deltato scale movement. - The ball moves with sine and cosine based on an angle value.
- Wall collisions change the ball angle.
- If the ball falls below the screen, the game resets the paddle, ball position, and angle.
- Paddle collision also changes the ball angle.
- The article says separate classes for paddle and ball would make the code cleaner.
- It mentions Slick’s
StateBasedGamefor games with menus, levels, and other states. - It also mentions Warbler for packaging a Ruby app into a
.jarfile. - Ludum Dare is cited as the motivation for exploring JRuby game development.