Star Ruby Ruby extension library for creating 2D games

Render

Rendering process in Star Ruby is executed through Textures. The final rendered window is achieved by layering textures on top of the main texture.

Render a image

At first we're going to write a code to render the image below(ruby.png) on the screen.

ruby.png

require "starruby"
include StarRuby

texture = Texture.load("ruby.png") # (1)

Game.run(320, 240) do
  Game.screen.clear # (2)
  Game.screen.render_texture(texture, 8, 8) # (3)
end
(1)

Generate Texture object from PNG file. Please refer Texture Class in API Reference

(2)

Game.screen is the texture which represents the screen itself. It is recommended you to call Texture#clear and clear the screen in the beginning of each frame, because the screen keeps the state of the previous frame.

(3)

Renders texture to the screen (Game.screen). You call Texture#render_texture when you want to render from textures to textures. Second and third arguments represents X-coordinate and Y-coordinate of rendering position.

This is the screen after you execute the code above.

Game Screen

Move images

(coming soon)

© Copyright 2012 Hajime Hoshi