desdemona

drawscenery

May 13th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. private void DrawScenery(GameTime thetime)//rysowanie terenu
  2. {
  3.  
  4. for (int i = 0; i < stages[current_stage-1].ground_data.Count(); i++)
  5. {
  6. Rectangle one_block;
  7. Rectangle source_block;
  8. for (int j = 0; j < stages[current_stage - 1].ground_data[i].number_of_blocks; j++)
  9. {
  10. one_block = new Rectangle((int)stages[current_stage - 1].ground_data[i].position.X + j * stages[current_stage - 1].block_size, (int)stages[current_stage - 1].ground_data[i].position.Y, stages[current_stage - 1].block_size, stages[current_stage - 1].block_size);
  11. if (j == 0)
  12. {
  13. source_block = new Rectangle(0, 0, stages[current_stage - 1].block_size, stages[current_stage - 1].block_size);
  14.  
  15.  
  16. }
  17. else if (j == (stages[current_stage - 1].ground_data[i].number_of_blocks - 1))
  18. {
  19. //right edge texture
  20. source_block = new Rectangle(2 * stages[current_stage - 1].block_size, 0, stages[current_stage - 1].block_size, stages[current_stage - 1].block_size);
  21. }
  22. else
  23. {
  24. source_block = new Rectangle(stages[current_stage - 1].block_size, 0, stages[current_stage - 1].block_size, stages[current_stage - 1].block_size);
  25. //middle texture
  26. }
  27.  
  28. if (current_stage == 2)
  29. {
  30. source_block.Y = stages[current_stage - 1].block_size;
  31. }
  32. else if (current_stage == 3)
  33. {
  34. source_block.Y = stages[current_stage - 1].block_size;
  35. }
  36. spriteBatch.Draw(tileset, one_block, source_block, Color.White);
  37. }
  38. }
  39.  
  40. for (int i = 0; i < stages[current_stage-1].food.Count(); i++)
  41. {
  42. Rectangle source;
  43. Rectangle destination;
  44.  
  45. if (stages[current_stage - 1].food[i].type == 1)
  46. {
  47. source = new Rectangle(5, 3, 39, 39);
  48. //pizza
  49. }
  50. else if (stages[current_stage - 1].food[i].type == 2)
  51. {
  52.  
  53. //fries
  54. source = new Rectangle(45, 3, 53, 42);
  55. }
  56. else
  57. {
  58. //burger
  59. source = new Rectangle(7, 44, 44, 52);
  60. }
  61.  
  62. destination = new Rectangle((int)stages[current_stage - 1].food[i].position.X, (int)stages[current_stage - 1].food[i].position.Y - (int)source.Height, (int)source.Width, (int)source.Height);
  63.  
  64. spriteBatch.Draw(food_texture, destination, source, Color.White);
  65. }
  66.  
  67. //aurelisz
  68. for (int i = 0; i < stages[current_stage - 1].spikes_pos.Count(); i++)
  69. {
  70. Rectangle s;
  71. Rectangle d;
  72.  
  73. s = new Rectangle(0, 0, 32, 32);
  74. d = new Rectangle((int)stages[current_stage - 1].spikes_pos[i].position.X, (int)stages[current_stage - 1].spikes_pos[i].position.Y, s.Width, s.Height);
  75.  
  76. stages[current_stage - 1].spikes_pos[i].change_fequency+= (float)thetime.ElapsedGameTime.TotalSeconds;
  77. if (stages[current_stage - 1].spikes_pos[i].change_fequency > 1f)
  78. {
  79. stages[current_stage - 1].spikes_pos[i].change_fequency = 0f;
  80. if (stages[current_stage - 1].spikes_pos[i].active == true)
  81. {
  82. stages[current_stage - 1].spikes_pos[i].active = false;
  83. }
  84. else
  85. {
  86. stages[current_stage - 1].spikes_pos[i].active = true;
  87. }
  88. }
  89.  
  90. if (stages[current_stage - 1].spikes_pos[i].active == true)
  91. {
  92. spriteBatch.Draw(spikes_texture, d, s, Color.White);
  93. }
  94. //aurelisz
  95. }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment