How to smoothly move mouse along a line in VB.NET - vb.net

I have been trying to move the mouse pointer along a line over a given timespan with mixed results. If the timespan is small enough, then each "delta" is big enough to move without too much inaccuracy caused by rounding off a PointF to a Point.
However, for longer timespans the deltas are so small that they suffer from rounding errors which causes my mouse point to not move along the original desired line.
How can I make the mouse move from one point to another in a fairly straight line without inaccuracy?
EDIT: Perhaps these would be of use?
http://en.wikipedia.org/wiki/Bresenham%27s_line_algorithm
Moving the mouse along a diagonal line

Related

How to scatter an image with random size, position, and rotation, without using a pattern fill? (ie, no instance is cut off)

Let's say you have an image such as this...
... and you want to quickly and easily scatter it around to create foliage. How would you achieve this aside from using a pattern fill or pattern stamp tool? (Both of which have the problem of abrupt edges.)
This is the sort of result I'm looking for, where none of the instances have cut-off edges, but in a way that doesn't involve me manually copying, scaling, and rotating each and every one.
If there is a way to either paint this with a brush, or even simply click to stamp these where each click results in a single instance of the image randomly scaled and rotated, that would be amazing.
After having used PS my whole life, this is the first time I've needed to do this, and I am baffled that it doesn't seem to exist.

GML line of sight not working

Im am creating a game where the character will be able to run about a prison only able to see walls and characters within its line of sight. The following screenshot is the desired effect.
Desired effect
However I have a problem where some walls are covered up due to the top corner not being visible as seen here.
Bottom right corner wall is covered
I am using the following code
checkPlayersx = x
checkPlayersy = y
if(!collision_line(checkPlayersx,checkPlayersy,obj_player.x,obj_player.y,obj_wall,1,0)
When looking at the bottom right block, the field of view is obstructed by the top and left tiles. You may have to find an other way to trigger this block.
You might encounter this issue with some other angular blocks too. What you could do is create a new object, that would have as parent the standard wall bloc, but it would take the ID of the adjacent blocks and light up if one of the adjacent blocks it lit up.
To detect the adjacent blocks during creation, it will be essential to create this block after it's neighbors. You can use the instance_nearest() function to detect them.
But the technique I would use is slightly different. I would create a cross-shaped sprite that would, when put in place of the block, cover the centers of the adjacent blocks, and use precise collision checking. At the creation of the wall, I would replace the wall sprite by the cross, and detect collisions with the adjacent walls. All adjacent walls IDs would be stored and checked every step for lighting in order to trigger the lighting of the wall. Then I would go back to the normal wall sprite, and voilĂ  !
Hoping this helps.

SQL Server 2012 Spatial Data Type

I am trying to draw arrows. I know how to draw lines which takes me half way there but I want the tip to have a small triangle just like an arrow. However even when I use a triangle as a point, obviously it does not always point towards the direction of the line and might sometimes produce weird looking arrows.
I would like to draw the passes a player makes on a soccer field. I do that using LINESTRING and 4 coordinates I have in a table in my database. I use the xFrom, yFrom, xTo and yTo coordinates and I manage to draw lines. However I would like to have the tip of the line to show as an arrow but I found nothing in Google or in SQL documentation.
I would like to use SSRS and not any other graphics vector program because its simpler and its incorporated easily in my overall report.
Anyone can suggest a way of turning a line into an arrow?
Thanks
Okay, first off I'd like to preface this answer with the statement that using SQL Server and Reporting Services as a graphics tool is asking for trouble. This is by far, not what it was meant for.
With that being said, I believe this would work. You will need to spend some time studying, though. When manipulating images, you have several operations that you can perform. (Like Rotating, skewing, resizing, etc.) The mathematics behind these operations can be performed using matrix algebra. What you will need to do is look at the line you have created. It has a slope. If you picture that line superimposed upon X and Y axes, you can see that there is an angle between the line and the Y axis. (Assumes that the triagle's base rests upon the X axis.) That angle is the angle that you will want to rotate your triangle that you're using as the tip of the arrow. That should fix your problem. You could create a formula to do the calculations. (If the formula engine is robust enough to handle matrix algebra.)
Here are a couple of pages that give you the basics of how to rotate an image.
http://datagenetics.com/blog/august32013/index.html
http://www.fastgraph.com/makegames/3drotation/
Good luck!

Visual Basic - Change Mouse Speed on control only

I need to change the mouse speed on a Picture Box in my VB paint program.
Is there a way to do this specifically for the object without changing the system's settings?
Rather than change the speed, you could modify the distance the pointer moves for each mouse event. This may not be a permanent solution, and if the UI thread is otherwise busy it could lead to jerky movement, but the technique is simply enough you could code it in less time than I took to write this paragraph.
In your event handler for MouseMove, get the distance (X,Y) the mouse pointer has moved.
Set Cursor.Position using some scaled value (nX, nY), where n determines the distance (and hence speed) the mouse pointer moves.
In other words, you'll be treating the mouse move increment as a vector, and you'll be multiplying that vector by a scalar value to modify the speed.
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor.position.aspx
As needed, use Boolean flags within the event handler to ensure that setting Cursor.Position does not trigger another even just because set Cursor.Position to a new point.
You might find that using the same scaling factor for all distances is inappropriate. For example, multiplying the move by a factor of 2 may be okay for short distances, but much too fast for large increments, in which case a lookup table or function would calculate the desired factor.
This technique would probably perform poorly if you need to decrease the speed of a move, as it could cause the mouse pointer to jump backward some fraction of the distance of its most recent move.

Proper rotation with changing x/y coordinates

I'm trying to make a little archer game, and the problem I'm having has to do with 2 pixels in particular, I'll call them _arm and _arrow. When a real archer is pulling back an arrow, he doesn't immediately pull the arrow back as far as his strength allows him, the arrow takes a little bit of time to be pulled back.
The _arm's angle is equal to the vector from a point to where the user touched on the screen. The rotation is perfect, so the _arm is good. The _arrow needs to be on the same line as _arrow, they are 1 pixel wide each so it looks as though the _arrow is exactly on top of the _arm.
I tried to decrement from the x/y coordinates based on a variable that changes with time, and I set the _arrow's location equal to the _arm's location, and tried to make it look like the _arrow was being pulled back. however, if you rotated, the x/y would mess up because it is not proportional on the x and y axis, so basically _arrow will either be slightly above the arm or slightly below it depending on the angle of the vector, based on touch.
How could I used the x/y position of _arm and the vector of touch to make the arrow appear as though it was being pulled back by a small amount, yet keep the arrow on top of the _arm sprite so that it's position would be similar to the arm, but slightly off yet still on top of the _arm pixel at all times. If you need anymore info, just leave a comment.
I'm not sure I've fully understood, but I'll have a go at answering anyway:
To make the arrow move and rotate to the same place as the consider adding the arrow as a child of the arm. You can still render it behind if you like by making its z is less than one: [arm addChild:arrow z:-1]
To then make the arrow move away from the arm as the bow is drawn, you then just set the position of the arrow with respect to the arm.
The problem I do see with this solution however is that this grouping of the sprites may be a little unusual after the arrow leaves the bow. Here you probably don't want the arrow to be a child of the arm as the coordinate systems are no longer related.
Even though they're sure what I "suggested would have solved [the] problem" here is the
Poster's solution
I had to get the x and y coords of the arm based of angle, then I got the sin/cos of a number that was based of the same angle as the arm and subtraced from that.