{"id":169435,"date":"2013-02-15T08:23:03","date_gmt":"2013-02-15T04:23:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=169435"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=169435","title":{"rendered":"<span class=\"post_title\">\u041c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u043e\u0442\u0432\u0430\u0436\u043d\u044b\u0439 \u0430\u0440\u043a\u0430\u043d\u043e\u0438\u0434 (\u0447\u0430\u0441\u0442\u044c 4)<\/span>"},"content":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0430, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043d\u0430\u0448\u0443 <a href=\"http:\/\/habrahabr.ru\/post\/166929\/\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443<\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u0441\u043e\u0443\u0434\u0430\u0440\u0435\u043d\u0438\u0438 \u0448\u0430\u0440\u0438\u043a\u0430 \u0441 \u0447\u0435\u043c \u043b\u0438\u0431\u043e \u043d\u0430 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u043f\u043e\u043b\u0435. \u041e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 SoundEngine (\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f) \u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/161959\/\">\u0440\u0430\u043d\u0435\u0435<\/a>. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e \u043d\u0435\u0439, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0413\u043b\u0430\u0432\u043d\u044b\u043c (\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u044b\u043c \u0434\u043b\u044f \u043c\u0435\u043d\u044f) \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 SoundEngine \u044f\u0432\u0438\u043b\u0430\u0441\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441 IwGl \u043d\u0430 IwGx. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e SoundEngine \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0439 \u0437\u0432\u0443\u043a\u043e\u0432\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u0441\u0438\u0441\u0442\u0435\u043c\u044b IwResManager. \u0421\u0430\u043c\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">sounds.group<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">CIwResGroup { \tname &quot;sounds&quot;  \t&quot;.\/sounds\/contact.wav&quot;  \tCIwSoundSpec \t{ \t\tname\t\t&quot;contact&quot; \t\tdata\t\t&quot;contact&quot; \t\tvol \t\t0.9 \t\tloop\t\tfalse \t}  \tCIwSoundGroup \t{ \t\tname\t\t&quot;sound_effects&quot; \t\tmaxPolyphony \t8 \t\tkillOldest\ttrue \t\taddSpec\t\t&quot;contact&quot; \t}  } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u043f\u044b\u0442\u043a\u0430 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 IwResManager \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0435\u0442 \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/1.bp.blogspot.com\/-McUvjhkr2CM\/URzUtCN6zCI\/AAAAAAAAARg\/A4lk9KIM6Yw\/s1600\/0001.PNG\" alt=\"image\"\/><\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 IwGeom \u0442\u0430\u043a\u0436\u0435 \u043c\u0430\u043b\u043e \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/3.bp.blogspot.com\/-yomz2gptRbQ\/URzUxw_HpwI\/AAAAAAAAARo\/Qhatt8RZ-j8\/s1600\/0002.PNG\" alt=\"image\"\/><\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0431\u0435\u0441\u043f\u043b\u043e\u0434\u043d\u044b\u0445 \u043f\u043e\u043f\u044b\u0442\u043e\u043a \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u044f \u0440\u0435\u0448\u0438\u043b \u043e\u0442\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f IwGl \u0438 \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043a IwGx. \u042f \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u043d\u0430\u0441\u0442\u0430\u0438\u0432\u0430\u044e \u043d\u0430 \u0442\u043e\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u043c\u043d\u0435 \u043e\u043d\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0438\u0431\u043e\u043b\u0435\u0435 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c.<\/p>\n<p>  \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0430\u0447\u043d\u0435\u043c \u0441 mkb-\u0444\u0430\u0439\u043b\u0430:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">arcanoid.mkb<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">#!\/usr\/bin\/env mkb options {      module_path=&quot;..\/yaml&quot;      module_path=&quot;..\/box2d&quot; +    module_path=&quot;$MARMALADE_ROOT\/examples&quot; }  subprojects { -    iwgl +    iwgx +    iwresmanager +    SoundEngine      yaml      box2d }  includepath { \t.\/source\/Main \t.\/source\/Model } files { \t[Main] \t(source\/Main) \tMain.cpp \tMain.h \tQuads.cpp \tQuads.h \tTouchPad.cpp \tTouchPad.h \tDesktop.cpp \tDesktop.h \tIO.cpp \tIO.h \tWorld.cpp \tWorld.h        +   ResourceManager.cpp +   ResourceManager.h  \t[Model] \t(source\/Model) \tIBox2DItem.h \tBoard.cpp \tBoard.h \tBricks.cpp \tBricks.h \tBall.cpp \tBall.h \tHandle.cpp \tHandle.h  +   [Data] +   (data) +   sounds.group }  assets {     (data)     level.json  +   (data-ram\/data-gles1, data\/data-gles1) +   sounds.group.bin } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0439 (\u0438 \u043f\u043e\u043a\u0430 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439) \u043c\u043e\u0434\u0443\u043b\u044c:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ResourceManager.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _RESOURCEMANAGER_H_ #define _RESOURCEMANAGER_H_  #include &lt;map&gt; #include &lt;string&gt;  #include &quot;s3e.h&quot; #include &quot;IwResManager.h&quot; #include &quot;IwSound.h&quot;  #define SOUND_GROUP &quot;sounds&quot;  using namespace std;  class ResourceManager { \tprivate: \t\tbool checkSound() {return true;} \tpublic: \t\tvoid init(); \t\tvoid release(); \t\tvoid update(); \t\tvoid fireSound(const char* name); };  extern ResourceManager rm;          #endif\t\/\/ _RESOURCEMANAGER_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">ResourceManager.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;ResourceManager.h&quot;  ResourceManager rm;  void ResourceManager::init() { \tIwSoundInit(); \tIwResManagerInit(); #ifdef IW_BUILD_RESOURCES \tIwGetResManager()-&gt;AddHandler(new CIwResHandlerWAV); #endif \tIwGetResManager()-&gt;LoadGroup(&quot;sounds.group&quot;); }  void ResourceManager::release() { \tIwResManagerTerminate(); \tIwSoundTerminate(); }  void ResourceManager::update() {     IwGetSoundManager()-&gt;Update(); }  void ResourceManager::fireSound(const char* name) { \tif (!checkSound()) return;     CIwResGroup* resGroup = IwGetResManager()-&gt;GetGroupNamed(SOUND_GROUP); \tCIwSoundSpec* SoundSpec = (CIwSoundSpec*)resGroup-&gt;GetResNamed(name,                    IW_SOUND_RESTYPE_SPEC); \tCIwSoundInst* SoundInstance = SoundSpec-&gt;Play(); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0410\u043a\u0442\u0438\u0432\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u044d\u0444\u0444\u0435\u043a\u0442 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0431\u0435\u0437 \u0437\u0430\u0442\u0435\u0439, \u0438\u0437 \u043c\u043e\u0434\u0443\u043b\u044f World:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">World.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"diff\">#include &quot;s3e.h&quot; +#include &quot;ResourceManager.h&quot; #include &quot;World.h&quot; #include &quot;Ball.h&quot; ... void World::PostSolve(b2Contact* contact, const b2ContactImpulse* impulse) { \timpact(contact-&gt;GetFixtureA()-&gt;GetBody()); \timpact(contact-&gt;GetFixtureB()-&gt;GetBody()); \tisContacted = true; +   rm.fireSound(CONTACT_SOUND); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u043d\u0435\u0441\u0442\u0438 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0437\u0432\u0443\u043a\u043e\u0432\u044b\u0445 \u044d\u0444\u0444\u0435\u043a\u0442\u043e\u0432. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0432\u043d\u0435\u0441\u0442\u0438 \u0440\u044f\u0434 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u0441 IwGl \u043d\u0430 IwGx.<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Desktop.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Desktop.h&quot; #include &quot;IwGx.h&quot; #include &quot;s3e.h&quot;  Desktop desktop;  void Desktop::init() {     IwGxInit();     IwGxLightingOff();     width = IwGxGetScreenWidth();     height = IwGxGetScreenHeight(); \tIwGxSetColClear(0, 0, 0, 0);     vSize = 0; \tduration = 1000 \/ 60; }  void Desktop::release() {     IwGxTerminate(); }  void Desktop::update() {     IwGxClear(IW_GX_COLOUR_BUFFER_F | IW_GX_DEPTH_BUFFER_F);     CIwMaterial* pMat = IW_GX_ALLOC_MATERIAL();     IwGxSetMaterial(pMat); }  void Desktop::refresh() {     IwGxFlush();     IwGxSwapBuffers();     s3eDeviceYield(duration);    }  int Desktop::toRSize(int x) const {     if (vSize == 0) return x;     return (x * width) \/ vSize; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Quads.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _QUADS_H_ #define _QUADS_H_  #include &quot;IwGX.h&quot;  #define MAX_VERTS 2000  class Quads {     private: \t\tCIwSVec2 verts[MAX_VERTS]; \t\tCIwColour cols[MAX_VERTS];         int     vertc;     public:         void update() {vertc = 0;}         void refresh(); \t\tvoid setVert(int x, int y, int r, int g, int b, int a); };  extern Quads quads;  #endif\t\/\/ _QUADS_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Quads.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Quads.h&quot; #include &quot;s3e.h&quot;  Quads quads;  void Quads::refresh() { \tIwGxSetVertStreamScreenSpace(verts, vertc);     IwGxSetColStream(cols, vertc);     IwGxDrawPrims(IW_GX_TRI_LIST, NULL, vertc); }  void Quads::setVert(int x, int y, int r, int g, int b, int a) { \tif (vertc &gt;= MAX_VERTS) return; \tverts[vertc].x = x; \tverts[vertc].y = y;     cols[vertc].r  = r;  \tcols[vertc].g  = g;  \tcols[vertc].b  = b;  \tcols[vertc].a  = a; \tvertc++; } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Bricks.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _BRICKS_H_ #define _BRICKS_H_  #include &quot;IwGX.h&quot; #include &quot;s3e.h&quot;  #include &quot;Desktop.h&quot; #include &quot;World.h&quot; #include &quot;IBox2DItem.h&quot;  #define BRICK_HALF_WIDTH   20 #define BRICK_HALF_HEIGHT  10  #include &lt;vector&gt;  using namespace std;  class Bricks: public IBox2DItem {     private:         struct SBrick {             SBrick(int x, int y): x(x),                                            y(y),                                            body(NULL),  \t\t\t\t\t\t\t\t\t\t  isBroken(false),                                           hw(BRICK_HALF_WIDTH),                                            hh(BRICK_HALF_HEIGHT) {}             SBrick(const SBrick& p): x(p.x),                                            y(p.y),                                            body(p.body),  \t\t\t\t\t\t\t\t\t\t  isBroken(p.isBroken),                                           hw(p.hw),                                            hh(p.hh) {}             int x, y, hw, hh; \t\t\tint isBroken; \t\t\tb2Body* body;         };         vector&lt;SBrick&gt;* bricks; \t\tvirtual bool impact(b2Body* b);     public:         Bricks(): bricks() {} \t\tvoid init(); \t\tvoid release();         void refresh();         void clear(){bricks-&gt;clear();}         void add(SBrick& b);      typedef vector&lt;SBrick&gt;::iterator BIter;      friend class Board; };  #endif\t\/\/ _BRICKS_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Bricks.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Bricks.h&quot; #include &quot;Quads.h&quot;  void Bricks::init() { \tbricks = new vector&lt;SBrick&gt;(); }  void Bricks::release() { \tdelete bricks; }  void Bricks::refresh() {     for (BIter p = bricks-&gt;begin(); p != bricks-&gt;end(); ++p) { \t\t    if (p-&gt;isBroken) continue; \t\t    quads.setVert(p-&gt;x - p-&gt;hw, p-&gt;y - p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t\t    quads.setVert(p-&gt;x - p-&gt;hw, p-&gt;y + p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t\t    quads.setVert(p-&gt;x + p-&gt;hw, p-&gt;y - p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t\t    quads.setVert(p-&gt;x + p-&gt;hw, p-&gt;y + p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t\t    quads.setVert(p-&gt;x + p-&gt;hw, p-&gt;y - p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t\t    quads.setVert(p-&gt;x - p-&gt;hw, p-&gt;y + p-&gt;hh, 0x00, 0xff, 0x50, 0xff); \t} }  bool Bricks::impact(b2Body* b) {     for (BIter p = bricks-&gt;begin(); p != bricks-&gt;end(); ++p) { \t\tif (p-&gt;body == b) { \t\t\tp-&gt;isBroken = true; \t\t\treturn true; \t\t} \t} \treturn false; }  void Bricks::add(SBrick& b) {  \tb.body = world.addBrick(b.x, b.y, b.hw, b.hh, (IBox2DItem*)this); \tbricks-&gt;push_back(b); } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0417\u0434\u0435\u0441\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u043e\u0431\u0445\u043e\u0434\u0430 \u0432\u0435\u0440\u0448\u0438\u043d \u0432 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0430\u0445. \u041f\u0435\u0440\u0432\u044b\u043c, \u0447\u0442\u043e \u044f \u0443\u0432\u0438\u0434\u0435\u043b, \u043f\u043e\u0441\u043b\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430 \u0441 IwGl \u043d\u0430 IwGx, \u0431\u044b\u043b\u0438 \u0443\u0433\u043e\u043b\u044c\u043d\u043e \u0447\u0435\u0440\u043d\u044b\u0435 \u0444\u0438\u0433\u0443\u0440\u044b \u043a\u0438\u0440\u043f\u0438\u0447\u0435\u0439 \u0438 \u0448\u0430\u0440\u0438\u043a\u0430 \u043d\u0430 \u043d\u0435\u0436\u043d\u043e \u043f\u0443\u0440\u043f\u0443\u0440\u043d\u043e\u043c \u0444\u043e\u043d\u0435. \u042f \u0443\u043c\u0443\u0434\u0440\u0438\u043b\u0441\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u00ab\u0441 \u0438\u0437\u043d\u0430\u043d\u043a\u0438\u00bb \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u0432\u0441\u0435 \u0442\u0440\u0435\u0443\u0433\u043e\u043b\u044c\u043d\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u0438.<\/p>\n<p>  \u0412\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e. \u042f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e IwGx \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u043f\u0430\u043c\u044f\u0442\u044c\u044e, \u043d\u043e \u0435\u0441\u0442\u044c \u0432\u0430\u0436\u043d\u043e\u0435 \u044d\u043c\u043f\u0438\u0440\u0438\u0447\u0435\u0441\u043a\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u043a \u043a\u0442\u043e\u0440\u043e\u043c\u0443 \u044f \u043f\u0440\u0438\u0448\u0435\u043b. \u0412\u0441\u044f \u043f\u0430\u043c\u044f\u0442\u044c \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u0430\u044f \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 (\u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0438 \u0432 STL) \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0430 \u0434\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 IwGxTerminate (\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d\u0430). \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u0432\u0435\u043a\u0442\u043e\u0440 bricks \u0441\u0442\u0430\u043b \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u043c \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u043d\u0435 \u0441\u0430\u043c\u043e\u0435 \u0438\u0437\u044f\u0449\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u043d\u043e \u043e\u043d\u043e \u0432\u043b\u0435\u043a\u043b\u043e \u0437\u0430 \u0441\u043e\u0431\u043e\u0439 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439.<\/p>\n<p>  \u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u044f\u0435\u043c \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u043e\u0434\u0443\u043b\u0438:<\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Ball.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _BALL_H_ #define _BALL_H_  #include &lt;vector&gt; #include &quot;s3e.h&quot;  #include &quot;Desktop.h&quot; #include &quot;World.h&quot; #include &quot;IBox2DItem.h&quot;  #define MAX_SEGMENTS       7 #define BALL_RADIUS        15  using namespace std;  class Ball: public IBox2DItem {     private:         struct Offset {             Offset(int dx, int dy): dx(dx), dy(dy) {}             Offset(const Offset& p): dx(p.dx), dy(p.dy) {}             int dx, dy;         };         vector&lt;Offset&gt;* offsets;         int      x;         int      y; \t\tb2Body*  body;     public:         void init();         void release();         void refresh(); \t\tvirtual void setXY(int X, int Y);      typedef vector&lt;Offset&gt;::iterator OIter; };  #endif\t\/\/ _BALL_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Ball.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Ball.h&quot; #include &quot;Desktop.h&quot; #include &quot;Quads.h&quot; #include &lt;math.h&gt;  void Ball::init(){     x = desktop.getWidth() \/ 2;     y = desktop.getHeight()\/ 2;  \toffsets = new vector&lt;Offset&gt;();     float delta = - PI \/ (float)MAX_SEGMENTS;     float angle = delta \/ 2.0f;     float r = (float)desktop.toRSize(BALL_RADIUS);     for (int i = 0; i &lt; MAX_SEGMENTS * 2; i++) {         offsets-&gt;push_back(Offset((int16)(cos(angle) * r), (int16)(sin(angle) * r)));         angle = angle + delta;         offsets-&gt;push_back(Offset((int16)(cos(angle) * r), (int16)(sin(angle) * r)));     } \tbody = world.addBall(x, y, (int)r, (IBox2DItem*)this); }  void Ball::release() { \tdelete offsets; }  void Ball::setXY(int X, int Y) { \tx = X; \ty = Y; }  void Ball::refresh() {     OIter o = offsets-&gt;begin();     int r = desktop.toRSize(BALL_RADIUS);     for (int i = 0; i &lt; MAX_SEGMENTS * 2; i++) { \t\t    quads.setVert(x + (r \/ 4), y + (r \/ 4), 0xff, 0xff, 0xff, 0xff); \t\t    quads.setVert(x + o-&gt;dx, y + o-&gt;dy, 0x00, 0x00, 0x00, 0x00); \t\t\to++; \t\t    quads.setVert(x + o-&gt;dx, y + o-&gt;dy, 0x00, 0x00, 0x00, 0x00); \t\t\to++; \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Handle.h<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#ifndef _HANDLE_H_ #define _HANDLE_H_  #include &quot;IwGX.h&quot; #include &quot;s3e.h&quot;  #include &quot;Desktop.h&quot; #include &quot;World.h&quot; #include &quot;IBox2DItem.h&quot;  #define HANDLE_COLOR        0xffff3000 #define HANDLE_H_WIDTH      40 #define HANDLE_H_HEIGHT     10  class Handle: public IBox2DItem { \tprivate:         int     x;         int     y; \t\tint     touchId; \tpublic:         void init();         void refresh();         void update(); \t\tvirtual void setXY(int X, int Y); };  #endif\t\/\/ _HANDLE_H_ <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">Handle.cpp<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cpp\">#include &quot;Handle.h&quot; #include &quot;Quads.h&quot; #include &quot;TouchPad.h&quot;  void Handle::init() {     x = desktop.getWidth() \/ 2;     y = desktop.getHeight(); \ttouchId = -1; }  void Handle::setXY(int X, int Y) { \tx = X; \ty = Y; }  void Handle::refresh() {  \tint hw = desktop.toRSize(HANDLE_H_WIDTH); \tint hh = desktop.toRSize(HANDLE_H_HEIGHT);      quads.setVert(x - hw, y - hh, 0x00, 0x30, 0xff, 0xff);     quads.setVert(x - hw, y + hh, 0x00, 0x30, 0xff, 0xff);     quads.setVert(x + hw, y - hh, 0x00, 0x30, 0xff, 0xff);     quads.setVert(x + hw, y + hh, 0x00, 0x30, 0xff, 0xff);     quads.setVert(x + hw, y - hh, 0x00, 0x30, 0xff, 0xff);     quads.setVert(x - hw, y + hh, 0x00, 0x30, 0xff, 0xff);  \tworld.addHandle(x, y, desktop.toRSize(HANDLE_H_WIDTH),                            desktop.toRSize(HANDLE_H_HEIGHT), (IBox2DItem*)this); }  void Handle::update() { \tTouch* t = NULL; \tif (touchId &gt; 0) { \t\tt = touchPad.getTouchByID(touchId); \t} else { \t\tt = touchPad.getTouchPressed(); \t} \tif (t != NULL) { \t\ttouchId = t-&gt;id; \t\tworld.moveHandle(t-&gt;x, t-&gt;y); \t} else { \t\ttouchId = -1; \t} } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u0412 Board \u043c\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u044f\u0435\u043c \u0434\u0432\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 (scopes \u0438 types) \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430. \u0414\u0430\u043b\u0435\u0435, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u0443\u0431\u0435\u0436\u0434\u0430\u0435\u043c\u0441\u044f, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/4.bp.blogspot.com\/-gboQUh316gI\/UR3DPTIXzyI\/AAAAAAAAASE\/f_hfC55auTY\/s1600\/0001.PNG\" alt=\"image\"\/><\/p>\n<p>  \u041c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u0443\u0431\u0440\u0430\u043b \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u043d\u0443\u044e \u0437\u0430\u043b\u0438\u0432\u043a\u0443 \u0441 \u043a\u0438\u0440\u043f\u0438\u0447\u0435\u0439. \u0427\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u0431\u044b\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043b\u0435\u043d\u044c \u0441 \u044d\u0442\u0438\u043c \u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f, \u0441 \u0443\u0447\u0435\u0442\u043e\u043c \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e, \u043d\u0430 \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u043d\u0430\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0442\u0435\u043a\u0441\u0442\u0443\u0440\u044b (\u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043e \u043a\u0430\u043a\u043e\u043c \u043b\u0438\u0431\u043e \u0442\u043e\u0432\u0430\u0440\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u043d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0434\u0430\u0436\u0435 \u043c\u0435\u0447\u0442\u0430\u0442\u044c). <\/p>\n<p>  \u0418\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u043a\u0441\u0442\u0443\u0440 \u044f \u0438 \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u044e \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437.      \t \t\t   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/169435\/\"> http:\/\/habrahabr.ru\/post\/169435\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">   \t\u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043f\u0435\u0440\u0435\u0440\u044b\u0432\u0430, \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043d\u0430\u0448\u0443 <a href=\"http:\/\/habrahabr.ru\/post\/166929\/\">\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443<\/a>. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0432\u0443\u043a\u043e\u0432\u043e\u0439 \u044d\u0444\u0444\u0435\u043a\u0442, \u043f\u0440\u043e\u0438\u0433\u0440\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u0441\u043e\u0443\u0434\u0430\u0440\u0435\u043d\u0438\u0438 \u0448\u0430\u0440\u0438\u043a\u0430 \u0441 \u0447\u0435\u043c \u043b\u0438\u0431\u043e \u043d\u0430 \u0438\u0433\u0440\u043e\u0432\u043e\u043c \u043f\u043e\u043b\u0435. \u041e \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 SoundEngine (\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u044b \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f) \u044f \u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b <a href=\"http:\/\/habrahabr.ru\/post\/161959\/\">\u0440\u0430\u043d\u0435\u0435<\/a>. \u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u044f \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443 \u043d\u0435 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u043e \u043d\u0435\u0439, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0442\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u043d\u0430\u043c\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0435.  <\/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-169435","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/169435","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=169435"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/169435\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=169435"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=169435"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=169435"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}