Beispiel #1
0
struct list *createList(int s) {
	struct list *p;
	p = malloc(sizeof(struct list));
	p -> head = p -> tail = NULL;
	SETSIZE(p, s);
	return p;
};
void BackgroundLayer::createBackground(std::string filename)
{
	bg = Sprite::create(filename);
	bg->setAnchorPoint(Point::ZERO);
	SETSIZE(bg, 1);
	bg->setPosition(Point::ZERO);
	this->addChild(bg);

	tempBg = Sprite::create(filename);
	tempBg->setAnchorPoint(Point(1, 0));
	SETSIZE(tempBg, 1);
	tempBg->setPosition(Point(visibleSize.width, 0));
	tempBg->setVisible(false);
	this->addChild(tempBg, 0);

	bgWidth = bg->getContentSize().width * bg->getScaleY();
}
Beispiel #3
0
struct object * staticAllocate(int sz) {
    staticPointer = WORDSDOWN(staticPointer, sz + 2);

    if (staticPointer < staticBase) {
        budd_panic_pointer("insufficient static memory", staticPointer);
    }

    SETSIZE(staticPointer, sz);
    return(staticPointer);
}
Beispiel #4
0
struct object * staticIAllocate(int sz) {
    int trueSize;
    struct object *result;

    trueSize = (sz + BytesPerWord - 1) / BytesPerWord;
    result = staticAllocate(trueSize);
    SETSIZE(result, sz);
    result->size |= FLAG_BIN;
    return result;
}
void GameScene::createQuitButton()
{
	auto closeItem = MenuItemImage::create("CloseNormal.png", "CloseSelected.png", CC_CALLBACK_1(GameScene::quitGame, this));
	closeItem->setPosition(Point(visibleSize.width / 2, 0));
	closeItem->setAnchorPoint(Point(0.5f, 0));
	SETSIZE(closeItem, 0.1);
	auto menu = Menu::create(closeItem, NULL);
	menu->setPosition(Point::ZERO);
	this->addChild(menu, 1);
}
Beispiel #6
0
struct object * gcialloc(int sz) {
    int trueSize;
    struct object *result;

    trueSize = (sz + BytesPerWord - 1) / BytesPerWord;
    result = gcalloc(trueSize);
    SETSIZE(result, sz);
    result->size |= FLAG_BIN;
    return result;
}
Beispiel #7
0
void GameScene::lose()
{
	setBulletSpeed(0);
	setTrashSpeed(0);

	this->removeChild(player);

	Sprite* s = Sprite::create("sprites/lose.png");
	s->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
	SETSIZE(s, 0.3);
	this->addChild(s);
}
Beispiel #8
0
struct object * gcalloc(int sz) {
    struct object *result;

    memoryPointer = WORDSDOWN(memoryPointer, sz + 2);

    if (memoryPointer < memoryBase) {
        return gcollect(sz);
    }

    SETSIZE(memoryPointer, sz);
    return(memoryPointer);
}
Beispiel #9
0
void ButtonLayer::RGBRGBMode()
{
    setUpRightButton(right, GREEN);
    setDownRightButton(right, BLUE);
    setUpLeftButton(left, GREEN);
    setDownLeftButton(left, BLUE);

    rS = Sprite::create();
    changeSprite(rS, RED);
    SETSIZE(rS, 0.1);
    rS->setPosition(Point(right, (up+down)/2));
    this->addChild(rS);

    lS = Sprite::create();
    changeSprite(lS, RED);
    SETSIZE(lS, 0.1);
    lS->setPosition(Point(left, (up+down)/2));
    this->addChild(lS);

    rightButtonFlag = true;
    leftButtonFlag = true;
}
Beispiel #10
0
Obstacle* ColorWallLayer::createWall(std::string filename)
{
	Sprite* wall;
	wall = Sprite::createWithSpriteFrameName(filename);
	SETSIZE(wall, 1);
	wall->setAnchorPoint(Point(0, 0));
	wall->setPosition(Point(origin.x + visibleSize.width, origin.y));
	addChild(wall);
	Obstacle* cw = Obstacle::create();
	cw->wall = wall;
	blockArray->pushBack(cw);

	return cw;
}
Beispiel #11
0
void XMX_Button::XMX_Button_addButton(int id, Sprite* button, float size, int x, int y, Method press/* =NULL */, Method release/* =NULL */)
{
	XMX_Button_Node* adding = XMX_Button_Node::create();
	SETSIZE(button, size);
	button->setPosition(Point(x,y));
	adding->button = button;
	addChild(adding->button);
	adding->rect = button->getBoundingBox();
	adding->onPress = press;
	adding->onRelease = release;
	adding->buttonFlag = true;
	adding->allowFlag = true;

	XMX_Button_addButton(id, adding);
}
Beispiel #12
0
void XMX_Button::XMX_Button_changeButton(int id, Sprite* button, float size, int x, int y)
{
	XMX_Button_Node* p = XMX_Button_searchButton(id);
	if (!p)
	{
		XMX_Button_addButton(id, button, size, x, y);
	}
	else
	{
		removeChild(p->button);
		SETSIZE(button, size);
		button->setPosition(Point(x,y));
		p->button = button;
		addChild(p->button);
		p->rect = button->getBoundingBox();
	}
}
Beispiel #13
0
void GameScene::setLead(Warrior* le)
{
	moveableGroup->setLead(le);

	informationGroup->addAllAttributes(le->getAllAttributes());
	informationGroup->addNickNameAttributes(le->getNickName());
	le->setAttributesChanged(false);

	lead = le;

	moveableGroup->removeChild(leadRound);
	leadRound = Sprite::create("players/lead.png");
	SETSIZE(leadRound, 0.11);
	leadRound->setPosition(node[le->getPositionIndex()]);
	moveableGroup->addChild(leadRound);

	focusPoint(true, lead->getPositionIndex());
}
Beispiel #14
0
bool Trash::init()
{
#define TrashSize 0.12

	bool bRet = false;
	do
	{
		CC_BREAK_IF(!Node::init());

		trash = Sprite::create("sprites/trash.png");
		trash->setAnchorPoint(Point(0, 0.5));
		SETSIZE(trash, TrashSize);
		this->addChild(trash);

		bRet = true;
	} while (0);
	return bRet;
}
Beispiel #15
0
void GameScene::win()
{
	setBulletSpeed(0);
	setTrashSpeed(0);

	this->removeChild(enemy);
	for (int i = danmakus.size() - 1; i >= 0; --i)
	{
		Danmaku* danmaku = danmakus.at(i);
		danmakus.eraseObject(danmaku);
		this->removeChild(danmaku);
	}

	Sprite* s = Sprite::create("sprites/win.png");
	s->setPosition(Point(visibleSize.width / 2, visibleSize.height / 2));
	SETSIZE(s, 0.3);
	this->addChild(s);
}
Beispiel #16
0
struct object * gcollect(int sz) {
    int i;

    gccount++;

    /* first change spaces */
    if (globalBudd.inSpaceOne) {
        memoryBase = globalBudd.spaceTwo;
        globalBudd.inSpaceOne = 0;
        oldBase = globalBudd.spaceOne;
    } else {
        memoryBase = globalBudd.spaceOne;
        globalBudd.inSpaceOne = 1;
        oldBase = globalBudd.spaceTwo;
    }

    memoryPointer = memoryTop = memoryBase + globalBudd.spaceSize;
    oldTop = oldBase + globalBudd.spaceSize;

    /* then do the collection */
    for (i = 0; i < rootTop; i++) {
        rootStack[i] = gc_move((struct mobject *)rootStack[i]);
    }

    for (i = 0; i < staticRootTop; i++) {
        (*staticRoots[i]) =  gc_move((struct mobject *)
                                     *staticRoots[i]);
    }

    flushCache();

    /* then see if there is room for allocation */
    memoryPointer = WORDSDOWN(memoryPointer, sz + 2);

    if (memoryPointer < memoryBase) {
        budd_panic_int("insufficient memory after garbage collection", sz);
    }

    SETSIZE(memoryPointer, sz);
    return(memoryPointer);
}
Beispiel #17
0
void Warrior::setWarriorSprite(Sprite* s, float size)
{
	warrior = s;
	SETSIZE(warrior, size);
	addChild(warrior);
}
Beispiel #18
0
static struct object * gc_move(struct mobject *ptr) {
    struct mobject *old_address = ptr, *previous_object = 0,
                   *new_address = 0, *replacement  = 0;
    int sz;

    while (1) {
        /*
         * part 1.  Walking down the tree
         * keep stacking objects to be moved until we find
         * one that we can handle
         */
        for (;; ) {
            /*
             * SmallInt's are not proper memory pointers,
             * so catch them first.  Their "object pointer"
             * value can be used as-is in the new space.
             */
            if (IS_SMALLINT(old_address)) {
                replacement = old_address;
                old_address = previous_object;
                break;

                /*
                 * If we find a pointer in the current space
                 * to the new space (other than indirections) then
                 * something is very wrong
                 */
            } else if ((old_address >=
                        (struct mobject *)memoryBase)
                       && (old_address <= (struct mobject *)memoryTop)) {
                budd_panic_pointer(
                    "GC invariant failure -- address in new space",
                    old_address);

                /* else see if not  in old space */
            } else if ((old_address < (struct mobject *)oldBase) ||
                       (old_address > (struct mobject *)oldTop)) {
                replacement = old_address;
                old_address = previous_object;
                break;

                /* else see if already forwarded */
            } else if (old_address->size & FLAG_GCDONE) {
                if (old_address->size & FLAG_BIN) {
                    replacement = old_address->data[0];
                } else {
                    sz = SIZE(old_address);
                    replacement = old_address->data[sz];
                }

                old_address = previous_object;
                break;

                /* else see if binary object */
            } else if (old_address->size & FLAG_BIN) {
                int isz;

                isz = SIZE(old_address);
                sz = (isz + BytesPerWord - 1) / BytesPerWord;
                memoryPointer = WORDSDOWN(memoryPointer,
                                          sz + 2);
                new_address = (struct mobject *)memoryPointer;
                SETSIZE(new_address, isz);
                new_address->size |= FLAG_BIN;

                while (sz) {
                    new_address->data[sz] =
                        old_address->data[sz];
                    sz--;
                }
                old_address->size |= FLAG_GCDONE;
                new_address->data[0] = previous_object;
                previous_object = old_address;
                old_address = old_address->data[0];
                previous_object->data[0] = new_address;
                /* now go chase down class pointer */

                /* must be non-binary object */
            } else {
                sz = SIZE(old_address);
                memoryPointer = WORDSDOWN(memoryPointer,
                                          sz + 2);
                new_address = (struct mobject *)memoryPointer;
                SETSIZE(new_address, sz);
                old_address->size |= FLAG_GCDONE;
                new_address->data[sz] = previous_object;
                previous_object = old_address;
                old_address = old_address->data[sz];
                previous_object->data[sz] = new_address;
            }
        }

        /*
         * part 2.  Fix up pointers,
         * move back up tree as long as possible
         * old_address points to an object in the old space,
         * which in turns points to an object in the new space,
         * which holds a pointer that is now to be replaced.
         * the value in replacement is the new value
         */
        for (;; ) {
            /* backed out entirely */
            if (old_address == 0) {
                return (struct object *)replacement;
            }

            /* case 1, binary or last value */
            if ((old_address->size & FLAG_BIN) ||
                (SIZE(old_address) == 0)) {
                /* fix up class pointer */
                new_address = old_address->data[0];
                previous_object = new_address->data[0];
                new_address->data[0] = replacement;
                old_address->data[0] = new_address;
                replacement = new_address;
                old_address = previous_object;
            } else {
                sz = SIZE(old_address);
                new_address = old_address->data[sz];
                previous_object = new_address->data[sz];
                new_address->data[sz] = replacement;
                sz--;

                /*
                 * quick cheat for recovering zero fields
                 */
                while (sz && (old_address->data[sz] == 0)) {
                    new_address->data[sz--] = 0;
                }

                SETSIZE(old_address, sz);
                old_address->size |= FLAG_GCDONE;
                new_address->data[sz] = previous_object;
                previous_object = old_address;
                old_address = old_address->data[sz];
                previous_object->data[sz] = new_address;
                break; /* go track down this value */
            }
        }
    }
}