Difference between revisions of "User:Etho/Physics Engine"
From Worms Knowledge Base
m (horizontal×vertical) |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | + | {{ParentArticle|[[:Category:Miscellaneous research notes]]}} | |
− | x = x0 + vx0*t + w*t*(t+1)/2 | + | x = x0 + vx0*t + w*t*(t+1)/2 |
− | y = y0 + vy0*t + g*t*(t+1)/2 | + | y = y0 + vy0*t + g*t*(t+1)/2 |
− | vx = vx0 + w*t | + | vx = vx0 + w*t |
− | vy = vy0 + g*t | + | vy = vy0 + g*t |
Where | Where | ||
− | t = time in ticks, a.k.a. frames (50ths of a second) | + | * t = time in ticks, a.k.a. frames (50ths of a second) |
− | x = horizontal position (pixels) | + | * x = horizontal position (pixels) |
− | y = vertical position (pixels) | + | * y = vertical position (pixels) |
− | x0 = initial horizontal position (pixels) | + | * x0 = initial horizontal position (pixels) |
− | y0 = initial vertical position (pixels) | + | * y0 = initial vertical position (pixels) |
− | vx = horizontal speed (pixels per tick) | + | * vx = horizontal speed (pixels per tick) |
− | vy = vertical speed (pixels per tick) | + | * vy = vertical speed (pixels per tick) |
− | vx0 = initial horizontal speed (pixels per tick) | + | * vx0 = initial horizontal speed (pixels per tick) |
− | vy0 = initial vertical speed (pixels per tick) | + | * vy0 = initial vertical speed (pixels per tick) |
− | w = wind (pixels per tick per tick) | + | * w = wind (pixels per tick per tick) |
− | g = gravity (pixels per tick per tick) | + | * g = gravity (pixels per tick per tick) |
And g=0.24. For a worm of course, w=0. | And g=0.24. For a worm of course, w=0. | ||
ProvX = ((iPosX(X)) + (VeloX(X) / 1000) * Tick(X) + ((WindSpeed / 1000) * (Wind(X) / 100)) * Tick(X) * (Tick(X) + 1) / 2) | ProvX = ((iPosX(X)) + (VeloX(X) / 1000) * Tick(X) + ((WindSpeed / 1000) * (Wind(X) / 100)) * Tick(X) * (Tick(X) + 1) / 2) | ||
+ | |||
ProvY = ((iPosY(X)) + (VeloY(X) / 1000) * Tick(X) + (Gravity / 1000) * Tick(X) * (Tick(X) + 1) / 2) | ProvY = ((iPosY(X)) + (VeloY(X) / 1000) * Tick(X) + (Gravity / 1000) * Tick(X) * (Tick(X) + 1) / 2) | ||
− | Add gravity to vertical speed. | + | * Add gravity to vertical speed. |
− | Add wind to horizontal speed. | + | * Add wind to horizontal speed. |
− | Add horizontal speed to provisional X coordinate. | + | * Add horizontal speed to provisional X coordinate. |
− | Add vertical speed to provisional Y coordinate. | + | * Add vertical speed to provisional Y coordinate. |
− | Check for collisions between last coordinates and provisional coordinates; if there's a collision, handle it. Otherwise, move to provisional coordinates. | + | * Check for collisions between last coordinates and provisional coordinates; if there's a collision, handle it. Otherwise, move to provisional coordinates. |
− | Start again for the next frame. | + | * Start again for the next frame. |
* FPS = 50/sec | * FPS = 50/sec | ||
Line 42: | Line 43: | ||
* forward jump | * forward jump | ||
* max speed = 32 pixels/frame | * max speed = 32 pixels/frame | ||
+ | |||
Screen Width = 6012 | Screen Width = 6012 | ||
+ | |||
2046 - 1920 - 2046 | 2046 - 1920 - 2046 | ||
+ | Vertical Distance of a 90 degree bazooka = 1200 pixels (aprox); velocity = -24.12 | ||
− | |||
Wormmask = SpriteX + 25, SpriteY + 21 | Wormmask = SpriteX + 25, SpriteY + 21 | ||
− | Forward Jump = 45 - 16 = 29; velocity = sin(60) * 4.5 | + | Forward Jump = 45 - 16 = 29; velocity = sin(60) * 4.5 |
− | At 0/0. horizontal change = 70 pixels, = +/-2.25 | + | At 0/0. horizontal change = 70 pixels, = +/-2.25 |
− | Backwards Jump = 54 - 16 = 38; velocity = sin(80) * 4.5 | + | Backwards Jump = 54 - 16 = 38; velocity = sin(80) * 4.5 |
− | At 0/0. horizontal change = 28 pixels, = +/-0.7814167995 | + | At 0/0. horizontal change = 28 pixels, = +/-0.7814167995 |
− | Straight Jump = 55 - 16 = 39; velocity => -4.446... < 4.502... | + | Straight Jump = 55 - 16 = 39; velocity => -4.446... < 4.502... |
− | At 0/0. horizontal change = 0 pixels, = 0 | + | At 0/0. horizontal change = 0 pixels, = 0 |
− | Backflip Jump = 87 - 16 = 71; velocity => -5.9583... < 6.000 sin(85)*6? | + | Backflip Jump = 87 - 16 = 71; velocity => -5.9583... < 6.000 sin(85)*6? |
− | At 0/0, horizontal change = 21 pixels; = +/- 0.434 | + | At 0/0, horizontal change = 21 pixels; = +/- 0.434 |
X = 0.42413 | X = 0.42413 | ||
+ | |||
Y = -5.98799 | Y = -5.98799 | ||
+ | |||
it starts with 90-3.6 degrees (86.4 degrees) with magnitude 4.5 then multiplies X by 3/2 and Y by 4/3 | it starts with 90-3.6 degrees (86.4 degrees) with magnitude 4.5 then multiplies X by 3/2 and Y by 4/3 | ||
Walking Frame Rate = 50 / 3 (3 cycles per second) | Walking Frame Rate = 50 / 3 (3 cycles per second) | ||
− | +0.50 | + | +0.50 |
− | no motion | + | no motion |
− | +0.50 | + | +0.50 |
− | +0.50 | + | +0.50 |
− | +0.50 | + | +0.50 |
− | +0.50 | + | +0.50 |
− | +1.50 | + | +1.50 |
− | +1.75 | + | +1.75 |
− | +1.50 | + | +1.50 |
− | +1.25 | + | +1.25 |
− | skip here and avoid the slower phase: | + | skip here and avoid the slower phase: |
− | +0.25 | + | +0.25 |
− | no motion | + | no motion |
− | +0.25 | + | +0.25 |
− | +0.25 | + | +0.25 |
− | +0.25 | + | +0.25 |
− | no motion | + | no motion |
− | no motion | + | no motion |
− | no motion | + | no motion |
repeat - but not quite; "no motion" frames shift and the period of true repetition is 50 frames travelling 27 pixels | repeat - but not quite; "no motion" frames shift and the period of true repetition is 50 frames travelling 27 pixels | ||
The optimum skipwalk cycle is actually 4.545 per second, because it has a period of 11 frames = 11/50 second. | The optimum skipwalk cycle is actually 4.545 per second, because it has a period of 11 frames = 11/50 second. | ||
+ | |||
Fall Damage = 158 pixels - 16 pixels = 142 pixels | Fall Damage = 158 pixels - 16 pixels = 142 pixels | ||
− | worm rect = | + | worm rect = 9x16 |
− | + | A worm's collision mask looks like this: | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | XXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXXXX | ||
+ | XXXXX | ||
+ | XXXXX | ||
+ | XXXXX | ||
+ | |||
+ | == See also == | ||
+ | * [[Worm Walking]] | ||
− | + | [[Category:Miscellaneous research notes]] |
Latest revision as of 10:13, 2 February 2012
x = x0 + vx0*t + w*t*(t+1)/2 y = y0 + vy0*t + g*t*(t+1)/2 vx = vx0 + w*t vy = vy0 + g*t
Where
- t = time in ticks, a.k.a. frames (50ths of a second)
- x = horizontal position (pixels)
- y = vertical position (pixels)
- x0 = initial horizontal position (pixels)
- y0 = initial vertical position (pixels)
- vx = horizontal speed (pixels per tick)
- vy = vertical speed (pixels per tick)
- vx0 = initial horizontal speed (pixels per tick)
- vy0 = initial vertical speed (pixels per tick)
- w = wind (pixels per tick per tick)
- g = gravity (pixels per tick per tick)
And g=0.24. For a worm of course, w=0.
ProvX = ((iPosX(X)) + (VeloX(X) / 1000) * Tick(X) + ((WindSpeed / 1000) * (Wind(X) / 100)) * Tick(X) * (Tick(X) + 1) / 2)
ProvY = ((iPosY(X)) + (VeloY(X) / 1000) * Tick(X) + (Gravity / 1000) * Tick(X) * (Tick(X) + 1) / 2)
- Add gravity to vertical speed.
- Add wind to horizontal speed.
- Add horizontal speed to provisional X coordinate.
- Add vertical speed to provisional Y coordinate.
- Check for collisions between last coordinates and provisional coordinates; if there's a collision, handle it. Otherwise, move to provisional coordinates.
- Start again for the next frame.
- FPS = 50/sec
- standard gravity = 0.24
- standard friction = 0.96
- low gravity friction = 0.99
friction multiplies a number every frame until the number becomes small enough
- max pixel climb walking = 14 pixels
- max pixel decline walking = 13 pixels
- max pixel climb sliding = 1 pixel
- color key = 0
- forward jump
- max speed = 32 pixels/frame
Screen Width = 6012
2046 - 1920 - 2046
Vertical Distance of a 90 degree bazooka = 1200 pixels (aprox); velocity = -24.12
Wormmask = SpriteX + 25, SpriteY + 21
Forward Jump = 45 - 16 = 29; velocity = sin(60) * 4.5 At 0/0. horizontal change = 70 pixels, = +/-2.25 Backwards Jump = 54 - 16 = 38; velocity = sin(80) * 4.5 At 0/0. horizontal change = 28 pixels, = +/-0.7814167995 Straight Jump = 55 - 16 = 39; velocity => -4.446... < 4.502... At 0/0. horizontal change = 0 pixels, = 0 Backflip Jump = 87 - 16 = 71; velocity => -5.9583... < 6.000 sin(85)*6? At 0/0, horizontal change = 21 pixels; = +/- 0.434
X = 0.42413
Y = -5.98799
it starts with 90-3.6 degrees (86.4 degrees) with magnitude 4.5 then multiplies X by 3/2 and Y by 4/3
Walking Frame Rate = 50 / 3 (3 cycles per second)
+0.50 no motion +0.50 +0.50 +0.50 +0.50 +1.50 +1.75 +1.50 +1.25 skip here and avoid the slower phase: +0.25 no motion +0.25 +0.25 +0.25 no motion no motion no motion
repeat - but not quite; "no motion" frames shift and the period of true repetition is 50 frames travelling 27 pixels
The optimum skipwalk cycle is actually 4.545 per second, because it has a period of 11 frames = 11/50 second.
Fall Damage = 158 pixels - 16 pixels = 142 pixels
worm rect = 9x16
A worm's collision mask looks like this:
XXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXXXX XXXXXXX XXXXXXX XXXXXXX XXXXX XXXXX XXXXX