Skip to content

Commit 6636627

Browse files
Add sprites for pipe rendering
1 parent 833271d commit 6636627

8 files changed

Lines changed: 86 additions & 7 deletions

src/rendering/mod.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ pub struct TextureAtlas {
181181

182182
underground: enum_map::EnumMap<Dir, enum_map::EnumMap<UndergroundDir, EntitySprite>>,
183183

184+
pipe: Vec<enum_map::EnumMap<Dir, EntitySprite>>,
185+
184186
accumulator: EntitySprite,
185187

186188
mining_drill: EntitySprite,
@@ -303,6 +305,15 @@ fn texture_atlas() -> TextureAtlas {
303305
items: vec![sprite_from_path!("temp_assets/plate.png", 1); 200].into_boxed_slice(),
304306

305307
player: sprite_from_path!("temp_assets/player.png", 1),
308+
pipe: vec![
309+
enum_map::EnumMap::from_array([
310+
entity_sprite_from_path_scaled!("temp_assets/belt_north.png", 1, 1.0),
311+
entity_sprite_from_path_scaled!("temp_assets/belt_east.png", 1, 1.0),
312+
entity_sprite_from_path_scaled!("temp_assets/belt_south.png", 1, 1.0),
313+
entity_sprite_from_path_scaled!("temp_assets/belt_west.png", 1, 1.0),
314+
]);
315+
10
316+
],
306317
belt: belts,
307318

308319
belt_corners: enum_map::EnumMap::from_array([
@@ -352,6 +363,75 @@ fn texture_atlas() -> TextureAtlas {
352363

353364
no_power: entity_sprite_from_path_scaled!("temp_assets/no_power.png", 1, 1.0),
354365

366+
pipe: vec![
367+
enum_map::EnumMap::from_array([
368+
entity_sprite_from_path_scaled!(
369+
"temp_assets/krastorio/steel-pipe-cross.png",
370+
1,
371+
1.0
372+
),
373+
entity_sprite_from_path_scaled!(
374+
"temp_assets/krastorio/steel-pipe-cross.png",
375+
1,
376+
1.0
377+
),
378+
entity_sprite_from_path_scaled!(
379+
"temp_assets/krastorio/steel-pipe-cross.png",
380+
1,
381+
1.0
382+
),
383+
entity_sprite_from_path_scaled!(
384+
"temp_assets/krastorio/steel-pipe-cross.png",
385+
1,
386+
1.0
387+
),
388+
]),
389+
enum_map::EnumMap::from_array([
390+
entity_sprite_from_path_scaled!(
391+
"temp_assets/krastorio/steel-pipe-to-ground-up.png",
392+
1,
393+
1.0
394+
),
395+
entity_sprite_from_path_scaled!(
396+
"temp_assets/krastorio/steel-pipe-to-ground-right.png",
397+
1,
398+
1.0
399+
),
400+
entity_sprite_from_path_scaled!(
401+
"temp_assets/krastorio/steel-pipe-to-ground-down.png",
402+
1,
403+
1.0
404+
),
405+
entity_sprite_from_path_scaled!(
406+
"temp_assets/krastorio/steel-pipe-to-ground-left.png",
407+
1,
408+
1.0
409+
),
410+
]),
411+
enum_map::EnumMap::from_array([
412+
entity_sprite_from_path_scaled!(
413+
"temp_assets/krastorio/big-storage-tank.png",
414+
1,
415+
1.0
416+
),
417+
entity_sprite_from_path_scaled!(
418+
"temp_assets/krastorio/big-storage-tank.png",
419+
1,
420+
1.0
421+
),
422+
entity_sprite_from_path_scaled!(
423+
"temp_assets/krastorio/big-storage-tank.png",
424+
1,
425+
1.0
426+
),
427+
entity_sprite_from_path_scaled!(
428+
"temp_assets/krastorio/big-storage-tank.png",
429+
1,
430+
1.0
431+
),
432+
]),
433+
],
434+
355435
assembler: vec![
356436
// TODO: Add animation for assembling machine
357437
entity_sprite_from_path_tiling!(

src/rendering/render_world.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ pub fn render_world<ItemIdxType: IdxTrait, RecipeIdxType: IdxTrait>(
13701370
let size =
13711371
data_store.fluid_tank_infos[usize::from(*ty)].size;
13721372

1373-
texture_atlas.belt[*rotation].draw(
1373+
texture_atlas.pipe[*ty as usize][*rotation].draw(
13741374
[
13751375
draw_offset.0 + pos.x as f32,
13761376
draw_offset.1 + pos.y as f32,
@@ -1787,13 +1787,12 @@ pub fn render_world<ItemIdxType: IdxTrait, RecipeIdxType: IdxTrait>(
17871787
pos,
17881788
rotation,
17891789
} => {
1790-
let size: [u16; 2] = [1, 1];
1791-
texture_atlas.belt[*rotation].draw(
1790+
let size = data_store.fluid_tank_infos[usize::from(*ty)].size;
1791+
1792+
texture_atlas.pipe[*ty as usize][*rotation].draw(
17921793
[
1793-
pos.x as f32 - camera_pos.0
1794-
+ num_tiles_across_screen_horizontal / 2.0,
1795-
pos.y as f32 - camera_pos.1
1796-
+ num_tiles_across_screen_vertical / 2.0,
1794+
draw_offset.0 + pos.x as f32,
1795+
draw_offset.1 + pos.y as f32,
17971796
],
17981797
size,
17991798
0,
25.9 KB
Loading
4 KB
Loading
2.14 KB
Loading
2.62 KB
Loading
2.7 KB
Loading
3.07 KB
Loading

0 commit comments

Comments
 (0)