示例#1
0
void UIMainWindow::update (uint32_t deltaTime)
{
	UIWindow::update(deltaTime);
	if (!_player->isMovementActive()) {
		flyPlayer();
	}
	if (!_grandpa->isMovementActive()) {
		moveSprite(_grandpa, 0.00008f);
	}
	if (!_mammut->isMovementActive()) {
		moveSprite(_mammut, 0.0001f);
	}
}
示例#2
0
文件: actor.c 项目: TomMinor/Snake
///
/// \brief UpdateSnakePos Offsets the snake, sets up the state of the head
/// and moves the rest of the body
/// \param _head
/// \param io_tail
/// \param _dir The direction the head should move
///
void updateSnakePos(Node * _head,
                    Node ** io_tail,
                    Move _dir)
{
  if(_head != NULL && *io_tail!=NULL)
  {
    if(_dir != NOTMOVING)
    {
      const int segmentRadius = _head->pos.h;
      const int moveOffset = segmentRadius/4;
      Node newNeck = *_head; // Keep track of the head's old position

      addState(_head, MOVING);

      moveSprite(_dir, &_head->pos, moveOffset);

      // Store the last move direction so the head
      // points in the right direction when there is no input
      _head->idleDirection = _dir;

      shiftSnakeBody(_head, io_tail, &newNeck.pos);
    }
    else
    {
      removeState(_head, MOVING);
    }
  }
}
示例#3
0
void IntroScene::run() {
	while (running) {
		handleEvents();
		moveSprite();
		checkCollision();
		render();
		update();
	}
}
示例#4
0
void Level::run() {
	while (running) {
		handleEvents();
		loadEnemyBullet();
		moveSprite();
		checkCollision();
		render();
		update();
	}
}
示例#5
0
/* Move a sprite. */
uint8_t moveSpriteIfNotBorder(uint8_t slot, int8_t x, int8_t y) {
	/* Fail if horizontal position is not within boundaries. */
	if ((GameSpriteSlots[slot].x+x<SPRITE_BORDER_WIDTH) || (GameSpriteSlots[slot].x+x>(SCREEN_WIDTH<<3)+SPRITE_BORDER_WIDTH))
		return 0;

	/* Actuall move sprite. */
	moveSprite(slot,x,y);

	/* Sucess. */
	return 1;
}
示例#6
0
void
moveSprites(SDL_Surface** screen, struct sprite** letters, int letterSpeed)
{
    struct sprite* current;

	current= *letters;
	while(current!=NULL){
		moveSprite(&(*screen), &current, letterSpeed);
		current = current->next;
	}
	current = *letters;
	while(current!=NULL){
		showSprite(&(*screen), &current);
		current=current->next;
	}
	SDL_Flip(*screen);
	current = *letters;
	while(current!=NULL){
		resetBackground(&(*screen), &current);
		current= current->next;
	}
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !CCLayer::init() )
    {
        return false;
    }
    
    CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
this->setTouchEnabled(true);
    /////////////////////////////
    // 2. add a menu item with "X" image, which is clicked to quit the program
    //    you may modify it.

    // add a "close" icon to exit the progress. it's an autorelease object
	CCSprite* pImage = CCSprite::create("bird.png");
	
	this->addChild(pImage,3,kBird);
	moveSprite();
    CCMenuItemImage *pCloseItem = CCMenuItemImage::create(
                                        "CloseNormal.png",
                                        "CloseSelected.png",
                                        this,
                                        menu_selector(HelloWorld::menuCloseCallback));
    
	pCloseItem->setPosition(ccp(origin.x + visibleSize.width - pCloseItem->getContentSize().width/2 ,
                                origin.y + pCloseItem->getContentSize().height/2));

    // create menu, it's an autorelease object
    CCMenu* pMenu = CCMenu::create(pCloseItem, NULL);
    pMenu->setPosition(CCPointZero);
    this->addChild(pMenu, 1);

    /////////////////////////////
    // 3. add your codes below...

    // add a label shows "Hello World"
    // create and initialize a label
    
    CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", TITLE_FONT_SIZE);
    
    // position the label on the center of the screen
    pLabel->setPosition(ccp(origin.x + visibleSize.width/2,
                            origin.y + visibleSize.height - pLabel->getContentSize().height));

    // add the label as a child to this layer
    this->addChild(pLabel, 1);

    // add "HelloWorld" splash screen"
    CCSprite* pSprite = CCSprite::create("HelloWorld.png");

    // position the sprite on the center of the screen
    pSprite->setPosition(ccp(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(pSprite, 0);
    
    return true;
}