Blender 3D: Noob to Pro/Making exe
This tutorial will show you how to make an executable for your game made in Blender.
Note: The methods listed in the "Windows" and "GNU/Linux or Mac OS X" sections work only for the operating system you are on when you create the file. To make it cross platform, use the "BlenderPlayer" method.
First create a folder that will hold all your game information. Name it something meaningful, like "Yo Frankie!".
The folder must contain four files that you can copy from your blender installation directory.(under windows it should be "C:\Program Files\Blender Foundation\Blender") They are:
- python24.dll (Or other relevant python file; python25.dll, python26.dll etc.)
(sometimes you will need the following also...
They are in the same folder.)
Not quite a Noob Note: If you are using the latest version of Blender you WILL need the following files)
I am running windows xp media edition and blender 2.46, here is a full list of files i needed:
On Blender 2.48a (Windows XP Media Center 2002, SP3), these .manifest files are also required:
If you use random Python module in your game, you will have to add one more file to your game directory. For Blender 2.49 it would be python26.zip, which you can find in Blender main directory (where blender.exe is). Otherwise there may be some errors during executing the game in system without installed Python.
Since Blender 2.56 you will need to enable Save As Runtime; first open blender with the game that you have created and open the file menu. Click on User Preferences then select Add Ons then Game Engine, check the box Game Engine Save As Runtime and return to the file menu. Save As Runtime will appear as an option in the export menu then save to the new folder that you have created and rename the file yourgamename.exe,
and then you can run the game!
If you encounter errors during the "Save As Runtime" process (I'm on Windows 7) you can right click on the Blender icon and select "Run as administrator". So you will have your fresh .exe and you can spread it with a piece of your favourite pepperoni pizza.
Making A Screensaver (Windows Only)
- First, save your runtime (that's the .exe addressed above.) via File->Save Game as Runtime. ("Save Runtime" in older versions)
- Now, go to your .exe game and rename it .scr - for instance, if your game was NotMyGame.exe, rename it to NotMyGame.scr. You can now right click to Install it, and then use it as your regular screensaver by applying it as you would any other screensaver (right click on desktop, properties... You know the drill.)
Screensavers are not games, and so they should not accept input. At most, they should be videos showing what your game does. If you just rename your regular game as a .scr, it will be remarkably boring, because your game needs input and screensavers do not.
Intel screensaver bug
There is a caveat with Intel Integrated Graphics drivers, found in many laptops though. The graphics driver shuts off OpenGL acceleration for screensavers, for some obscure reason. The way to work around this is to rename the .scr extension to a .sCr as the driver's algorithm is dependent on case-sensitive characters. If you experience very low framerates in your screensaver, you should attempt this fix, It is tested and reported to work.
GNU/Linux or Mac OS X
Open blender with the game that you have created and open the file menu. Click on Save Game as Runtime and then save to the new folder that you have created and rename the file yourgamename...
and then you can run the game!
The methods shown above only create an executable for your operating system. Well, BlenderPlayer can fix that.
- Make a new folder to store all your game data.
- Then save your .blend file into the directory.
- You can skip this step and the next step if you do not want a Windows version. For the Windows users, copy blenderplayer.exe to the new folder from a Windows copy of Blender. Then copy all your DLL files for Blender as mentioned for Windows to the folder.
- Next you have to make an MS-DOS batch file (for UNIX users, this is the shell script equivalent). In a simple text editor, in CR-LF mode if available (Notepad is always in this mode, and NOT a word processor!), copy and paste this text:
Save it as YourGameName-Windows.bat in your game folder.
- You can skip this step if you do not want a UNIX (basically Mac OS X and GNU/Linux) port. For GNU/Linux (at least), make a shell script. (A shell script is the UNIX term for a batch file.) In a simple text editor, in LF mode (unfortunately Notepad can't be used), copy and paste this text:
Save the file as YourGameName-UNIX.sh in your game folder. You will need to have BlenderPlayer in the same directory as the .blend game file.
- Write a readme for your program. This is again best done with a simple text editor like Notepad or gedit, but it does not matter which mode it is in. You should include the name of the game, a description, perhaps a walkthrough or hints, and if you made a *NIX port, mention that it requires BlenderPlayer, available with Blender.
Blender and the BlenderPlayer fall under the GNU General Public License. Blend files are copyrighted to their respected owners and do not fall under the GPL as long as they are not packed in the BlenderPlayer. If a user does not want the blend files to fall under the GPL, it is recommended not to use the "Save Game as Runtime" feature. To put it another way, the user must keep the blend files and the BlenderPlayer in separate files. More information can be found at http://www.blender.org/education-help/faq/gpl-for-artists/. (Blender 2.4 now has a run game from file actuator.)
Proprietary Blend Files
Blender has no built-in functionality to "lock" or protect user generated content. As a result, anyone who has Blender can open and/or modify blend files. However, it's still possible to lock blend files. Common methods involve encrypting the blend file and then temporary decrypting it at runtime. This can be accomplished by using python scripts or by using external 3rd party applications (which are feasible under the GPL v2).