3320 // the gear has, also get the vector offset |
3320 // the gear has, also get the vector offset |
3321 pspeed:= (Gear^.dX * iterator^.dX + Gear^.dY * iterator^.dY); |
3321 pspeed:= (Gear^.dX * iterator^.dX + Gear^.dY * iterator^.dY); |
3322 ox := (iterator^.X - Gear^.X); |
3322 ox := (iterator^.X - Gear^.X); |
3323 oy := (iterator^.Y - Gear^.Y); |
3323 oy := (iterator^.Y - Gear^.Y); |
3324 poffs:= (Gear^.dX * ox + Gear^.dY * oy); |
3324 poffs:= (Gear^.dX * ox + Gear^.dY * oy); |
3325 // create a normal of the portal vector |
3325 // create a normal of the portal vector, but ... |
3326 nx := - Gear^.dY; |
3326 nx := Gear^.dY; |
3327 ny := Gear^.dX; |
3327 ny := Gear^.dX; |
3328 // pick the normal vector that's pointing skywards |
3328 // ... decide where the top is based on the hog's direction when firing the portal |
3329 if (not ny.isNegative) then |
3329 if Gear^.Elasticity.isNegative then |
3330 begin |
3330 nx.isNegative := not nx.isNegative |
3331 nx.isNegative := not nx.isNegative; |
3331 else |
3332 ny.isNegative := not ny.isNegative; |
3332 ny.isNegative := not ny.isNegative; |
3333 end; |
3333 |
3334 // now let's find out how much speed the gear has in the |
3334 // now let's find out how much speed the gear has in the |
3335 // direction of that normal |
3335 // direction of that normal |
3336 nspeed:= (nx * iterator^.dX + ny * iterator^.dY); |
3336 nspeed:= (nx * iterator^.dX + ny * iterator^.dY); |
3337 noffs:= (nx * ox + ny * oy); |
3337 noffs:= (nx * ox + ny * oy); |
3338 |
3338 |
3339 // now let's project those back to the connected portal's vectors |
3339 // now let's project those back to the connected portal's vectors |
3340 nx := - conPortal^.dY; |
3340 nx := conPortal^.dY; |
3341 ny := conPortal^.dX; |
3341 ny := conPortal^.dX; |
3342 if ny.isNegative then |
3342 if conPortal^.Elasticity.isNegative then |
3343 begin |
3343 nx.isNegative := not nx.isNegative |
3344 nx.isNegative := not nx.isNegative; |
3344 else |
3345 ny.isNegative := not ny.isNegative; |
3345 ny.isNegative := not ny.isNegative; |
3346 end; |
3346 |
3347 //AddFileLog('poffs:'+cstr(poffs)+' noffs:'+cstr(noffs)+' pspeed:'+cstr(pspeed)+' nspeed:'+cstr(nspeed)); |
3347 //AddFileLog('poffs:'+cstr(poffs)+' noffs:'+cstr(noffs)+' pspeed:'+cstr(pspeed)+' nspeed:'+cstr(nspeed)); |
3348 iterator^.dX := -pspeed * conPortal^.dX - nspeed * nx; |
3348 iterator^.dX := -pspeed * conPortal^.dX + nspeed * nx; |
3349 iterator^.dY := -pspeed * conPortal^.dY - nspeed * ny; |
3349 iterator^.dY := -pspeed * conPortal^.dY + nspeed * ny; |
3350 if iterator^.Kind = gtCake then |
3350 if iterator^.Kind = gtCake then |
3351 poffs := poffs * _0_5; |
3351 poffs := poffs * _0_5; |
3352 iterator^.X := conPortal^.X + poffs * conPortal^.dX + noffs * nx; |
3352 iterator^.X := conPortal^.X + poffs * conPortal^.dX + noffs * nx; |
3353 iterator^.Y := conPortal^.Y + poffs * conPortal^.dY + noffs * ny; |
3353 iterator^.Y := conPortal^.Y + poffs * conPortal^.dY + noffs * ny; |
3354 |
3354 |
3473 newPortal^.IntersectGear := nil; |
3473 newPortal^.IntersectGear := nil; |
3474 |
3474 |
3475 if CurrentHedgehog <> nil then |
3475 if CurrentHedgehog <> nil then |
3476 With CurrentHedgehog^ do |
3476 With CurrentHedgehog^ do |
3477 begin |
3477 begin |
|
3478 // let's save the HH's dX's direction so we can decide where the "top" of the portal hole |
|
3479 newPortal^.Elasticity.isNegative := CurrentHedgehog^.Gear^.dX.isNegative; |
|
3480 // when doing a backjump the dx is the opposite of the facing direction |
|
3481 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then |
|
3482 newPortal^.Elasticity.isNegative := not newPortal^.Elasticity.isNegative; |
|
3483 |
3478 // make portal gun look unloaded |
3484 // make portal gun look unloaded |
3479 Ammo^[CurSlot, CurAmmo].Timer := Ammo^[CurSlot, CurAmmo].Timer or 2; |
3485 Ammo^[CurSlot, CurAmmo].Timer := Ammo^[CurSlot, CurAmmo].Timer or 2; |
3480 |
3486 |
3481 // set portal to the currently chosen color |
3487 // set portal to the currently chosen color |
3482 if ((Ammo^[CurSlot, CurAmmo].Timer and 1) <> 0) then |
3488 if ((Ammo^[CurSlot, CurAmmo].Timer and 1) <> 0) then |