Difference between revisions of "User:Etho/Physics Engine"

From Worms Knowledge Base

Jump to: navigation, search
m (The wiki doesn't support single line breaks, so I've made this easier to read by using lists and codes.)
m (Parent Article)
Line 1: Line 1:
 +
{{ParentArticle|[[Game logic]]}}
 
* [[Worm Walking]]
 
* [[Worm Walking]]
  

Revision as of 16:03, 2 May 2007

(Up to Game logic)
 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 = 16x9

 0XXXXXXX0
 0XXXXXXX0
 0XXXXXXX0
 0XXXXXXX0
 XXXXXXXXX
 XXXXXXXXX
 XXXXXXXXX
 XXXXXXXXX
 XXXXXXXXX
 XXXXXXXXX
 0XXXXXXX0
 0XXXXXXX0
 0XXXXXXX0
 00XXXXX00
 00XXXXX00
 00XXXXX00
Personal tools