77 implementation |
77 implementation |
78 uses uCollisions, uVariables, Math, uConsts, uVisualGearsList, uFloat, uSound, uRenderUtils, uWorld, uUtils; |
78 uses uCollisions, uVariables, Math, uConsts, uVisualGearsList, uFloat, uSound, uRenderUtils, uWorld, uUtils; |
79 |
79 |
80 procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
80 procedure doStepFlake(Gear: PVisualGear; Steps: Longword); |
81 var sign: real; |
81 var sign: real; |
82 moved: boolean; |
82 moved, rising, outside: boolean; |
83 vfc, vft: LongWord; |
83 vfc, vft: LongWord; |
|
84 spawnMargin: LongInt; |
|
85 const |
|
86 randMargin = 50; |
84 begin |
87 begin |
85 if SuddenDeathDmg then |
88 if SuddenDeathDmg then |
86 begin |
89 begin |
87 if (vobSDCount = 0) then exit; |
90 if (vobSDCount = 0) then exit; |
88 end |
91 end |
161 begin |
164 begin |
162 X:= X - cScreenSpace; |
165 X:= X - cScreenSpace; |
163 moved:= true |
166 moved:= true |
164 end; |
167 end; |
165 |
168 |
166 if round(Y) < (LAND_HEIGHT - 1024 - 75) then |
169 // it's possible for flakes to move upwards |
|
170 if SuddenDeathDmg then |
|
171 rising:= (cGravityf * vobSDFallSpeed) < 0 |
|
172 else |
|
173 rising:= (cGravityf * vobFallSpeed) < 0; |
|
174 |
|
175 if gear^.layer = 2 then |
|
176 spawnMargin:= 400 |
|
177 else |
|
178 spawnMargin:= 200; |
|
179 |
|
180 // flake fell far below map? |
|
181 outside:= (not rising) and (round(Y) - spawnMargin + randMargin > LAND_HEIGHT); |
|
182 // if not, did it rise far above map? |
|
183 outside:= outside or (rising and (round(Y) < LAND_HEIGHT - 1024 - spawnMargin - randMargin)); |
|
184 |
|
185 // if flake left acceptable vertical area, respawn it opposite side |
|
186 if outside then |
167 begin |
187 begin |
168 X:= cLeftScreenBorder + random(cScreenSpace); |
188 X:= cLeftScreenBorder + random(cScreenSpace); |
169 Y:= Y+(1024 + 200 + random(50)); |
189 if rising then |
170 moved:= true |
190 Y:= Y + (1024 + spawnMargin + random(50)) |
171 end |
|
172 else if (Gear^.Layer = 2) and (round(Y) - 400 > LAND_HEIGHT) and (cGravityf >= 0) then |
|
173 begin |
|
174 X:= cLeftScreenBorder + random(cScreenSpace); |
|
175 Y:= Y-(1024 + 400 + random(50)); // TODO - configure in theme (jellies for example could use limited range) |
|
176 moved:= true |
|
177 end |
|
178 else if (Gear^.Layer <> 2) and (round(Y) - 150 > LAND_HEIGHT) and (cGravityf >= 0) then |
|
179 begin |
|
180 X:= cLeftScreenBorder + random(cScreenSpace); |
|
181 Y:= Y-(1024 + 200 + random(50)); |
|
182 moved:= true |
|
183 end |
|
184 else if (round(Y) < LAND_HEIGHT-1200) and (cGravityf < 0) then // gravity can make flakes move upwards |
|
185 begin |
|
186 X:= cLeftScreenBorder + random(cScreenSpace); |
|
187 if Gear^.Layer = 2 then |
|
188 Y:= Y+(1024 + 150 + random(100)) |
|
189 else |
191 else |
190 Y:= Y+(1024 + random(50)); |
192 Y:= Y - (1024 + spawnMargin + random(50)); |
191 moved:= true |
193 moved:= true; |
192 end; |
194 end; |
|
195 |
193 if moved then |
196 if moved then |
194 begin |
197 begin |
195 Angle:= random(360); |
198 Angle:= random(360); |
196 dx:= 0.0000038654705 * random(10000); |
199 dx:= 0.0000038654705 * random(10000); |
197 dy:= 0.000003506096 * random(7000); |
200 dy:= 0.000003506096 * random(7000); |