Exemplo n.º 1
0
void Entity::checkCollisionsWithLevel(Level &lvl) {
    
	if (!isAnyFieldBelowMe(lvl))
		int a = 0 ;
	// czy jednostka koliduje z czymœ od do³u
    if (isAnyFieldBelowMe(lvl))
        playerOnGround();

	// czy jednostka koliduje z czymœ od góry
    if(isAnyFieldAboveMe(lvl))
        fall();

	// czy jednostka koliduje z czymœ po lewej stronie
    if (isAnyFieldOnLeft(lvl)) 
        moveRight();
    
	// czy jednostka koliduje z czymœ po prawej stronie
    if (isAnyFieldOnRight(lvl))
        moveLeft();

};
Exemplo n.º 2
0
void CBip::processWalking()
{
    // Move normally in the direction
    if( xDirection == RIGHT )
    {
	moveRight( WALK_SPEED );
    }
    else
    {
	moveLeft( WALK_SPEED );
    }
    
  mTimer++;
  
  if(mTimer < WALK_TIME)
    return;  
  
  mTimer = 0;
  setAction(A_BIP_STAND);
	
}
Exemplo n.º 3
0
//--------------------------------------------------------------
void testApp::keyReleased(int key){

    switch(key){
        case OF_KEY_RETURN:
            current_point = (current_point+1)%4;
            break;
        case OF_KEY_LEFT:
            moveLeft();
            break;
        case OF_KEY_RIGHT:
            moveRight();
            break;
        case OF_KEY_UP:
            moveUp();
            break;
        case OF_KEY_DOWN:
            moveDown();
            break;
    }

}
Exemplo n.º 4
0
void Match::moveTowardBall(Player *p)
{
    int x = ball->getPosX(), y =  ball->getPosY(), px = p->getPosX(), py = p->getPosY();
    int team = p->getTeam();
    if((py < y && team == 1) || (py > y && team == 2))
    {
        moveLeft(p);
    }
    else if((py < y && team == 2) || (py > y && team == 1))
    {
        moveRight(p);
    }
    else if((px < x && team == 1) || (px > x && team == 2))
    {
        moveUp(p);
    }
    else if((px < x && team == 2) || (px > x && team == 1))
    {
        moveBack(p);
    }
}
Exemplo n.º 5
0
void keyboard(unsigned char key, int x, int y) {
	switch (key) {
		case 27:
		case 'q':
		case 'Q':
			/* quit the program */
			exit(0);
			break;
		case ' ':
			/* toggle between opengl and sofware rendering */
			opengl_test = !opengl_test;
			redisplay();
			break;
		case 'w':
			moveForward();
			redisplay();
			break;
		case 'a':
			moveLeft();
			redisplay();
			break;
		case 'd':
			moveRight();
			redisplay();
			break;
		case 's':
			moveBack();
			redisplay();
			break;
		case 'b':
			/* toggle bilinear interpolation of the textures */
			bilerp_flag = !bilerp_flag;
			switchTextureFiltering();
			redisplay();
		default:
			break;
	}

	return;
}
Exemplo n.º 6
0
	bool Camera::update(int pixelsMovedHorizontal, int pixelsMovedVertical)
	{
		if ( GetAsyncKeyState(Qt::Key::Key_W))
		{
			moveForward();
		}
		if ( GetAsyncKeyState(Qt::Key::Key_S))
		{
			moveBackward();
		}
		if ( GetAsyncKeyState(Qt::Key::Key_A))
		{
			moveLeft();
		}	
		if ( GetAsyncKeyState(Qt::Key::Key_D))
		{
			moveRight();
		}	
		if ( GetAsyncKeyState(Qt::Key::Key_R))
		{
			moveUp();
		}	
		if ( GetAsyncKeyState(Qt::Key::Key_F))
		{
			moveDown();
		}	
		if ( GetAsyncKeyState(VK_OEM_MINUS))
		{
			stepMovement(-0.2f);
		}	
		if ( GetAsyncKeyState(VK_OEM_PLUS))
		{
			stepMovement(0.2f);
		}
		if ( GetAsyncKeyState(VK_RBUTTON))
		{
			turn(pixelsMovedHorizontal, pixelsMovedVertical);
		}
		return true;
	}
void CMimrock::processJump()
{
    if(xDirection == LEFT)
    {
	moveLeft(JUMP_SPEED);
    }
    else
    {
	moveRight(JUMP_SPEED);
    }
    
    mTimer--;
    
    if(blockedd && yinertia>=0)
    {
	mTimer = BOUNCE_TIME;
	yinertia = -BOUNCE_HEIGHT;
	setAction(A_MIMROCK_BOUNCE);
	playSound( SOUND_KEEN_BUMPHEAD );
    }
    
}
Exemplo n.º 8
0
void Character::moveToward(Character* aim, bool isDirFixed){
	//int aimPosX = aim->getPositionX();
	//MessageBox(Value(aimPosX).asString().c_str(), "test");
	int offX = aim->getPositionX() - this->getPositionX();
	int offY = aim->getPositionY() - this->getPositionY();
	if (abs(offY) >= abs(offX)){
		if (offY < 0){
			moveDown(isDirFixed);
		}
		else if (offY > 0){
			moveUp(isDirFixed);
		}
	}
	else{
		if (offX < 0){
			moveLeft(isDirFixed);
		}
		else if (offX > 0){
			moveRight(isDirFixed);
		}
	}
}
Exemplo n.º 9
0
/**
* Move zombie one space
*
* @param dungeon A pointer to the dungeon
* @param zombie A pointer to the zombie
* @param moveNum The number of moves the player has made
*
* @return RESULT_DIE if the player has died in the game
*         else 0
*/
int moveZombie(Dungeon* dungeon, Object* zombie, unsigned int moveNum) {
    int result=0;

    if(zombie->moves == moveNum)
        return 0;

    if(zombie->direction->x == DIR_LEFT) {
        if((result = moveLeft(dungeon, zombie)))
            return result;
        if((result = checkFloor(dungeon, zombie)))
            return result;
    } else if(zombie->direction->x == DIR_RIGHT) {
        if((result = moveRight(dungeon, zombie)))
            return result;
        if((result = checkFloor(dungeon, zombie)))
            return result;
    }

    zombie->moves++;

    return 0;
}
Exemplo n.º 10
0
void GameScene::onTouchEnded(Touch* touch, Event* event) {
    if (isWin() || isGameOver()) {
        return;
    }

    GestureDetector::GestureType gesture = mGestureDetector.endPoint(touch->getLocation());
    bool gestureValid = true;
    bool moved = false;
    switch (gesture) {
    case GestureDetector::MoveLeft:
        moved = moveLeft();
        break;
    case GestureDetector::MoveRight:
        moved = moveRight();
        break;
    case GestureDetector::MoveUp:
        moved = moveUp();
        break;
    case GestureDetector::MoveDown:
        moved = moveDown();
        break;
    case GestureDetector::Unknown:
    default:
        gestureValid = false;
        break;
    }

    if (gestureValid) {
        if (moved) {
            generateCard(true);
            CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(
                    MOVE_SUCESS_SOUND, false);
        } else {
            CocosDenshion::SimpleAudioEngine::getInstance()->playEffect(
                    MOVE_FAILED_SOUND, false);
        }
        doCheck();
    }
}
Exemplo n.º 11
0
// 控制敌方向下一层地板移动
void Enemy::downFloor()
{
	log("Enemy::downFloor");
	//首先获取主角相对于敌人的位置
	RelativeDirection rd = getActorRD();

	if (canDownSuccess(getPosition())) {
		moveDown();
	}
	else if (isAboveFloor(getPosition())){
		if (rd == RD_LEFT ) {
			if (!isInOneFloor()) {
				moveLeft();
			}
		}
		else if (rd == RD_RIGHT) {
			if (!isInOneFloor()) {
				moveRight();
			}
		}
	}
}
Exemplo n.º 12
0
void doallMoves(from)
{
    char game[ 36 ];
    memcpy(game, moves[ from ].game, 36);

    int level = moves[ from ].level + 1;

    char have[ 256 ];
    memset(have, 0, 256);

    for (int pos = 0; pos < 36; pos++)
    {
        int ccc = game[ pos ];

        if ((ccc == '_') || have[ ccc ]) continue;

        have[ ccc ] = 1;

        int len = blocks[ ccc ].len;
        int dir = blocks[ ccc ].dir;

        if (dir == 0)
        {
            moveLeft(game, from, level, pos, ccc, len, 1);
            if (solved) return;

            moveRight(game, from, level, pos, ccc, len, 1);
            if (solved) return;
        }
        else
        {
            moveUp(game, from, level, pos, ccc, len, 1);
            if (solved) return;

            moveDown(game, from, level, pos, ccc, len, 1);
            if (solved) return;
        }
    }
}
Exemplo n.º 13
0
void Match::moveToOwnGoal(Player *p)
{
    int x, y;
    int team = p->getTeam();
    int px = p->getPosX(), py = p->getPosY();

    if(team == 1)
    {
        x = 0;
        y = 3;
    }
    else if(team == 2)
    {
        x = Player::FIELD_WIDTH;
        y = 3;
    }

    if((px < x && team == 1) || (px > x && team == 2))
    {
        moveUp(p);
    }
    else if((px < x && team == 2) || (px > x && team == 1))
    {
        moveBack(p);
    }
    else if((py < y && team == 1) || (py > y && team == 2))
    {
        moveLeft(p);
    }
    else if((py < y && team == 2) || (py > y && team == 1))
    {
        moveRight(p);
    }
    else if(py == y && px == x)
    {
        moveUp(p);
    }
}
Exemplo n.º 14
0
//show integer for a specified amount of time
void SegDisp::showInteger(int num, int ms, char align){
	int d[4] = {sd_EMPTY, sd_EMPTY, sd_EMPTY, sd_EMPTY};
	if (num > 9999){
		Error(8);
	}
	else if (num < -999){
		Error(9);
	}
	else if (align!='L' && align!='R'){
		Error(10);
	}
	else if(ms < 0){
		Error(11);
	}
	splitInteger(num, d);
	
	//handle alignment
	if (align=='L'){
		moveLeft(d);
	}
	
	showSequence(numbers[d[0]],numbers[d[1]],numbers[d[2]],numbers[d[3]],ms,-1);
}
Exemplo n.º 15
0
void InfoScreens::infoModeBtnClicked(MultiFunctionButtonAction event)
{
	switch (event) {
		case BTN_CLICK:
//			debugf("click");
			moveRight();
			break;
		case BTN_DOUBLE_CLICK:
//			debugf("BTN_DOUBLE_CLICK");
			moveLeft();
			break;
		case BTN_LONG_CLICK:
//			debugf("BTN_LONG_CLICK, going to edit mode, %i", getCurrent()->getallEditableParams().size());

			if(getCurrent()->getallEditableParams().size() != 0) {
				setViewMode(ViewMode::EDIT);
			}
			break;
		case BTN_HOLD_CLICK:
//			debugf("BTN_HOLD_CLICK, going to edit mode");
			break;
	}
}
Exemplo n.º 16
0
void CSparky::processWalking()
{
  
  mLookTimer++;
  
  // Move normally in the direction
  if( xDirection == RIGHT )
  {
    moveRight( WALK_SPEED );
  }
  else
  {
    moveLeft( WALK_SPEED );
  }
   
  mTimer = 0;
  
  if(mLookTimer >= TIME_FOR_LOOK)
  {
    setAction(A_SPARKY_LOOK);
    mLookTimer = 0;
  }
}
Exemplo n.º 17
0
// calls other move functions
void gameBoard::move(char direction) {
            
    // move tiles up
    if (direction == 'w') {
        moveUp();
    }
        
    // move tiles down
    else if (direction == 's') {
        moveDown();
    }
        
    // move tiles left
    else if (direction == 'a') {
        moveLeft();
    }
        
    // move tiles right
    else if (direction == 'd') {
        moveRight();
    }

}
Exemplo n.º 18
0
void InfoScreens::editModeBtnClicked(MultiFunctionButtonAction event)
{
	switch (event) {
		case BTN_CLICK:
			debugf("click");
			moveRight();
//				handleClick();
			break;
		case BTN_DOUBLE_CLICK:
			debugf("BTN_DOUBLE_CLICK");
			moveLeft();
//				handleDoubleClick();
			break;
		case BTN_HOLD_CLICK:
			debugf("BTN_HOLD_CLICK");
//				handleLongClick();
			break;
		case BTN_LONG_CLICK:
			debugf("BTN_LONG_CLICK");
//				handleHoldClick();
			break;
	}
}
Exemplo n.º 19
0
void FrenzyWindow::keyPressEvent(QKeyEvent * event)
{

    switch(event->key())
    {
    case Qt::UpArrow:
        emit moveUp();
        break;
    case Qt::DownArrow:
        emit moveDown();
        break;
    case Qt::LeftArrow:
        emit moveLeft();
        break;
    case Qt::RightArrow:
        emit moveRight();
        break;
    default:
            event->ignore();
            break;

    }
}
Exemplo n.º 20
0
void CBlooguard::processWalking()
{
    // Move normally in the direction
    if( xDirection == RIGHT )
    {
	moveRight( WALK_SPEED );
    }
    else
    {
	moveLeft( WALK_SPEED );
    }
    
    mTimer++;
    if( mTimer < TIME_UNTIL_CLUB )  
	return;
    
    mTimer = 0;
    
    if(mGoodClubChance)
    {
	setAction(A_BLOOGUARD_CLUBBING);
    }
}
Exemplo n.º 21
0
void scramble_times(Board_t* board, int times){
    int i;
    for(i=0; i<times; i++){
        switch(rand()%4){
        case 0: 
            if((*board).zero_r>0)
                moveUp(board);
            break;
        case 1:
            if((*board).zero_r<(BOARD_SIZE-1))
                moveDown(board);
            break;
        case 2: 
            if((*board).zero_c>0)
                moveLeft(board);
            break;
        case 3:
            if((*board).zero_c<(BOARD_SIZE-1))
                moveRight(board);
            break;
        }
    }
}
Exemplo n.º 22
0
/**
* Attempt to jump JUMP_HEIGHT spaces up and to the left
* NOTE: If there are not JUMP_HEIGHT spaces, player will stay at the highest
*       point until JUMP_HEIGHT moves upward have been made. The player will
*       then move down until the floor is reached. Player will move left a
*       space for each move up and down unless a wall or floor is hit.
*
* @param dungeon A pointer to the dungeon
* @param dungeon A pointer to the object to move
*
* @return RESULT_WIN if the player has won the game
*         RESULT_DIE if the player has died in the game
*         else 0
*/
int jumpLeft(Dungeon* dungeon, Object* object) {
    int result=0;

    object->direction->y = DIR_UP;
    object->direction->x = DIR_LEFT;
    for(int up=1; up<=JUMP_HEIGHT; up++) {
        if((result = moveUp(dungeon, object)))
            return result;
        if((result = moveLeft(dungeon, object)))
            return result;
        if((result = moveEnemies(dungeon, object->moves)))
            return result;
        sendCurrentDungeonView(dungeon->start);
    }

    object->direction->y = DIR_DOWN;
    if((result = checkFloor(dungeon, object)))
        return result;

    object->direction->x = 0;

    return 0;
}
Exemplo n.º 23
0
void CPoisonSlug::processCrawling()
{

    if( m_timer < SLUG_MOVE_TIMER )
    {
        m_timer++;
        return;
    }
    else
    {
        m_timer = 0;
    }

    // Chance to poo
    if( getProbability(30) )
    {
        m_timer = 0;
        setAction( A_SLUG_POOING );
        playSound( SOUND_SLUG_DEFECATE );
        CSlugSlime *slime = new CSlugSlime(mp_Map, 0, getXMidPos(), getYDownPos()-(1<<(CSF-1)), 0);
        gEventManager.add( new EventSpawnObject( slime ) );

        xDirection = -xDirection;
        return;
    }

    // Move normally in the direction
    if( xDirection == RIGHT )
    {
        moveRight( 2*m_Action.h_anim_move );
    }
    else
    {
        moveLeft( 2*m_Action.h_anim_move );
    }
}
Exemplo n.º 24
0
// 控制敌方向上一层地板移动
void Enemy::upFloor()
{
	log("Enemy::upFloor");
	//首先获取主角相对于敌人的位置
	RelativeDirection rd = getActorRD();

	if (canUpSuccess(getPosition())) {  // 如果可以向上移动则向上移动
		log("Enemy::upFloor::moveUp");
		moveUp();
	} 
	//否则搜索上一层次离自己最近的
	else if (isAboveFloor(getPosition())){                     //否则尽量靠近主角  // 要判断敌人是否在地板上才能决定左右移动
		if (!isInOneFloor()) { //不在同一层的话
			auto floor = getCurUpperFloor(getPosition());
			RelativeDirection rd = getUpperFloorRD(floor);
			if (rd == RD_LEFT) {
				moveLeft();
			}
			else {
				moveRight();
			}
		}
	}
}
Exemplo n.º 25
0
unsigned int fuzzMove(unsigned int rseed){
  for(int counter=0; counter < 1e4; counter++){


    game* state=rndState(floor(36.*rand_r(&rseed)/(float)RAND_MAX), rand_r(&rseed), rand_r(&rseed)/(float)RAND_MAX);
    game* backUp=cpyGame(state);
    moveUp(state);
    if(tstBookkeeping(state)!=0) printf("moveUp bookkeeping error %i\n", tstBookkeeping(state));
    if(tstScore(state, backUp)!=0) printf("move Up tstScore error %i\n", tstScore(state, backUp));
    
    delGame(state);
    state=cpyGame(backUp);
    moveDown(state);
    if(tstBookkeeping(state)!=0) printf("moveDown bookkeeping error %i\n", tstBookkeeping(state));
    if(tstScore(state, backUp)!=0) printf("moveDown tstScore error %i\n", tstScore(state, backUp));
    
    delGame(state);
    state=cpyGame(backUp);
    moveLeft(state);
    if(tstBookkeeping(state)!=0) printf("moveLeft bookkeeping error %i\n", tstBookkeeping(state));
    if(tstScore(state, backUp)!=0) printf("moveLeft tstScore error %i\n", tstScore(state, backUp));
    
    delGame(state);
    state=cpyGame(backUp);
    moveRight(state);
    if(tstBookkeeping(state)!=0) printf("moveRight bookkeeping error %i\n", tstBookkeeping(state));
    if(tstScore(state, backUp)!=0) printf("moveRight tstScore error %i\n", tstScore(state, backUp));
    
    if(counter% 1000 == 0)printf("Loop %i passed. \n", counter);

    delGame(state);
    delGame(backUp);
  }

return rseed;
}
Exemplo n.º 26
0
void CCouncilMember::processWalking()
{
	performCollisions();
	processFalling();


	// Check if there is a cliff and move him back in case
	performCliffStop(m_Action.H_anim_move_amount<<1);


	if( m_timer < ELDER_MOVE_TIMER )
	{
		m_timer++;
		return;
	}
	else
	{
		m_timer = 0;
	}

	// Chance if he will think
	if( getProbability(25) )
	{
		m_timer = 0;
		mp_processState = &CCouncilMember::processThinking;
		setAction(A_COUNCIL_MEMBER_THINK);
		return;
	}

	// Move normally in the direction
	if( m_hDir == RIGHT )
		moveRight( m_Action.H_anim_move_amount<<1 );
	else
		moveLeft( m_Action.H_anim_move_amount<<1 );

}
Exemplo n.º 27
0
void CPoisonSlug::processCrawling()
{

    if( m_timer < SLUG_MOVE_TIMER )
    {
	m_timer++;
	return;
    }
    else
    {
	m_timer = 0;
    }

	// Chance to poo
	if( getProbability(30) )
	{
		m_timer = 0;
		setAction( A_SLUG_POOING );
		playSound( SOUND_SLUG_DEFECATE );
		CSlugSlime *slime = new CSlugSlime(mp_Map, 0, getXMidPos(), getYDownPos()-(1<<CSF));
		g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( slime ) );
		
		xDirection = -xDirection;
		return;		
	}

	// Move normally in the direction
	if( xDirection == RIGHT )
	{
		moveRight( m_Action.velX<<1 );
	}
	else
	{
		moveLeft( m_Action.velX<<1 );
	}
}
Exemplo n.º 28
0
void Snake::move()
{
	if(storeTime <= clock()- 70 && gameStatus==CONTINUE)
	{
		if(direction== rightDir)
		{
			moveRight();
		}
		else if(direction== leftDir)
		{
			moveLeft();
		}
		else if(direction== upDir)
		{
			moveUp();
		}
		else//(direction== downDir)
		{
			moveDown();
		}

		glutPostRedisplay();
	}
}
Exemplo n.º 29
0
inline void Box<T>::moveBottomLeft(const Point<T> &p) { moveLeft(p.getX()); moveBottom(p.getY()); }
Exemplo n.º 30
0
inline void Box<T>::moveTopLeft(const Point<T> &p) { moveLeft(p.getX()); moveTop(p.getY()); }