Author Topic: WhoreMaster: Abby's Crossing  (Read 139791 times)

0 Members and 1 Guest are viewing this topic.

Offline Xela

  • Global Moderator
  • *****
  • Posts: 6893
  • "It's like hunting cows"
Re: I've been messing around with pygame
« Reply #15 on: October 29, 2013, 12:36:46 PM »
It sounds dreadfully unambitious when you put it in those terms. But yes, I suppose so. With a side order of learning Python and Qt and a lot of fun making steampunk widgets with Inkscape :)

"unambitious" is not the right word here, it should be "sane". More features can always be added later.

I've been meaning to try out Inkscape but never seem to find the time :(
Like what we're doing?

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #16 on: October 29, 2013, 12:57:33 PM »
"unambitious" is not the right word here, it should be "sane". More features can always be added later.

"Sane" works for me, I must admit :)

I've been meaning to try out Inkscape but never seem to find the time :(

Yeah, I get the same thing whenever I try and learn a 3D modelling package - I'm always too busy coding to put the necessary hours in.

That said, there are a ton of decent inkscape tuts, as well as the examples on the website. Definitely worth the time if you can spare it :)

Offline rudistoned

  • Full Member
  • ***
  • Posts: 229
Re: I've been messing around with pygame
« Reply #17 on: October 29, 2013, 01:37:44 PM »
Are you planning to open-source your game?

Congratulations on the style. It really delivers a particular mood, provides atmosphere.

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #18 on: October 29, 2013, 02:16:40 PM »
Are you planning to open-source your game?

Yes. If it ever gets to the point where it's halfway worth playing, I'll release the source. 

Congratulations on the style. It really delivers a particular mood, provides atmosphere.

Thanks. I've been playing around with some of these ideas for a long time now. It would be nice to finally do something with them :)

Offline rudistoned

  • Full Member
  • ***
  • Posts: 229
Re: I've been messing around with pygame
« Reply #19 on: October 29, 2013, 02:28:14 PM »
I see. How did you make the buttons? Are the whole buttons images or did you load an image into the background and let Qt draw the text and border? If it is the latter I'd be interested in the code. The way Pytherworld does that is pretty slow.

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #20 on: October 29, 2013, 05:36:39 PM »
I see. How did you make the buttons? Are the whole buttons images or did you load an image into the background and let Qt draw the text and border? If it is the latter I'd be interested in the code. The way Pytherworld does that is pretty slow.

They're a mix. The ones on the initial screen are pure images, bump-mapped in the Gimp. But that's not practical for every button, so the subsequent ones use a background image with text on top.

This is the pure image version. The "n, h, p, d" args stand for "normal, hover, pressed, disabled":

Code: [Select]
class ImageButton(QPushButton):
        def __init__(self, name, parent, n, h, p, d, *args, **kw):

                ssfmt = """
                QPushButton {{
                        background-image : url({0});
                        border: 1px solid transparent;
                }}
                QPushButton:hover {{
                        background-image : url({1});
                }}
                QPushButton:pressed {{
                        background-image : url({2});
                }}
                QPushButton:disabled {{
                        background-image : url({3});
                }}
                """

                QPushButton.__init__(self, parent, *args, **kw)
                self.setObjectName(name)
                ss = ssfmt.format(n, h, p, d)
                self.setStyleSheet(ss)

The mixed button and images ones work like this:

Code: [Select]
class MixedButton(QPushButton):
        def __init__(self, text, parent=None, *args, **kw):

                QPushButton.__init__(self, parent, *args, **kw)
                self.setText(text)

                ssfmt = """
                        QPushButton {{
                                color           : yellow;
                                background-image : url({0});
                                border: 1px solid transparent;
                                padding-top     : 8px;
                        }}
                        QPushButton:hover {{
                                background-image : url({1});
                        }}
                        QPushButton:pressed {{
                                background-image : url({2});
                                padding-top     : 12px;
                        }}
                        QPushButton:disabled {{
                                background-image : url({3});
                        }}
                """
                ss = ssfmt.format(
                        "work/button_blank_normal.png",
                        "work/button_blank_hover.png",
                        "work/button_blank_active.png",
                        "work/button_blank_disabled.png",
                )
                self.setStyleSheet(ss)
                self.setFont(QtGui.QFont("Gabrielle", 24))

I gather you're using QtCreator while I'm hand coding, so it might not be entirely straightforward. Let me know if I can help further.

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #21 on: October 30, 2013, 01:29:17 AM »
I see. How did you make the buttons? Are the whole buttons images or did you load an image into the background and let Qt draw the text and border? If it is the latter I'd be interested in the code. The way Pytherworld does that is pretty slow.

It occurs to me that some button images might be helpful as well. Basically I have the border drawn into the button, like this:



I made that by drawing the frame and the text in Inkscape and then using the Gimp to bump map it to give it a slightly rounded look. I added the leather background in a separate layer using the Gimpressionist filter.

For the hover image, I made another leather texture in a brighter shade of red



To get the disabled version I copied the frame and text layer, desaturated, and exported the result using the darker background



Finally, for the active image, I duplicated the text and border and gave it a gaussian blur. By displaying the blur layer on top of the non-blurrred one, I get a shine effect for the active button. Add the brighter background and we have our mousedown image



Of course, that's a lot of work if I'm going to do it for every button in the game, so I only bump-mapped the text on the opening screen buttons. For the rest I use the bump-mapped borders, but no text, and then use PyQt to add the caption. The code for that is in the previous post.

OK, that's about all I got. Hope I'm not teaching my granny how to suck eggs :)

[edit]

Since I'm talking about making images, here's the message area widget I was talking about:



I think I feel a new sig coming on...

[edit]

What the hell, here's the "printer" widget as part of the main screen.



The layout still needs a little love. It's a bit cramped and the style is uneven, but in some ways that suits the theme. Some things could be lined up a bit better, but I think I'm going to get a big empty spot in the middle of the screen which is going to stand out amidst all that clutter. I suppose I can always add a bit of decoration or some pointless blinking lights. I'm tending towards a brass nude statuette if I can find or make a suitable graphic.

It occurs to me that I'm in danger of taking this seriously.

Saving seems to be working, but I'll not know until loading is implemented. That's the next job.
« Last Edit: October 30, 2013, 02:00:19 PM by DocClox »

Offline rudistoned

  • Full Member
  • ***
  • Posts: 229
Re: I've been messing around with pygame
« Reply #22 on: October 30, 2013, 05:07:07 PM »
OK, that's about all I got. Hope I'm not teaching my granny how to suck eggs :)
Thank you very much for the in-depth explanation! I actually know very little about image editing and creating game graphics, so that was really helpful.

In regard to the button classes:
I use QtDesigner for some parts of the GUI, true, but when you're working with Qt from Python and you want to do dynamic things like adding or removing widgets at runtime, using drag and drop or similar stuff, you have to create your widgets in code. The longer I use Qt, the more I do in code. Based on that experience I understand what you are doing in the button classes. I've been thinking a while about creating nice buttons similar to yours programmatically, using some image as background and create the borders, shape and text with Qt. I have not researched if a glow effect is possible, but the other things should be doable, maybe just with style sheets alone.


The message area widget is nice. I also really like the humor and atmosphere in the texts.

It's a bit cramped and the style is uneven
What stands out most to me is that the image frame has more linear, edgy elements than the other widgets. It's style is more precise and technical, especially when compared with the softer, rounder style of the message area widget.


I'm tending towards a brass nude statuette if I can find or make a suitable graphic.

It occurs to me that I'm in danger of taking this seriously.
The brass nude statuette or Abby's crossing? ;D


Saving seems to be working, but I'll not know until loading is implemented. That's the next job.
Saving complete class instances with pickle (or PyYAML for human-readable savegames) worked best for me. Saves you the trouble of maintaining serialization methods on your objects.

UPDATE:
Forgot to mention the Google protocol buffers. Those are another serialization method that works with Python, C++ and Java. No idea if the features they offer are useful to you. I have not yet used them for one of my projects.

UPDATE2:
Just realized that it should not be too hard to write a generic serialization method that turns an object into, say, XML. The most difficult part I can see is saving a useful reference to the object's class.

LAST UPDATE (I promise ;D ):
Since serializing to XML is not fundamentally different to serializing into other data formats, someone of course already wrote a Python XML serializer: http://sourceforge.net/projects/pyxser/
« Last Edit: October 30, 2013, 05:55:18 PM by rudistoned »

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #23 on: October 31, 2013, 03:50:50 AM »
Thank you very much for the in-depth explanation! I actually know very little about image editing and creating game graphics, so that was really helpful.

My pleasure. I could probably whomp up a tutorial if people would find it helpful

I use QtDesigner for some parts of the GUI, true, but when you're working with Qt from Python and you want to do dynamic things like adding or removing widgets at runtime, using drag and drop or similar stuff, you have to create your widgets in code.

I wondered about that, I must admit.

The longer I use Qt, the more I do in code. Based on that experience I understand what you are doing in the button classes. I've been thinking a while about creating nice buttons similar to yours programmatically, using some image as background and create the borders, shape and text with Qt. I have not researched if a glow effect is possible, but the other things should be doable, maybe just with style sheets alone.

Glow is easy - just use a blur layer. I kept the glow on the AC buttons fairly subtle, but it doesn't need to be. The important thing is to resize the image layer so you have some empty pixels around the non-glowing button. Otherwise the blur gets truncated by the edge of the button.

The message area widget is nice. I also really like the humor and atmosphere in the texts.

:D

What stands out most to me is that the image frame has more linear, edgy elements than the other widgets. It's style is more precise and technical, especially when compared with the softer, rounder style of the message area widget.

Yeah, I think you're right. I went for a more organic feel for the design and while I like the result, I'm not sure it fits with the rest.

I might try combining the printer and the viewscreen frame. Maybe mount the brothel name panel in between the two. That would free some space for the message area and reduce the feeling of clutter as well. Maybe once I have a few more screens up.

The brass nude statuette or Abby's crossing? ;D

Abby's Crossing :)

Saving complete class instances with pickle (or PyYAML for human-readable savegames) worked best for me. Saves you the trouble of maintaining serialization methods on your objects.

Pickle seems to do the job nicely at the moment. The task now is to suitably theme QTableWidget and friends so I can present a list of save files.

[edit]



:D
« Last Edit: October 31, 2013, 07:55:53 AM by DocClox »

Offline rudistoned

  • Full Member
  • ***
  • Posts: 229
Re: I've been messing around with pygame
« Reply #24 on: October 31, 2013, 08:27:05 AM »
@statuette
Splendid!  :D

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #25 on: October 31, 2013, 02:10:56 PM »
@statuette
Splendid!  :D

:D

QTableView is a lot of work to customise, but I think I've got it sussed now...


Offline hewhocumsbynight

  • Hero Member
  • *****
  • Posts: 683
  • All Hail the Crimson King!
Re: I've been messing around with pygame
« Reply #26 on: October 31, 2013, 03:18:22 PM »
DocClox, can I just say that I absolutely love the names of your files?  The aliteration is great!
My MEGA folder can be found at:  https://mega.co.nz/#F!EYhAgTyI!keiMX47NrnGOEozwNb2Vfg

Torrent link of my version, effective September, 2016:  magnet:?xt=urn:btih:4606F11A1C216337D7F3DFD6716307F48CFB996A&dn=WhoreMaster.06.02.29&tr=udp%3a%2f%2ftracker.openbittorrent.com%3a80

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #27 on: November 01, 2013, 02:08:27 PM »
DocClox, can I just say that I absolutely love the names of your files?  The aliteration is great!

Glad you like 'em :)

Spent most of yesterday writing a save manager and changing the save and load routines to pickle the brothel name, timestamp and file name before pickling the main data. That should let me scan the save games and get the data for the load screen without having to load each saved game in full to find out the brothel name. Of course, I could just use the brothel name as file name, but then I'd have to filter out punctuation in the names and I'd sooner not do that.

Also started work today. So the breakneck pace of development will slow down somewhat.

[edit]

On the other hand, I finally got the thing running on Windows as well as Linux, so I might try and see if I can make that exe bundling trick work.

Not that there's anything to play yet, but I'd like to get that sorted out sooner rather than later :)
« Last Edit: November 02, 2013, 05:36:13 AM by DocClox »

Offline rudistoned

  • Full Member
  • ***
  • Posts: 229
Re: I've been messing around with pygame
« Reply #28 on: November 02, 2013, 08:07:31 AM »
Should you go with PyInstaller, here is some advise for you:

First of all, good choice :) I really like PyInstaller as many things work out-of-the-box that didn't when I tried py2exe.

Here's the "but": PyInstaller 2.1 (newest stable version) has a problem with Qt and the PySide bindings. I have no idea why and have not been able to get around it. Luckily, version 2.0 of PyInstaller just works for Qt with PySide, no fiddling required what so ever. Official support for PySide has been announced for version 2.2, which has not been released so far.

Now, you are using the PyQt bindings with Qt (any particular reason why you chose PyQt instead of PySide?). PyQt is already supported by PyInstaller, but there have been problems in the past. If it does not work with some version of PyInstaller, I strongly encourage you to try the stable version before and the latest dev version to see if it works there.

I don't remember if I ever tried to package Qt with anything else then PyInstaller, so I don't have advise on py2exe and friends.

Offline DocClox

  • Dev Team
  • *****
  • Posts: 1867
  • Messing Around With Python
Re: I've been messing around with pygame
« Reply #29 on: November 02, 2013, 08:27:02 AM »
Should you go with PyInstaller, here is some advise for you:

First of all, good choice :) I really like PyInstaller as many things work out-of-the-box that didn't when I tried py2exe.

I am indeed using PyInstaller. And having a hell of a time of it since all the documentation seems out of date. Downloading the package didn't seem to have the install scripts where they were supposed to be. So I googled a bit more and found page that said to use pip. So I installed setuptools and pip and used pip to install pyinstall.

Now everything says to run pyinstaller.py, but I don't seem to have that, just an exe. I've not yet tried the exe - busy running a search for the .py at the moment.

Now, you are using the PyQt bindings with Qt (any particular reason why you chose PyQt instead of PySide?). PyQt is already supported by PyInstaller, but there have been problems in the past. If it does not work with some version of PyInstaller, I strongly encourage you to try the stable version before and the latest dev version to see if it works there.

Hmmm ... as it happens I'm using PyQt, mainly because I hadn't heard of Pyside at the time. From what I've seen since Pyside seems popular and regarded as being more pythonic. Is it a lot of hassle to migrate? I must admit I'm tempted to stay with what is working at the moment :)

I don't remember if I ever tried to package Qt with anything else then PyInstaller, so I don't have advise on py2exe and friends.

I'll see how I get on with pyinstaller then. Once my search finishes, anyway...

[edit]

... aaaaannnd, that seems to work! The exe version bundles it up just fine. All it needs is the resources folder and everything looks peachy.

Now I just need the saving debugged. Is pickle supposed to handle lists of objects? I've got a GameData object that holds (among other things) a list of Brothel objects. The Game data elements are getting reloaded, but the brothel list is not.  I guess I can always pickle them individually - it's still heaps better than reading and writing each and every field.

Oh, and thanks for the help, Rudi!

[edit]

Also, pickle seems to be working properly after all. I was loading the file to a temp variable, testing for None, and if not none, assigning the result to my global data reference. The problems seems to be that I was actually creating a new local variable rather than overwriting the global. Python scoping still catches me out from time to time.
« Last Edit: November 02, 2013, 10:08:02 AM by DocClox »