Dev Blog - Trilarion

Discussion of ongoing programming work.
Forum rules
Posted relevant content can be used under GPL or GFDL (http://www.gnu.org/) for the project. Thanks!
Post Reply
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

Re: Dev Blog - Trilarion

Post by Trilarion »

Yes it will save in a save game. Basically the position of each object as well as its z-index will be stored in the scenario file. Upon scenario creation the positions will be created randomly (and could potentially be changed manually but who wants this) and then stored and when the save game is loaded the graphics is recreated on the screen. Btw. it's your art Ven I'm taking here as templates and only a small part of it.

I want to improve it still quite a bit, so I hope this isn't the end yet. Then I want to propose this and hope you can make the graphics (textures, objects, ...) even better.
Veneteaou
Posts: 280
Joined: Sat Aug 25, 2012 4:23 am

Re: Dev Blog - Trilarion

Post by Veneteaou »

Yes I should be able to once I do some testing. My wife wants me to find a job so she can stay home with the kids, so IDK when that will be, but I can definitely do it.
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXII- Rivers, Borders

Post by Trilarion »

And the result of this evenings experiment is a way to procedurally create rivers and borders. Rivers are paths of points connected by Bezier curves and painted by texture brush while borders are paths or straight lines painted with a solid color patterned brush. The cool thing is that rivers can now potentially even join and the objects can be placed around the river.

Of course they can still be improved. Amongst others it would be nice to have a more natural shape of the river bendings, with increasing width towards river mouth. But for a start it is not too bad. I'm still not doing much programming on my own, mostly exploiting the capabilities of the graphics framework (as it should be).
Prototyp_Terrain_4.jpg
Prototyp_Terrain_4.jpg (24.76 KiB) Viewed 14182 times
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXIII - Custom shaped terrain areas

Post by Trilarion »

The picture of today might look a bit less impressive at first glance, especially because of the weird shapes, but these mark a real breakthrough actually. So even with the weird shapes owning to me not having enough time to make something nice and just taking random distortions, they show that I can detect a bunch of tiles which are connected to each other by same terrain type, then getting the corner points of this area, then deforming it and then paint it again.

The idea for continuous terrain is then as follows:
  • Having textures that extend over a single tile.
  • Having areas that combine all tiles of same terrain type into a single shape
  • Distort this shape in a nice partly random way, so that it doesn't show straight edges anymore (the original Imperialism had that too)
  • Paint it by using a the textures
  • Or place objects (trees, hills, mountains) in a random way into these areas
This is a bit different to the original but seems even less difficult from an artistic perspective and uses all the capabilities of a modern graphical user interaction framework like Qt. I hope it will look good enough but I'm sure the continuity issue will be completely solved by this. With relatively low effort this will allow an endless number of non repeatable maps.

That's the plan but still much is to do.
Prototyp_Terrain_5.jpg
Prototyp_Terrain_5.jpg (28.17 KiB) Viewed 14167 times
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXIV - Audio

Post by Trilarion »

So this week will be all about audio. Audio playback is surprisingly difficult on Python. The exact requirements for audio are:

Reliably play mp3 or ogg audio files from Python 3 on all three OS (Windows, Linux, Mac) without major problems and with as little overhead as possible. Simple handling is a plus.

Here are the results:

1. PyAudio
Available in Python 2 and 3. Only plays uncompressed (.wav) audio. FAIL

2. PyGlet
Under Windows bundled with AVbin and plays mp3 or ogg out of the box in Python 2 and 3. Under Linux only available for Python 2 and without AVbin. FAIL

3. PyGame
Only supports ogg (never mp3). Under Linux not easily available for Python 3. NOT OPTIMAL.

4. Phonon from PySide (which we use anyway)
Only layer on plattform capabilities. Under Windows relies on DirectShow (audio/mpeg available, but audio/ogg not, can be installed for free from xiph.org. Under Linux (Ubuntu) the direct opposite (audio/ogg is preinstalled, audio/mpeg needs to install gstreamer or something else on my machine, at least it asks on the fly). However PySide exists for Python 2 and 3 on Windows and Linux. ALMOST PASS. BEST OPTION.

So we have a clear winner due to all other competing packages completely failing the requirements.

We will use PySide/Phonon and rely on plattform audio capabilities and will store the audio data in type audio/ogg.

Now I need to figure out how to make Phonon playback in seek mode (for sound effects), maybe buffer for low latencies) and how to display a nice toast (little half transparent notification window). Then audio will be done for the moment.
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXV - Audio

Post by Trilarion »

Currently I have a minor annoyance. I cannot read the meta data (in particular title) of the songs from the ogg files. The framework should deliver it but doesn't. I posted on Stackoverflow about it. In the worst case it means I have to put the titles manually in an extra file instead of reading them from the audio files. It would mean a small unecessary overhead, but if the problem cannot be fixed otherwise this will be the solution. Audio is not the major point of this project, it should just work smoothly with low effort.
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXVI - Start screen

Post by Trilarion »

So this week is all about recreating the start screen. Today I could display the start image so far (in about 30 minutes). Funny thing is that the more time I spent programming the shorter the code actually gets because I learn more about the idioms and because the first solutions tend to be overly complicated. In a way embarassing because the output in code lines per time ratio decreases but the beauty of the code definitely increases and the error-proneness goes down.

Time to fire up the old Java code again and compare how it was done there to learn and to make sure everything is still there.
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXVII - Start screen

Post by Trilarion »

A bit slower than I expected. The start screen is showing, but the effect of the images when the mouse is hoovering and the whole point, the further menus and screens and ... are not showing at all. Well it is a lot of work actually. And I have to relearn a bit about the programming style. Java is all about objects, Python is all about shortcuts and this also means that Python just doesn't profit from objects and object hierachies so much. Java is about bureaucracy and if there is an effect at all it is exactly the effect you wanted while Python is all about taking a big gun out and shooting and if you thought very well before shooting you may only hit what you wanted.

Enough of semi-smart comparisons. In case you want to see the activity of the source code repository, you can do so here.

The new project is now about 500 lines of Python code long made in 14 updates of the repository. It's a start.

To get a comparison. The old Java project had about 5k-10k lines of code and the finished game will likely be around 100k lines of code or more.
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXVIII - Start screen

Post by Trilarion »

Finally time to show a picture. It looks.. like in the old version. Which is good, exactly what I wanted. Now my Sprint for this week hasn't finished yet. I will work on the preferences dialog until friday.
current start screen
current start screen
Clipboard01.jpg (144.45 KiB) Viewed 14086 times
User avatar
Trilarion
Founder
Posts: 845
Joined: Thu Jan 12, 2012 9:27 pm
Location: Central germany

XXXIX - Packaging

Post by Trilarion »

First of all I realized that the old Java package doesn't run anymore. For whatever reason - maybe I made a mistake or something else changed. It still runs from Netbeans though for comparison reasons. But I won't fix it anmyore. Inspired by this I investigated packaging of Python apps.

Well it isn't a nice topic either. Windows packages are fairly straightforward, although they also result in quite some overhead. Basically there is 4 MB game specific data (most of it is music) and 52 MB Python and Qt runtimes. Luckily both can be compressed quite well resulting in a 17 MB install file for Windows. Well I had feared it would be more. It is okay.

Linux packaging of Python 3 applications is a bit difficult as far as I can tell. Making a rpm or deb package covers some but not all distributions and requires some funny intermediate steps. Mac packaging ... well I cannot do it anyway, so somebody else has to figure out how to make an installer.

So for all OS outside of Windows there will be for now a plain vanilla package (4 MB in size currently) which just says: Get Python 3, Get Pyside, Start "start.py". This shouldn't be too difficult either.

The later way I already got it starting on my Linux distro today and immediately I saw one glitch where Qt-Linux obviously behaves different from Qt-Windows but apart from that it worked right out of the box. :)
Post Reply