bool transition_out(long id, pState dest) { if (state_id == id) { state = dest; return(true); } return(false); }
long transition(pState[] befores, pState after) { foreach (pState before in befores) { if (state == before) { state = after; return(++state_id); } } return(0); }
long transition(pState before, pState after) { if (state == before) { state = after; return(++state_id); } else { return(0); } }
private void UpdateMovement(KeyboardState aCurrentKeyboardState) { if (aCurrentKeyboardState.IsKeyDown(Keys.Space) == true) { beginningSpacePressed = true; } if ((mCurrentState == pState.Flying || mCurrentState == pState.Jumping) && beginningSpacePressed == true) { mSpeed = Vector2.Zero; mDirection = Vector2.Zero; if (aCurrentKeyboardState.IsKeyDown(Keys.Space) == true) { mCurrentFacing = Facing.Up; mSpeed.Y = PLAYER_SPEED; mDirection.Y = MOVE_UP; rotation = 0; mCurrentState = pState.Jumping; } else if (mCurrentState == pState.Dead) { mSpeed.Y = 0; mDirection.Y = 0; rotation = 0; } else { mSpeed.Y = PLAYER_SPEED; mDirection.Y = MOVE_DOWN; mCurrentFacing = Facing.Right; if (rotation < .5f && Position.Y != graphicsDevice.Viewport.Height - Size.Height) { rotation -= MathHelper.ToRadians(rotationVelocity); } else if (Position.Y == graphicsDevice.Viewport.Height - Size.Height) { rotation = 0; } } // check for environment hit CheckPlayerBrickCrash(); } }
public ActionResult Agregar(EstadoCLS oEstadoCLS) { if (!ModelState.IsValid) { return(View(oEstadoCLS)); } else { using (var bd = new proyectoSEntities1()) { pState oEstado = new pState(); oEstado.nombreS = oEstadoCLS.nombreS; bd.pState.Add(oEstado); bd.SaveChanges(); } } return(RedirectToAction("Index")); }
public void Update(GameTime theGameTime) { KeyboardState aCurrentKeyboardState = Keyboard.GetState(); GamePadState aCurrentGamepadState = GamePad.GetState(PlayerIndex.One); UpdateMovement(aCurrentKeyboardState); UpdateBullet(theGameTime, aCurrentKeyboardState, aCurrentGamepadState); mPreviousKeyboardState = aCurrentKeyboardState; mPreviousGamepadState = aCurrentGamepadState; CheckBulletBrickHit(); base.Update(theGameTime, mSpeed, mDirection); /* Stop the player from moving off the screen correction */ // HORIZONTAL PLAYER POSITION DOES NOT CHANGE // VERTICAL POSITION - if this is reached player = DEAD if (Position.Y >= graphicsDevice.Viewport.Height - Size.Height / 4) { Position.Y = graphicsDevice.Viewport.Height - Size.Height / 4; mCurrentState = pState.Dead; } if (Position.Y < 0) { Position.Y = 0; } /* End player off screen correction */ // FrameTimer += theGameTime.ElapsedGameTime; if (FrameTimer >= FrameLength) { FrameTimer = TimeSpan.Zero; FrameNum = (FrameNum + 1) % FRAME_COUNT; } if (FrameNum >= FRAME_COUNT) { FrameNum = 0; } if (score == 10 || score == 20) { UpdatePlayerSkin(theGameTime, mContentManager); } if (mCurrentState == pState.Jumping) { float timer = (float)theGameTime.ElapsedGameTime.TotalSeconds; _remainingDelay -= timer; if (_remainingDelay <= 0) { LoadFallingBrick(); _remainingDelay = _delay; } } // update surroundings if (fallingBrick != null) { fallingBrick.Update(theGameTime); } CheckBulletBrickHit(); }
public void die() { mCurrentState = pState.Dead; }
public void Update(GameTime theGameTime) { KeyboardState aCurrentKeyboardState = Keyboard.GetState(); GamePadState aCurrentGamepadState = GamePad.GetState(PlayerIndex.One); //UpdateMovement(aCurrentKeyboardState); if (Stationary) { if (((aCurrentKeyboardState.IsKeyDown(Keys.Space) == true && mPreviousKeyboardState.IsKeyDown(Keys.Space) == false))) { Stationary = false; } } if (!Stationary) { UpdateMovement(aCurrentKeyboardState); } UpdateBullet(theGameTime, aCurrentKeyboardState, aCurrentGamepadState); mPreviousKeyboardState = aCurrentKeyboardState; mPreviousGamepadState = aCurrentGamepadState; //CheckBulletBrickHit(); base.Update(theGameTime, mSpeed, mDirection); /* Stop the player from moving off the screen correction */ // HORIZONTAL PLAYER POSITION DOES NOT CHANGE // VERTICAL POSITION - if this is reached player = DEAD if (Position.Y >= graphicsDevice.Viewport.Height - Size.Height / 4) { Position.Y = graphicsDevice.Viewport.Height - Size.Height / 4; mCurrentState = pState.Dead; } if (Position.Y < 0) { Position.Y = 0; mCurrentState = pState.Dead; } /* End player off screen correction */ // FrameTimer += theGameTime.ElapsedGameTime; if (FrameTimer >= FrameLength) { FrameTimer = TimeSpan.Zero; FrameNum = (FrameNum + 1) % FRAME_COUNT; } if (FrameNum >= FRAME_COUNT) { FrameNum = 0; } if (score == 10 || score == 20) { UpdatePlayerSkin(theGameTime); } //if (mCurrentState == pState.Jumping) //{ // float timer = (float)theGameTime.ElapsedGameTime.TotalSeconds; // _remainingDelay -= timer; // if (_remainingDelay <= 0) // { // LoadFallingBrick(); // _remainingDelay = _delay; // } //} playerRect = new Rectangle( (int)this.Position.X - FrameSize, (int)(Position.Y - Size.Height / 4.0f + 10), (int)((float)this.Size.Width / 3.0f), (int)((float)this.Size.Height / 4.0f) ); //// update surroundings //if (fallingBrick != null) // fallingBrick.Update(theGameTime); //CheckBulletBrickHit(); }