아이폰 게임중에 [ Minimal Maze ] 라는 게임이 있습니다.
안드로이드는 검색이 안되는 것으로 보아 아이폰용만 출시를 한듯합니다.
어렵지만 재미난, 물리를 적용한 특이한 풀이 방식의 퍼즐 게임입니다.

이 게임의 핵심은 바디(body)를 회전시키는 것입니다.




바디의 회전

바디를 회전시키면 위 게임을 쉽게 구현할 수 있습니다.
다음은 간단하게 위 게임의 핵심 로직을 구현해 본 것입니다.

void HelloWorld::setBox2dWorld()

{

    _parent = this->addNewSprite(Vec2(240160), Size(00),

                                                     b2_kinematicBodynullptr0);


    b2Body* body0 = this->addNewSprite(Vec2(240180), Size(3232),

                                                                 b2_dynamicBody"SpinningPeas.png"1);


    b2Body* body1 = this->addNewSprite(Vec2(240160 - 100), Size(20010),

                                                                 b2_dynamicBodynullptr2);

    b2Body* body2 = this->addNewSprite(Vec2(240160 + 100), Size(20010),

                                                                 b2_dynamicBodynullptr2);

    b2Body* body3 = this->addNewSprite(Vec2(240 - 100160), Size(10200),

                                                                 b2_dynamicBodynullptr2);

    b2Body* body4 = this->addNewSprite(Vec2(240 + 100160), Size(10200),

                                                                 b2_dynamicBodynullptr2);

    b2Body* body5 = this->addNewSprite(Vec2(240110), Size(10100),

                                                                 b2_dynamicBodynullptr2);


    b2WeldJointDef weldJointDef1;

    weldJointDef1.Initialize(body1, _parent, body1->GetPosition());

    b2WeldJoint* weldJoint1 = (b2WeldJoint *)_world->CreateJoint(&weldJointDef1);


    b2WeldJointDef weldJointDef2;

    weldJointDef2.Initialize(body2, _parent, body2->GetPosition());

    b2WeldJoint* weldJoint2 = (b2WeldJoint *)_world->CreateJoint(&weldJointDef2);


    b2WeldJointDef weldJointDef3;

    weldJointDef3.Initialize(body3, _parent, body3->GetPosition());

    b2WeldJoint* weldJoint3 = (b2WeldJoint *)_world->CreateJoint(&weldJointDef3);


    b2WeldJointDef weldJointDef4;

    weldJointDef4.Initialize(body4, _parent, body4->GetPosition());

    b2WeldJoint* weldJoint4 = (b2WeldJoint *)_world->CreateJoint(&weldJointDef4);


    b2WeldJointDef weldJointDef5;

    weldJointDef5.Initialize(body5, _parent, body5->GetPosition());

    b2WeldJoint* weldJoint5 = (b2WeldJoint *)_world->CreateJoint(&weldJointDef5);



    _parent->SetAngularVelocity(0.5f);

}







바디(body)를 회전시키라고 했더니 학생이 다음과 같이 똑같이 만들었습니다.
(공부를 위해 똑같이 따라 만든 것입니다.)


2017년 경일게임스쿨 5기 윤현민 : Minimal Maze