private void UpdateAngles(float gameSpeed) { if (_rotateLeft) { _sprite.Rotate(_rotationSpeed * gameSpeed); } else { _sprite.Rotate(-_rotationSpeed * gameSpeed); } //Keep Seasaw from rotating too far left if (_sprite.Angle > 0.32f) { _sprite.Angle = 0.32f; _rotateLeft = false; } //Keep Seasaw from rotating too far Right if (_sprite.Angle < -0.32f) { _sprite.Angle = -0.32f; } //Update the angle variables _angle = _sprite.Angle; _angle2 = (FMath.PI / 2) - _angle; }
public void Update() { if (!_killed) { //Move Player AnimatePlayer(); Move(); CheckJump(); //Stop player from falling through the ground if (_sprite.Position.Y < _defaultYPos + _floorHeight) { _sprite.Position = new Vector2(_sprite.Position.X, _defaultYPos + _floorHeight); _jump = false; } //Rotate Player if (_sprite.Angle > _angle) { _sprite.Rotate(-0.05f); } else if (_sprite.Angle < _angle) { _sprite.Rotate(0.05f); } //Reset rotation; _angle = 0.0f; } else { if (_killedByFire) { KillPlayerByFire(); } } //Storing Bounds2 box data for collisions _min.X = _sprite.Position.X; _min.Y = _sprite.Position.Y - ((_size * _scale) * 0.5f); _max.X = _sprite.Position.X + ((_size * _scale) * 0.3f); _max.Y = _sprite.Position.Y + ((_size * _scale) * 0.5f); _box.Min = _min; _box.Max = _max; _min.X = _sprite.Position.X - ((_size * _scale) * 0.5f); _min.Y = _sprite.Position.Y - ((_size * _scale) * 0.5f); _max.X = _sprite.Position.X + ((_size * _scale) * 0.5f); _max.Y = _sprite.Position.Y - ((_size * _scale) * 0.5f); _bottomBox.Min = _min; _bottomBox.Max = _max; }
public static void love_graphics_draw(TextureInfo drawable, float x, float y, float r, float sx, float sy, float ox, float oy) { // create a new sprite var sprite = new SpriteUV() { TextureInfo = drawable }; // make the texture 1:1 on screen sprite.Quad.S = drawable.TextureSizef; // center the sprite around its own .Position // (by default .Position is the lower left bit of the sprite) sprite.CenterSprite(TRS.Local.TopLeft); // our scene only has 2 nodes: scene->sprite scene.AddChild(sprite); sprite.Position = new Vector2(x - ox, 544 - y + oy); sprite.Pivot = new Vector2(ox, -oy); sprite.Scale = new Vector2(sx, sy); sprite.Rotate(-r); sprite.BlendMode = BlendMode.Normal; sprite.Color = setColor; }
public void UpdateAngle() { if (_rotateLeft) { _sprite.Rotate(-_rotationSpeed); } else { _sprite.Rotate(_rotationSpeed); } if (_sprite.Angle > 0.55f) { _sprite.Angle = 0.55f; _rotateLeft = false; } if (_sprite.Angle < -0.55f) { _sprite.Angle = -0.55f; } _angle = _sprite.Angle; }
public AmmoItem(Vector2 pos) { //assign the position of the item Position = pos; //create a new texture if one doesn't exist yet if (AmmoItem.ammoTexture == null) { ammoTexture = new Texture2D("/Application/data/tiles/ammo.png", false); } //create a sprite for this specific ammo item SpriteUV sprite = new SpriteUV(); sprite.TextureInfo = new TextureInfo(AmmoItem.ammoTexture); sprite.Scale = new Vector2(0.5f, 0.5f); sprite.Pivot = new Vector2(0.5f, 0.5f); //rotate by a random angle sprite.Rotation = sprite.Rotation.Rotate(Support.random.Next(-180, 180)); //schedule this sprite to rotate every frame by a fraction of an angle sprite.Schedule((dt) => { sprite.Rotate(0.01f); }, -1); //create an underlying shadow for the item SpriteUV shadow = new SpriteUV(new TextureInfo(Bullet.fireTexture)); shadow.CenterSprite(new Vector2(0.25f, 0.25f)); shadow.Color = Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.SetAlpha(Colors.Yellow, 0.5f); shadow.Scale = new Vector2(2.0f, 2.0f); //add a shadow and a sprite to this GameEntity this.AddChild(shadow); this.AddChild(sprite); //calculate the bounds of this AmmoItem bounds = new Bounds2(); sprite.GetlContentLocalBounds(ref bounds); }
public void setRotation(float rotation) { float degreesToRad = (rotation * Sce.PlayStation.HighLevel.GameEngine2D.Base.Math.Pi) / 180; sprite.Rotate(degreesToRad); }