Advertisement
Guest User

Untitled

a guest
Apr 24th, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <SFML\Graphics.hpp>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. sf::RenderWindow Okno( sf::VideoMode( 800, 600, 32 ), "sss" );
  9. const sf::Input & sterowanie = Okno.GetInput();
  10. Okno.SetFramerateLimit(60);
  11.  
  12. sf::Shape Red = sf::Shape::Rectangle(0,0,40,40,sf::Color::Red,1,sf::Color::Black);
  13. sf::Shape White = sf::Shape::Rectangle(0,0,40,40,sf::Color::White,1,sf::Color::Black);
  14.  
  15. sf::Vector2f Center(400, 300);
  16. sf::Vector2f HalfSize(400, 300);
  17. sf::View Obraz(Center,HalfSize);
  18. Okno.SetView(Obraz);
  19.  
  20. const sf::Input & mysz = Okno.GetInput();
  21.  
  22. bool Color[20][15] = {0};
  23.  
  24. string czesc;
  25. while(Okno.IsOpened())
  26. {
  27.  
  28. sf::Event Event;
  29.  
  30.  
  31.  
  32. while(Okno.GetEvent(Event))
  33. {
  34. if(Event.Type == sf::Event::MouseButtonPressed && Event.MouseButton.Button == sf::Mouse::Left)
  35. Color[((int)(mysz.GetMouseX()/40))][((int)(mysz.GetMouseY()/40))] = 1;
  36.  
  37. if(Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::Right)
  38. Obraz.Move(40,0);
  39. }
  40.  
  41.  
  42.  
  43. Okno.Clear(sf::Color::Green);
  44.  
  45. for(int x = 0 ; x < 20 ; x++)
  46. {
  47. for(int y = 0 ; y < 15 ; y++)
  48. {
  49. if(Color[x][y] == 0)
  50. {
  51. White.SetPosition(x*40,y*40);
  52. Okno.Draw(White);
  53. }
  54. else
  55. {
  56. Red.SetPosition(x*40,y*40);
  57. Okno.Draw(Red);
  58. }
  59. }
  60. }
  61.  
  62. Okno.Display();
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement