public void update(Time dt) { mWorldView.Move(new Vector2f(0, mScrollSpeed * (float)dt.Seconds)); mPlayerAircraft.setVelocity(0, 0); while (!mCommandQueue.isEmpty()) { mSceneGraph.onCommand(mCommandQueue.pop(), dt); } Vector2f velocity = mPlayerAircraft.getVelocity(); if (velocity.X != 0 && velocity.Y != 0) { velocity.X /= (float)Math.Sqrt(2); velocity.Y /= (float)Math.Sqrt(2); mPlayerAircraft.setVelocity(velocity); } mPlayerAircraft.accelerate(new Vector2f(0, mScrollSpeed)); #region legacycode //float movementnum = 200; // //Y input //if (Keyboard.IsKeyPressed(Keyboard.Key.W)) {velocity.Y = -movementnum + mScrollSpeed;} //if (Keyboard.IsKeyPressed(Keyboard.Key.S)) {velocity.Y = movementnum + mScrollSpeed;} ////Y Stopper //if (Keyboard.IsKeyPressed(Keyboard.Key.W) != true && Keyboard.IsKeyPressed(Keyboard.Key.S) != true) velocity.Y = mScrollSpeed; ////X input //if (Keyboard.IsKeyPressed(Keyboard.Key.A)) { velocity.X = -movementnum; } //if (Keyboard.IsKeyPressed(Keyboard.Key.D)) { velocity.X = movementnum; } ////X Stopper //if (Keyboard.IsKeyPressed(Keyboard.Key.A) != true && Keyboard.IsKeyPressed(Keyboard.Key.D) != true) velocity.X = 0; ////Command test //Command com = new Command(); //com.category = (uint)Category.PlayerAircraft; //com.actionfunc = new AircraftMover().movefunc; //if (position.X <= mWorldBounds.Left + 120 || position.X >= mWorldBounds.Left + mWorldBounds.Width - 120) //{ // velocity.X = -velocity.X;//could be -velocity.X //} //mPlayerAircraft.setVelocity(velocity); ////update #endregion spawnEnemies(); mSceneGraph.update(dt,this.mCommandQueue); FloatRect viewBounds = new FloatRect(mWorldView.Center.X - mWorldView.Size.X / 2, mWorldView.Center.Y - mWorldView.Size.Y / 2, mWorldView.Size.X, mWorldView.Size.Y); //no idea if this works const float borderDistance = 40; Vector2f postion = mPlayerAircraft.Position; postion.X = Math.Max(postion.X, viewBounds.Left + borderDistance); postion.X = Math.Min(postion.X, viewBounds.Left + viewBounds.Width - borderDistance); postion.Y = Math.Max(postion.Y, viewBounds.Top + borderDistance); postion.Y = Math.Min(postion.Y, viewBounds.Top + viewBounds.Height - borderDistance); mPlayerAircraft.Position = postion; }
public override bool update(Time dt) { RenderWindow window = mContext.window; View view = window.GetView(); mPausedText.Position = new Vector2f(view.Center.X, view.Center.Y); mInstructionText.Position = new Vector2f(view.Center.X, view.Center.Y + 50); backgroundShape.Position = new Vector2f(view.Center.X - view.Size.X / 2, view.Center.Y - view.Size.Y / 2); return false; }
public override void updateCurrent(Time dt,CommandQueue queue) { if (isDestroyed()) { mIsMarkedForRemoval = true; return; } checkProjectileLaunch(dt,queue); updateMovementPattern(dt); base.updateCurrent(dt,queue); updateTexts(); }
public void update(Time dt) { //IEnumerator<State> itr = mStack.GetEnumerator(); //itr.MoveNext(); ////if (itr == null) { applyPendingChanges(); return; } //for (int i = mStack.Count; i > 0; i--) //{ // if (!itr.Current.update(dt)) { applyPendingChanges(); return; } // itr.MoveNext(); //} foreach (State state in mStack) { if (!state.update(dt)) { applyPendingChanges(); return; } } applyPendingChanges(); }
public void onCommand(Command command, Time dt) { if (command.category == getCategory()) { command.actionfunc(this, dt); } foreach (SceneNode child in mChildren) { child.onCommand(command, dt); } }
public void update(Time dt, CommandQueue queue) { updateCurrent(dt, queue); updateChildren(dt, queue); }
public void launchfunc(SceneNode node, Time time) { Aircraft aircraft = (Aircraft)node; aircraft.launchMissile(); }
//ignore this warning public override void updateCurrent(Time dt) { this.Position = new Vector2f(this.Position.X + mVelocity.X * (float)dt.Seconds, this.Position.Y + mVelocity.Y * (float)dt.Seconds); }
private void update(Time dt) { mStateStack.update(dt); }
public void shootfunc(SceneNode node, Time time) { Aircraft aircraft = (Aircraft)node; aircraft.fire(); }
public Aircraft(Type type, ResourceHolder<Texture, ResourceID> textures, ResourceHolder<Font,FontID> fonts) :base(Table[(int)type].hitpoints) { mType = type; mSprite = new Sprite(textures.get(toTextureID(type))); FloatRect bounds = mSprite.GetLocalBounds(); mSprite.Origin = new Vector2f(bounds.Width / 2, bounds.Height / 2); TextNode healthDisplay = new TextNode(fonts, " "); ; mHealthDisplay = healthDisplay; attachChild(healthDisplay); mTravelledDistance = 0; mDirectionIndex = 0; mIsFiring = false; mIsLaunchingMissile = false; MissileAmmo = 3; mIsMarkedForRemoval = false; mFireCountdown = Time.Zero; mFireRateLevel = 1; mSpreadLevel = 1; mFireCommand = new Command(); mFireCommand.category = (uint)Category.PlayerAircraft; mFireCommand.actionfunc = (SceneNode node, Time time) => { SceneNode aircraft = (Aircraft)node; createBullets(aircraft, textures); }; mLaunchCommand = new Command(); }
public void movefunc(SceneNode node, Time time) { Aircraft aircraft = (Aircraft)node; //I am having a really hard time converting the derivedAction method, so hopefully it will work by itself for now. aircraft.accelerate(velocity); }
public virtual void updateCurrent(Time dt, CommandQueue queue) { }
public override bool update(Time dt) { return true; }
private void updateChildren(Time dt) { foreach (SceneNode child in mChildren) child.update(dt); }
public virtual void updateCurrent(Time dt) { }
public void update(Time dt) { updateCurrent(dt); updateChildren(dt); }
private void updateChildren(Time dt, CommandQueue queue) { foreach (SceneNode child in mChildren) child.update(dt, queue); }
public void update(Time dt) { foreach (State state in mStack) { if (!state.update(dt)) { applyPendingChanges(); return; } } applyPendingChanges(); }
public void checkProjectileLaunch(Time dt, CommandQueue commands) { if (mIsFiring && mFireCountdown <= Time.Zero) { commands.push(mFireCommand); //POSSIBLE ISSUE WITH MFIRECOMMAND NOT POINTING TO PROPER FUNC mFireCountdown += Time.FromSeconds((float)1 / ((float)mFireRateLevel + (float)1)); mIsFiring = false; } else if (mFireCountdown > Time.Zero) mFireCountdown -= dt; if (mIsLaunchingMissile) { commands.push(mLaunchCommand); mIsLaunchingMissile = false; } }
public virtual bool update(Time dt);
public void updateMovementPattern(Time dt) { List<Direction> directions = Table[(int)mType].directions; if (directions.Count != 0) { float distanceToTravel = directions[(int)mDirectionIndex].distance; if (mTravelledDistance > distanceToTravel) { mDirectionIndex = (mDirectionIndex + 1) % directions.Count; mTravelledDistance = 0; } float radians = Utility.toRadian(directions[(int)mDirectionIndex].angle + 90); float vx = getMaxSpeed() * (float)Math.Cos(radians); float vy = getMaxSpeed() * (float)Math.Sin(radians); setVelocity(vx, vy); mTravelledDistance += getMaxSpeed() * (float)dt.Seconds; } }
private void update(Time elapsedTime) { mWorld.update(elapsedTime); }
public virtual bool update(Time dt) { return true; }
public override bool update(Time dt) { //if (starttimer.ElapsedTime >= Time.FromMilliseconds(3000)) square.Position = new Vector2f(square.Position.X, square.Position.Y + (float)dt.Milliseconds / 2); b2World.Step(dt.Milliseconds/1000f, 9, 2); square.Position = new Vector2f(UnitConverter.toPixScale(b2Body.Position.X), UnitConverter.toPixScale(b2Body.Position.Y)); square.Rotation = b2Body.Angle; return true; }