예제 #1
0
파일: model.cpp 프로젝트: Shazoo/keeperrl
void Model::update(double totalTime) {
  if (addHero) {
    CHECK(playerControl && playerControl->isRetired());
    landHeroPlayer();
    addHero = false;
  }
  int absoluteTime = view->getTimeMilliAbsolute();
  if (playerControl) {
    if (absoluteTime - lastUpdate > 50) {
      playerControl->render(view);
      lastUpdate = absoluteTime;
    }
  }
  do {
    Creature* creature = timeQueue.getNextCreature();
    CHECK(creature) << "No more creatures";
    Debug() << creature->getTheName() << " moving now " << creature->getTime();
    currentTime = creature->getTime();
    if (playerControl && !playerControl->isTurnBased()) {
      while (1) {
        UserInput input = view->getAction();
        if (input.getId() == UserInputId::IDLE)
          break;
        else
          lastUpdate = -10;
        playerControl->processInput(view, input);
      }
    }
    if (currentTime > totalTime)
      return;
    if (currentTime >= lastTick + 1) {
      MEASURE({ tick(currentTime); }, "ticking time");
    }
예제 #2
0
bool Exit::Exiting()
{
    UserInput UserInput;

    bool Correct = false;

    int Choice = 0;
    while (Correct == false) {
        cout << "Are you sure you want to exit?" << endl;
        cout << "Yes = 1 No = 2" << endl;

        Choice = UserInput.GetInt(2);

        Correct = UserInput.ValidateInput(Choice);

        if (Correct == true) {
            if (Choice == 1) {
                return false;
            }
            if (Choice == 2) {
                return true;
            }
        }
    }
}
/** execute - executes during normal operation of splash state */
void Splash_State::execute(SDL_GameEngine * a_pvEngine) {
	//record boolean for changing the splash screen
	bool bSplashChange = false;
	
	//get the user input
	UserInput vUI = a_pvEngine->getInput();
	//change the splash screen if a key was pressed
	bSplashChange |= (vUI.getKey() != KEY_NONE);

	//change the splash screen if the timer exceeds the speed of the transition
	bSplashChange |= ( (m_uiTimer+=a_pvEngine->getMSDelay()) >= m_uiSpeed );
	
	//if splash screen changes
	if(bSplashChange) {
		//set splash screen to inactive
		m_pvSplashScreen->setActive(false);
		//if more splash screens need to be drawn
		if(m_uiCurrentSplash < m_uiSplashAmount) {
			//set timer to 0
			m_uiTimer = 0;
			//set splash screen to the next one
			m_pvSplashScreen = (SDL_SplashScreen *)a_pvEngine->getRes(RESOURCE_SPLASH, ++m_uiCurrentSplash);
			//set the speed of the new splash screen
			m_uiSpeed = m_pvSplashScreen->getSpeed();
			//set the new splash screen as active
			m_pvSplashScreen->setActive(true);
		}
		//else if no more need to be drawn
		else
			//go to the next state
			a_pvEngine->nextState();
	}
}
예제 #4
0
void readNumbers(double ary[], int size)
{
	UserInput in;
	cout << "Enter " << size << " integers:" << endl;
	for (int i(0); i < size; i++)
	{
		ary[i] = in.readDouble();
	}
}
예제 #5
0
int main()
{
	UserInput in;
	cout << "Enter your age: ";
	int age = in.readInt();

	int dogAge = age / 7;

	cout << "Hello, your age in dog years is " << dogAge << endl;

	for (int i = 0; i < dogAge; i++)
	{
		cout << (i+1) << "..." << endl;
	}

	return 0;
}
예제 #6
0
optional<Model::ExitInfo> Model::update(double totalTime) {
  if (addHero) {
    CHECK(playerControl && playerControl->isRetired());
    landHeroPlayer();
    addHero = false;
  }
  int absoluteTime = view->getTimeMilliAbsolute();
  if (playerControl && absoluteTime - lastUpdate > 20) {
    playerControl->render(view);
    lastUpdate = absoluteTime;
  } else
  if (spectator && absoluteTime - lastUpdate > 20) {
    view->updateView(spectator.get(), false);
    lastUpdate = absoluteTime;
  } 
  do {
    Creature* creature = timeQueue.getNextCreature();
    CHECK(creature) << "No more creatures";
    //Debug() << creature->getName().the() << " moving now " << creature->getTime();
    currentTime = creature->getTime();
    if (spectator)
      while (1) {
        UserInput input = view->getAction();
        if (input.getId() == UserInputId::EXIT)
          return ExitInfo::abandonGame();
        if (input.getId() == UserInputId::IDLE)
          break;
      }
    if (playerControl && !playerControl->isTurnBased()) {
      while (1) {
        UserInput input = view->getAction();
        if (input.getId() == UserInputId::IDLE)
          break;
        else
          lastUpdate = -10;
        playerControl->processInput(view, input);
        if (exitInfo)
          return exitInfo;
      }
    }
    if (currentTime > totalTime)
      return none;
    if (currentTime >= lastTick + 1) {
      MEASURE({ tick(currentTime); }, "ticking time");
    }
예제 #7
0
/**********************************
Project 5
A program
  that asks the user to enter strings 
  print the string 
  encrypt the string and print the encrypted string.
*   
********************************/
int main()
{
	string originalText;
	string encryptString;
	DisplayRep displayReport;
	UserInput userIn;
	//Get text from user
	displayReport.displayHeader();
	originalText = userIn.userEnterIn();
	EncryptableString<string> myEncryptString(originalText);

	
	//Send text to be encoded and display the result
	encryptString = myEncryptString.encrypt(originalText);
	displayReport.displayEncrypt(encryptString);

	cout << endl;
	cout << endl;

	
	return 0;
}
예제 #8
0
void Player::makeMove() {
    vector<Vec2> squareDirs = creature->getConstSquare()->getTravelDir();
    const vector<Creature*>& creatures = creature->getLevel()->getAllCreatures();
    if (creature->isAffected(Creature::HALLU))
        ViewObject::setHallu(true);
    else
        ViewObject::setHallu(false);
    MEASURE(
        model->getView()->refreshView(creature),
        "level render time");
    if (Options::getValue(OptionId::HINTS) && displayTravelInfo && creature->getConstSquare()->getName() == "road") {
        model->getView()->presentText("", "Use ctrl + arrows to travel quickly on roads and corridors.");
        displayTravelInfo = false;
    }
    static bool greeting = false;
    if (Options::getValue(OptionId::HINTS) && displayGreeting) {
        CHECK(creature->getFirstName());
        model->getView()->presentText("", "Dear " + *creature->getFirstName() + ",\n \n \tIf you are reading this letter, then you have arrived in the valley of " + NameGenerator::worldNames.getNext() + ". There is a band of dwarves dwelling in caves under a mountain. Find them, talk to them, they will help you. Let your sword guide you.\n \n \nYours, " + NameGenerator::firstNames.getNext() + "\n \nPS.: Beware the goblins!");
        model->getView()->presentText("", "Every settlement that you find has a leader, and they may have quests for you."
                                      "\n \nYou can turn these messages off in the options (press F2).");
        displayGreeting = false;
        model->getView()->refreshView(creature);
    }
    for (const Creature* c : creature->getVisibleEnemies()) {
        if (c->isSpecialMonster() && !contains(specialCreatures, c)) {
            privateMessage(MessageBuffer::important(c->getDescription()));
            model->getView()->refreshView(creature);
            specialCreatures.push_back(c);
        }
    }
    if (travelling)
        travelAction();
    else if (target)
        targetAction();
    else {
        UserInput action = model->getView()->getAction();
        Debug() << "Action " << int(action.type);
        vector<Vec2> direction;
        bool travel = false;
        if (action.type != UserInput::IDLE)
            model->getView()->retireMessages();
        switch (action.type) {
        case UserInput::FIRE:
            fireAction(action.getPosition());
            break;
        case UserInput::TRAVEL:
            travel = true;
        case UserInput::MOVE:
            direction.push_back(action.getPosition());
            break;
        case UserInput::MOVE_TO:
            if (action.getPosition().dist8(creature->getPosition()) == 1) {
                Vec2 dir = action.getPosition() - creature->getPosition();
                if (const Creature* c = creature->getConstSquare(dir)->getCreature()) {
                    if (!creature->isEnemy(c)) {
                        chatAction(dir);
                        break;
                    }
                }
                direction.push_back(dir);
            } else if (action.getPosition() != creature->getPosition()) {
                target = action.getPosition();
                target = Vec2(min(creature->getLevel()->getBounds().getKX() - 1, max(0, target->x)),
                              min(creature->getLevel()->getBounds().getKY() - 1, max(0, target->y)));
                // Just in case
                if (!target->inRectangle(creature->getLevel()->getBounds()))
                    target = Nothing();
            }
            else
                pickUpAction(false);
            break;
        case UserInput::SHOW_INVENTORY:
            displayInventory();
            break;
        case UserInput::PICK_UP:
            pickUpAction(false);
            break;
        case UserInput::EXT_PICK_UP:
            pickUpAction(true);
            break;
        case UserInput::DROP:
            dropAction(false);
            break;
        case UserInput::EXT_DROP:
            dropAction(true);
            break;
        case UserInput::WAIT:
            creature->wait();
            break;
        case UserInput::APPLY_ITEM:
            applyAction();
            break;
        case UserInput::THROW:
            throwAction();
            break;
        case UserInput::THROW_DIR:
            throwAction(action.getPosition());
            break;
        case UserInput::EQUIPMENT:
            equipmentAction();
            break;
        case UserInput::HIDE:
            hideAction();
            break;
        case UserInput::PAY_DEBT:
            payDebtAction();
            break;
        case UserInput::CHAT:
            chatAction();
            break;
        case UserInput::SHOW_HISTORY:
            messageBuffer.showHistory();
            break;
        case UserInput::UNPOSSESS:
            if (creature->canPopController()) {
                creature->popController();
                return;
            }
            break;
        case UserInput::CAST_SPELL:
            spellAction();
            break;
        case UserInput::DRAW_LEVEL_MAP:
            model->getView()->drawLevelMap(creature);
            break;
        case UserInput::EXIT:
            model->exitAction();
            break;
        case UserInput::IDLE:
            break;
        default:
            break;
        }
        if (creature->isAffected(Creature::SLEEP) && creature->canPopController()) {
            if (model->getView()->yesOrNoPrompt("You fell asleep. Do you want to leave your minion?"))
                creature->popController();
            return;
        }
        for (Vec2 dir : direction)
            if (travel) {
                vector<Vec2> squareDirs = creature->getConstSquare()->getTravelDir();
                if (findElement(squareDirs, dir)) {
                    travelDir = dir;
                    lastLocation = creature->getLevel()->getLocation(creature->getPosition());
                    travelling = true;
                    travelAction();
                }
            } else if (creature->canMove(dir)) {
                creature->move(dir);
                itemsMessage();
                break;
            } else {
                const Creature *c = creature->getConstSquare(dir)->getCreature();
                if (creature->canBumpInto(dir)) {
                    creature->bumpInto(dir);
                    break;
                } else if (creature->canDestroy(dir)) {
                    privateMessage("You bash the " + creature->getSquare(dir)->getName());
                    creature->destroy(dir);
                    break;
                }
            }
    }
    for (Vec2 pos : creature->getLevel()->getVisibleTiles(creature)) {
        ViewIndex index = creature->getLevel()->getSquare(pos)->getViewIndex(creature);
        (*levelMemory)[creature->getLevel()].clearSquare(pos);
        for (ViewLayer l : {
                    ViewLayer::ITEM, ViewLayer::FLOOR_BACKGROUND, ViewLayer::FLOOR, ViewLayer::LARGE_ITEM
                })
            if (index.hasObject(l))
                remember(pos, index.getObject(l));
    }
}
예제 #9
0
int main(int argc, char ** argv)//must be the header for sdl application and yes the arg stuff
{
	//INIT

	srand((unsigned int)time(NULL));
	SDL_Init(SDL_INIT_EVERYTHING);
	SDL_Surface * screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
	SDL_Event e;
	UserInput ui; //This is the UserInput class.
	//networking

#ifdef WITH_NETWORKING
	ServerModule s(9999);
	while(s.getState() != NetModule::LISTENING)
	{
		s.run();
		printf("Server state: %s \n", s.getStateText());
	}
	ClientModule c("127.0.0.1",9999);
	while(c.getState() != NetModule::WAITING_FOR_DATA)//allows player to connect
	{
		s.run();
		printf("Server state: %s \n", s.getStateText());
		c.run();
		printf("Client state: %s \n", c.getStateText());
	}
#endif
	//Timer stuff, for updateing sprites and anything else
	Uint32 then = SDL_GetTicks(), now, passed, second = 0;

	//the user interface variable
	bool running = true;
	baseEngine be;

	Hud Ghud;
	World world;
	SDL_Sprite test("Sprites/player0.bmp", P_WIDTH, P_HEIGHT, FRAME_RATE, NUM_ROWS);
	//SDL_Sprite test("Sprites/dragon.bmp", DRAGON_FRAME, DRAGON_FRAME, FRAME_RATE, NUM_ROWS);
	Player eTest(ONE_HUNDRED_PERCENT, ONE_HUNDRED_PERCENT, false, false, false, false, false, false, &test, &world);
	world.add(&eTest);
	world.setCamera(eTest.getCamera());
	//printf("%d %d %d\n", sizeof(test), sizeof(world), sizeof(eTest));
	//music test stuff
	AudioHandler ah;
	//ah.playRandom();
	
	be.setWorld(&world);
	be.setPlayer(&eTest);
	be.setRun(true);
#ifdef WITH_NETWORKING
	char send[1000], old[1000], *in;
	bool changeInInfoSoSend = false;
#endif
	if(!be.getWorld()->getSuccess()){printf("The map was loaded unsuccessfully. THERE IS A PROBLEM.");}
	UserInput aui;
	MyFont hi;
	TTtext fps;
	int ifps = 0;
	char cfps[10];
	hi.setFont(FONTSIZE);
	fps.setFont(hi.getFont());
	fps.setMessage("0");
	while(be.getRun()) //While loop, can be easily used for testing.
	{
		ifps++;
		//update the time
		now = SDL_GetTicks();
		passed = now - then;
		then = now;
		if(now - second > 1000)
		{
			sprintf_s(cfps, "%i", ifps);
			fps.setMessage(cfps);
			ifps = 0;
			second = now;
		}
#ifdef WITH_NETWORKING
		if(c.getInbox()->getRawList() != NULL&& (unsigned char *)old != c.getInbox()->getRawList())
		{
			in = (char *)c.getInbox()->getRawList();
			c.getInbox()->clear();
			printf("server info: %s\n",in);
			world.convertFromServer(in);
		}

#endif
		//input
		while(SDL_PollEvent(&e)) //Polls the events of SDL
		{
			switch(e.type) //If there's an event, then what type?
			{
				case SDL_QUIT: be.setRun(false); break; //If The event is SDL quit, get outta there.
				case SDL_MOUSEBUTTONDOWN:
					ui.setMouse(e.motion.x, e.motion.y);
					ui.setClick(e.motion.state);
	//				printf("mouse state : %i \n", e.motion.state);
					break;
				case SDL_MOUSEBUTTONUP:
					ui.setMouse(e.motion.x, e.motion.y);
					ui.setClick(CLICK_NONE);
					break;
				case SDL_MOUSEMOTION: //If the mouse moves, then do this.
					ui.setMouse(e.motion.x, e.motion.y);
					break;
				case SDL_KEYDOWN: //This will work until we can get it without using a switch statement.
					ui.setKey(e.key.keysym.sym);

	//				printf("Key Pressed: %c \n", e.key.keysym.sym);
					ui.updateUI(false);
					break;
				case SDL_KEYUP:
					ui.setKey(e.key.keysym.sym);
					ui.updateUI(true);
					break;
			}
		}
#ifdef WITH_NETWORKING
		eTest.handleInput(&ui, &world, &ah);
#else
		//eTest.handleInput(&ui, &world, &ah);
#endif
		be.handleInput(&ui);
		//update
		/*if(screen->h < 0 || screen->h > 1280)
		{
			SDL_FreeSurface(screen);
			SDL_Surface * screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
		}*/
	//		screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE);
//		SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
		be.updateState();
		//world.update(passed);
		//Ghud.updateHud(&eTest, &ui, passed);
		//ah.update(world.getCurrentWorld());//need to figure out to switch songs when entering a new area
		//draw
		//reset the screen.
#ifdef WITH_NETWORKING
		strcpy(send, world.convertAllEntitiesToCharBuffer());
		for(int i = 0; i < strlen(send)&& changeInInfoSoSend == false; i++)
		{
			if(old[i] != send[i])
				changeInInfoSoSend = true;
		}
		if(changeInInfoSoSend)
		{	
	//		printf("sent: %i vs hit: %i\n", send[2], ui.getClick());
			c.getOutbox()->add(send);
			for(int i = 0; i < strlen(send); i++)
			{
				old[i] = send[i];
			}
			changeInInfoSoSend = false;
		//	printf("user in: %c %c\n", ui.getKeyLR(), ui.getKeyUD());
		}
#endif
		//reset the mouse input. Why was this so hard to figure out?
		ui.resetClick();
#ifdef WITH_NETWORKING
		
		for(int i = 0; i<3;i++){
			s.run();
			c.run();
		}
#endif
//		SDL_Flip(screen);
		SDL_Delay(SDLDELAY);
		
	}
	SDL_FreeSurface(screen);
	SDL_Quit();//must do to free the memory that was used for init	
	return 0;
}
void CommandMoveLeft::update(float dt) {
	if (!_block)
		return;

	auto body1 = _block->getBody();
	if (!body1) {
		stopBlock();
		return;
	}
	auto body2 = _block->getAttachedBody();
	if (!body2) {
		stopBlock();
		return;
	}
	float32 offset = ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::MOVEOFFSET);
	float32 blockSizeInMeters = _blockSize.width / ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D);

	if (body1->GetFixtureList()->GetFilterData().categoryBits == Block::blockFlags::PASSIVE
		|| body2->GetFixtureList()->GetFilterData().categoryBits == Block::blockFlags::PASSIVE)
		stopBlock();
	
	if (body1->GetFixtureList()->GetFilterData().categoryBits == Block::blockFlags::NEED_TO_STOP
		|| body2->GetFixtureList()->GetFilterData().categoryBits == Block::blockFlags::NEED_TO_STOP) {
		Vec2 posOnField = _block->getPosOnField();
		Sprite *sprite1 = (Sprite*)body1->GetUserData();
		Sprite *sprite2 = (Sprite*)body2->GetUserData();
		Size size = sprite1->getContentSize();
		b2Filter filter;

		if (GameField::getBlock({ posOnField.x - 1, posOnField.y })){
			stopBlock();

			filter = body1->GetFixtureList()->GetFilterData();
			filter.categoryBits = Block::blockFlags::ACTIVE;
			body1->GetFixtureList()->SetFilterData(filter);

			filter = body2->GetFixtureList()->GetFilterData();
			filter.categoryBits = Block::blockFlags::ACTIVE;
			body2->GetFixtureList()->SetFilterData(filter);

			body1->SetTransform(_positionOldFirst, 0);
			body2->SetTransform(_positionOldSecond, 0);

			sprite1->setPosition({ (body1->GetPosition().x 
					* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.width / 2
				, (body1->GetPosition().y 
					* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.height / 2 });
			sprite2->setPosition({ (body2->GetPosition().x 
					* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.width / 2
				, (body2->GetPosition().y 
					* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.height / 2 });

			SimpleUI *simpleUI = MainGameScene::getUI();
			UserInput *input = (UserInput*)simpleUI->getChildrenByName(UserInput::name());
			input->dropInputEvents();

			return;
		}

		if (!_isUndo) {
			body1->SetTransform({ _positionOldFirst.x - blockSizeInMeters, body1->GetPosition().y }, 0);
			body2->SetTransform({ _positionOldSecond.x - blockSizeInMeters, body2->GetPosition().y }, 0);
		}
		else {
			body1->SetTransform({ _positionOldFirst.x + blockSizeInMeters, body1->GetPosition().y }, 0);
			body2->SetTransform({ _positionOldSecond.x + blockSizeInMeters, body2->GetPosition().y }, 0);
		}
		sprite1->setPosition({ (body1->GetPosition().x 
				* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.width / 2
			, (body1->GetPosition().y 
				* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.height / 2 });
		sprite2->setPosition({ (body2->GetPosition().x 
				* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.width / 2
			, (body2->GetPosition().y 
				* ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::SCALE_RATIO_BOX2D)) - size.height / 2 });

		stopBlock();

		filter = body1->GetFixtureList()->GetFilterData();
		filter.categoryBits ^= Block::blockFlags::NEED_TO_STOP;
		filter.categoryBits = Block::blockFlags::STOPPED;
		body1->GetFixtureList()->SetFilterData(filter);
		
		filter = body2->GetFixtureList()->GetFilterData();
		filter.categoryBits ^= Block::blockFlags::NEED_TO_STOP;
		filter.categoryBits = Block::blockFlags::STOPPED;
		body2->GetFixtureList()->SetFilterData(filter);

		body1->SetActive(false);
		body1->SetActive(true);
		body2->SetActive(false);
		body2->SetActive(true);
	}

	if ((_positionOldFirst.x - body1->GetPosition().x) < blockSizeInMeters
			&& !_isUndo
			&& _isExecute) {
		if ((_positionOldFirst.x - (body1->GetPosition().x - offset)) >= blockSizeInMeters) {
			while (offset > 0) {
				offset -= ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::MOVEOFFSET) / 100;
				if ((_positionOldFirst.x - (body1->GetPosition().x - offset)) < blockSizeInMeters) {
					stopBlock();
					body1->SetTransform({ body1->GetPosition().x - offset, body1->GetPosition().y }, 0);
					body2->SetTransform({ body2->GetPosition().x - offset, body2->GetPosition().y }, 0);
					return;
				}
			}
		}
		CCASSERT(offset, "offset can't be 0");
		if (body1->GetLinearVelocity().x > 0
			&& (_positionOldFirst.x - body1->GetPosition().x) < (blockSizeInMeters / 7)) {  
			stopBlock();
			body1->SetTransform(_positionOldFirst, 0);
			body2->SetTransform(_positionOldSecond, 0);
			return;
		}
		body1->SetLinearVelocity({ (float32)(body1->GetLinearVelocity().x - offset), body1->GetLinearVelocity().y });
		body2->SetLinearVelocity({ (float32)(body2->GetLinearVelocity().x - offset), body2->GetLinearVelocity().y });
		_positionOldFirst.y = body1->GetPosition().y;
		_positionOldSecond.y = body2->GetPosition().y;
	}
	else if ((body1->GetPosition().x - _positionOldFirst.x) < blockSizeInMeters
				&& _isUndo
				&& _isExecute) {
		if (((body1->GetPosition().x + offset) - _positionOldFirst.x) >= blockSizeInMeters) {
			while (offset > 0) {
				offset -= (ConstantsRegistry::getValueForKey(ConstantsRegistry::constants::MOVEOFFSET) / 100) * 10;
				if (((body1->GetPosition().x + offset) - _positionOldFirst.x) < blockSizeInMeters) {
					stopBlock();
					body1->SetTransform({ body1->GetPosition().x + offset, body1->GetPosition().y }, 0);
					body2->SetTransform({ body2->GetPosition().x + offset, body2->GetPosition().y }, 0);
					return;
				}
			}
		}
		CCASSERT(offset, "offset can't be 0");
		if (body1->GetLinearVelocity().x < 0
			&& (_positionOldFirst.x - body1->GetPosition().x) < (blockSizeInMeters / 7)) {
			stopBlock();
			body1->SetTransform(_positionOldFirst, 0);
			body2->SetTransform(_positionOldSecond, 0);
			return;
		}
		body1->SetLinearVelocity({ (float32)(body1->GetLinearVelocity().x + offset), body1->GetLinearVelocity().y });
		body2->SetLinearVelocity({ (float32)(body2->GetLinearVelocity().x + offset), body2->GetLinearVelocity().y });
		_positionOldFirst.y = body1->GetPosition().y;
		_positionOldSecond.y = body2->GetPosition().y;
	}
	else
		stopBlock();
}