/************************************************************************* set the movement range of the thumb for the horizontal axis. *************************************************************************/ void Thumb::setHorzRange(float min, float max) { Sizef parentSize(getParentPixelSize()); // ensure min <= max, swap if not. if (min > max) { float tmp = min; max = min; min = tmp; } d_horzMax = max; d_horzMin = min; // validate current position. const float cp = CoordConverter::asAbsolute(getXPosition(), parentSize.d_width); if (cp < min) { setXPosition(cegui_absdim(min)); } else if (cp > max) { setXPosition(cegui_absdim(max)); } }
/************************************************************************* set the movement range of the thumb for the horizontal axis. *************************************************************************/ void Thumb::setHorzRange(float min, float max) { // ensure min <= max, swap if not. if (min > max) { float tmp = min; max = min; min = tmp; } d_horzMax = max; d_horzMin = min; // validate current position. float cp = getXPosition(); if (cp < min) { setXPosition(min); } else if (cp > max) { setXPosition(max); } }
LocationCamera::LocationCamera(unsigned int width, unsigned int height, unsigned int xPosition, unsigned int yPosition) { setXPosition(xPosition); setYPosition(yPosition); setWidth(width); setHeight(height); }
Obstacle::Obstacle(float x, float y, float z, ObstacleType obsType) : GameObject(), obsType(obsType) { type = OBSTACLE; setXPosition(x); setYPosition(y); setZPosition(z); BoundingCilinder *bc = getBoundingCilinder(); if (obsType == COLUMN) { bc->setHeight(12.5f); bc->setRadius(2.0f); } else if (obsType == BARREL) { bc->setHeight(2.5f); bc->setRadius(1.2f); } }
void Application::handlePlayer2Input(bool leftButton, bool rightButton, bool upButton, bool downButton, bool fireButton){ static bool downPressed = false; static bool upPressed = false; static bool sendButtonUp = false; static bool sendButtonDown = false; if (downButton){ downPressed = true; } else if(downPressed){ if(player2->tank->weapon->getDegrees() > -75){ player2->tank->weapon->decDegrees(); player2->weaponAnimation->runBackward(); sendButtonDown = true; } downPressed = false; } if (upButton){ upPressed = true; } else if(upPressed){ if(player2->tank->weapon->getDegrees() < 65){ player2->tank->weapon->incDegrees(); player2->weaponAnimation->runForward(); sendButtonUp = true; } upPressed = false; } if (leftButton){ if(!rightButton){ if(!player2->tank->isBlocking()){ player2->tank->moveLeft(); player2->tankAnimation->runBackward(); } } } if (rightButton){ if(!leftButton){ if(!player2->tank->outOfScreen()){ player2->tank->moveRight(); player2->tankAnimation->runForward(); } } } if (fireButton){ tank2->fire(); firedMissile = true; } //NETWORKING if(client != NULL){ //sending info if(isClient && player2Turn){ //sending if tank has moved if(leftButton || rightButton){ setXPosition(player2->tank->getPositionX()); client->sendData(&xPosition, PACKET_SIZE); } //sending if weapon has moved if(sendButtonDown){ setDownIsPressed(sendButtonDown); client->sendData(&downIsPressed, PACKET_SIZE); sendButtonDown = false; } if(sendButtonUp){ setUpIsPressed(sendButtonUp); client->sendData(&upIsPressed, PACKET_SIZE); sendButtonUp = false; } //sending if fired a missile if(fireButton){ setFirePressed(fireButton); client->sendData(&firePressed, PACKET_SIZE); } } } }
void Application::handlePlayer1Input(bool leftButton, bool rightButton, bool upButton, bool downButton, bool fireButton){ static bool wPressed = false; static bool sPressed = false; static bool sendButtonS = false; static bool sendButtonW = false; if (upButton){ wPressed = true; } else if(wPressed){ if(player1->tank->weapon->getDegrees() > -65){ player1->tank->weapon->decDegrees(); player1->weaponAnimation->runForward(); sendButtonW = true; } wPressed = false; } if (downButton){ sPressed = true; } else if(sPressed) { if(player1->tank->weapon->getDegrees() < 75){ player1->tank->weapon->incDegrees(); player1->weaponAnimation->runBackward(); sendButtonS = true; } sPressed = false; } if (leftButton){ if(!rightButton){ if(!player1->tank->outOfScreen()){ player1->tank->moveLeft(); player1->tankAnimation->runBackward(); } } } if (rightButton){ if(!leftButton){ if(!player1->tank->isBlocking()){ player1->tank->moveRight(); player1->tankAnimation->runForward(); } } } if (fireButton){ tank1->fire(); firedMissile = true; } //NETWORKING if(server != NULL){ //sending info if(isServer && player1Turn){ //sending if tank has moved if(leftButton || rightButton){ setXPosition(player1->tank->getPositionX()); server->sendData(&xPosition, PACKET_SIZE); } //sending if weapon has moved if(sendButtonS){ setDownIsPressed(sendButtonS); server->sendData(&downIsPressed, PACKET_SIZE); sendButtonS = false; } if(sendButtonW){ setUpIsPressed(sendButtonW); server->sendData(&upIsPressed, PACKET_SIZE); sendButtonW = false; } //sending if fired a missile if(fireButton){ setFirePressed(fireButton); server->sendData(&firePressed, PACKET_SIZE); } } } }