Throwing stuff with the mouses force or velocity

For questions about using Classic.

Post » Sat Nov 15, 2008 5:15 pm

I need to write a bit of code that lets me grab a platform with the mouse and then throw it with the mouse. Any one have any Ideas on how to do this or example .caps?

here is the psudocode I am currently using
Platform Variables needed:
+startX
+startY

+curX
+curY
+clicked
:::::::::::::::::::::::::::::::
+On click [platform]:
-set : startX = mousex
-set : startY= mousey
-set :clicked =1
____________________
+On Mouse Hold:
-set : currentX = Xmouse
-set : currentY = Ymouse
______________________
+On Mouse Up
+Clicked = 1

-X velocity = startX-currentX (//iffy code here, but use these numbers together to get a speed)
-Y velocity = startY-currentY
______________________
+Every 3 ticks:
+On Mouse Hold:
-set : startX = currentX
-set : startY= currentY
// so the platform does not go flying if it is held in 1 spot too long....
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Sat Nov 15, 2008 7:04 pm

Hope this helps:

http://willhostforfood.com/users/deadey ... ndtoss.cap

I had this example lying around from way back when, I just re-made it for the current physics engine.

There's a bug though, if you let go of the left mouse button while the mouse is outside of the window, the lock-on for the object you picked up isn't reset, so next time you pick up an object it will pick up the previous one along with it. This can be fixed pretty easily though, I just didn't bother.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Nov 15, 2008 7:41 pm

worked great thanks a bunch!
B
5
S
2
G
4
Posts: 632
Reputation: 2,829

Post » Sat Nov 15, 2008 10:33 pm

No problem :)
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests