{"id":335938,"date":"2022-07-20T15:00:12","date_gmt":"2022-07-20T15:00:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335938"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335938","title":{"rendered":"<span>\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0433\u0440\u0443 \u043d\u0430 Monogame, \u043d\u0435 \u043f\u0440\u0438\u0432\u043b\u0435\u043a\u0430\u044f \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u0441\u0430\u043d\u0438\u0442\u0430\u0440\u043e\u0432. \u0427\u0430\u0441\u0442\u044c 2, \u043d\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u0435\u043c \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043d\u0430 \u0433\u043b\u043e\u0431\u0443\u0441<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438: <a href=\"https:\/\/habr.com\/ru\/post\/676850\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 0<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/676998\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/p>\n<p><em>4.4 \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435<\/em><\/p>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0431\u0435\u043b\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u043a, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u043e \u0433\u043e\u043b\u0443\u0431\u043e\u043c\u0443 \u0444\u043e\u043d\u0443. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u0430 \u0441\u0442\u0430\u043b\u0430 \u0445\u043e\u0442\u044f \u0431\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u043d\u0430 \u0438\u0433\u0440\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043b\u044e\u0431\u043b\u044e \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0443, \u0442\u043e \u0441\u0442\u0430\u0432\u043b\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u043d\u0430 \u043c\u043e\u0435\u043c \u0441\u0430\u043c\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 View.<\/p>\n<pre><code class=\"cs\">\/\/View protected override void Initialize() {   base.Initialize();   _graphics.IsFullScreen = false;   _graphics.PreferredBackBufferWidth = 1024;   _graphics.PreferredBackBufferHeight = 768;   _graphics.ApplyChanges(); }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 _graphics \u043c\u0435\u0442\u043e\u0434 ApplyChanges. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043e\u043b\u0448\u0435\u0431\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f.  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0430\u0448\u0438\u043d\u043a\u0443. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u0430\u0432\u043e\u043e\u0431\u043b\u0430\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f, \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0435\u0435 \u0441\u0430\u043c\u0438. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0434\u0438\u0437\u0430\u0439\u043d:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/8cb\/e76\/dae\/8cbe76dae3ddbe0efe82a1ef3a218ab0.jpeg\" width=\"597\" height=\"759\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/8cb\/e76\/dae\/8cbe76dae3ddbe0efe82a1ef3a218ab0.jpeg\" data-blurred=\"true\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u044d\u0442\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u0430\u043c \u043f\u043e\u0440\u0430 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u043d\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u0436. \u042d\u0442\u043e \u0442\u043e\u0436\u0435 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043c\u0430\u0448\u0438\u043d\u043e\u043a, \u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043d\u0430 \u043c\u0435\u0441\u0442\u043e White Placeholder.  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Initialize \u043d\u0430\u0448\u0435\u0439 \u041c\u043e\u0434\u0435\u043b\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435, \u0430 \u043c\u043d\u043e\u0433\u043e.  <\/p>\n<pre><code class=\"cs\">public class GameCycle : IGameplayModel {     public event EventHandler&lt;GameplayEventArgs> Updated = delegate { };      private int _currentId; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430      public int PlayerId { get; set; }     public Dictionary&lt;int, IObject> Objects { get; set; }         public void Initialize()     {                Objects = new Dictionary&lt;int, IObject>();        _currentId = 1; \/\/\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u044e\u0447        Car player = new Car();        player.Pos = new Vector2 (512-90, 500);        player.ImageId = 1;        player.Speed = new Vector2 (0, 0);        \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f        \/\/\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a\u043b\u044e\u0447\u0430        Objects.Add (_currentId, player);        PlayerId = _currentId;        _currentId++;     }<\/code><\/pre>\n<p>\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0438\u0433\u0440\u043e\u043a\u0430 <em>new Vector2 (512-90, 500) <\/em>\u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u044d\u043a\u0440\u0430\u043d\u0430. 90, \u0442\u0430\u043a \u043a\u0430\u043a \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0432\u043d\u0430 180. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u043e\u0442 \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0430 \u0437\u0434\u0435\u0441\u044c \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0432\u043e View \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Clear \u043e\u0431\u044a\u0435\u043a\u0442\u0430 GraphicsDevice \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c DarkSeaGreen):<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/81f\/8d9\/b0e\/81f8d9b0eb75bf38d791d743eb94a2c8.png\" width=\"338\" height=\"253\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/81f\/8d9\/b0e\/81f8d9b0eb75bf38d791d743eb94a2c8.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a \u0433\u043e\u043b\u0430\u044f \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430. \u041f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043d\u0435\u0447\u0442\u043e, \u043e\u0442\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0435\u0435 \u0438\u0433\u0440\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u0432\u043f\u0435\u0440\u0435\u0434, \u043e\u043d\u0430 \u0443\u0439\u0434\u0435\u0442 \u0437\u0430 \u043a\u0440\u0430\u0439 \u044d\u043a\u0440\u0430\u043d\u0430, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u044b \u0435\u0435 \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0435 \u043f\u043e\u043b\u0435 \u0437\u0440\u0435\u043d\u0438\u044f, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0437\u0430 \u043c\u0430\u0448\u0438\u043d\u043a\u043e\u0439. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u0443.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432 MonoGame \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Matrix, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u0443. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432, \u0433\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a \u0434\u043b\u044f \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u041d\u043e, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0439 \u0438\u0433\u0440\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043c\u0435\u0440\u0443 \u0441\u0430\u043c\u0443 <s>\u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043b\u0430\u0441\u0442\u0438\u043a\u043e\u0432\u043e\u0439 \u0431\u0443\u0442\u044b\u043b\u043a\u0438<\/s>. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0449\u0443 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0447\u0435\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b (\u0447\u0435\u0433\u043e \u044f \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0434\u043e\u0431\u0438\u0432\u0430\u043b\u0441\u044f) \u2014 \u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u2014 \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 _spriteBatch.Draw, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u0438 \u0433\u0434\u0435. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0433\u0434\u0435 \u043c\u044b \u0435\u0433\u043e \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c, \u0430 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0435 \u0437\u0440\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c? \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439, \u0442\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043c\u0435\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 GameCycleView \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 _visualShift, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435, \u0430 \u0432 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0435 Draw \u0432\u044b\u0447\u0442\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0438\u0437 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:  <\/p>\n<pre><code class=\"cs\">public class GameCycleView : Game, IGameplayView { \/\/&lt;.....................>   private Vector2 _visualShift = new Vector2(0, 0);   \/\/&lt;.....................>   protected override void Draw(GameTime gameTime)   {     GraphicsDevice.Clear(Color.DarkSeaGreen);     base.Draw(gameTime);     _spriteBatch.Begin();          foreach (var o in _objects.Values)     {     _spriteBatch.Draw(       _textures[o.ImageId],        o.Pos - _visualShift\/*\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438*\/,       Color.White       );     }     _spriteBatch.End();   }     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u0435\u043a\u0442\u043e\u0440 _visualShift, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0446\u0438\u043a\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0434\u0432\u0438\u0433 \u043c\u0430\u0448\u0438\u043d\u043a\u0438. \u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c? \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u043f\u0440\u043e\u0435\u0445\u0430\u043b\u0430 \u043d\u0430 10 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432\u0432\u0435\u0440\u0445. \u0415\u0441\u043b\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u0430\u043c\u0435\u0440\u0430 \u0445\u043e\u0447\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0447\u0442\u043e \u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u043c\u0435\u0440\u0430 \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u0430, \u0430 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0438\u0440 \u0441\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441 \u043d\u0430 10 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432\u043d\u0438\u0437.  <\/p>\n<p>\u0417\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0432\u043e View \u0433\u043e\u0442\u043e\u0432\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0435 \u0441 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e. \u0414\u0435\u043b\u0430\u0442\u044c \u043c\u044b \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 GameplayEventArgs \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 POVShift, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430: <\/p>\n<pre><code class=\"cs\">public class GameplayEventArgs : EventArgs {     public Dictionary&lt;int, IObject> Objects { get; set; }     public Vector2 POVShift { get; set; } }<\/code><\/pre>\n<p>\u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u0436\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u044d\u0442\u0443 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (\u0441\u043e\u0437\u0434\u0430\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Update \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e playerInitPos, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0446\u0438\u043a\u043b\u0430 \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0442\u044f \u0435\u0435 \u0438\u0437 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0446\u0435) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 Updated:<\/p>\n<pre><code class=\"cs\">public void Update() {   Vector2 playerInitPos = Objects[PlayerId].Pos;   foreach (var o in Objects.Values)   {     o.Update();   }   Vector2 playerShift = Objects[PlayerId].Pos - playerInitPos;   Updated.Invoke(this, new GameplayEventArgs {      Objects = this.Objects, POVShift = playerShift     } ); }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0430 \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a \u0438\u0433\u0440\u043e\u043a\u0430 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u043d\u0430\u0435\u043c, \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0433\u0440\u043e\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b View \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 LoadGameCycleParameters \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 IGamePlayView, \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432 \u0432 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0435\u0440\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 GameCycleView.<\/p>\n<pre><code class=\"cs\">public interface IGameplayView {     event EventHandler CycleFinished;     event EventHandler&lt;ControlsEventArgs> PlayerSpeedChanged;       void LoadGameCycleParameters(       Dictionary&lt;int, IObject> _objects,        Vector2 POVShift     );     void Run(); }<\/code><\/pre>\n<pre><code class=\"cs\">\/\/Presenter private void ModelViewUpdate(object sender, GameplayEventArgs e) {     _gameplayView.LoadGameCycleParameters(e.Objects, e.POVShift); }<\/code><\/pre>\n<pre><code class=\"cs\">\/\/View public void LoadGameCycleParameters(Dictionary&lt;int, IObject> Objects, Vector2 POVShift) {     _objects = Objects;     _visualShift += POVShift; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0448 \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442. \u041d\u043e \u0431\u0435\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u2014 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430:  <\/p>\n<pre><code class=\"cs\">public void Initialize() {     Objects = new Dictionary&lt;int, IObject>();     _currentId = 1; \/\/\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u044e\u0447     Car player = new Car();     player.Pos = new Vector2(512 - 90, 500);     player.ImageId = 1;     player.Speed = new Vector2(0, 0);         Objects.Add(_currentId, player);     PlayerId = _currentId;     _currentId++;      Car anotherCar = new Car();   anotherCar.Pos = new Vector2(200, 50);     anotherCar.ImageId = 1;     anotherCar.Speed = new Vector2(0, 0);   Objects.Add(_currentId, anotherCar);   _currentId++; }<\/code><\/pre>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/014\/f13\/d47\/014f13d47ff9795e044cdcc35ab46a28.gif\" width=\"390\" height=\"306\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/014\/f13\/d47\/014f13d47ff9795e044cdcc35ab46a28.gif\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043c\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u043d\u0430\u0434\u043e, \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u044b \u0442\u0440\u0430\u0441\u0441\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043d\u0435\u0439. <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/677718\/\"> https:\/\/habr.com\/ru\/post\/677718\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0447\u0430\u0441\u0442\u0438: <a href=\"https:\/\/habr.com\/ru\/post\/676850\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 0<\/a>, <a href=\"https:\/\/habr.com\/ru\/post\/676998\/\" rel=\"noopener noreferrer nofollow\">\u0427\u0430\u0441\u0442\u044c 1<\/a><\/p>\n<p><em>4.4 \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u043e\u0444\u043e\u0440\u043c\u043b\u0435\u043d\u0438\u0435<\/em><\/p>\n<p>\u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438\u0441\u044c \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0431\u0435\u043b\u044b\u0439 \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u043a, \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0430\u044e\u0449\u0438\u0439\u0441\u044f \u043f\u043e \u0433\u043e\u043b\u0443\u0431\u043e\u043c\u0443 \u0444\u043e\u043d\u0443. \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u0430 \u0441\u0442\u0430\u043b\u0430 \u0445\u043e\u0442\u044f \u0431\u044b \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0439 \u043d\u0430 \u0438\u0433\u0440\u0443. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0443\u0434\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u0422\u0430\u043a \u043a\u0430\u043a \u044f \u043b\u044e\u0431\u043b\u044e \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0443, \u0442\u043e \u0441\u0442\u0430\u0432\u043b\u044e \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0431\u044b\u043b\u043e \u043d\u0430 \u043c\u043e\u0435\u043c \u0441\u0430\u043c\u043e\u043c \u043f\u0435\u0440\u0432\u043e\u043c \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u0435 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 View.<\/p>\n<pre><code class=\"cs\">\/\/View protected override void Initialize() {   base.Initialize();   _graphics.IsFullScreen = false;   _graphics.PreferredBackBufferWidth = 1024;   _graphics.PreferredBackBufferHeight = 768;   _graphics.ApplyChanges(); }<\/code><\/pre>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0432\u0441\u0442\u0443\u043f\u0438\u043b\u0438 \u0432 \u0441\u0438\u043b\u0443, \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0443 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 _graphics \u043c\u0435\u0442\u043e\u0434 ApplyChanges. \u0411\u0435\u0437 \u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432\u043e\u043b\u0448\u0435\u0431\u0441\u0442\u0432\u0430 \u043d\u0435 \u0441\u043b\u0443\u0447\u0438\u0442\u0441\u044f.  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0448\u0430\u0433\u043e\u043c \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043c\u0430\u0448\u0438\u043d\u043a\u0443. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 \u043f\u0440\u0430\u0432\u043e\u043e\u0431\u043b\u0430\u0434\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u0438 \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f, \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u0435\u0435 \u0441\u0430\u043c\u0438. \u042f \u0432\u044b\u0431\u0440\u0430\u043b \u0442\u0430\u043a\u043e\u0439 \u0434\u0438\u0437\u0430\u0439\u043d:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u044d\u0442\u0443 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0443, \u0437\u043d\u0430\u0447\u0438\u0442, \u0432\u0430\u043c \u043f\u043e\u0440\u0430 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043f\u0435\u043d\u0441\u0438\u043e\u043d\u043d\u044b\u0439 \u0441\u0442\u0430\u0436. \u042d\u0442\u043e \u0442\u043e\u0436\u0435 \u0437\u0430\u0433\u043b\u0443\u0448\u043a\u0430, \u0432 \u043a\u043e\u043d\u0446\u0435 \u043c\u044b \u0434\u043e\u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0435 \u0441\u043f\u0440\u0430\u0439\u0442\u044b \u043c\u0430\u0448\u0438\u043d\u043e\u043a, \u043d\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u044c\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u044f\u0442\u043d\u0435\u0435, \u0447\u0435\u043c \u0440\u0430\u043d\u044c\u0448\u0435. \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0435\u0435 \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043d\u0430 \u043c\u0435\u0441\u0442\u043e White Placeholder.  <\/p>\n<p>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u0437\u0431\u0430\u0432\u0438\u043c\u0441\u044f \u043e\u0442 \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0430 \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0443 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043a\u043b\u044e\u0447\u0435\u0439 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Initialize \u043d\u0430\u0448\u0435\u0439 \u041c\u043e\u0434\u0435\u043b\u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435-\u0442\u0430\u043a\u0438 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 \u043d\u0430 \u043a\u0430\u0440\u0442\u0435, \u0430 \u043c\u043d\u043e\u0433\u043e.  <\/p>\n<pre><code class=\"cs\">public class GameCycle : IGameplayModel {     public event EventHandler&lt;GameplayEventArgs> Updated = delegate { };      private int _currentId; \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u0435 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430      public int PlayerId { get; set; }     public Dictionary&lt;int, IObject> Objects { get; set; }         public void Initialize()     {                Objects = new Dictionary&lt;int, IObject>();        _currentId = 1; \/\/\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u044e\u0447        Car player = new Car();        player.Pos = new Vector2 (512-90, 500);        player.ImageId = 1;        player.Speed = new Vector2 (0, 0);        \/\/\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u043e\u0432\u043e\u0433\u043e \u043f\u043e\u043b\u044f        \/\/\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u043c \u0438\u043d\u043a\u0440\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043a\u043b\u044e\u0447\u0430        Objects.Add (_currentId, player);        PlayerId = _currentId;        _currentId++;     }<\/code><\/pre>\n<p>\u041c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u0447\u0438\u0441\u043b\u0430 \u0432 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0438 \u0438\u0433\u0440\u043e\u043a\u0430 <em>new Vector2 (512-90, 500) <\/em>\u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u0434\u043b\u044f \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u043f\u043e \u0446\u0435\u043d\u0442\u0440\u0443 \u044d\u043a\u0440\u0430\u043d\u0430. 90, \u0442\u0430\u043a \u043a\u0430\u043a \u0448\u0438\u0440\u0438\u043d\u0430 \u0441\u043f\u0440\u0430\u0439\u0442\u0430 \u0443 \u043c\u0435\u043d\u044f \u0440\u0430\u0432\u043d\u0430 180. \u041f\u043e\u0437\u0434\u043d\u0435\u0435 \u043e\u0442 \u0445\u0430\u0440\u0434\u043a\u043e\u0434\u0430 \u0437\u0434\u0435\u0441\u044c \u0438 \u043d\u0430 \u0434\u0440\u0443\u0433\u0438\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u0431\u0430\u0432\u0438\u0442\u044c\u0441\u044f. \u0412\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c (\u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0446\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 \u0432\u043e View \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Clear \u043e\u0431\u044a\u0435\u043a\u0442\u0430 GraphicsDevice \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c DarkSeaGreen):<\/p>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0442\u0435\u043f\u0435\u0440\u044c \u044d\u0442\u043e \u0445\u043e\u0442\u044f \u0431\u044b \u043d\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a \u0433\u043e\u043b\u0430\u044f \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430. \u041f\u043e\u0445\u043e\u0436\u0435 \u043d\u0430 \u043d\u0435\u0447\u0442\u043e, \u043e\u0442\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0435\u0435 \u0438\u0433\u0440\u0443. \u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043d\u0430\u0448\u0443 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u0432\u043f\u0435\u0440\u0435\u0434, \u043e\u043d\u0430 \u0443\u0439\u0434\u0435\u0442 \u0437\u0430 \u043a\u0440\u0430\u0439 \u044d\u043a\u0440\u0430\u043d\u0430, \u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043c\u044b \u0435\u0435 \u043d\u0435 \u0443\u0432\u0438\u0434\u0438\u043c \u043d\u0438\u043a\u043e\u0433\u0434\u0430. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0435 \u043f\u043e\u043b\u0435 \u0437\u0440\u0435\u043d\u0438\u044f, \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u043e \u0437\u0430 \u043c\u0430\u0448\u0438\u043d\u043a\u043e\u0439. \u0422\u043e \u0435\u0441\u0442\u044c, \u043d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u0443.<\/p>\n<p>\u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435, \u0432 MonoGame \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 Matrix, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u0430\u043c\u0435\u0440\u0443. \u0421\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043c\u043d\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432, \u0433\u0434\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043a\u0430\u043a \u0434\u043b\u044f \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0445, \u0442\u0430\u043a \u0438 \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432. \u041d\u043e, \u043a\u0430\u043a \u043c\u043d\u0435 \u043a\u0430\u0436\u0435\u0442\u0441\u044f, \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u0441\u043b\u043e\u0436\u043d\u043e \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0439 \u0438\u0433\u0440\u044b, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u044b \u0441\u043e\u0431\u0435\u0440\u0435\u043c \u043a\u0430\u043c\u0435\u0440\u0443 \u0441\u0430\u043c\u0443 <s>\u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043b\u0430\u0441\u0442\u0438\u043a\u043e\u0432\u043e\u0439 \u0431\u0443\u0442\u044b\u043b\u043a\u0438<\/s>. <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u0431\u0440\u0430\u0449\u0443 \u0432\u0430\u0448\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0430 \u0447\u0435\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u044b (\u0447\u0435\u0433\u043e \u044f \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u0434\u043e\u0431\u0438\u0432\u0430\u043b\u0441\u044f) \u2014 \u043d\u0435\u0432\u0430\u0436\u043d\u043e, \u043a\u0430\u043a \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0443 \u043d\u0430\u0448\u0435\u0439 \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u2014 \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0430 \u043f\u043e\u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 _spriteBatch.Draw, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u0438 \u0433\u0434\u0435. \u0418\u043d\u044b\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0433\u0434\u0435 \u043c\u044b \u0435\u0433\u043e \u043d\u0430\u0440\u0438\u0441\u0443\u0435\u043c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435, \u0434\u043b\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u043d\u0438 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c, \u0430 \u043c\u043e\u0433\u0443\u0442 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c. \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u043e\u043b\u0435 \u0437\u0440\u0435\u043d\u0438\u044f \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u0438 \u043d\u0435 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u043b\u0438. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u043e\u043f\u0440\u043e\u0441 \u2014 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e\u043d\u0438 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0442\u044c? \u0422\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u0448\u0430 \u043a\u0430\u043c\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u0443 \u043d\u0430\u0441 \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b\u0430 \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439, \u0442\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u044b \u0440\u0438\u0441\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043c\u0435\u0449\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043c\u0435\u0441\u0442\u0438\u043b\u0430\u0441\u044c \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u0432\u043e\u0435\u0433\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043e\u0431\u044a\u044f\u0432\u0438\u043c \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 GameCycleView \u043d\u043e\u0432\u043e\u0435 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 _visualShift, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u0440\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0435, \u0430 \u0432 \u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0435 Draw \u0432\u044b\u0447\u0442\u0435\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043b\u044f \u0438\u0437 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438:  <\/p>\n<pre><code class=\"cs\">public class GameCycleView : Game, IGameplayView { \/\/&lt;.....................>   private Vector2 _visualShift = new Vector2(0, 0);   \/\/&lt;.....................>   protected override void Draw(GameTime gameTime)   {     GraphicsDevice.Clear(Color.DarkSeaGreen);     base.Draw(gameTime);     _spriteBatch.Begin();          foreach (var o in _objects.Values)     {     _spriteBatch.Draw(       _textures[o.ImageId],        o.Pos - _visualShift\/*\u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0438*\/,       Color.White       );     }     _spriteBatch.End();   }     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c \u0438\u0437 \u043f\u043e\u0437\u0438\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u0432\u0435\u043a\u0442\u043e\u0440 _visualShift, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0446\u0438\u043a\u043b \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0434\u0432\u0438\u0433 \u043c\u0430\u0448\u0438\u043d\u043a\u0438. \u041f\u043e\u0447\u0435\u043c\u0443 \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u043c? \u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u043f\u0440\u043e\u0435\u0445\u0430\u043b\u0430 \u043d\u0430 10 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432\u0432\u0435\u0440\u0445. \u0415\u0441\u043b\u0438 \u0433\u0438\u043f\u043e\u0442\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043a\u0430\u043c\u0435\u0440\u0430 \u0445\u043e\u0447\u0435\u0442 \u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0430\u0448\u0438\u043d\u043a\u0438 \u043d\u0430 \u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0437\u0438\u0446\u0438\u0438, \u0447\u0442\u043e \u0438 \u0440\u0430\u043d\u044c\u0448\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u043a\u0430\u043c\u0435\u0440\u0430 \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u0430, \u0430 \u0432\u0435\u0441\u044c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0438\u0440 \u0441\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0441 \u043d\u0430 10 \u043f\u0438\u043a\u0441\u0435\u043b\u0435\u0439 \u0432\u043d\u0438\u0437.  <\/p>\n<p>\u0417\u0430\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u0432\u043e View \u0433\u043e\u0442\u043e\u0432\u0430, \u043d\u0443\u0436\u043d\u043e \u0441\u0432\u044f\u0437\u0430\u0442\u044c \u0435\u0435 \u0441 \u043b\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0447\u0430\u0441\u0442\u044c\u044e. \u0414\u0435\u043b\u0430\u0442\u044c \u043c\u044b \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 GameplayEventArgs \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u043b\u0435 POVShift, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0438 \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0446\u0438\u043a\u043b\u0430: <\/p>\n<pre><code class=\"cs\">public class GameplayEventArgs : EventArgs {     public Dictionary&lt;int, IObject> Objects { get; set; }     public Vector2 POVShift { get; set; } }<\/code><\/pre>\n<p>\u0412 \u043c\u043e\u0434\u0435\u043b\u0438 \u0436\u0435 \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u044d\u0442\u0443 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u0441\u043c\u0435\u0449\u0435\u043d\u0438\u044f (\u0441\u043e\u0437\u0434\u0430\u0432 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 Update \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e playerInitPos, \u0432 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u043c \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0446\u0438\u043a\u043b\u0430 \u0438 \u0437\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0442\u044f \u0435\u0435 \u0438\u0437 \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 \u043a\u043e\u043d\u0446\u0435) \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0447\u0435\u0440\u0435\u0437 \u0441\u043e\u0431\u044b\u0442\u0438\u0435 Updated:<\/p>\n<pre><code class=\"cs\">public void Update() {   Vector2 playerInitPos = Objects[PlayerId].Pos;   foreach (var o in Objects.Values)   {     o.Update();   }   Vector2 playerShift = Objects[PlayerId].Pos - playerInitPos;   Updated.Invoke(this, new GameplayEventArgs {      Objects = this.Objects, POVShift = playerShift     } ); }<\/code><\/pre>\n<p>\u0422\u0430\u043a \u043a\u0430\u043a \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u0435, \u0430 \u0430\u0439\u0434\u0438\u0448\u043d\u0438\u043a \u0438\u0433\u0440\u043e\u043a\u0430 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u043d\u0430\u0435\u043c, \u0432\u044b\u0442\u044f\u043d\u0443\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0438\u0433\u0440\u043e\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0438 \u0431\u044b\u0441\u0442\u0440\u043e.<\/p>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b View \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u043b\u0430 \u043d\u043e\u0432\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440, \u0434\u043b\u044f \u0447\u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 LoadGameCycleParameters \u0432 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0435 IGamePlayView, \u0435\u0433\u043e \u0432\u044b\u0437\u043e\u0432 \u0432 \u043f\u0440\u0435\u0437\u0435\u043d\u0442\u0435\u0440\u0435 \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0432 GameCycleView.<\/p>\n<pre><code class=\"cs\">public interface IGameplayView {     event EventHandler CycleFinished;     event EventHandler&lt;ControlsEventArgs> PlayerSpeedChanged;       void LoadGameCycleParameters(       Dictionary&lt;int, IObject> _objects,        Vector2 POVShift     );     void Run(); }<\/code><\/pre>\n<pre><code class=\"cs\">\/\/Presenter private void ModelViewUpdate(object sender, GameplayEventArgs e) {     _gameplayView.LoadGameCycleParameters(e.Objects, e.POVShift); }<\/code><\/pre>\n<pre><code class=\"cs\">\/\/View public void LoadGameCycleParameters(Dictionary&lt;int, IObject> Objects, Vector2 POVShift) {     _objects = Objects;     _visualShift += POVShift; }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c, \u0435\u0441\u043b\u0438 \u043c\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443, \u0442\u043e \u0443\u0432\u0438\u0434\u0438\u043c \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u043a\u0430 \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043a\u043b\u0430\u0432\u0438\u0448 \u043d\u0435 \u0438\u0441\u0447\u0435\u0437\u0430\u0435\u0442. \u041d\u043e \u0431\u0435\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043e\u043d\u0430 \u0438\u043b\u0438 \u043d\u0435\u0442. \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442, \u0447\u0442\u043e\u0431\u044b \u044d\u0442\u043e \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e \u2014 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0435\u0449\u0435 \u043e\u0434\u043d\u0443 \u043c\u0430\u0448\u0438\u043d\u043a\u0443 \u0432 \u043d\u0430\u0448\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0433\u0440\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430:  <\/p>\n<pre><code class=\"cs\">public void Initialize() {     Objects = new Dictionary&lt;int, IObject>();     _currentId = 1; \/\/\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u043a\u043b\u044e\u0447     Car player = new Car();     player.Pos = new Vector2(512 - 90, 500);     player.ImageId = 1;     player.Speed = new Vector2(0, 0);         Objects.Add(_currentId, player);     PlayerId = _currentId;     _currentId++;      Car anotherCar = new Car();   anotherCar.Pos = new Vector2(200, 50);     anotherCar.ImageId = 1;     anotherCar.Speed = new Vector2(0, 0);   Objects.Add(_currentId, anotherCar);   _currentId++; }<\/code><\/pre>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043c\u0435\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043a\u0430\u043a \u043d\u0430\u0434\u043e, \u0438 \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0432 \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043a\u0430\u0440\u0442\u044b \u0442\u0440\u0430\u0441\u0441\u044b \u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u043d\u0435\u0439. <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/677718\/\"> https:\/\/habr.com\/ru\/post\/677718\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-335938","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335938"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335938\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}