what framework to use for python card game? - python

my question is quite simple, but I can't move on until I solve it. I want to develop a card game, something like Magic the Gathering. I suppose there will be just a little of animation, but much work with images, image transformation and special rendering - some kind of things, that every unit has now attack plus 2 so cards on table will adapt.
I thought Python will be best for it, because it easy to develop with it and I know it pretty well. Also I have a little of experience with PyQt and Pygame. But I can't decide which one is better for that purpose. What do you think will be easier to use: PyQt, Pygame or something else?

if you want just a simple animation and want to finish your game fast. use the pyqt's scene view. refer to (Rapid GUI programming using python and pyqt) book if you want to learn more about scene view.

PySolitaire is a collection of more than 300 solitaire and Mahjongg games. So maybe if you browse around, perhaps you can get some idea.
What is better? If you are developing games, PyGame I guess.

Both pygame and pyqt will work for what you want to do, but I'd recommend pyqt: you'll be able to use standard widgets (like listboxes, textboxes, menus, buttons, ...).
I've never worked with pyqt myself, but I image that drag 'n drop is something built-in, which will be really useful for a card game.
With pygame on the other hand you'll have to make everything yourself. This will give it more of a game feel as you can draw everything exactly like you want it to look like, but it'll take more work as you have to implement basic stuff yourself.

Related

Creating a GUI of hexagonal buttons (Python)

I want to create a little game and I want to make a GUI of hexagonals buttons but I actually don't find a good library except Turtle that looks not really good to make buttons and PyQt that isn't working on Python 3.10.
If you have any idea of library that can do it or another method, thanks for helping !

Can I create a canvas with multiple moving objects and still be able to provide actions?

Let´s say I want to create a game in Python, where a lot of cars will move in canvas, and I still (while they are moving) want to be able to make some actions, like buying items from a shop and so on. Is this possible to do in Python, without any game library import?
Short answer: Yes, but it's not recommended.
Long answer:
For the first part of your question is doable. You can use the tkinter module to create multiple moving objects on your canvas. This is done by using an object oriented program which makes different classes for your cars, in this scenario, and sets them to move. If you want a link for that, here it is. Adding functionality can be a bit annoying, but again, it's tkinter. However, putting these together? It sucks. Based on a lot of articles I've read, making a game in tkinter, is, to put it simply, a very long and painful experience. I highly recommend you to use a game library such as pygame or pyglet, but you technically still can do it in tkinter. So, in conclusion: don't make a game in tkinter, but you still technically can.

Python Script (main) + Blender "face" animation

SO I am infact doing something very similar to this user posts:
https://stackoverflow.com/questions/6800292/python-ai-and-3d-animation
but it has no answers and I couldn't contact the user.
Basically I have a functioning python script that answers me with an action accordingly to my voice command. (Fetch emails, weather forecast, turn lights ON/OFF, etc), it has been made using the pyspeech library which is pretty darn good.
Now I want to give my programm a "face"! I thought about modelling the face with Blender (have some knowledge and would build up on it) and I know I could animate it, so the lips move and such.
So I want to know if it is at all possible to:
Load the "face" that I made from blender from my main python script (so when my programm start the face would be there on the screen too)
Run from the script the animations such that when for example when my programm says "You're welcome" I would run the animation that the lips move on the face to simulate it is speaking.
I know that blender has a good python integration (maybe correct is to say it is built on?) and that is why I thought it would be a good program to use.
Hope someone can help and tell me if that is at all possible and maybe show me some right way to go, my googling just showed me always python scripting with Blender which is not what I exactly need here... I think...
Cheers,
Flavio
Indeed, what you want is possible.
If all you want is to play pre-rendered animation videos based on decisions on your program, any GUI that allows you to embedd and play video in a widget will do for your application.
You could rool out your own GUI using Pygame (which has video support, but you will need one of the "minor" more or less "amateur" widget toolkits made for pygame to make up the remaining of your application, as pygame is pretty low level.
On a higher level, although I'had not embedded video, I think you could go with PyQT4 (googled a bit, not that many examples either, buthints that there are eamples in QT4 source) or GTK+ (the samething, it looks like there are more examples).
Another option would be to build your application to run inside the Blener Game Engine itself - It offers both a high level Toolkit, and ways to customize behaviors to user actions (even without coding).
The major drawback in doing this is: I don't know which are the options to distribute an application that needs Blender Game Engine nowadays - your users will need to install Blender (but it is likely Blender folks made an easy way to jhandle this).
On the upper hand: you get the most flexibility, it would even be possible to render some sequences in realtime (as opposed to pre-rendered videos) in your app.
One thing: Blender nowadays use Python 3.x - if the other libraries you need are Python 2, you willl need to make one different process for the GUI inside Blender, and exchange data with your application's backeend in Python 2 (for example using jsonrpc or xmlrpc - that is enoguh simple in Python).

How to code a wxPython GUI program for orientating disks in a cube?

I am a geology student and am trying to come up with a program for illustrating joint networks in rock masses.
Basically I just need wxPython script, or any snippets of script that would be able to create a GUI program which displays a number of disks inside a box, with the parameters (ie relative position, orientation and radius) of the disks being input at the beginning. Does anyone know of any script like that, or if thats even possible? My problem is that this is for my thesis, and although I have dabbled in Python before, not on anything anywhere near as complex as this, and certainly not GUI. I literally don't even know where to begin trying to display geometric shapes.
I unfortunately don't have the time to learn enough wxPython to do this, I'm looking for any pre-written example code. I have downloaded wxPython and have done some tutorials on creating message windows etc but now I'm not sure where to look for help now. Any advice/tips/code at ALL would be greatly appreciated, I am desperate for help!
I'm not sure I understand exactly what you are trying to do here. Are you creating an interactive GUI or just a visualization? It sounds like you want something in 3D. In that can you should check out VPython which has some tutorials and demo code. Also much more powerful is PyOpenGL. For something and actual 2D user interface in wxPython you should really look through the demo code included with wxPython. There is quite a nice library of complete examples with source code that you can just copy and modify. I am pretty sure there are some examples for drawing polygons of arbitrary size/shape.

wxPython or pygame for a simple card game?

I have been playing around with writing some simple card games in Python for fun and I would like to add a graphical user interface (GUI) to the games. Which library would you recommend for writing the GUI for a simple card game?
If all you want is a GUI, wxPython should do the trick.
If you're looking to add sound, controller input, and take it beyond a simple card game, then you may want to use pygame.
I haven't used wxPython, but Pygame by itself is rather low-level. It allows you to catch key presses, mouse events and draw stuff on the screen, but doesn't offer any pre-made GUI controls. If you use Pygame, you will either have to write your own GUI classes or use existing GUI extensions for Pygame, like Phil's Pygame Utilities.
Generally, PyGame is the better option for coding games. But that's for the more common type of games - where things move on the screen and you must have a good "frame-rate" performance.
For something like a card game, however, I'd go with wxPython (or rather, PyQt). This is because a card game hasn't much in terms of graphics (drawing 2D card shapes on the screen is no harder in wx / PyQt than in PyGame). And on the other hand, you get lots of benefits from wx - like a ready-made GUI for interaction.
In Pygame you have to create a GUI yourself or wade through several half-baked libraries that do it for you. This actually makes sense for Pygame because when you create a game you usually want a GUI of your own, that fits the game's style. But for card games, most chances are that wx's standard GUI widgets will do the trick and will save you hours of coding.
The answers to this related question may be very useful for you:
What can Pygame do in terms of graphics that wxPython can't?
I'd say pygame -- I've heard it's lots of fun, easy and happy. Also, all of my experiences with wxPython have been sad an painful.
But I'm not bias or anything.
pygame is the typical choice, but pyglet has been getting a lot of attention at PyCon. Here's a wiki entry on Python Game libraries: http://wiki.python.org/moin/PythonGameLibraries

Categories

Resources