This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-10-15 22:02:08

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Flawless box physics

For a game I'm working on, I'm trying to create a box with perfect physics. It would be a rigid body, and fall based on how far from an edge it is. It would also need restitution and velocity for the turning to be applied as well. If anyone could help me it would be greatly appreciated. I have a few ideas, but I'd love if some of the resident physics scratchers (AB3, amcerbu, etc.) could point me in the right direction. When I get a chance I'll post a rough script. Thanks if anyone can help. I appreciate it, since this is a more difficult problem to tackle in scratch. (By all this I don't mean turn x degrees base in some sensors, I mean the real deal all out math approach. It'll likely require trig and advanced knowledge of the scratch functions).


........................................................................................................................................................................................................................................

Offline

 

#2 2012-10-15 22:15:42

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Flawless box physics

I've been trying to figure this out for a while as well.  Here's a Google document with some drawings and equations that I wrote up while I was working on figuring out the math.  I sort of abandoned it (maybe this will get me back working on it again). 

Anyway, here's the document.  I've made it public to anyone who has the link.  You don't need a Google account to view. 
https://docs.google.com/document/d/1Pzo … 0RDpk/edit

Last edited by amcerbu (2012-10-15 22:17:21)

Offline

 

#3 2012-10-15 22:27:03

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Flawless box physics

That looks scary on my phone  tongue . I'll take a look later when I'm on my laptop, thanks.


........................................................................................................................................................................................................................................

Offline

 

#4 2012-10-15 23:04:05

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: Flawless box physics

*commenting on topic so I remember it exists*


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

#5 2012-10-15 23:09:16

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Flawless box physics

Oh, it's for the Portal clone, isn't it?  The companion cube, must be.

Offline

 

#6 2012-10-15 23:26:55

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Flawless box physics

Interesting question...looks like there's going to be a lot of math discussed here so I'll see if I can help at some point.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#7 2012-10-15 23:28:54

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Flawless box physics

Wow. Did I seriously script this

when gf clicked

go to x: (0) y: (-90)
set [xv v] to [0]
set [yv v] to [0]
forever  

set [bleh v] to [0]
set [xv v] to ((xv) * (0.9))
change x by (xv)
if <touching color [#000008]?> 

change x by ((xv) * (-1))
set [xv v] to [0]
end

set [yv v] to ((yv) * (0.9))
change y by (yv)
if <touching color [#000008]?> 

set [ytempstore v] to (yv)
change y by ((yv) * (-1))
set [yv v] to [0]
end

if <(yv) < [4]> 

change y by (-1)
if <not <touching color [#000008]?>> 

change [yv v] by (-1)
end

change y by (1)
end

set [tempdirstore v] to (direction)
point in direction (90 v)
change y by (-1)
if <touching color [#000008]?>

change x by (24)
if <touching color [#000008]?>

set [side v] to [l]
change x by (-48)
if <touching color [#000008]?> 

set [side v] to [none]
end

change x by (24)
else

change x by (-48)
if <touching color [#000008]?> 

set [side v] to [r]
end

change x by (24)
end

else

set [side v] to [none]
end

change y by (1)
point in direction (tempdirstore)
if <(side) = [r]>

turn cw (ytempstore) degrees
else

turn ccw (ytempstore) degrees
end

end

? ._.


........................................................................................................................................................................................................................................

Offline

 

#8 2012-10-15 23:44:58

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Flawless box physics

amcerbu wrote:

Oh, it's for the Portal clone, isn't it?  The companion cube, must be.

Yep. And thanks for your help, I appreciate it.


........................................................................................................................................................................................................................................

Offline

 

#9 2012-10-16 23:56:03

amcerbu
Scratcher
Registered: 2009-07-21
Posts: 500+

Re: Flawless box physics

Okay, I'll probably have time to work on 2D rigid body physics over the weekend.  I've compiled a bunch of PDFs about this stuff, because I intended to do some legitimate research and find out the real answer, rather than trying random things and hoping they'd work. 

I've got a bunch of crazy computer science/physics papers saved in a "Physics Programming" folder.  I just haven't had the chance to decipher them yet.

Offline

 

#10 2012-10-17 00:04:06

zubblewu
Scratcher
Registered: 2011-02-17
Posts: 1000+

Re: Flawless box physics

amcerbu wrote:

Okay, I'll probably have time to work on 2D rigid body physics over the weekend.  I've compiled a bunch of PDFs about this stuff, because I intended to do some legitimate research and find out the real answer, rather than trying random things and hoping they'd work. 

I've got a bunch of crazy computer science/physics papers saved in a "Physics Programming" folder.  I just haven't had the chance to decipher them yet.

Awesome. You have no idea how much I appreciate all the help you've been  tongue


........................................................................................................................................................................................................................................

Offline

 

#11 2012-10-17 01:08:52

fg123
Scratcher
Registered: 2008-11-13
Posts: 1000+

Re: Flawless box physics

amcerbu is quite amazing at this stuff. I'm good with the whole scratch thing, but hopelessly flail at math.


Hai.

Offline

 

#12 2012-10-17 04:21:43

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: Flawless box physics

Good stuff, amcerbu! I'm actually in the middle of implementing an engine for this in JS here.


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer