Welcome Guest ( Log In | Register )

[ Big| Medium| Small] -

Post new topic Reply to topic  [ 4 posts ] 
  Mon Jul 25, 2011 4:36 pm
User avatar

Omnipresent Merchant
Workshop: PHPBB Gaming
Creating an RPG using a forum as a base


The description is a bit vague - this is not about creating "forum RPGs" (pen and paper on a screen), rather, this is about creating visual online games, "MMORPGs" due to their potential scale, using a PHPBB forum as a strong base.

The case study will be my own game, Afar, which has become one of the more active on this board and is created and maintained using a PHPBB forum as a base.

Why use a forum? Why not just plain and straight PHP?

I do not trust myself to know how to make a strong and sturdy authentication system, nor a good-to-use administration panel.

While most of the coding and such is custom, the absolute base of a forum provides:

  • A professional, safe, sturdy authentication (login/logout) system tried and tested over years
  • A forum! Built into the game. Which you don't have to register seperate for. Which is complete and working from the get-go.

Before we start: what you need

First of all, you need a PHP and MySQL web host. You will probably have to pay for this. I am using a VPS (Virtual Private Server) at $19.99 a month, with a domain name which costs £15 a year.

PHPMyAdmin is invaluable and should really be installed. It will make things a lot easier and I will be using it for this workshop.

The stats you need depends entirely on your game, but take note that running a game using PHPBB is going to take rather more processing and bandwidth than just a simple forum.

Once you have set up PHPBB (please see PHPBB.com) you are going to need the mod for "pages". I believe that is this one but obviously versions might have changed and such since I set up Afar.

If you've done it right, check your host for, in your phpbb folder (whatever you decided to call it):

- page.php
- includes/functions.php

These are your game, in essence.

Behind the scenes... creating your files

At the top of functions.php you need to include a new file:

include 'functions_game.php';

Now create the following files:


How the game will work

Pages will be created in the admin control panel, linking to other pages, creating maps which can be followed to create an explorable world.

action.php will hold "things we can do" - actions.

page.php handles how the pages are displayed on the screen.

functions_game.php will hold important functions that are not part of phpbb by default. They will enable editing of profile fields on the go, game variables and switches, and the concept of user stats and variables.

Important notes before we begin

The system behind Afar is tailored to it, and is different to what I am going to describe now. Afar was not built to be "the system behind many games", it is the system behind Afar.

What I am going to describe how to do is basically a shell system which can then be used for any game, in a similar, but altogether different, style.

Useful things to know before we begin

  • HTML
  • Basic PHP or knowledge of how programming languages work in general
  • Basic SQL and knowing your way around phpmyadmin

Goals and aims

I would like to therefore list the goals and aims of this workshop, what will be achieved:

- A basic game created in PHPBB
- A series of graphical maps representing an explorable world
- The basics of creating a battle system and other useful "features"

Some ground rules

  • The following coding and tutorial is offered as is with no warranty as to even it's usability or fit-for-purposeness.
  • I and HBGames hold no responsibility for any losses or damage incurred by use, or misuse, of this tutorial in any way shape or form.
  • No making a game better than Afar >:o

Top Top

  Mon Jul 25, 2011 5:03 pm
User avatar

Omnipresent Merchant

What we're going to do today

Every programmer has to start by saying hello to the world, right?

Well, let's go a step further and create a world to say hello too.

In this tutorial we will create the concept of a "map", creating several individual game maps and linking them together to create a path.

The Basics

A map is a page.

I have made the definition between maps and pages because a page doesn't have to be a map; a map is just one type of page. In RPG Maker you might call this a "scene", where a map is a type of scene but not every scene is a map.

Prior to this tutorial you need:

- PHPBB set up
- Static pages mod, or something similar, installed

Whichever page mod you choose should ideally have an Admin Control Panel module.

Creating our maps

The mod I have chosen for pages has the following attributes for each page:

  • Page Title
  • Description
  • URL Identifier
  • Page Content
  • Page Order
  • Display Page?
  • Display page to guests?

I will explain how we will be using these attributes in our map now:

Page Title

The title that appears in the title bar of the Internet browser. Useful for letting the player know where they are.


This is for us, the admin. It will only be shown to us, and it's useful for letting us know what this page is all about. "This is the map with three trees" is a useful description, for example.

URL identifier

This needs to be memorable.

In Afar, I start every map with the suffix "area-".

A woodlands might be "area-woods-3" for example.

Feel free to use any identifier, if you'll remember it. "map-004" might even be useful to you if you want to hide the type of map you're in, etc.

For this tutorial from now on I will be using this format:


For all maps.

Page Content

This is where we map out the area. For now, as we haven't coded any custom bbcode in, we're stuck with basic things such as [img], [url], and text descriptions which can use [b], [u], [i], etc.

Page Order

Moot. Does not concern us as we won't be using a page listing (unless you want to yourself).

Display Page?

Defines whether this map is viewable to the general public, i.e. non-staff players.

Display page to guests?

Probably best to turn this off for all maps, unless you want sneaky snoopers snooping, search engines revealing spoilers, etc.

Our First Map

We are going to now create the town of HBGaverney.

Page title: HBGaverney Town Square
Page description: This is the main town area where all players start
URL identifier: map-1
Page content: -
Order: 0 (not relevant)
Display page: yes
Display to guests: no

Page Content

This is where you construct your town.

In future I will describe how to populate it with NPCs, buildings, and interactive objects and such. For now we'll have to go text based (sortof).

[center][b]HBGaverney Town Square[/b[/center]

Welcome to HBGaverney, a town which lies in the middle of the Known World. It is busy and such with shops and other things. Oh my.

Testing your map

Go to:


...and see if it works!

Jazzing up your town

For now you're stuck with basic bbcodes.

By the way, useful for later, go to the admin control panel and posting, then click add bbcode.

Enter the following:




Hopefully that is straightforward - if not we're gonna have problems!

To add some sparkle we can add an image:


Try changing the text, adding italics, bold, etc; just basic edits for now.

Our maps won't stay this basic forever once we start actually getting into interactivity, motion, graphics, etc.

Top Top

  Mon Jul 25, 2011 9:52 pm
User avatar

Omnipresent Merchant

A world is no good if you can't travel around it, right?

We have HBGaverney town, or, map-1.

Create our Path of Maps

map-2: The beginning of a woodland path to the North.
map-3: Continuation of this path Northwards.
map-4: A small clearing; the end of the path.

Create them as before with the right parameters.

How to travel

The equivalent of a map transfer or teleport event is simply a hyperlink, to put it basically.

This is as simple as:


But we don't want to do that! Let's make it a bit more interesting.

Setting up some bbcodes

Custom bbcodes are basically how we map. In Afar I have gone further than this, creating my own bbcode-like system I narcistically called aCode, in PHP. But for this game we'll stick to PHPBB's method.

What we are going to create are some widgets for moving along the map.

Create an image for an "up" arrow. For this example I will use:

Image // make a better image for this tutorial

This is stored in images/interface/north.png

Let's go to the BBCODE creation page!

Step One: the code


The image will show if [up]map-1[/up] is used and not much else. Only numbers, letters, and a small amount of special characters are allowed as an IDENTIFIER.


<a href="page.php?p={IDENTIFIER}"><img src="images/interface/north.png" /></a>

Now any time we want to add a maplink heading up, or north, we use:


Your task

Repeat this for down, left, and right.

Putting it all together

Let's go to map-1 - HBGaverney Town.

[center][b]HBGaverney Town Square[/b][/center]

Welcome to HBGaverney, a town which lies in the middle of the Known World. It is busy and such with shops and other things. Oh my.


Test it! Try it!

Map 2: the start of the path to the North

All we need to do here is the same, but we add two maplinks.


In Afar I took this a bit further creating a token to go in the middle. See if you can work out how this is done.

Now do the same for the rest of the maps creating a sequence as such:


This is our first path.

Top Top

  Tue Jul 26, 2011 2:17 pm
User avatar

Omnipresent Merchant


This is where it becomes complicated.

Anything else you add to your game now might as well be a "script", something you shove in and it adds a new feature.

It's going to get difficult explaining that, mainly because features are going to be different in everyone's games. The best system done this way will have the systems made for that game.


In Afar I created the game with the following key systems:

- Battle system
- Items, inventory, equipment
- Player Stats
- Player variables and switches
- Quests and Journal
- World Map

Most of these rely on one system:

Player Variables and Switches

Game variables and switches generally aren't going to be displayed, just accessed and used in conditions. Therefore we can take it into it's own table, seperate from actual player stats and such.

In PHPMyAdmin

Create the following table in the database:


It should have the following format:

phpbb_game_variables( 'id', 'name', 'user_id', 'value' );

I think it's important to note at this point that a switch is just a boolean variable. Space can be saved by doing a seperate table for such variables, as I did in Afar, however, for now I am going to treat any switch as a type of variable that will just hold a 1 or 0.

'value' -> text
'id' -> integer, primary key, auto increment
'user_id' -> integer
'name' -> text

I think it's important at this stage to point out we have character pages built into our game already.


Your id, as the admin, will almost certainly be "2". 1 is counted as "guest", or anonymous. 3 to about 50 are bot accounts built into the forum software.

2 is you, the admin, probably.

So, if you go to:


You'll see your character page... well, forum profile. It's a little over the top at the moment with lots of unecessary information. When we come to theming your game we'll cover how to change the look and layout of this.

So, now that we know what u=, we know what 'user_id' is probably going to be equal to for our account. This is useful for testing the variables.

The variables table will eventually look like this:

id	name	user_id	value
1 'nick' 2 'Amy Pond'
2 'class' 2 'Adventurer'
3 'gold' 2 '5014'
4 'exp' 2 '27192'
5 'nick' 3 'Botbot'


Open functions_game.php in the text editor of your choice.

I use codeblocks.

The following functions are typical get-set functions for player variables:

function get_gamevar($name, $user_id=0)
global $user, $db; // use the user and database arrays

if ($user_id=0) { $user_id = $user->data['user_id']; }

// above: by default, the player target is defined as "the current player",
// otherwise we can specify one when calling the function.

$sql = "SELECT * FROM `phpbb_game_variables` WHERE name='".$name."' AND user_id='".$user_id."' LIMIT 1";

// perform the sql query
$result = $db->sql_query($sql);

$row = $db->sql_fetchrow($result);

return $row;

To be completed.

Top Top
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

Who is online

Users browsing this forum: No users and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

We are an independent, not-for-profit game making community.
Board Index
About Us
Downloadable Games
Free Browser Games
Games in Development
RPG Maker Support
Game Maker Support
Construct 2 Support
HBGames the eZine
Advanced RPG Maker
Site Announcements
Powered by phpBB © phpBB Group