Jump to content
SubSpace Forum Network

Recommended Posts

Posted (edited)

I think theres something like this in linux, but i made one for windows.

 

I made a custom window form derived off of .net framework that allows you to "throw" your windows around your desktop. It has friction, MinLimit, and DivideRate variables. Dividerate should be between 2 and 4. friction is between 0 and 1, 1 being no friction.

Edited by tcsoccerman
Posted

If you do a single click in the window, it will launch itself real fast (most likely considering the last MouseMove event)

 

If you drop it partially outside of your screen, it bounces left and right over and over (until speed reaches 0)

Posted (edited)

i noticedthat first comment too, so i founda a way to fix it. just reset the velocities on some certain clicks and moves.

 

 

the second one is because i have to invert the xvel and yvel if it gets to a wall, which is why that happens. don't feel like fixing that.

Edited by tcsoccerman
Posted

To fix the first problem, it's pretty simple...

 

I assume you keep a 'previouslocation' coordinate on each MouseMove events, then compare it with the current position on a MouseUp event to determine the velocity?

So to fix the problem, simply set the previouslocation to the currentlocation on the MouseDown event

 

And the second one, yeah... but you simply have to make it check for a right-edge collision only if the velocity is positive, and check for a left-edge collision if negative (same for Y velocity)

Posted (edited)

well what i did was reset the x and y velocity to 0 at certain events.

 

for the second one, thats what i do, but if you think about it deeply and look at my source, you will see why that happens. it's fixable if i create more variables and other stuff, but i just don't feel like worrying so much over a small thing like that.

 

the new version is alot better trust me.

Edited by tcsoccerman
Posted

if(xVel > 0 && xVel < minLimit && yVel > 0 && yVel < minLimit ||
xVel < 0 && xVel > -minLimit && yVel < 0 && yVel > -minLimit)

 

Make that:

if (abs(xVel) > 0 && abs(xVel) < minLimit && abs(yVel) > 0 && abs(yVel) < minLimit)

Might be Math.abs, not sure...

 

 

 

On subject:

if(((this.Location.X  + (int)(xVel)) + this.Width) > Screen.PrimaryScreen.Bounds.Width ||
 (this.Location.X  + (int)(xVel)) < 0)
{
xVel = - xVel;
}
else if(((this.Location.Y  + (int)(yVel)) + this.Height) > Screen.PrimaryScreen.Bounds.Height ||
   (this.Location.Y  + (int)(yVel)) < 0)
{
yVel = - yVel;
}

 

if(((this.Location.X + (int)(xVel)) + this.Width) > Screen.PrimaryScreen.Bounds.Width && xVel > 0 ||

(this.Location.X + (int)(xVel)) < 0 && xVel < 0)

{

xVel = - xVel;

}

else if(((this.Location.Y + (int)(yVel)) + this.Height) > Screen.PrimaryScreen.Bounds.Height && yVel > 0 ||

(this.Location.Y + (int)(yVel)) < 0 && yVel < 0)

{

yVel = - yVel;

}

 

That's what I meant

Posted
There's an EXE somewhere, it's just an empty window that you can throw around, it doesn't make you throw around ALL your windows
Posted
Go into bin/debug/testgrounds.exe then just drag and throw that screen around. Lol, I lost it outside the edge of my screen :X
Posted (edited)

rootbear-make sure you have .net framework installed. i'd also use the bin/debug/testgrounds.exe one

 

edit:

 

ok, i added sam's changes. thank you!

i also added some textbox's to change the settings while using it.

 

from top to buttom these are what they are

 

top textbox-slipperiness. the higher this number the more slippery. 1 there is no friction.

middle - dividerate. sord of confusing just mess around with it. pretty much determines how far it is thrown, 1 being farthest.

buttom - minlimit. determines when to stop moving the form, otherwise it would continue forever, moving ever so slightly.

 

have fun messing around

TestApp.zip

Edited by tcsoccerman
Guest
This topic is now closed to further replies.
×
×
  • Create New...