axmol/tests/cpp-tests/Source/ChipmunkTestBed/ChipmunkTestBed.h

346 lines
8.5 KiB
C
Raw Normal View History

/****************************************************************************
* Copyright (c) 2021 @aismann; Peter Eismann, Germany; dreifrankensoft
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
2021-12-28 16:06:23 +08:00
//
// cocos2d
//
#ifndef __CHIPMUNKTESTBED_H__
#define __CHIPMUNKTESTBED_H__
#include "axmol.h"
#include "chipmunk/chipmunk.h"
#include "../BaseTest.h"
#include "extensions/cocos-ext.h"
#include "demo/ChipmunkDemo.h"
2021-12-28 16:06:23 +08:00
class ChipmunkTestBed : public TestCase
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ChipmunkTestBed);
2021-12-28 16:06:23 +08:00
ChipmunkTestBed();
~ChipmunkTestBed();
2021-12-28 16:06:23 +08:00
void onEnter() override;
void createResetButton();
2022-10-18 19:17:36 +08:00
void reset(ax::Ref* sender);
2021-12-28 16:06:23 +08:00
void update(float dt) override;
virtual void initPhysics();
2022-10-18 19:17:36 +08:00
void onMouseDown(ax::Event* event);
void onMouseUp(ax::Event* event);
void onMouseMove(ax::Event* event);
2021-12-28 16:06:23 +08:00
void DrawInfo();
void updateInit(ChipmunkDemo tt);
2021-12-28 16:06:23 +08:00
cpSpace* _space; // strong ref
2022-10-18 19:17:36 +08:00
ax::extension::PhysicsDebugNodeChipmunk2D* _debugLayer; // weak ref
2021-12-28 16:06:23 +08:00
int keyPresses;
bool mousePresses = false;
private:
2022-10-18 19:17:36 +08:00
ax::EventListenerMouse* _mouseListener;
ax::Node* _trackNode;
ax::DrawNode* draw;
ax::Label* drawInfo;
};
2021-12-28 16:06:23 +08:00
class LogoSmashDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(LogoSmashDemo);
std::string title() const override;
void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PlinkDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PlinkDemo);
virtual std::string title() const override;
virtual void onEnter() override;
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class TumbleDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(TumbleDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PyramidStackDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PyramidStackDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PyramidToppleDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PyramidToppleDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class ChainsDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ChainsDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class OneWayDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(OneWayDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PlanetDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PlanetDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class TheoJansenDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(TheoJansenDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class TankDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(TankDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class BenchDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(BenchDemo);
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class SpringiesDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(SpringiesDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class StickyDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(StickyDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class ShatterDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ShatterDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class CraneDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(CraneDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class JointsDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(JointsDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class ConvexDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ConvexDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PumpDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PumpDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class PlatformerPlayerDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(PlatformerPlayerDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class QueryDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(QueryDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class ContactGraphDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ContactGraphDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class BuoyancyDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(BuoyancyDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class SliceDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(SliceDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class UnicycleDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(UnicycleDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
2021-12-28 16:06:23 +08:00
class ExampleDemo : public ChipmunkTestBed
{
public:
2021-12-28 16:06:23 +08:00
CREATE_FUNC(ExampleDemo);
virtual std::string title() const override;
virtual void onEnter() override;
2021-12-28 16:06:23 +08:00
void initPhysics() override;
virtual void update(float dt) override;
};
DEFINE_TEST_SUITE(ChipmunkTestBedTests);
#endif /* __CHIPMUNKTESTBED_H__ */