Exemple #1
0
static void testInit() {
	Camera * cameraPtr;
	Camera cameraStruct;
	
	cameraPtr = Camera_create();
	TestCase_assert(cameraPtr->orientation.x == 0.0f, "Expected 0 but got %f", cameraPtr->orientation.x);
	TestCase_assert(cameraPtr->orientation.y == 0.0f, "Expected 0 but got %f", cameraPtr->orientation.y);
	TestCase_assert(cameraPtr->orientation.z == 0.0f, "Expected 0 but got %f", cameraPtr->orientation.z);
	TestCase_assert(cameraPtr->orientation.w == 1.0f, "Expected 1 but got %f", cameraPtr->orientation.w);
	TestCase_assert(cameraPtr->position.x == 0.0f, "Expected 0 but got %f", cameraPtr->position.x);
	TestCase_assert(cameraPtr->position.y == 0.0f, "Expected 0 but got %f", cameraPtr->position.y);
	TestCase_assert(cameraPtr->position.z == 0.0f, "Expected 0 but got %f", cameraPtr->position.z);
	TestCase_assert(cameraPtr->dispose != NULL, "Method unexpectedly NULL");
	TestCase_assert(cameraPtr->getMatrix != NULL, "Method unexpectedly NULL");
	cameraPtr->dispose(cameraPtr);
	
	Camera_init(&cameraStruct);
	TestCase_assert(cameraStruct.orientation.x == 0.0f, "Expected 0 but got %f", cameraStruct.orientation.x);
	TestCase_assert(cameraStruct.orientation.y == 0.0f, "Expected 0 but got %f", cameraStruct.orientation.y);
	TestCase_assert(cameraStruct.orientation.z == 0.0f, "Expected 0 but got %f", cameraStruct.orientation.z);
	TestCase_assert(cameraStruct.orientation.w == 1.0f, "Expected 1 but got %f", cameraStruct.orientation.w);
	TestCase_assert(cameraStruct.position.x == 0.0f, "Expected 0 but got %f", cameraStruct.position.x);
	TestCase_assert(cameraStruct.position.y == 0.0f, "Expected 0 but got %f", cameraStruct.position.y);
	TestCase_assert(cameraStruct.position.z == 0.0f, "Expected 0 but got %f", cameraStruct.position.z);
	TestCase_assert(cameraStruct.dispose != NULL, "Method unexpectedly NULL");
	TestCase_assert(cameraStruct.getMatrix != NULL, "Method unexpectedly NULL");
	cameraStruct.dispose(&cameraStruct);
}
Exemple #2
0
Scene* Scene_create(GameEngine* engine, Scene* lastScene) {
    Scene* this = allocStruct(Scene);

    this->engine = engine;
    SDL_Point screenSize;
    SDL_RenderGetLogicalSize(engine->renderer, &screenSize.x, &screenSize.y);
    this->camera = Camera_create(screenSize.x, screenSize.y);
    this->walkableBounds.x = 0;
    this->walkableBounds.w = 0;
    this->walkableBounds.y = 295 * PHYSICS_SCALE;
    this->walkableBounds.h = 185 * PHYSICS_SCALE;

    this->entities = Vector_Create();
    this->triggers = Vector_Create();
    this->bodies = Vector_Create();
    this->shapes = Vector_Create();

    this->sky = Sky_create(engine->textureCache);

    withSprintf(path, "images/%s/bg.png", anyArgs("red"), {
            SDL_Texture* texture = TextureCache_getForUnconstantPath(engine->textureCache, path);
            this->background = Sprite_create(texture);
        });