Complete Roguelike Tutorial, using python3+pysdl2

From RogueBasin
Revision as of 04:21, 4 January 2017 by Lukems-br (talk | contribs)

Jump to: navigation, search

Short introduction


Welcome to this tutorial! As you probably guessed, the goal is to have a one-stop-shop for all the info you need on how to build a good Roguelike from scratch. We hope you find it useful! But first, some quick Q&A.

Why Python?

Most people familiar with this language will tell you it's fun! Python aims to be simple but powerful, and very accessible to beginners. This tutorial would probably be much harder without it. We insist that you install/use Python 3.x and go through at least the first parts of the Python Tutorial. This tutorial will be much easier if you've experimented with the language first. Remember that the Python Library Reference is your friend -- the standard library has everything you might need and when programming you should be ready to search it for help on any unknown function you might encounter.

This tutorial is for Python 3 only, and it is strongly recommended you use the Python 3.5 x86 release.

If you choose to use earlier versions of Python 3 (2.x), you may encounter problems you need to overcome.
If you choose to use Python 2, be aware this tutorial is not compatible with it and you are on your own.

Why SDL2?

Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware via OpenGL and Direct3D. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games. SDL officially supports Windows, Mac OS X, Linux, iOS, and Android. Support for other platforms may be found in the source code. SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python. SDL 2.0 is distributed under the zlib license. This license allows you to use SDL freely in any software [1].

SDL is extensively used in the industry in both large and small projects: MobyGames listed 141 games using SDL in 2017 [2]; the SDL website itself listed around 700 games in 2012 [3]; important commercial examples are Angry Birds or Unreal Tournament; Open Source examples are OpenTTD, The Battle for Wesnoth or Freeciv; the PC game Homeworld was ported to the Pandora handheld and Jagged Alliance 2 to Android via SDL; applications like the emulators DOSBox, VisualBoyAdvance and ZSNES all use SDL; the Source Engine (on its Linux and Mac versions) and the CryEngine uses SDL.

A common misconception is that SDL is a game engine, but this is not true. However, the library is well-suited for building an engine on top of it. And with python and PySDL2 it shouldn't be hard to build it.

WHat is PySDL2?

PySDL2 is a wrapper around the SDL2 library. It has no licensing restrictions, nor does it rely on C code, but uses ctypes instead (considering that ctypes is part of Python's standard library, all you need is a python installation and SDL2 runtime binaries.

In this tutorial we're using SDL2 version 2.0.5.

Other versions could work, but this tutorial do not guarantee compatibility with other versions - you're on your own for it.

Is this a copy?

More like a port. A mere port of the great Complete Roguelike Tutorial, using python+libtcod. It helped a lot of people, so it deserves as many ports as it gets - including this (py)SDL2 one.

Start the tutorial

Follow the first link to get started!

  • Part 1: Graphics
    Create a simple scene that draws our character to screen (first graphically, using an image; then using a bitmap font, so that we can see our precious "@"); improve that scene so that the character can be moved around with the arrow keys.