Devana how a browser game is made

25Sep/105

the grid

The grid is the game's map. I didn't name it "map" because the game will eventually allow users to modify it to such a degree that they will be able to create other types of games in which the term "map" may or not be suitable. So I've named it "grid".

I've also created the install page of the game, where the admin account is created and the grid data is inserted into the database.

The grid data is taken from a png image where each pixel is a grid sector. The color coding is as follows:
blue [RGB: 0, 0, 255] is the blocked type of sector; [water]
green [RGB: 0, 255, 0] is the active sector; [available for building towns, or as I call them, "nodes"]

The grid table has the following columns:
x is the horizontal grid coordinate; on the image it goes from left to right passing through the 0 and imageWidth-1 values;
y is the vertical grid coordinate; on the image it goes from top to bottom passing through the 0 and imageHeight-1 values;

type is the grid sector type identifier;
-> 0 for the blocked type of sector [blue pixels]
-> 1 for the active sector [green pixels]
-> 2 will be for constructed nodes [towns]

id is the image tile identifier if the type is not 2; if the type is 2, then the id is the node id from the nodes table.

And here are the files so far: devanaFiles

Filed under: devana 5 Comments
21Sep/100

tap4

Lots of people said that Devana 1.x.x has messy code and an ugly UI. They were right.
So, a while ago, before starting work on Devana 2.0, I created 2 small projects.

The first was tap4.net which today became open source. It helped me learn more about HTML, CSS and it also started the template system that I'm currently using in Devana 2.0.
The code is a bit messy, but fully functional.

Enjoy! :)

Filed under: misc No Comments
19Sep/1017

getting started

As one would do with all web-based projects, the start is very important. This is when you define your core rules that will later on influence the whole project. So spending some time thinking on how these rules should be is beneficial.

Now, to clear things, I don't consider myself a programming guru, so some things you might read here might seem, or frankly be, outrageous; I don't use frameworks, so no jQuery or any of that stuff.

I use a basic template system in which each displayed page is made out of 2 separate php pages: 1 page handles data processing while the other handles the way that data is displayed.
There also is a default.css file for each template that governs over the form of the various html objects. Each object type has it's own CSS class.
A config.php file handles the MySQL database connection. There are a header.php, footer.php which generate the menus and other header/footer stuff.

There also is multilingual support. This also is basic. There is a php file for each supported language; that file contains an array of labels. The labels change according to the language, while their identifiers stay the same across all language files.
To show various messages I use a special div, which is displayed only when a php variable ($msg) is not null.

The ids of database entries are also automatically managed, so that no gaps are created when deleting entries. Instead, the ids of deleted entries are stored in a free_ids table so that they will be used the next time entries are added to that table.
Also, I manage concurrent write attempts made to the database via table lock.

The code is written in an object oriented manner, using an array to store the data from the database. All the classes are stored in core.php. core.js will hold the various JavaScript functions used across the pages.

Here are the files so far. Account registration & login are working. devanaFiles

Filed under: devana 17 Comments
11Sep/104

hello world

Welcome to the development blog of Devana 2.0, a "when it's done" to be released browser based open source game.
To check out the current version, go to the sf.net Devana page.

Filed under: misc 4 Comments