python graphic user interface - python

I recently finished a big project i have been working on, and i am looking for a new challenge. I was thinking about making python play a game, and making it unbeatable. to do this, i need an easy way of entering the other players move, and i was thinking about something where i can create multiple buttons which the user can press. (for example: if i want to make tic tac toe i would want 9 individual buttons that are triggered by a mouse click, to get the input).
I have no idea if this is possible in python. i have seen multiple pages about this, but some pages have such a large amount of information on them that i don't know where to start.
thanks in advance for any answers,
Harm

Related

how to press the key automatically in the game?

sorry in advance for my bad english.
I'm writing a game automation program , specifically the game requires a key press to start doing (something) , but when i use KeyBoard.press() function from KeyBoard module i have problem where game doesn't recognize my key i tried in game chat box and it still works , it means the key is still pressed down but the game doesn't pick up , i tried using some other functions like " KeyBoard.press_and_release() , KeyBoard.send() " and some other modules but the result is the same,
here is the example code
While True:
if (...):
keyboard.press('e')
keyboard.release('e')
but what confuses me is when i add time.sleep() between the press and release commands it works but what confuses me is when i add time.sleep() between the press and release commands it works but there is a big delay
Anyone have any solution for me?
While True:
if (...):
keyboard.press('e')
time.sleep(0.05)
keyboard.release('e')
If I understand properly (and, I might not, sorry) it could be an issue with the game rather than python. Some games, especially online games, implement features specifically to stop automation.
Have you tried your code in a different context - another game or, seeing as it simulates key presses, a text editor? I think you are saying it works in the chat box but not for game control inputs. If it works as intended outside of the game but not inside that would suggest the problem is something to do with how the game handles key presses.
In that while loop, you might be simulating 20 key presses a second, while a more usual average would be between about 5 and 7 with the world record reported at 16. Perhaps the game detects if the rate is too high and discounts those key presses. Also, a physical keyboard will be subject to repeat rate and repeat delay, which the game may be testing to specifically try and eliminate this type of virtualized automation. Or, something else entirely - without knowing which game you are trying to automate I am left with guess work.
That said, with your reference to an in-game chat box, I strongly suspect you are trying to automate an online multi-player game. Even if you are just doing it for your own personal interest (and not to get an advantage over other players), that kind of thing is frowned upon and can potentially get your game account banned. I would normally suggest you share which game you are trying to automate with the community to get more specific information, but I doubt you will be happy to do that.

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.

How to move a table-game's pieces with drag and drop using python's tkinter and canvas?

As a beginner I would like to finish this project of a table game called "Ming Mang". I created a GUI with python tkinter-canvas and can't seem to handle part where I get to move the pieces (that can only move in a + direction, no x movements) on the table. Please, note that I am a beginner in python, and don't really understand some of the advanced properties. So, it would be perfect if you could suggest a few simple functions (not too simple though :D ).
I will join my code bellow (if I can).
thanks
enter image description here

what framework to use for python card game?

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.

What is the right way to design an adventure game with PyGame?

I have started development on a small 2d adventure side view game together with a couple of people. The game will consist of the regular elements: A room, a main character, an inventory, npcs, items and puzzles. We've chosen PyGame since we all are familiar with python from before. My question is quite theoretical, but how would we design this in a good way? Would every object on the screen talk to some main loop that blits everything to the screen?
(Hope this question isn't too discussion-y)
Thanks
Python Adventure Writing System - http://home.fuse.net/wolfonenet/PAWS.htm - might be useful
http://proquestcombo.safaribooksonline.com/1592000770 may also be useful

Categories

Resources