Hi Everyone. I have been working towards making a game and I've been hitting a few brick walls.I was working on making the particles on screen be able to be clicked and dragged. They click and drag just fine, but when one is dragged beyond the bounds of the screen, that's when I witness a glitch.I did some print statements and I have observed that the sprites are being removed from the group (and they do get deleted on the wall collision check under other circumstances no problem).I have a problem if the user happens to click and drag the image to the bounds of the screen. The image will collide with the wall and the program would recognize it. It will still stay on the mouse like it is still in the dragged state, and even though it has been removed from the group. The sprite will continue to follow the cursor even after MOUSEBUTTONUP, unless the user clicks on another sprite. The new sprite will replace the existing one and will act normally unless the user drags the sprite to the window bounds, or if I did a sprite delete like in a collision detection test. I thought this was a minor error until I was trying to do a collision detection (not shown in code).

I have been trying to figure this out, but it's a little hard for me to debug. I hope my explanation makes sense.

This is the partial code that runs just fine, isolating the trouble area:

I don't have your images so it is very hard for me to debug this. If you could put your project on github with all needed resources it would be much easier.

First thing I noticed though is that there are major drawing issues. Every object should only be drawn once per frame. Don't recall the draw functions just because you are dragging it; and don't update the screen until everything in that frame has finished. Draw everything once per frame and update the screen only once.

Thank you for the help. It 'worked for the most part until I added a method to have the items move across the screen. The only way around it was to change the dragging method. It works fine now. I'm in the process of doing other things to it.Here is the link to the github repo like you've asked.

I have a few questions. I originally used mouse.getpressed(1, 0, 0) to see if the user had left clicked down. I remember having the program work differently than if I had used MOUSEBUTTONDOWN instead. Specifically, the program took it as something literal. If the button pressed is the left click, I could get away with pressing down anywhere on the screen and then being able to drag my mouse over to the particle (while left click still activated) which would satisfy the condition of being dragged. What is the different between MOUSEBUTTONDOWN and mouse.getpressed(1, 0, 0)?

I don't quiet get what Rect.move_ip() does based on the documentation's definition of it and the part it says for rect.collidepoint() where it says "A point along the right or bottom edge is not considered to be inside the rectangle." Is that part saying that if an object is on the border of the other rectangle's right or bottom side it would not be considered? If that object was along the border of the top or left side, would the method consider the two rectangles as collided with one another?

tells you the state of all the mouse buttons. It can be called at any time. Quite often though it is not the correct tool. If you wanted to drag any sushi with you as you moused over them, while holding down the mouse though; yes, you could use this.

On the other hand is an event. We can catch it in our event loop; check what button it is that triggered the event; and then act appropriately.

Next. The difference between pygame.Rect.move() and pygame.Rect.move_ip(). The second one operates in place. This means that the act of calling it changes our original rect. Take a look at the following:

Next I would like to mention your images. Jpgs are generally a bad choice; you should generally use pngs. Jpgs ruin the pallets of images. I edited your images a bit and made some minor changes so your program will use transparency. Replace your images with the attached images and test with the following code: