How do you make a rect move to the mouse when dragged in pygame? [duplicate] - pygame

This question already has answers here:
pygame rect is slipping out of the mouse curser
(2 answers)
Drag multiple sprites with different "update ()" methods from the same Sprite class in Pygame
(2 answers)
Closed 18 days ago.
I am trying to make a rect move to the mouses location as long as it is being dragged. How can I do this? The loop I am going to store this in is
while stuff.collidepoint(pygame.mouse.get_pos()):
I tried to make it drag but my brain would not work

Related

How to impliment Gravity in a game in which the player moves by changing velocity? [duplicate]

This question already has answers here:
How to fix character constantly accelerating in both directions after deceleration Pygame?
(1 answer)
Pygame game help: Easing/Acceleration
(1 answer)
How do you properly implement gravity to a free floating space object and some sort of friction when thrusting in opposite direction
(1 answer)
Closed 1 year ago.
The game is a tile based 2d platformer.
Separately handling the velocity and acceleration on the player causes it to bug out.
This happens cause the player's velocity becomes big enough to phase through the platform.
How do I go about checking if the player is grounded or not, since I can change the y velocity of the player to 0.
Currently I have to manually set the velocity to 0 after every frame and as a result I cant implement gravity

Can I tile a background image a certain number of times? [duplicate]

This question already has answers here:
repeat css background image a set number of times
(7 answers)
Closed 2 years ago.
I know how to make a tiled background in HTML using the repeat element, but I was wondering if I could get the image to repeat a certain number of times? Is there any way I can control that...?
Sadly, there is not CSS option for this, The best hack you could get is to make more divs with this background and have them placed where you need them.
I have also heard that there is a way to do it with jquery, but that is beyond my knowledge, so you could look there.

How to have your mouse point at one point when you load a webpage? [duplicate]

This question already has answers here:
Move mouse cursor using javascript in Chrome or Firefox using any method (Plugin, GreaseMonkey?)
(3 answers)
Closed 8 years ago.
So I am making a hover game for my webpage. I just want my mouse to automatically point at a point say a button or a box i create with css when that page loads.
is there any way to do this?
No. There's no way for a web page to control the position of the mouse cursor.

How to draw a line linking two elements on HTML page? [duplicate]

This question already has answers here:
Drawing arrows on an HTML page to visualize semantic links between textual spans
(10 answers)
Closed 9 years ago.
I want to draw a line on HTML web page dynamically to connect two html elements, which can move on html page.
This action is something like connect two Rectangle's angle, like this:
Is there any way to achieve this?
You may want to look at this tutorial. This tutorial teach you how to draw lines by HTML Canvas API.
HTML5 Canvas Line Tutorial
To draw a line using HTML5 Canvas, we can use the beginPath(),
moveTo(), lineTo(), and stroke() methods.
First, we can use the beginPath() method to declare that we are about
to draw a new path. Next, we can use the moveTo() method to position
the context point (i.e. drawing cursor), and then use the lineTo()
method to draw a straight line from the starting position to a new
position. Finally, to make the line visible, we can apply a stroke to
the line using stroke(). Unless otherwise specified, the stroke color
is defaulted to black.
http://www.html5canvastutorials.com/tutorials/html5-canvas-lines/
You could use the HTML5 canvas but you will have to be more specific with your question so we can help you further.

External Flash Movie behind an HTML Overlay Div [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Div Z-Index issue with Flash movie
Okay, is there a way to have an external flash movie that I have iframed in from another server show up behind an overlay div? Currently when I open my overlay, the flash movie shows through it.
You need to make sure you either have the param wmode set to transparent or opaque - using the default setting (window) will place it above any other content (think: infinite z-index).
edit: if you are not able to embed the flash yourself, you may have issues - that param needs to be set. Is it something that you can embed yourself just by moving the embed code to your site?