void animatePerson (int obj, persona * per) { // Set a new costume onScreenPerson * moveMe = findPerson (obj); if (moveMe) { // if (moveMe -> continueAfterWalking) abortFunction (moveMe -> continueAfterWalking); // moveMe -> continueAfterWalking = NULL; // moveMe -> walking = false; moveMe -> spinning = false; moveMe -> myPersona = per; rethinkAngle (moveMe); if (moveMe-> walking) { setFrames (* moveMe, ANI_WALK); } else { setFrames (* moveMe, ANI_STAND); } } }
void Sprite::init(SDL_Surface* image, int frames, int frameTime, int w, int h) { setImage( image ); setFrames( frames - 1 ); setFrameTime( frameTime ); setSize( w, h ); }
bool addPerson (int x, int y, int objNum, persona * p) { onScreenPerson * newPerson = new onScreenPerson; if (! checkNew (newPerson)) return false; // EASY STUFF newPerson -> thisType = loadObjectType (objNum); newPerson -> scale = 1; newPerson -> extra = 0; newPerson -> continueAfterWalking = NULL; moveAndScale (* newPerson, x, y); newPerson -> frameNum = 0; newPerson -> walkToX = x; newPerson -> walkToY = y; newPerson -> walking = false; newPerson -> spinning = false; newPerson -> show = true; newPerson -> direction = 0; newPerson -> angle = 180; newPerson -> wantAngle = 180; newPerson -> angleOffset = 0; newPerson -> floaty = 0; newPerson -> walkSpeed = newPerson -> thisType -> walkSpeed; newPerson -> myAnim = NULL; newPerson -> spinSpeed = newPerson -> thisType -> spinSpeed; newPerson -> r = 0; newPerson -> g = 0; newPerson -> b = 0; newPerson -> colourmix = 0; newPerson -> transparency = 0; newPerson -> myPersona = p; setFrames (* newPerson, ANI_STAND); // HEIGHT (BASED ON 1st FRAME OF 1st ANIMATION... INC. SPECIAL CASES) int fNumSigned = p -> animation[0] -> frames[0].frameNum; int fNum = abs (fNumSigned); if (fNum >= p -> animation[0] -> theSprites -> bank.total) { if (fNumSigned < 0) { newPerson -> height = 5; } else { newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[0].yhot + 5; } } else { newPerson -> height = p -> animation[0] -> theSprites -> bank.sprites[fNum].yhot + 5; } // NOW ADD IT IN THE RIGHT PLACE onScreenPerson * * changethat = & allPeople; while (((* changethat) != NULL) && ((* changethat) -> y < y)) changethat = & ((* changethat) -> next); newPerson -> next = (* changethat); (* changethat) = newPerson; return (bool) (newPerson -> thisType != NULL); }
bool fireball::initialize(Game *gamePtr, TextureManager *textureM) { Entity::initialize(gamePtr, fireballNS::WIDTH, fireballNS::HEIGHT, fireballNS::COLUMNS, textureM); setFrames(fireballNS::START_FRAME, fireballNS::END_FRAME); setCurrentFrame(fireballNS::START_FRAME); setFrameDelay(fireballNS::ANIMATION_DELAY); setVelocity({ fireballNS::SPEED, 0 }); setEdge(fireballNS::FIREBALL_EDGE); return true; }
// =================================== Constructor ===================================== purdue::purdue (string filename, int windowWidth, int windowHeight, int x): enemy (filename, windowWidth, windowHeight, x, EN_HEIGHT, EN_WIDTH, HSPEED) { //purdue train constructor rWalk = true; lWalk = false; yOffset = 385; setFrames (); setScore (50); }
bool walkMe (onScreenPerson * thisPerson, bool move = true) { float xDiff, yDiff, maxDiff, s; for (;;) { xDiff = thisPerson -> thisStepX - thisPerson -> x; yDiff = (thisPerson -> thisStepY - thisPerson -> y) * 2; s = thisPerson -> scale * thisPerson -> walkSpeed; if (s < 0.2) s = 0.2; maxDiff = (TF_abs (xDiff) >= TF_abs (yDiff)) ? TF_abs (xDiff) : TF_abs (yDiff); if (TF_abs (maxDiff) > s) { if (thisPerson -> spinning) { spinStep (thisPerson); setFrames (* thisPerson, ANI_WALK); } s = maxDiff / s; if (move) moveAndScale (* thisPerson, thisPerson -> x + xDiff / s, thisPerson -> y + yDiff / (s * 2)); return true; } if (thisPerson -> inPoly == -1) { if (thisPerson -> directionWhenDoneWalking != -1) { thisPerson -> wantAngle = thisPerson -> directionWhenDoneWalking; thisPerson -> spinning = true; spinStep (thisPerson); } break; } if (! doBorderStuff (thisPerson)) break; } thisPerson -> walking = false; setFrames (* thisPerson, ANI_STAND); moveAndScale (* thisPerson, thisPerson -> walkToX, thisPerson -> walkToY); return false; }
void BoxMesh::construct() { int i ; Box bounds = getBounds() ; Point center = (bounds.max - bounds.min) / 2 ; // Vertex verts.push_back(Point(bounds.min.x(), bounds.min.y(), bounds.min.z())); verts.push_back(Point(bounds.max.x(), bounds.min.y(), bounds.min.z())); verts.push_back(Point(bounds.min.x(), bounds.max.y(), bounds.min.z())); verts.push_back(Point(bounds.max.x(), bounds.max.y(), bounds.min.z())); verts.push_back(Point(bounds.min.x(), bounds.min.y(), bounds.max.z())); verts.push_back(Point(bounds.max.x(), bounds.min.y(), bounds.max.z())); verts.push_back(Point(bounds.min.x(), bounds.max.y(), bounds.max.z())); verts.push_back(Point(bounds.max.x(), bounds.max.y(), bounds.max.z())); // Texture coordinates for (i = 0 ; i < 8 ; i++) tverts.push_back(Point2D(0,0)); // Indices int inds[] = { 0, 4, 1, 5, 3, 7, 2, 6, 0, 4, 6, 7, 4, 5, 0, 1, 2, 3 } ; for (i = 0 ; i < sizeof(inds)/sizeof(inds[0]) ; i++) indices.push_back(inds[i]); // Primitives Primitive p ; p.firstElement = 0 ; p.numElements = 10 ; p.type = Primitive::NoMaterial | Primitive::Strip | Primitive::Indexed ; primitives.push_back(p) ; p.firstElement = 10 ; p.numElements = 4 ; primitives.push_back(p) ; p.firstElement = 14 ; primitives.push_back(p) ; // Normals std::vector<Point>::iterator ptr ; for (ptr = verts.begin() ; ptr != verts.end() ; ptr++) { Point normal ; normal = *ptr - center ; normal.normalize() ; normals.push_back (normal) ; enormals.push_back (encodeNormal(normal)) ; } // Other stuff setFrames (1) ; setParent (-1) ; calculateCenter() ; calculateRadius() ; }
void Goblin::senseDistance(int wallX, int level){ // +50 lets it overlap castle a bit, for some depth float distance = spriteData.x + 50 - wallX; float maxDistance = GAME_WIDTH - wallX + 50; // change speed based on distance from wall and framedelay // if at tower do not execute large if else if if(distance > 0){ if(distance/maxDistance < .1) { velocity.x = -goblinNS::SPEED - 45; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_9); } else if(distance/maxDistance < .2) { velocity.x = -goblinNS::SPEED - 40; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_8); } else if(distance/maxDistance < .3) { velocity.x = -goblinNS::SPEED - 35; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_7); } else if(distance/maxDistance < .4) { velocity.x = -goblinNS::SPEED - 30; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_6); } else if(distance/maxDistance < .5){ velocity.x = -goblinNS::SPEED - 25; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_5); } else if(distance/maxDistance < .6) { velocity.x = -goblinNS::SPEED - 20; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_4); } else if(distance/maxDistance < .7) { velocity.x = -goblinNS::SPEED - 15; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_3); } else if(distance/maxDistance < .8) { velocity.x = -goblinNS::SPEED - 10; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_2); } else { velocity.x = -goblinNS::SPEED - 5; setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY_1); } } else { velocity.x = 0; setFrames(goblinNS::ATTACK_START_FRAME, goblinNS::ATTACK_END_FRAME); setFrameDelay(goblinNS::GOBLIN_ANIMATION_DELAY); } velocity.x *= level * 0.85; //velocity.x *= .15; setFrameDelay(getFrameDelay() / level); }
void BaseAudioFile::close() { setFileType(kAudioFileNone); BaseAudioFile::setPCMFormat(kAudioFileInt8); setHeaderEndianness(kAudioFileLittleEndian); setAudioEndianness(kAudioFileLittleEndian); setSamplingRate(0); setChannels(0); setFrames(0); setPCMOffset(0); clearErrorFlags(); }
//============================================================================= // toss // //============================================================================= void Bottle::toss(Entity *target) { setFrames(bottleNS::START_THROW_FRAME,bottleNS::END_THROW_FRAME); setCurrentFrame(bottleNS::START_THROW_FRAME); posVector = target->getPosition(); attackVector = target->getPosition() - D3DXVECTOR2(spriteData.x,spriteData.y);//get direction to fly; radVector = attackVector; velocity = velocity = normalize(attackVector)*bottleNS::AIR_SPEED; visible = true; active = true; }
bool turnPersonToFace (int thisNum, int direc) { onScreenPerson * thisPerson = findPerson (thisNum); if (thisPerson) { if (thisPerson -> continueAfterWalking) abortFunction (thisPerson -> continueAfterWalking); thisPerson -> continueAfterWalking = NULL; thisPerson -> walking = false; thisPerson -> spinning = false; turnMeAngle (thisPerson, direc); setFrames (* thisPerson, (thisPerson == speech->currentTalker) ? ANI_TALK : ANI_STAND); return true; } return false; }
void StatusWidget::setFrames(Role role, const QPixmap& frames, size_t numFrames, double frameRate) { QList<QPixmap> frameList; size_t frameHeight = frames.height()/numFrames; for (size_t i = 0; i < numFrames; ++i) { QPixmap frame = frames.copy(0, i*frameHeight, frames.width(), frameHeight); frameList.append(frame); } setFrames(role, frameList, frameRate); }
bool stopPerson (int o) { onScreenPerson * moveMe = findPerson (o); if (moveMe) if (moveMe -> continueAfterWalking) { abortFunction (moveMe -> continueAfterWalking); moveMe -> continueAfterWalking = NULL; moveMe -> walking = false; moveMe -> spinning = false; setFrames (* moveMe, ANI_STAND); return true; } return false; }
bool Animation::initWithAnimationFrames(const Vector<AnimationFrame*>& arrayOfAnimationFrames, float delayPerUnit, unsigned int loops) { _delayPerUnit = delayPerUnit; _loops = loops; setFrames(arrayOfAnimationFrames); for (auto& animFrame : _frames) { _totalDelayUnits += animFrame->getDelayUnits(); } return true; }
void Boxer::animate(float frameTime) { if(input->isKeyDown(VK_RIGHT) || input->isKeyDown(VK_LEFT)){ isWalking = false; } else{ isWalking = true; } if (isAttacking) { setFrameDelay(0.05); setFrames(12, 23); if (currentFrame == endFrame) isAttacking = false; else return; } if (isWalking) { setFrameDelay(0.1); setFrames(6, 11); flipHorizontal(!facingRight); } else { setFrameDelay(0.075); setFrames(0, 5); flipHorizontal(!facingRight); } }
NPC_guyRed::NPC_guyRed() { npcName = "Red Guy"; speach.push_back("No actually my head is not on Fire! ... why do people keep asking that?"); speach.push_back("Careful don't fall into that mysteriously placed hole and latter."); //SDL_Surface* temp = TTF_RenderText_Blended(font,npcName.c_str(), fgColor); //surfaceText.push_back(temp); SDL_Surface* temp = TTF_RenderText_Blended(font,speach[0].c_str(), fgColor); surfaceText.push_back(temp); temp = TTF_RenderText_Blended(font,speach[1].c_str(), fgColor); surfaceText.push_back(temp); npcImage = load_imageBlue("../Images/npc/guyRed.bmp"); setFrames(); }
void walkAllPeople () { onScreenPerson * thisPerson = allPeople; while (thisPerson) { if (thisPerson -> walking) { walkMe (thisPerson); } else if (thisPerson -> spinning) { spinStep (thisPerson); setFrames (* thisPerson, ANI_STAND); } if ((! thisPerson -> walking) && (! thisPerson -> spinning) && thisPerson -> continueAfterWalking) { restartFunction (thisPerson -> continueAfterWalking); thisPerson -> continueAfterWalking = NULL; } thisPerson = thisPerson -> next; } }
NPC::NPC(){ TTF_Init(); setStats(1,1,1,1,1,1); // need to be set because it is still a Entity instance, but these will never be used. npcName = "Default NPC"; //speach.push_back("I don't know what kinda of NPC I am. :("); // default image - should not be used. But just in case SDL_Surface* tempSurface = IMG_Load("../Images/npc/default.png"); npcImage = SDL_DisplayFormatAlpha(tempSurface); SDL_FreeSurface(tempSurface); setFrames(); // set the frames sentence = 0; font = TTF_OpenFont("../Fonts/coolvetica.ttf",25); fgColor.r = 255; fgColor.g = 255; fgColor.b = 255; surfaceTextRect.x = 40; surfaceTextRect.y = 500; }
NPC_guy1::NPC_guy1() { npcName = "NPC Guy"; speach.push_back("Hey Mr. have you ever seen a guy with his head on fire?"); speach.push_back("Well for only 3 gold coins I'll show you someone just like that,"); speach.push_back("Fine your lose."); //SDL_Surface* temp = TTF_RenderText_Blended(font,npcName.c_str(),fgColor); //surfaceText.push_back(temp); SDL_Surface* temp = TTF_RenderText_Blended(font,speach[0].c_str(),fgColor); surfaceText.push_back(temp); temp = TTF_RenderText_Blended(font,speach[1].c_str(),fgColor); surfaceText.push_back(temp); temp = TTF_RenderText_Blended(font,speach[2].c_str(),fgColor); surfaceText.push_back(temp); npcImage = SDL_LoadBMP("../Images/npc/guy1.bmp"); SDL_SetColorKey( npcImage, SDL_SRCCOLORKEY, SDL_MapRGB( npcImage->format, 0xff, 0xff, 0xff ) ); setFrames(); }
NPC_girl1::NPC_girl1() { npcName = "NPC Girl"; // non original name speach.push_back("Hello, Hero..."); speach.push_back("Please protect me from that scary fire head guy!"); //SDL_Surface* temp = TTF_RenderText_Blended(font,npcName.c_str(),fgColor); //surfaceText.push_back(temp); SDL_Surface* temp = TTF_RenderText_Blended(font,speach[0].c_str(), fgColor); surfaceText.push_back(temp); temp = TTF_RenderText_Blended(font,speach[1].c_str(), fgColor); surfaceText.push_back(temp); // should load image //SDL_Surface* tempSurface = IMG_Load("../Images/npc/girl1.bmp"); //npcImage = SDL_DisplayFormatAlpha(tempSurface); //SDL_FreeSurface(tempSurface); npcImage = load_imageBlue("../Images/npc/girl1.bmp"); //SDL_SetColorKey( npcImage, SDL_SRCCOLORKEY, SDL_MapRGB( npcImage->format, 0xff, 0xff, 0xff ) ); setFrames(); }
bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay) { CCARRAY_VERIFY_TYPE(pFrames, CCSpriteFrame*); m_uLoops = 1; m_fDelayPerUnit = delay; CCArray* pTmpFrames = CCArray::array(); setFrames(pTmpFrames); if (pFrames != NULL) { CCObject* pObj = NULL; CCARRAY_FOREACH(pFrames, pObj) { CCSpriteFrame* frame = (CCSpriteFrame*)pObj; CCAnimationFrame *animFrame = new CCAnimationFrame(); animFrame->initWithSpriteFrame(frame, 1, NULL); m_pFrames->addObject(animFrame); animFrame->release(); m_fTotalDelayUnits++; }
void CylinderMesh::construct() { int i, firstTop ; int steps = (unsigned int)(complexity * 64.0f) ; float angle ; Point normal ; Box bounds = getBounds() ; Point center = getCenter() ; float radius = getRadius() ; Primitive p ; p.type = Primitive::NoMaterial | Primitive::Strip | Primitive::Indexed ; if (steps < 4) steps = 4 ; if (steps > 64) steps = 64 ; steps &= ~1 ; // Bottom addVertex (center.x(), center.y(), bounds.min.z()) ; for (angle = 0.0f, i = 0 ; i < steps ; i++, angle += 2.0f*M_PI/(float)steps) { addVertex (cosf(angle)*radius + center.x(), sinf(angle)*radius + center.y(), bounds.min.z()) ; } for (i = 1 ; i <= steps ; i++) { p.firstElement = indices.size() ; p.numElements = 3 ; indices.push_back (0) ; indices.push_back (i) ; indices.push_back (i == steps ? 1 : i+1) ; primitives.push_back(p) ; } // Top firstTop = verts.size() ; addVertex (center.x(), center.y(), bounds.max.z()) ; for (angle = 0.0f, i = 0 ; i < steps ; i++, angle += 2.0f*M_PI/(float)steps) { addVertex (cosf(angle)*radius + center.x(), sinf(angle)*radius + center.y(), bounds.max.z()) ; } for (i = 1 ; i <= steps ; i++) { p.firstElement = indices.size() ; p.numElements = 3 ; indices.push_back (firstTop) ; indices.push_back (firstTop+(i == steps ? 1 : i+1)) ; indices.push_back (firstTop+i) ; primitives.push_back(p) ; } // Walls int pos ; for (pos = indices.size(), i = 0 ; i < steps-1 ; i++, pos += 4) { indices.push_back (i+1) ; indices.push_back (firstTop+i+1) ; indices.push_back (i+2) ; indices.push_back (firstTop+i+2) ; p.firstElement = pos ; p.numElements = 4 ; primitives.push_back(p) ; } indices.push_back (i+1) ; indices.push_back (firstTop+i+1) ; indices.push_back (1) ; indices.push_back (firstTop+1) ; p.firstElement = pos ; p.numElements = 4 ; primitives.push_back(p) ; // Other stuff setFrames (1) ; setParent (-1) ; calculateBounds() ; calculateCenter() ; calculateRadius() ; }
void NPC::calcVelocity(float frameTime) { float angle, xLength, yLength, tempX, tempY; static int xSign = 1; static int ySign = 1; xLength = moseyEndX-moseyStartX; yLength = moseyEndY-moseyStartY; static float timeTillPause = pauseInterval; static float timeTillMosey = pauseTime; if(speaking) { // prevent movement while speaking setVelocity(VECTOR2(0.0,0.0)); return; } if(timeTillPause > 0.0) timeTillPause -= frameTime; else if(timeTillMosey > 0.0) { // NPC should be paused setVelocity(VECTOR2(0.0,0.0)); timeTillMosey -= frameTime; return; } else { timeTillPause = pauseInterval; timeTillMosey = pauseTime; } // if he is not paused, continue on to mosey... // if vector is negative, it's moving left if(xLength < 0) { setFrames(2,3); flipHorizontal(true); // if the NPC is further left than the endpoint, swap endpoint and startpoint if(spriteData.x < moseyEndX) { tempX = moseyStartX; moseyStartX = moseyEndX; moseyEndX = tempX; } } else if(xLength > 0) { // if movement is positive, check for x > endpoint, then swap setFrames(2,3); flipHorizontal(false); if(spriteData.x > moseyEndX) { tempX = moseyStartX; moseyStartX = moseyEndX; moseyEndX = tempX; } } // if vector is negative, he's moving up if(yLength < 0) { setFrames(4,5); // if the NPC is higher than that the endpoint, swap endpoint and startpoint if(spriteData.y < moseyEndY) { tempY = moseyStartY; moseyStartY = moseyEndY; moseyEndY = tempY; setCurrentFrame(0); } } else if(yLength > 0) { setFrames(0,1); if(spriteData.y > moseyEndY) { tempY = moseyStartY; moseyStartY = moseyEndY; moseyEndY = tempY; setCurrentFrame(4); } } if(xLength == 0.0) { if(yLength < 0) angle = -(float)PI/2; // prevent divide by 0 when xLength is 0. atan(inf) = -PI/2 if(yLength > 0) angle = (float)PI/2; } else if(xLength < 0) angle = atan(yLength/xLength)+((float)PI); // rotate by 180 degrees else angle = atan(yLength/xLength); setVelocity(VECTOR2(npcNS::MOVE_SPEED*cos(angle)*xSign, npcNS::MOVE_SPEED*sin(angle)*ySign)); }
void StatusWidget::setIcon(Role role, const QPixmap& icon) { setFrames(role, icon, 1, 0.0); }
bool doBorderStuff (onScreenPerson * moveMe) { if (moveMe -> inPoly == moveMe -> walkToPoly) { moveMe -> inPoly = -1; moveMe -> thisStepX = moveMe -> walkToX; moveMe -> thisStepY = moveMe -> walkToY; } else { // The section in which we need to be next... int newPoly = currentFloor -> matrix[moveMe -> inPoly][moveMe -> walkToPoly]; if (newPoly == -1) return false; // Grab the index of the second matching corner... int ID, ID2; if (! getMatchingCorners (currentFloor -> polygon[moveMe -> inPoly], currentFloor -> polygon[newPoly], ID, ID2)) return fatal ("Not a valid floor plan!"); // Remember that we're walking to the new polygon... moveMe -> inPoly = newPoly; // Calculate the destination position on the coincidantal line... int x1 = moveMe -> x, y1 = moveMe -> y; int x2 = moveMe -> walkToX, y2 = moveMe -> walkToY; int x3 = currentFloor -> vertex[ID].x, y3 = currentFloor -> vertex[ID].y; int x4 = currentFloor -> vertex[ID2].x, y4 = currentFloor -> vertex[ID2].y; int xAB = x1 - x2; int yAB = y1 - y2; int xCD = x4 - x3; int yCD = y4 - y3; double m = (yAB * (x3 - x1) - xAB * (y3 - y1)); m /= ((xAB * yCD) - (yAB * xCD)); if (m > 0 && m < 1) { moveMe -> thisStepX = x3 + m * xCD; moveMe -> thisStepY = y3 + m * yCD; } else { int dx13 = x1-x3, dx14 = x1-x4, dx23 = x2-x3, dx24 = x2-x4; int dy13 = y1-y3, dy14 = y1-y4, dy23 = y2-y3, dy24 = y2-y4; dx13 *= dx13; dx14 *= dx14; dx23 *= dx23; dx24 *= dx24; dy13 *= dy13; dy14 *= dy14; dy23 *= dy23; dy24 *= dy24; if (sqrt((double) dx13 + dy13) + sqrt((double) dx23 + dy23) < sqrt((double) dx14 + dy14) + sqrt((double) dx24 + dy24)) { moveMe -> thisStepX = x3; moveMe -> thisStepY = y3; } else { moveMe -> thisStepX = x4; moveMe -> thisStepY = y4; } } } float yDiff = moveMe -> thisStepY - moveMe -> y; float xDiff = moveMe -> x - moveMe -> thisStepX; if (xDiff || yDiff) { moveMe -> wantAngle = 180 + ANGLEFIX * atan2(xDiff, yDiff * 2); moveMe -> spinning = true; } setFrames (* moveMe, ANI_WALK); return true; }
/** Called when asyn clients call pasynInt32->write(). * This function performs actions for some parameters, including ADAcquire, ADBinX, etc. * For all parameters it sets the value in the parameter library and calls any registered callbacks.. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus mythen::writeInt32(asynUser *pasynUser, epicsInt32 value) { int function = pasynUser->reason; int status = asynSuccess; static const char *functionName = "writeInt32"; /* Reject any call to the detector if it is running */ if ((function != ADAcquire) && acquiring_) { asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: detector is busy\n", driverName, functionName); return asynError; } /* Set the parameter and readback in the parameter library. * This may be overwritten when we read back the * status at the end, but that's OK */ status |= setIntegerParam(function, value); if (function == ADAcquire) { getIntegerParam(SDReadMode, &readmode_); status |= setAcquire(value); } else { if (function == SDSetting) { status |= loadSettings(value); } else if (function == SDUseFlatField) { status |= setFCorrection(value); } else if (function == SDUseCountRate) { status |= setRCorrection(value); } else if (function == SDUseBadChanIntrpl) { status |= setBadChanIntrpl(value); } else if (function == SDBitDepth) { status |= setBitDepth(value); } else if (function == SDNumGates) { status = setNumGates(value); } else if (function == SDUseGates) { status = setUseGates(value); } else if (function == SDNumFrames) { status |= setFrames(value); } else if (function == SDTrigger) { status |= setTrigger(value); } else if (function == SDReset) { status |= setReset(); } else if (function == ADImageMode) { //getIntegerParam(SDNumFrames, &frames_); status |= setFrames(frames_); } else { /* If this is not a parameter we have handled call the base class */ if (function < FIRST_SD_PARAM) status = ADDriver::writeInt32(pasynUser, value); } status |= getSettings(); } /* Update any changed parameters */ status |= callParamCallbacks(); if (status) asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%d\n", driverName, functionName, status, function, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%d\n", driverName, functionName, function, value); return((asynStatus)status); }
NotePlayHandle::NotePlayHandle( InstrumentTrack* instrumentTrack, const f_cnt_t _offset, const f_cnt_t _frames, const note& n, NotePlayHandle *parent, int midiEventChannel, Origin origin ) : PlayHandle( TypeNotePlayHandle, _offset ), note( n.length(), n.pos(), n.key(), n.getVolume(), n.getPanning(), n.detuning() ), m_pluginData( NULL ), m_filter( NULL ), m_instrumentTrack( instrumentTrack ), m_frames( 0 ), m_totalFramesPlayed( 0 ), m_framesBeforeRelease( 0 ), m_releaseFramesToDo( 0 ), m_releaseFramesDone( 0 ), m_released( false ), m_hasParent( parent != NULL ), m_hadChildren( false ), m_muted( false ), m_bbTrack( NULL ), m_origTempo( engine::getSong()->getTempo() ), m_origBaseNote( instrumentTrack->baseNote() ), m_frequency( 0 ), m_unpitchedFrequency( 0 ), m_baseDetuning( NULL ), m_songGlobalParentOffset( 0 ), m_midiChannel( midiEventChannel >= 0 ? midiEventChannel : instrumentTrack->midiPort()->realOutputChannel() ), m_origin( origin ) { if( hasParent() == false ) { m_baseDetuning = new BaseDetuning( detuning() ); m_instrumentTrack->m_processHandles.push_back( this ); } else { m_baseDetuning = parent->m_baseDetuning; parent->m_subNotes.push_back( this ); parent->m_hadChildren = true; m_bbTrack = parent->m_bbTrack; } updateFrequency(); setFrames( _frames ); // inform attached components about new MIDI note (used for recording in Piano Roll) if( m_origin == OriginMidiInput ) { m_instrumentTrack->midiNoteOn( *this ); } if( hasParent() || ! m_instrumentTrack->isArpeggioEnabled() ) { const int baseVelocity = m_instrumentTrack->midiPort()->baseVelocity(); // send MidiNoteOn event m_instrumentTrack->processOutEvent( MidiEvent( MidiNoteOn, midiChannel(), midiKey(), midiVelocity( baseVelocity ) ), MidiTime::fromFrames( offset(), engine::framesPerTick() ), offset() ); } }
void makeSilent (onScreenPerson & me) { setFrames (me, ANI_STAND); }
void makeTalker (onScreenPerson & me) { setFrames (me, ANI_TALK); }
//============================================================================= // update // typically called once per frame // frameTime is used to regulate the speed of movement and animation //============================================================================= void Avatar::update(float frameTime) { // Walls if (spriteData.x > GAME_WIDTH-(squareNS::WIDTH * squareNS::SCALE)-(avatarNS::WIDTH * avatarNS::AVATAR_SCALE)) // if hit right screen edge { spriteData.x = GAME_WIDTH-(squareNS::WIDTH * squareNS::SCALE)-(avatarNS::WIDTH)*avatarNS::AVATAR_SCALE; // position at right screen edge velocity.x = 0; } else if (spriteData.x < squareNS::WIDTH*squareNS::SCALE) // else if hit left screen edge { spriteData.x = squareNS::WIDTH*squareNS::SCALE; // position at left screen edge velocity.x = 0; } if (spriteData.y > GAME_HEIGHT-(squareNS::HEIGHT * squareNS::SCALE)-(avatarNS::HEIGHT)*avatarNS::AVATAR_SCALE) // if hit bottom screen edge { spriteData.y = GAME_HEIGHT-(squareNS::HEIGHT * squareNS::SCALE)-(avatarNS::HEIGHT)*avatarNS::AVATAR_SCALE; // position at bottom screen edge velocity.y = 0; } else if (spriteData.y < 2*(squareNS::HEIGHT*squareNS::SCALE)) // else if hit top screen edge { if(!nextLevel) { spriteData.y = 2*(squareNS::HEIGHT*squareNS::SCALE); // position at top screen edge velocity.y = 0; } else { if((spriteData.x < 7*(squareNS::WIDTH * squareNS::SCALE) || spriteData.x > 8*(squareNS::WIDTH * squareNS::SCALE)) && getDirectionFacing() == avatarNS::UP) { spriteData.y = 2*(squareNS::HEIGHT*squareNS::SCALE); // position at top screen edge velocity.y = 0; } if(spriteData.x < 7*(squareNS::WIDTH * squareNS::SCALE) && getDirectionFacing() == avatarNS::LEFT) { spriteData.x = 7*(squareNS::WIDTH * squareNS::SCALE); velocity.x = 0; } if(spriteData.x > 8*(squareNS::WIDTH * squareNS::SCALE) && getDirectionFacing() == avatarNS::RIGHT) { spriteData.x = 8*(squareNS::WIDTH * squareNS::SCALE); velocity.x = 0; } if (spriteData.y < 0) { spriteData.y = 0; velocity.y = 0; } } } velocity.x = 0; velocity.y = 0; if(input->isKeyDown(VK_RIGHT) && !input->isKeyDown(VK_UP) && !input->isKeyDown(VK_DOWN)){ //puts precedence over vertical movement if multiple keys held if(direction != avatarNS::RIGHT) { direction = avatarNS::RIGHT; setCurrentFrame(8); } velocity.x = avatarNS::SPEED; setFrames(8, 11); Entity::update(frameTime); audio->playCue(WALKING); } if(input->isKeyDown(VK_LEFT) && !input->isKeyDown(VK_UP) && !input->isKeyDown(VK_DOWN)){ if(direction != avatarNS::LEFT) { setDirectionFacing(avatarNS::LEFT); setCurrentFrame(4); } velocity.x = -avatarNS::SPEED; setFrames(4, 7); Entity::update(frameTime); audio->playCue(WALKING); } if(input->isKeyDown(VK_UP)) { if(direction != avatarNS::UP) { setDirectionFacing(avatarNS::UP); setCurrentFrame(12); } velocity.y = -avatarNS::SPEED; setFrames(12, 15); Entity::update(frameTime); audio->playCue(WALKING); } if(input->isKeyDown(VK_DOWN)) { if(direction != avatarNS::DOWN) { setDirectionFacing(avatarNS::DOWN); setCurrentFrame(0); } velocity.y = avatarNS::SPEED; setFrames(0, 3); Entity::update(frameTime); audio->playCue(WALKING); } spriteData.x += frameTime * velocity.x; // move ship along X spriteData.y += frameTime * velocity.y; // move ship along Y }