• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Xirion

C++ SDL Game integration with Python

6 posts in this topic

Greetings!

I already know how to make games with C++ and SDL (already done a few)
but i've been reading a lot about learning a scripting code would be helpful,
so i was thinking on learning python but my question is, how do i actually
use a python script in my game development with C++ and SDL?
are there some tutorials out there so i can take a look on them?

I hope you can help me with that.

Thank you.

[size=3][i]PS: Sorry for my bad english[/i][/size]
0

Share this post


Link to post
Share on other sites
There is two way to use python with C++ but in both cases you will have to expose your c++ API to python by generating bindings (using [url="http://www.swig.org/"]swig[/url] for example).


1) [b]Extending python[/b]: you install your API bindings as a standard python extension and use it from the python interpreter: your program will start from python where you will call your C++ code. This method allow you to use the standard python packages and use some powerful debuggers to debug your python code.

2) [b]Embedding python[/b]; you will integrate python inside your application by embedding the python interpreter. You will have to link and use the python c api from your C++ code to call your python scripts. With this method you will have a more specific python interpreter without stuff you don't need but you will have more problems for debugging your python scripts (I have never seen any decent debugger for debugging embeded python).


I personnaly choose the first method: I write my high level code in python and low level performance critical code in c++. That way I can use standard python modules and debug easily my application. (For debugging the c++ code I compile my bindings with debug information and attach to the python process from my IDE ).

Here are a few links about embedding and extending:

[url="http://docs.python.org/extending/"]http://docs.python.org/extending/[/url]

[url="http://twistedmatrix.com/users/glyph/rant/extendit.html"]http://twistedmatrix...t/extendit.html[/url]

And here is an so discussion about the different way to create python bindings:

[url="http://stackoverflow.com/questions/456884/extending-python-to-swig-not-to-swig-or-cython"]http://stackoverflow...-swig-or-cython[/url]

I choose swig because of the great documentation, the stl support (std::shared_ptr,...) and the good integration with cmake.
1

Share this post


Link to post
Share on other sites
Hi, thank you for the quick response.
I got another question though. What can i actually do using python scripts
that help me in game develop? What is the most common use of this in
2D game development?
0

Share this post


Link to post
Share on other sites
You have all the benefits from a scripting language

- [b]no compile time[/b]: stop your app, change a variable value in a script (let say the position of quad) and restart it to see the change immediately. You may even reload module at runtime if you detect a change in the script (but that is up to you to detect changes)

- don't bother with memory management and other low level stuffs, just think about your [b]high level gameplay cod[/b][b]e[/b]

- [b]easy[/b] to learn: even artists could write scripts (but keep in mind that real programmers will probably do a better job at scripting than an artist)

Using a scripting language just [b]improve your productivity[/b]!

Also, if you decide to go with extending python, you will find all the tools to create tools for your engine. Using [url="http://www.riverbankcomputing.co.uk/software/pyqt/intro"]PyQt[/url] is an effective way to make GUI tools such as an editor for your engine.
1

Share this post


Link to post
Share on other sites
Hi! Thank you again!
Also do you know by any chance a tutorial or/and example on this topic?
I work with my girlfriend (Graphic Designer) and i really want her to enter the
world of programming (so i help her in illustration and she helps me on programming).
I really like the part you say that artist can script.

Greetings.
0

Share this post


Link to post
Share on other sites
What kind of tutorial are you interested in? About c++ to python or just about python?

I'm afraid there are not a lots of tutorial about how to expose your engine to python (except for simple things), you will most likely have to choose a bindings generator, learn how it works and what you can do with it. Also read the python documentation about [url="http://docs.python.org/extending/extending.html"]extending and embedding[/url] and check the [url="http://www.gamedev.net/blog/415-abwoods-coding-notes/"]Abwood's Coding Notes[/url] to have a look at how things could be done.

For learning python, there is a lots of good tutorials on the web, just google "learn python" to find them.

If you speak french, I recommend reading this [url="http://inforef.be/swi/download/apprendre_python.pdf"]book[/url]. It is released under the creative commons license ( free ) and explains the fundementals very well.
1

Share this post


Link to post
Share on other sites
Yes i was actually hoping for something on C++ plus Python.
I'll take a look on the links you provided. I'm reading a book on Python fundamentals wich seems very simple and easy to understand, sadly it doesn't cover what i'm asking for. And nope, i don't speak french, i'm currently improving my english and struggling with my japanese.

I really appreciate your time and your advices.

Thank you very much.
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0