Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [PyGame] Problem when moving game window
#1
When I start the program, the widow often opens off to the side and I need to move it to see the whole thing. I click the title bar, move the window, and when the game redraws all the sprites have moved and are in places they shouldn't be able to get to. This doesn't happen if the game is paused.

Is there a way to stop this or is it just something basic to python? Perhaps I can code it pause while the title bar is clicked on? If you know of how to code where the window should open on my monitor that would work, but I'd rather just fix the problem.
Quote
#2
The position of the pygame window should have no effect on what is draw on the window. So moving the window should not mess up the graphics of the game. Resizing, however, can mess it up if not coded properly. So i am not sure if i am misunderstanding you? Unless you are purposefully changing code based on window movement?

You can see this tutorial under "window modifications" for window placement.
Quote
#3
I don't think you misunderstand. The window opens, the program starts running, and if it is running while I click on the title bar and move it, when I let go the sprites are all over the place and in places they should not be.

OK, so just this moment I did some experimenting. The problem is not really with moving the window, just clicking on the title bar. The enemies are trying to get me through the wall, but can't. I click and then appear on the other side of the wall. It gets weirder. I clicked and held the title bar, I heard a whole bunch of sounds like the enemies were taking damage, which then stopped. I let go and when the window drew the next frame all the enemies where gone. The player was unhurt by the enemies all killed each other... but they aren't coded to do that. lol.

I think I'll just make it start on Pause for now. If this all doesn't ring a bell then my describing it won't be of much use.

Once I'm done the tutorial maybe I'll nice it up and post a .zip for someone to run and look at if they want. It's really weird.
Quote
#4
Hope this works: https://github.com/Michaelm1789/All-my-stuff

Try running it, get to where and enemy is trying to get you behind a wall and click and hold the title bar for a second or two and let go. I don't have all the SFX balanced, so you may want to lower your volume a bit.

Hit 'n' to turn off "night mode" if you prefer. It's a faithful copy of the tutorial, so I didn't change anything that would matter.

There might be no fix, but it's definitely a bug. If it doesn't happen to you then I know it's my machine.
Quote
#5
metulburr@ubuntu:~/Downloads/Tile Based Game$ python3 main.py 
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "main.py", line 254, in <module>
    g = Game()
  File "main.py", line 35, in __init__
    self.load_data()
  File "main.py", line 71, in load_data
    self.item_images[item] = pg.image.load(path.join(img_folder, ITEM_IMAGES[item])).convert_alpha()
pygame.error: Couldn't open img/shotgun.png
(Jan-14-2020, 06:24 PM)michael1789 Wrote: Try running it, get to where and enemy is trying to get you behind a wall and click and hold the title bar for a second or two and let go.

You should use the exact filename as linux is case sensitive. It would make your programs more available. I had to change all the filenames to even run it.

Regarding your issue...i dont have that happen based on what you explained to replicate the issue. Nothing odd happens when i hold the title bar mid game or move the window behind a wall with enemies on the other side.
Quote
#6
Thank-you for checking. Sorry about the file names, I has no idea about that.

It'll have to stay a mystery. I'm running a dinosaur of a laptop. Could be Windows 10 and an ancient graphics card or some other thing unique to my setup. At least I know it's not in the program.

Thanks again!

M.
Quote
#7
If its windows 10 then its not that ancient. What are the python and pygame versions you are using?

To find out what windows version you are using type dxdiag in your search bar in windows and run the program associated with it. A window will popup with information about your system including what windows version is being used currently.
Quote
#8
I bought it from a guy who fixes up old computers and sends them to El Salvador. I googled it and this model was released 10 years ago (2010). lol. That's pretty old.

Widows 10 pro 64 bit (10.0, build 17763)
Python 3.8.0
Pygame 1.9.6
Quote
#9
For the record i bought the desktop i ran your program on in 2011. It is actually my main computer since then still. I dont think that is the issue.

What was your pygame installation process? Did you use pip to install, a wheel, etc.? Does it happen every time or once in awhile? Is it a certain spot on the wall or anywhere? How long does it take at the wall for it to occur? Does it happen on startup and title grab or both?

I would create debuging logic to identify what is going on at the time for every kill as well as the player to see how it jumped over the wall exactly. A screencast of the issue may help since i can not replicate it. You could also try decreasing the FPS to identify what is going on to slow it down.
Quote
#10
pip install pygame

What screen capture software would you recommend? I've never done that before.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  [PyGame] Problem With Entering Game Loop ElevenDecember 3 211 Jan-19-2020, 08:25 AM
Last Post: michael1789
  Snake Game - obstacle problem Samira 3 642 Oct-31-2019, 02:58 PM
Last Post: Samira
  [PyGame] Game Logic problem with a "The Game of Life" Replication Coda 2 895 Dec-24-2018, 09:26 AM
Last Post: Coda
  [PyGame] Pong game key.event problem erickDarko 2 1,636 Dec-12-2018, 03:17 PM
Last Post: erickDarko

Forum Jump:


Users browsing this thread: 1 Guest(s)