Tuesday, September 1, 2015

Second release




New features:
  • Added slavers quest from submission at 4chan. (30% chance on encounters after start of crystals quest).
  • Rewrited all code base + BGE Core Library + quests.
    • Fixed button events bug.
    • Fixed teleport bug.
    • Added a quest system.
    • Added a interface system.
    • Added debug tools.
    • Fixed spegetti code (a little).

Download:
https://mega.nz/#!Wl0izQiY!h3JtObf7G8YPSB-NX4-hJ8gjTWoSHo05vMJZqh74VYw

The code behind

Journey Through Izildia is made with Blender Game Engine (BGE). BGE is integrated as part of blender, a software for general 3D purpose. Tough you don't require Blender to run the game, you still require a part of it, and that's what you find in the "engine" folder of the game. Blender generates .Blend files. Usually when a developer releases a game made with Blender he merges the .Blend file of the game with a blender player in hope that this will prevent other people to edit the game. However there are tools like"build game addon" that let's you extract that blend and edit it anyway. Instead in this game I used a launcher, a program that all it does is run the engine passing as arguments the path of the .Blend file and the configurations made in a config.txt file. In Journey Through Izildia the extension of the izildia.blend file has been renames to izildia.map, just to hide it from curious glances.


BGE is rather a bad game engine as is, but a lot of things that it lacks (like GUI or network support) can be added using python scripts. Learning to code properly in BGE is suicide, you won't find almost any example of good programming in BGE games or tutorials. Actually, devs that use BGE usually aren't programmers and the only this they touch are logic bricks. In Journey Through Izildia, and actually all games I made using BGE, are coded using with as less logic briks as possible. The reason is simple. To make 200 objects do something with logic bricks you need to add 200 logic bricks, one on each object. If now you want to modify something on that function, you'll need to modify 200 logic bricks. That, with Python, it's done in 2 lines of code.



In the first release all code was inside the .Blend file. And it was a mess. There was almost no OOP and all quests where put in a huge file of spaghetti code called journey.py. The main.py contained all the game logic and interface events (which were handled poorly) only helped by another file called utils.py which contained everything. In the new version only the main and some other files very specific to that .Blend are inside the .Blend file, all the other code is outside on the data folder. Inside that folder there are 3 sub folders containing python scripts, each one with a __init__.py for proper initialization.

Core: A package to extend BGE functionality. Includes functionality to play sound, change textures and handle GUI elements such as buttons, cursors or the game window. It also includes standard classes like quests, dices, players, inventories, etc...

Script: This is were the game resides. The main loop of the game calls the control.py  functions in order to do pretty much everything. This file also stores the player and the dice, which are standard objects of the core package. The game_gui.py and map.py files do what its name implies.

Quest: This is where the quests are. Without this the game can still work, but you won't get any quest or special events. The most basic of the quests is the izildia.py, which generates special behavior that are part of the locations in the map. One quest can disable all other quests after itself for that event using "quest.taken = True".