Ragnarok Engine: Tutorial 1 – Initing the Engine

What is an engine without a few tutorials to get user’s jumpstarted?

This tutorial will cover the basics necessary to get the Ragnarok Engine up and running.

The first step is to import our Ragnarok engine for use.
The ‘as R’ clause here acts as a alias for Ragnarok, meaning we can access its
members by typing R instead of Ragnarok.
import Ragnarok as R

This single line of code is all it takes to actually initalize the engine.
We are telling Ragnarok that we want to create a window of size 640 by 480,
and that it should bear the title “RAGNAROK TUTORIAL 1″.
Notice how we are making use of the Vector2 class to pass in the window size.
engine = R.Ragnarok(R.Vector2(640, 480), “RAGNAROK TUTORIAL 1″)

One of Ragnarok’s goals is to reduce micro management in your code. It does this by automatically
updating and drawing your objects for you. You can control the draw and update order by changing an
object’s update_order and draw_order properties. A low number will draw/update first, while a higher number will draw/update overtop the lower numbers. The world is the entity within the engine that does all this work for us. We grab an instance of it here for easier access.
world = engine.get_world()

The world’s clear_color property defines what color the backbuffer should be
erased to after each draw operation.
world.clear_color = (0, 0, 0)

That’s it! All we have to do now is tell Ragnarok to begin spinning its game loop.

At this point you should be presented with a blank screen. Don’t worry though, Ragnarok can do much more than this!

Check back in for Tutorial 2 to see how to add sprites and other entities to the world.

You can download the source for this tutorial here.
Linux user? Download the gzipped tar here.


Leave a Reply