CGO_Player::CGO_Player () { ani = NULL; shadow = &a_shadow; setArea(ea_gameBoard); moveAbs(0, 0); dx = CGO_Player::dy = 3; setActive(false); setLifeState(LALIVE); setAniDirState(SSTAND, ASOUTH); setRunState(XSTAND); setColor(cred); setType(GOT_PLAYER); setName("Unnamed Player"); setTeam(TEAM_RED); dropedBombs = 0; powerups[PBOMB ] = BWBOMB; powerups[PFLAME ] = BWFLAME; powerups[PSKATE ] = BWSKATE; powerups[PKICKER ] = BWKICKER; powerups[PJELLY ] = BWJELLY; powerups[PTRIGGER ] = BWTRIGGER; powerups[PPUNCH ] = BWPUNCH; powerups[PGRAB ] = BWGRAB; powerups[PSPOOGE ] = BWSPOOGE; powerups[PGOLDFLAME] = BWGOLDFLAME; powerups[PDISEASE ] = BWDISEASE; powerups[PDISEASE3 ] = BWDISEASE3; }
Trundler::Trundler(int blockX, int blockY, Field *field) : Enemy(TRUNDLER, field), dir(TRUNDLE_RIGHT), inAir(false), yvel(0), yvelTimer(TRUNDLER_FALL_DELAY) { moveAbs(blockX * 32, blockY * 32); setBoundingBox(22, 25, 3, 3); }
RedSpark::RedSpark(int blockX, int blockY) : Collidable(RED_SPARK) { setBoundingBox(32, 20, 0, 6); moveAbs(blockX * 32, blockY * 32); type = CT_REDSPARK; collidableBlocksMarker = false; }
CGO_Bomb::CGO_Bomb () { ani = &(a_bomb[BREG]); setArea(ea_gameBoard); ticksTimeoutDefault = 2000; ticksTimeout = ticksTimeoutDefault; moveAbs(0, 0); }
void TutorialUnit::setPosition(QPointF targetPosition) { QMutexLocker lock(&mMutex); checkHAL(); targetPosition -= mOffset; targetPosition /= mScaling; QMutexLocker waitLock(&mWaitMutex); emit moveAbs(targetPosition); mWait.wait(&mWaitMutex, 10000); }
Pickup::Pickup(int pickupType, int blockX, int blockY) : Collidable(pickupSprites[pickupType]), bob(0), bobDelay(BOB_DELAY) { this->pickupType = pickupType; type = Collidable::CT_PICKUP; moveAbs(blockX * 32 + 4, blockY * 32 + 4); setBoundingBox(12, 10, 6, 7); }
Trapper::Trapper(int blockX, int blockY, Field *field) : Enemy(TRAPPER, field) { setBoundingBox(22, 22, 3, 3); moveAbs(blockX * 32 + 2, blockY * 32 + 2); }
void Quadrotor::executeTimeLineCommand() { //* //return; if(readTimeline) { double current_time = QuadTimer::GetProcessTime(); if(!isExecuting) { char command[100]; char* commandstr; double peektime = -1; //double com_time; commandstr = timeline->readNextCommand(peektime); //read the command type if(sscanf(commandstr,"%lf %s",&comTime,command)==EOF) {readTimeline = false; return;} sprintf(delayedCommand,"%lf %s",peektime,commandstr); isExecuting = true; } else if(current_time>=comTime && !isMoving) { //command to set quad position sscanf(delayedCommand,"%lf %lf %s",&nextTime,&comTime,command); //printf("\n%s",command); //printf("\n%s",delayedCommand); comOrientationTime = 0; if(!strcmp(command,"POS")) { sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime, command,&comVect.x,&comVect.y,&comVect.z); moveAbs(comVect) ; } else if(!strcmp(command,"ROT")) { sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime, command,&comVect.x,&comVect.y,&comVect.z); } else if(!strcmp(command,"MOV")) { sscanf(delayedCommand,"%lf %lf %s %lf %f %f %f",&nextTime,&comTime, command,&comOrientationTime,&comVect.x,&comVect.y,&comVect.z); isExecuting = true; quadTime.getTimeDiffSec(); comOrientationTime = current_time + comOrientationTime; if(orientationMode == QuadOrientationMode::FREE) {} else if(orientationMode == QuadOrientationMode::ANOTHERQUAD) { } else if(orientationMode == QuadOrientationMode::UPRIGHT) {} //Operations to align the quad with the direction of motion comDirection = glm::vec3(comVect.x-pos_x,comVect.y-pos_y,comVect.z-pos_z); comDirection = glm::normalize(comDirection); /*glm::vec3 x_axis(1.0f,0.0f,0.0f); * glm::vec3 rotation_axis = glm::cross(comDirection,x_axis); * * * rotation_axis = glm::normalize(rotation_axis); * float angle = glm::angle(x_axis,comDirection); * Model = glm::rotate(glm::mat4(1.0f), -angle, rotation_axis); */ } else if(!strcmp(command,"LOOKATQUAD")) { char quadname[10]; sscanf(delayedCommand,"%lf %lf %s %s",&nextTime,&comTime,command, quadname); otherQuad = Quadrotor::getQuadFromName(quadname); orientationMode = QuadOrientationMode::ANOTHERQUAD; } else if(!strcmp(command,"LOOKATPOINT")) { glm::vec3 position; sscanf(delayedCommand,"%lf %lf %s %f %f %f",&nextTime,&comTime,command, &position.x,&position.y,&position.z); lookAtPoint = position; orientationMode = QuadOrientationMode::POINT; } else if(!strcmp(command,"FREE")) { orientationMode = QuadOrientationMode::FREE; } else if(!strcmp(command,"FIREAT")) { float r,g,b,a; char ammotype[20]; char quadname[10]; sscanf(delayedCommand,"%lf %lf %s %s %f %f %f %f %s",&nextTime,&comTime,command, quadname,&r,&g,&b,&a,ammotype); AMMOTYPE::ENUM ammo_type = AMMOTYPE::getAmmotypeFromString(string(ammotype)); Ammo::fire(getBarrelPosition(),string(quadname),glm::vec4(r,g,b,a),5,this,ammo_type); } else if(!strcmp(command,"FIREATPOINT")) { float r,g,b,a; char ammotype[20]; glm::vec3 position; sscanf(delayedCommand,"%lf %lf %s %f %f %f %f %f %f %f %s",&nextTime,&comTime,command, &position.x, &position.y, &position.z,&r,&g,&b,&a,ammotype); AMMOTYPE::ENUM ammo_type = AMMOTYPE::getAmmotypeFromString(string(ammotype)); Ammo::fire(getBarrelPosition(),position,glm::vec4(r,g,b,a),5,this,ammo_type); } customCommandParser(string(delayedCommand)); //Operations to align the quad with the direction of motion isMoving = true; // printf("\nGot command:%f %f %f %f",com_time,com_posx,com_posy,com_posz); } else if(current_time<=comOrientationTime) //dont have to worry about modes other than MOV { glm::vec3 current_axis, current_up; double delta_time = comOrientationTime-current_time; getOrientation(current_axis,current_up,glm::vec3(1.0,0.0,0.0)); current_axis = glm::normalize(current_axis); comRotationAxis = glm::cross(current_axis,comDirection); double timediff = quadTime.getTimeDiffSec(); if(timediff>delta_time) timediff = delta_time; float axisAngle = glm::angle(current_axis,comDirection); // printf("\nX: %f",angle_axis); /*if(axisAngle>Pi) { printf("\n%f",axisAngle); axisAngle = (2*Pi-axisAngle); }*/ axisAngle = axisAngle*(float) (timediff/ delta_time); Model = glm::rotate(Model,axisAngle,comRotationAxis); //* glm::vec3 eye = glm::vec3(0,0,0), center = glm::vec3( Model*glm::vec4(1.0f,0.0f,0.0f,1.0f)), up = glm::vec3(0,1,0); glm::mat4 mm = getOrientationMatrix(eye,center,up); Model = mm; Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0)); //*/ } else if(current_time>=nextTime) { isExecuting = false;isMoving=false;} else if(current_time>=comTime) { if(!strcmp(command,"MOV")) { glm::vec3 distance = glm::vec3(comVect.x-pos_x,comVect.y-pos_y,comVect.z-pos_z); /* if(orientationMode == QuadOrientationMode::ANOTHERQUAD) { glm::vec3 otherQuadPosition = otherQuad->getQuadPosition(); glm::vec3 otherDirectionRelative = otherQuadPosition - getQuadPosition(); glm::vec3 upVector,tempVector; //getOrientation(); glm::vec3 eye = glm::vec3(0,0,0),center = otherDirectionRelative,up = glm::vec3(0,1,0); glm::mat4 mm = getOrientationMatrix(eye,center,up); Model = mm; Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0)); }*/ if(orientationMode != QuadOrientationMode::ANOTHERQUAD && orientationMode != QuadOrientationMode::POINT) { //* glm::vec3 eye = glm::vec3(0,0,0), center = comDirection, up = glm::vec3(0,1,0); glm::mat4 mm = getOrientationMatrix(eye,center,up); Model = mm; Model = glm::rotate(Model,-glm::half_pi<float>(),glm::vec3(0,1,0)); //*/ } double delta_time = nextTime-current_time; double timediff = quadTime.getTimeDiffSec(); if(delta_time < timediff) timediff=delta_time; glm::vec3 dist2 = distance *(float) (timediff/ delta_time); moveRel(dist2); // printf("\ndelta pos:%f %f %f",dist2.x,dist2.y,dist2.z); } } // printf("\ncurrent pos:%f %f %f",pos_x, pos_y,pos_z); } //*/ }