Ragnarok Engine Ragnarok is small and concise 2D game engine built on top of Pygame to make game creation easier.
While Pygame is a library, Ragnarok attempts to assume the role of an engine, featuring many capabilities that would take a lot of work to create from the ground up in Pygame.
The engine is built in such a way that it attempts to be used under any scenario and game environment. It is easy to set up, maintain, and extend for your particular needs.
It was first started in 2010 by Clinton Myers, and since then it seemed lost. Some places on the internet pointed to it but the source to it had vanished. Fortunatelly the Web Archive had scrapped his blog in 2012 and saved the tutorials he had put up, and in a strike of luck, he had hosted his codes in mediafire, which seens to never delete the uploaded files!
There are other options to make games, Unreal is a great option, there is also Unity, but they are just too much, they have such a vast and complex API that I struggle to do the most simple things. Therefore I went to the simpler, and friendlier Python. A simple implementation, with a simple way to setup the GUI, and simple way to instantiate stuff in the world is exactly what I need to do something fast. And I hope it will help you too.
By the way, the original game made by Clinton Myers was downloaded from Mediafire and uploaded here, it is in the tutorial folder so you can see how the engine can be applied on a real working game. The game itself was made to run on Python2, so it will require a specific installation, but you can follow the instructions on the game.
This code is being expanded and ported to python 3.6
Many basic classes and methods are already inplace for Ragnarok Engine3
- 2D and 3D Vector Math Library
- Sprites with easy rotation, scaling, texture loading, etc.
- SpriteSheet and Animation classes
- Text objects that can be rotated, scaled, and translated
- A customizable 2D Camera
- A managed World system that updates, draws, and automatically offsets objects by the camera's translation.
- Collision System
- Input Handling Systems
- Particle Systems
- Pool class for efficiently reusing objects
- TileMaps
You may install it from source using:
pip install setup.py
or install from pypi
pip install RagnarokEngine3
Quite simple, you should look the tutorials for more information, but to verify if it is working properly you may simply create a minimum project.
from RagnarokEngine3.RE3 import Ragnarok, Vector2
engine = Ragnarok(Vector2(640, 480), "RAGNAROK WHITE SCREEN")
world = engine.get_world()
world.clear_color = (255, 255, 255)
engine.run()
The API can be better understood looking directly at the code, the text here is just for a quick glance and does not contains the important methods that are present inside classes.
Provides basic 2D Vector operations
Provides basic 3D Vector operations
Provides basic 4D Vector operations
Returns the dot product of two Vectors3 or two Vectors4
Distance betwen two vectors of same size
Returns the angle between two Vectors3 or two Vectors4
Project vector1 onto vector2 as long as both are vectors with 3 or 4 dimensions
Add each of the components of vec1 and vec2 together and return a new vector.
Take vec1 and reflect it about vec2.
Method that returns the sign of a number, -1 for negative, 0 if the value is zero, 1 if the value is positive.
Ray object, used for raycasts
A matrix of Vector4, it takes *args as argument, which defines that it can accept a variable number of parameters. This allows us to be a bit more flexible in how we can create a Matrix, as the user can define all four rows, or only one or two rows upon init.
Prepares the Ragnarok library for use. preferred_back_size attempts to set the resolution of the window to the specified size. (-1, -1) attempts native resolution. window_name is the text that displays on the top-left of the pygame window.
Create a pool of reusable objects. Reduces memory allocations due to new objects being constantly generated (such as in bullets being fired, etc.) object_count is the number of objects that we will hold into our pool, while the function used to init our objects.
The base class of our game engine. Represents an object that can be updated.
An object that represents something that can be drawn.
An object that represents something that can be drawn with an image.
An object that represents something that can be drawn/written.
Particle(self, image_path="", color_start=(255, 255, 255), color_end=(255, 255, 255), rotation_range=(0, 0), rotation_speed=1.0, start_scale=Vector2(1, 1), end_scale=Vector2(1, 1), lifetime=1000.0)
image_path is the path to the texture we wish to load.
color_start is the starting color of the particle.
color_end is the ending color of the particle.
rotation_range is a tuple that defines the potential starting rotational values.
The rotation will be between the first and second arguments.
rotation_speed is how fast the particle rotates per second.
start_scale is the starting scale of the particle.
end_scale is the ending scale of the particle.
lifetime is the length that the particle exists before dying.
ParticleEmitter(self, coords=Vector2(0, 0), particle_type=None, lifetime=1000.0, emit_rate=1000.0, direction_range=(0, 0), particle_speed=1, max_particles=1000)
coords is the position of the emitter.
particle_type is the type of particle to generate.
lifetime is the length that the particle system lasts (not the particles.) -1 means to last for eternity.
emit_rate is the amount of time that must elapse before a new particle is generated.
direction_range is the direction in which the particles are emitted.
Utilitarian class to hold sprite sheets
sprite_sheet is a SpriteSheet that our animation will pull its cells from.
end_frame is the ending frame of the animation. 0 or less indicates to use the number of frames in the sprite_sheet
Note that the animation cannot run any faster than the game's FPS. If the game runs at 60fps, the best the animation can do is 60fps as well.
Utilitarian class that represents an animation that is made up of seperate images rather than a single spritesheet.
Timer object, with alarm and so on
A class with basic physics implemented.
Provides an abstract base class for collidable objects.
Represents an axis aligned bounding circle.
Represents an axis aligned bounding box.
Handles the collisions between all Collidable Objects.
NOTE: This button doesn't display any graphics by itself. Inherit from it to define its behavior.
Menu with keyboard focus and mouse focus
A structure that contains the states of our mouse buttons.
Wraps around Pygame's Mouse module to provide some more information to the user, such as what buttons were pressed on the previous frame.
Contains a reference to all pressed status of all the keys
Wrapper for keyboard with KeyState
Represents an object to be placed in the tile map.
Allows the player to warp to a different level or to a different location on the current level.
binding_type is an array of strings telling us what type of tile this is. For example, we could pass in a string "DamageTile". When a character collides with a set of tiles, we could check the list of tiles they touched to see if any are a "DamageTile". If so we can cause damage to the character.
We could also specify ["DamageTile", "Walkthrough"], which we could interpert as allowing the character to pass through the tile, but causing damage to them while they do so.
TileMap(self, spritesheet, tile_bindings, tile_map, collision_map, object_map, object_ary, level_name)
spritesheet is the spritesheet by which we will pull our sprites from.
tile_bindings is used to give our tiles game-implementation-specific meaning.
tile_map is our file that defines what tiles should display and where they should display at.
collision_map defines what tiles are solid or not.
object_map allows us to place objects into the map (such as enemies) by pulling thier instance data from the object_ary.
object_ary is an array of initalization functions. These functions are used to create new objects and add them to the tile map.
The object_ary functions should accept a parameter of type TileMap. This is used to pass to the TileMapObjects.
Manages our various tile maps. Allows us to load and unload maps.
Provides a class that updates the camera.
Provides a class that updates the camera using spring technique for smooth movement.
A Camera
World Entity
You can follow the tutorials here!
See the contribute file!
PRs accepted.
Small note: If editing the Readme, please conform to the standard-readme specification.