programming language used?

Ask, comment, read.
User avatar
Tomislav Uzelac
2x2 Games
Posts: 1685
Joined: Mon Apr 04, 2011 11:24 pm
Location: Zagreb, Croatia

Re: programming language used?

Unread postby Tomislav Uzelac » Wed Sep 25, 2013 9:55 pm

Hi "lhughes",

here's what we're doing. We use Python 2.7 and Pygame 1.7 (I think, not 100% sure, but whatever is on the build machine since ~2yrs ago).

We set up a a software surface using pygame, but do not use pygame for rendering, just for input. Instead we both blit and draw onto the pygame surface using cairo. This involves some ctypes magic to set up - email me and I'll send you the code if you want. To get the performance, we use a "dirty rect" type algorithm. This doesn't really help with full screen redraws (i.e. scrolling) but we don't do a lot of those anyway.

My "head in this direction" advice is: use SDL2 (via pySDL) and do your blitting on an OpenGL context. I don't think you need to make any OpenGL calls for that, just use the SDL2 primitives (Sprite etc). Don't be put off by the work-in-progress feel of SDL2/pySDL - e.g. you may need to get the latest version from their repos and compile everything yourself.

This combination is what we'll be using ourselves, for our next project.

Cheers! :)

lhughes41
Cadet
Posts: 2
Joined: Wed Sep 25, 2013 5:57 pm

Re: programming language used?

Unread postby lhughes41 » Thu Sep 26, 2013 1:42 am

Thank you for your quick reply. Should have been less rude, my name is Lucian (Luke) Hughes. I very much appreciate your gracious granting of insights that I am sure cost you some coding 'blood' :-)
So my performance when doing internal rendering and even to screen seems pretty good (I have an offscreen surface which I also write to in a dirty rect kind of way and then dirty rect to display (possible in pygame)) . My real issue was with scrolling a large resolution screen around without hardware acceleration. Ah well.
May I ask why you wanted to use cairo for your "internal" blit and draws rather than what came native to pygame? Is it significantly faster or more expressive? What motivated you?
The 'head in this direction' advise is very interesting if somewhat daunting! Pygame is heading that way too, fyi. I wonder if SDL2 would be better at grabbing hardware surfaces.
Looking forward to your next project, I admire your work, and enjoyed your recent podcast interview at Game Design Roundtable.
Luke
p.s. once I understand your motivation for cairo perhaps I will take advantage of your code offer. To return the favor (though you probably don't need it) I know a good texture atlas tool I can point you too if that interests you. I have integrated into my load code now.
p.p.s. I came to python from an interpretative language background (LISP and AI of all things).. I just couldn't bear to return to types and some C variant :-)

User avatar
Tomislav Uzelac
2x2 Games
Posts: 1685
Joined: Mon Apr 04, 2011 11:24 pm
Location: Zagreb, Croatia

Re: programming language used?

Unread postby Tomislav Uzelac » Fri Sep 27, 2013 8:26 am

Hi Luke! :-)

I chose cairo because it gave me blits, masking, curves, lines, gradients etc, all in one place. Compared to pygame at the time I was looking at it, it was much more sofisticated. I found it to be fast enough for what I wanted to do, so I never tested for raw speed.

Natan
Newcomer
Posts: 1
Joined: Sat Jan 04, 2014 12:27 pm

Re: programming language used?

Unread postby Natan » Sat Jan 04, 2014 12:48 pm

Hi Tomislav,

I am very impressed by the work done on Unity of command,
I do not get tired to play and replay the various campaigns ...
I am not proffessional programmer, but fan of wargame since numerous years...
I tried different wargame techniques that could serve me in my projects ....
I have a question on how you programmed the drag & drop for your map in the game ?
I tried without much success to reproduce this in my project
but I can not control the scrolling of my map in the direction of movement of the mouse ...
the map scrolls too fast ...
how do you effectively control the direction and speed of scrolling?

I am interested in any information you could give me to advance in my project.

Thank you in advance if you'll share some information with me
sorry for my english, I'm french.

Natan

User avatar
Spooner
Colonel
Posts: 252
Joined: Fri Sep 09, 2011 2:43 pm
Location: UK
Contact:

Re: programming language used?

Unread postby Spooner » Mon Jan 06, 2014 3:23 pm

For the next game, we will be using cx-freeze, because unlike the other exe-builders, such as those used by UOC, it supports Python 3.3 (UoC actually uses Python 2.6) and builds for all three platforms nicely!

I agree with Tom - if you are building anything in Python now, definitely use SDL2 rather than pygame since it is vastly superior because of its hardware support. The high level Python Sprite object wraps SDL2 nicely (Automatically supporting OpenGL or DirectX depending on platform - we are forcing use of OpenGL on all platforms though, since that gives us a lot more options if we want to do low level things that SDL2 doesn't wrap, like GLSL shaders, in the future). I've been able to extend the Sprite object so we can draw onto hardware surfaces using the friendly Cairo interface, rather than lower level drawing.

You might be interested in looking at my open-source game, Smash and Grab (unfinished, sadly): http://forums.tigsource.com/index.php?topic=22722.0 - It is implemented in Ruby rather than Python (the latter is a better choice for serious game development) but the code might give you insight into something you haven't got in your design yet.

User avatar
Spooner
Colonel
Posts: 252
Joined: Fri Sep 09, 2011 2:43 pm
Location: UK
Contact:

Re: programming language used?

Unread postby Spooner » Mon Jan 06, 2014 3:38 pm

A couple of thoughts about Unity:

@Tom: Unity supports C# (a lot like Java), Boo (A type-safe variant of Python, though I don't think it is much supported or used) and actionscript (a lot like javascript).

@Natan: Unity is definitely a better platform than Python if you are looking at mobile, web and console compatibility in the future.

User avatar
Spooner
Colonel
Posts: 252
Joined: Fri Sep 09, 2011 2:43 pm
Location: UK
Contact:

Re: programming language used?

Unread postby Spooner » Thu May 08, 2014 9:18 am

I'd recommend looking at pysdl2, which was officially released recently: it supports hardware accelerated textures as well as everything pygame does (pygame is built on top of sdl1, as I'm sure you are aware). By relying on purely software rendering in UoC, we limited ourselves significantly, most noticeability in preventing zooming in the game.

As an alternative, you might consider using opengl in sdl2, though if you aren't conversant with that, just using sdl2's hardware textures (A high level wrapper around opengl or directX, depending on platform) will be easier and quite fast enough for anything but the most advanced 2D use.