@@ -319,6 +319,7 @@ fn ensure_environment_initialized(state: &mut AquariumState) {
319
319
/// Update the aquarium by one tick with simple wall-bounce physics and environment.
320
320
pub fn update_aquarium ( state : & mut AquariumState , assets : & [ FishArt ] ) {
321
321
let ( aw, ah) = ( state. size . 0 as f32 , state. size . 1 as f32 ) ;
322
+ let dt: f32 = 0.033 ;
322
323
323
324
// Ensure environment exists.
324
325
ensure_environment_initialized ( state) ;
@@ -332,7 +333,7 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
332
333
state. env . ships . push ( Ship {
333
334
x : -( sw as f32 ) ,
334
335
y : 0 ,
335
- vx : 1 .0,
336
+ vx : 6 .0,
336
337
} ) ;
337
338
}
338
339
if state. env . sharks . is_empty ( ) {
@@ -343,7 +344,7 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
343
344
state. env . sharks . push ( Shark {
344
345
x : -40.0 ,
345
346
y,
346
- vx : 1.2 ,
347
+ vx : 8.0 ,
347
348
} ) ;
348
349
}
349
350
if state. env . whales . is_empty ( ) {
@@ -352,12 +353,12 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
352
353
state. env . whales . push ( Whale {
353
354
x : state. size . 0 as f32 + 10.0 ,
354
355
y,
355
- vx : -0.6 ,
356
+ vx : -4.0 ,
356
357
} ) ;
357
358
}
358
359
for fish in & mut state. fishes {
359
- fish. position . 0 += fish. velocity . 0 ;
360
- fish. position . 1 += fish. velocity . 1 ;
360
+ fish. position . 0 += fish. velocity . 0 * dt ;
361
+ fish. position . 1 += fish. velocity . 1 * dt ;
361
362
362
363
let ( fw, fh) = assets
363
364
. get ( fish. fish_art_index )
@@ -398,16 +399,16 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
398
399
} ;
399
400
state. bubbles . push ( Bubble {
400
401
position : ( bx, mid_y) ,
401
- velocity : ( 0.0 , -0.3 ) ,
402
+ velocity : ( 0.0 , -3.0 ) ,
402
403
} ) ;
403
404
}
404
405
}
405
406
406
407
// Update bubbles (rise) and cull above waterline (y < 0).
407
408
let mut kept = Vec :: with_capacity ( state. bubbles . len ( ) ) ;
408
409
for mut b in state. bubbles . drain ( ..) {
409
- b. position . 0 += b. velocity . 0 ;
410
- b. position . 1 += b. velocity . 1 ;
410
+ b. position . 0 += b. velocity . 0 * dt ;
411
+ b. position . 1 += b. velocity . 1 * dt ;
411
412
if b. position . 1 >= 0.0 {
412
413
kept. push ( b) ;
413
414
}
@@ -416,7 +417,7 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
416
417
417
418
// Move ships.
418
419
for ship in & mut state. env . ships {
419
- ship. x += ship. vx ;
420
+ ship. x += ship. vx * dt ;
420
421
let ( sw, _) = if ship. vx >= 0.0 {
421
422
measure_block ( SHIP_R )
422
423
} else {
@@ -431,7 +432,7 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
431
432
432
433
// Move sharks.
433
434
for shark in & mut state. env . sharks {
434
- shark. x += shark. vx ;
435
+ shark. x += shark. vx * dt ;
435
436
let ( sw, _) = if shark. vx >= 0.0 {
436
437
measure_block ( SHARK_R )
437
438
} else {
@@ -448,7 +449,7 @@ pub fn update_aquarium(state: &mut AquariumState, assets: &[FishArt]) {
448
449
449
450
// Move whales.
450
451
for whale in & mut state. env . whales {
451
- whale. x += whale. vx ;
452
+ whale. x += whale. vx * dt ;
452
453
let ( ww, _) = if whale. vx >= 0.0 {
453
454
measure_block ( WHALE_R )
454
455
} else {
0 commit comments