Difference between revisions of "Complete roguelike tutorial using C++ and libtcod - extra 1: about editors and IDE"

From RogueBasin
Jump to navigation Jump to search
Line 37: Line 37:


You also have to run SublimeText from the MSys terminal so that it has the path to g++.
You also have to run SublimeText from the MSys terminal so that it has the path to g++.
==PSPad: old school and full featured [windows and linux through wine]==
===Presentation===
[http://www.pspad.com/en/download.php PSPad] is a more classical and less minimalist all-purposes text editor. With ftp read/write, HTML formatting and file comparison tools, it's perfect for web development but it can also be used for C++, especially because of its code explorer window that helps you to find a method in the current tab.
To create your project, just select Project / create project from directory and select your project's directory.
===Compilation===
To compile with pspad on Windows, open Project / Project Settings and fill the compiler tab :
Compiler : full path to the g++ executable
Parameters : use the same parameters as the command line version, but use absolute paths, for example :
E:\path\tuto\src\*.cpp -IE:\path\tuto\include -LE:\path\tuto\lib -ltcod-mingw -static-libgcc -static-libstdc++ -o E:\path\tuto\tuto.exe
Default directory : the directory containing the g++ executable (else pspad will complain about missing mingw dlls)
Check "Capture program output window" and "hide output window"
Set the log parser to :
%F:%L:%C:*
That's it. Hit ctrl+f9 to compile.




[[Category:Developing]]
[[Category:Developing]]

Revision as of 13:41, 21 October 2015

Complete roguelike tutorial using C++ and libtcod
-originally written by Jice
Text in this tutorial was released under the Creative Commons Attribution-ShareAlike 3.0 Unported and the GNU Free Documentation License (unversioned, with no invariant sections, front-cover texts, or back-cover texts) on 2015-09-21.


So far we've seen how to compile the C++ code but we didn't mention how to write it. In this article, I present a few great tools to write C++ code, covering all the needs from the minimalist, distraction-free text editor to the most heavily featured Integrated Development Environment. This is my personal selection, but remember the best tool is the one you're comfortable with so don't hesitate to try others until you find your best fit.

We'll start with the lightweight tools and finish with the heavyweight.

SublimeText: minimalist and powerful [windows and linux]

Presentation

If you like minimalist UI and having every feature available with a few keystroke without having to browse huge menu trees or a swarm of icons, SublimeText is definitely the editor you need.

All you have to do is to add your project directory to the current project (Project / Add folder to project) and you're done. SublimeText can display a side bar with the content of the project but you don't even need it, thanks to the amazing "Go to anything" feature. You want to open the Actor.cpp file ? Hit ctrl+p and type act, a suggestion list will open and you'll be able to open it (or switch to the tab if it's already open) faster than you would do with a mouse click.

Want to find the render function in your huge Engine.cpp file ? Use ctrl+p and type eng#upd (or ctrl+r / ren if current tab is already Engine.cpp). If Engine.hpp is open rather than cpp, simply type engcp#upd, that should work.

Want to go to line 50 in Engine.cpp ? ctrl+p / eng:50 (or ctrl+g / 50 if current tab is already Engine.cpp).

Compilation

Select Tools / Build System / New Build System and paste this in the file :

{
   "cmd": ["g++.exe src/*.cpp -o tuto -Iinclude -Llib -ltcod-mingw -static-libgcc -static-libstdc++"],
   "shell":true,
   "working_dir":"${project_path:${folder}}",
   "file_regex":"^(...*?):([0-9]*)",
   "encoding": "cp1252"
}

Save it as tuto.sublime-build, for example. Then check than tuto is selected in Tools/Build Systems. And hit ctrl+b to build. You can click in a compilation error to open the corresponding file.

Note that to make this work on windows with SublimeText 2.0.1, I had to slightly change the Data/Packages/Default/exec.py file from SublimeText distribution. You need to add stdin=subprocess.PIPE parameter to the subprocess.Popen call :

self.proc = subprocess.Popen(arg_list, stdout=subprocess.PIPE,stdin=subprocess.PIPE,
   stderr=subprocess.PIPE, startupinfo=startupinfo, env=proc_env, shell=shell)

You also have to run SublimeText from the MSys terminal so that it has the path to g++.

PSPad: old school and full featured [windows and linux through wine]

Presentation

PSPad is a more classical and less minimalist all-purposes text editor. With ftp read/write, HTML formatting and file comparison tools, it's perfect for web development but it can also be used for C++, especially because of its code explorer window that helps you to find a method in the current tab.

To create your project, just select Project / create project from directory and select your project's directory.

Compilation

To compile with pspad on Windows, open Project / Project Settings and fill the compiler tab :

Compiler : full path to the g++ executable

Parameters : use the same parameters as the command line version, but use absolute paths, for example :

E:\path\tuto\src\*.cpp -IE:\path\tuto\include -LE:\path\tuto\lib -ltcod-mingw -static-libgcc -static-libstdc++ -o E:\path\tuto\tuto.exe

Default directory : the directory containing the g++ executable (else pspad will complain about missing mingw dlls)

Check "Capture program output window" and "hide output window"

Set the log parser to :

%F:%L:%C:*

That's it. Hit ctrl+f9 to compile.