Compiling tpt with Visual Studio (old)
Note: this guide is outdated and will only work for the old c source
Original author: Triclops200
Main contributors: raj.k, HolyExLxF, FacialTurd(Simon), Jacob1
"Small" authors: wikku9 (added quotations marks to Additional Dependecies list and other) ,Pyromaniac555 (fixed lists, checked spelling and grammar, etc. (still checking)), Me4502 (added pthread link)
The Linux guide to setup is here.
Contributors are welcome to port this tutorial to Mac OS X (or improve the existing tutorials).
This is a guide to get you started on coding for The Powder Toy. If you have any questions, just ask in the Discussion section on The Powder Toy forums.
It would help if you have programmed before, but it is fine if you never have.
This takes a while to setup, so be patient and follow the instructions carefully.
Its not recommended to begin coding elements until you are able to compile a clean source.
GitHub set-up can be skipped, just go to 'Visual Studio (Windows)'
Doing these steps in order is highly recommended.
- Create an account at this site: [].
- Download and install MySysGit.
- Download and install SmartGit.
- Set up SmartGit:
- Choose Non Commercial so you can get unlimited use.
- Insert as much information as you can.
- Your API token is at GitHub.com > Account Settings > Account Admin.
- Give your email to GitHub (necessary [] under email addresses).
- Open GitBash (from the first program you installed) and type this then hit enter:
- ssh-keygen -t rsa -C "<yourgithubusernamewithout<>signs>@github.com"
- Leave the file location blank when it prompts you.
- Type a strong passphrase and confirm the passphrase (they will not show up, so don't be surprised it looks blank).
- Open this with notepad: C:\WINDOWS\Users\<username>\.ssh\id_rsa.pub. Make sure to have the File Type setting on All Files, instead of Text Documents.
- Go to [] > SSH Public Keys. Copy the entire file contents into the the "Key" box. Make sure you don't add any extra spaces or lines (there IS an extra line at the end, though). Leave the Title text box blank and hit "Add key".
- Open GitBash and type: $ ssh email@example.com
- Type your passphrase you made earlier and click Yes. If it doesn't work, try
- $ ssh firstname.lastname@example.org
- If it still doesn't work, verify you did step 6 right (set another file location or overwrite).
- Go to [] and click the "Fork" button. This will create a copy of The Powder Toy in your account.
- Download the source code.
- Open SmartGit, and go to File > Clone.
- Press "Select from GitHub" and choose your repository.
- If your rsa_pub file (the one you made in step # isn't highlighted and the program asks, choose it.
- Type in your passphrase if the program prompts you.
- Choose the directory where you want to store the source files.
- Congratulations! You now have an easy way to make changes to the code and upload it to GitHub.
- To make changes and send a request to Simon to have it implemented in the official code, open SmartGit (make sure you've saved your changes in Visual Studio).
- powder.c and any other files you may have changed should be listed as "Modified".
- Press "Commit" at the top, list the things you have changed in the text box, and press "Commit".
- Press "Push" at the top, and press "Push" again.
- Go to your Powder Toy repository page on GitHub and press "Pull Request" at the top.
- Send the request to facialturd (Simon's username) and you should be done. Verify that the code has been changed if you like.
- If Simon decides to accept your request, your code will be in the official Powder Toy source code. Congratulations!
Visual Studio (Windows)
If you can't be bothered to do any of this yourself, then I have uploaded a complete visual studio 2010 project with source (for v82.0 of Powder Toy). https://www.box.com/s/xzarykzoraiorpi41iy1 It has all the libraries and headers you need to compile this version, it statically links everything so no .dll's needed! Just remember to switch it to release mode for better performance/size.
- Download Visual C++ 2010 Express because of it's great debugging and auto-code tools. It is completely free.
- Open Visual Studio. You should register it (you don't have to pay anything; it's free) if you plan on using it for more than 30 days.
- If you wish, (this should already be on by default), turn on line numbers by going to Tools > Options > Text Editor > C/C++, and turn on "Line numbers" in the Display subsection.
- Download this: Required Libraries (extract it right into your source code folder) (or, if you want a statically linked version that doesn't need a bunch of DLL files to run, download this, but be warned that these libraries may or may not work, and linking may take a very long time to complete)
- Press File > New > New Project from Existing Code.
- Choose the folder from your source code folder.
- Choose Windows application project and leave everything unchecked. Press "Finish". (You don't need to change any of the other options)
- Under Build > Configuration Manager, open the drop-down box under "Active Solution Configuration:" and change it to "Release". (unless you have a good reason to keep it as Debug, which runs slower than Release)
- Go to Project > Properties.
- Under Configuration Properties > General:
- Change Output Directory from
(notice that there is no backslash between "$(SolutionDir)" and "Build\").
- Change Target Name to whatever name you want the compiled file to have, minus the ".exe" extension. (or just leave it be to have the file named as the project name)
- Under Configuration Properties > VC++ Directories:
- Open the drop down menu for Include Directories (if you don't see the arrow that opens the drop-down menu, try clicking on the line), click "<Edit...>", and add
(type that exactly -- also note that there is no backslash between "$(ProjectDir)" and "Includes")
- It's important to make sure, after you click OK to close the "Include Directories" dialog box, that this comes before everything else under "Include Directories" -- otherwise you'll get some nasty errors when you try to compile.
- Open the drop down menu for Library Directories, click "<Edit...>", and add
(note that there is no backslash between "$(ProjectDir)" and "Libraries")
- Go to Configuration Properties > C/C++.
- Under "General", open the drop-down menu for "Warning Level" and choose the option to turn off all warnings. (This will make it easier if you get any errors during compiling, as you won't have to dig through a bunch of unimportant warnings to get to the errors.)
- Under "Preprocessor", open the drop-down for "Preprocessor Definitions", click "<Edit...>", and add (if you're using the static libraries, you'll have to use the list from the "Preprocessor definitions.txt" file located in the zip file with the libraries you downloaded instead of this list below):
LUACONSOLE GRAVFFT X86 X86_SSE2
- If for some reason the libfftw3f-3.lib included in the Libraries folder doesn't work (it should), try using this one (and follow the instructions on the site).
- Under "Code Generation", open up the drop-down menu for "Floating Point Model" and set it to Fast. (this'll get you a noticeable speed improvement)
- Go to Configuration Properties > Linker > Input.
- Open the drop down menu for "Additional Dependencies," click "<Edit...>", and enter the following text (if you're using the static libraries, you'll have to use the list from the "Linker libraries.txt" file located in the zip file with the libraries you downloaded instead of this one below):
shell32.lib ws2_32.lib wsock32.lib SDL.lib SDLmain.lib libbz2.lib regex.lib pthreadVC2.lib lua5.1.lib libfftw3f-3.lib
- Press OK until you close the project properties.
- Hit the F7 key on your keyboard, or click Build > Build Solution.
- If something goes wrong (i.e. you get an error of some sort), ask on The Powder Toy forums
- The resulting executable and its required DLLs can be found in the "Build" folder in your source code directory.