MASSIVE performance improvement by fixing rendering
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -414,63 +414,71 @@ class _WolfRendererState extends State<WolfRenderer>
|
||||
Expanded(
|
||||
child: LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return Stack(
|
||||
children: [
|
||||
CustomPaint(
|
||||
size: Size(constraints.maxWidth, constraints.maxHeight),
|
||||
painter: RaycasterPainter(
|
||||
map: currentLevel,
|
||||
textures: gameMap.textures,
|
||||
player: player,
|
||||
fov: fov,
|
||||
doorOffsets: doorOffsets,
|
||||
entities: entities,
|
||||
sprites: gameMap.sprites,
|
||||
),
|
||||
),
|
||||
// Weapon Viewmodel
|
||||
Positioned(
|
||||
bottom: -20,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: Transform.translate(
|
||||
offset: Offset(
|
||||
0,
|
||||
// Bobbing math: only moves if velocity is > 0
|
||||
(moveStepX.abs() + moveStepY.abs()) > 0
|
||||
? math.sin(
|
||||
DateTime.now()
|
||||
.millisecondsSinceEpoch /
|
||||
100,
|
||||
) *
|
||||
12
|
||||
: 0,
|
||||
return Center(
|
||||
child: AspectRatio(
|
||||
aspectRatio: 16 / 10,
|
||||
child: Stack(
|
||||
children: [
|
||||
CustomPaint(
|
||||
size: Size(
|
||||
constraints.maxWidth,
|
||||
constraints.maxHeight,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
height: 500,
|
||||
child: CustomPaint(
|
||||
painter: WeaponPainter(
|
||||
sprite:
|
||||
gameMap.sprites[player
|
||||
.currentWeapon
|
||||
.currentSprite],
|
||||
painter: RaycasterPainter(
|
||||
map: currentLevel,
|
||||
textures: gameMap.textures,
|
||||
player: player,
|
||||
fov: fov,
|
||||
doorOffsets: doorOffsets,
|
||||
entities: entities,
|
||||
sprites: gameMap.sprites,
|
||||
),
|
||||
),
|
||||
// Weapon Viewmodel
|
||||
Positioned(
|
||||
bottom: -20,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: Center(
|
||||
child: Transform.translate(
|
||||
offset: Offset(
|
||||
0,
|
||||
// Bobbing math: only moves if velocity is > 0
|
||||
(moveStepX.abs() + moveStepY.abs()) > 0
|
||||
? math.sin(
|
||||
DateTime.now()
|
||||
.millisecondsSinceEpoch /
|
||||
100,
|
||||
) *
|
||||
12
|
||||
: 0,
|
||||
),
|
||||
child: SizedBox(
|
||||
width: 500,
|
||||
height: 500,
|
||||
child: CustomPaint(
|
||||
painter: WeaponPainter(
|
||||
sprite:
|
||||
gameMap.sprites[player
|
||||
.currentWeapon
|
||||
.currentSprite],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
if (damageFlashOpacity > 0)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.red.withValues(
|
||||
alpha: damageFlashOpacity,
|
||||
if (damageFlashOpacity > 0)
|
||||
Positioned.fill(
|
||||
child: Container(
|
||||
color: Colors.red.withValues(
|
||||
alpha: damageFlashOpacity,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user