//Gets info from game and menu items. //public MainMenu(SpriteFont spriteFont, string[] menuItems) public MainMenu(SpriteFont spriteFont) { this.spriteFont = spriteFont; //this.menuItems = menuItems; Input.Initialize(); fontColor = Color.White; //MeasureMenu(); LoadContent(); logo = new Sprite("logo"); logo.Scale = 0.4f; logo.Position = new Vector2(Stuff.Resolution.X * 0.675f, Stuff.Resolution.Y * 0.3f); buttons = new List<Button>(); //start game Button b = new Button("Buttons", new Vector2(150, 50), new Rectangle(0, 120 * 2, 250, 120), false, false); buttons.Add(b); //high scores b = new Button("Buttons", new Vector2(150, 170), new Rectangle(0, 120 * 4, 250, 120), false, false); buttons.Add(b); //settings b = new Button("Buttons", new Vector2(150, 290), new Rectangle(0, 120 * 5, 250, 120), false, false); buttons.Add(b); //exit game b = new Button("Buttons", new Vector2(150, 410), new Rectangle(0, 120 * 7, 250, 120), false, false); buttons.Add(b); menuEgg = new MenuEgg(); }
public Slot_old(Game game) : base(game) { img = new Sprite(game, GraphicsCollection.GetPack("steag")); img.StackOrder = 6; AddChild(img); }
public void AttachAnimation(Sprite sprite, Animation animation, params ActiveAnimationSetUpdater[] animationUpdaters) { animation.Initialize(this, sprite); foreach (var animationUpdater in animationUpdaters) { animationUpdater.Add(animation); } Animation activeAnimation = sprite.ActiveAnimation; if (activeAnimation == null) { sprite.ActiveAnimation = animation; this.animations.Add(animation); } else { while (activeAnimation.NextAnimation != null) { activeAnimation = activeAnimation.NextAnimation; if (activeAnimation == animation) throw new ArgumentException("Same animation attached more than once"); } activeAnimation.NextAnimation = animation; } }
public Reticle(Texture2D tex, SpriteBatch sb, Vector2 pos) { this._sprite = new Sprite(tex, sb, pos); this._mouseState = Mouse.GetState(); this._position.X = this._mouseState.Position.X; this._position.Y = this._mouseState.Position.Y; }
/// <summary> /// Instantiates the cursor. /// Sets the cursor's layer. /// Offsets the cursor to be centered on it's position. /// </summary> private void CreateCursor() { _cursor = new Sprite(Content.Load<Texture2D>("cursor"), Vector2.Zero); _cursor.Layer = 1.0f; _cursor.SetOffset(Anchor.Center); Drawables.Add(_cursor); }
public override void Draw(GameTime gameTime) { //TODO: Handle rotation?? //TODO: Keep only one sprite and change it, do not recreate one Sprite s = new Sprite(Texture, RectangleToRender, Color, Layer) { Rotation = GameObject.Transform.Rotation, Color = Color, Origin = Origin, Scale = GameObject.Transform.Scale }; Engine.SpriteRenderer.Draw(s); //if (Texture != null) //spriteBatch.Draw( // Texture, // RectangleToRender, // null, // Color, // 0, // //new Vector2((float)RectangleToRender.Width / 2, (float)RectangleToRender.Height / 2),//TODO: Why is the Origin acting so weird? // Vector2.Zero, // SpriteEffects.None, // 0); }
public MainScene(ContentManager content, GraphicsDeviceManager graphicsManager) { Stuff.Initialize(content, graphicsManager); graphics = graphicsManager; onScreenMessages = new OnScreenMessages(); Camera2d.Position = Stuff.ScreenCenter; input = new Input(); characters = new List<Character>(); player = new Player(characters); debugTiles = new List<Sprite>(); for (int i = -10; i < 30; i++) { Sprite s = new Sprite("SpriteSheet"); s.Source = new Rectangle(1 * 150, 9 * 150, 150, 150); s.Position = new Vector2(i * 150, 400); debugTiles.Add(s); } for (int i = 0; i < 100; i++) { Sprite tempSprite = new Sprite("SpriteSheet"); tempSprite.Source = new Rectangle(11 * 150, 9 * 150, 150, 150); tempSprite.Position = new Vector2(150*i, 250 + (-150*i)); debugTiles.Add(tempSprite); } }
public GraphBar(Game game, int percent) : base(game) { visual = new Sprite(game, GraphicsCollection.GetPack("pixel")); Percent = percent; AddChild(visual); }
/// <summary> /// Creates a new Moveable tile. /// </summary> /// <param name="sprite">Sprite representing texture, size, and position of the tile. </param> /// <param name="collision">Type of collision for the tile.</param> /// <param name="velocity">Tile velocity: .X is the movement angle in radians and .Y is the speed in pixels per second.</param> public MoveableTile(Sprite sprite, TileCollision collision, Vector2 velocity) : base(sprite, collision) { this.velocity = velocity; Leader = this; // By default, tiles lead themselves }
/// <summary> /// Creates the CombatTextureHolder's arrays, and all the members in them. /// </summary> /// <param name="manager">Main game class's Content Loader.</param> protected CombatTextureHolder(GraphicsDevice graphics) { int numAbilities = ConstantHolder.textureLoader.getTexturesByType((int)TextureTypes.Ability).Count; int numAbilityEffects = ConstantHolder.textureLoader.getTexturesByType((int)TextureTypes.AbilityEffect).Count; abilityButtonSprites = new Sprite[numAbilities]; abilityAnimationSprites = new Sprite[numAbilities]; abilityEffectSprites = new Sprite[numAbilityEffects]; abilityImpactSprites = new Sprite[numAbilities]; effectIconSprites = new Sprite[numAbilityEffects]; int abilityIndex = 0; foreach (TextureXML tex in ConstantHolder.textureLoader.textureCategories[(int)TextureTypes.Ability]) { ConstantHolder.AbilityButtonDict.Add(tex.fileName, abilityIndex); //For abilities, portrait = impact loadAbilityAnimation(graphics, abilityIndex++, tex.fileName, tex.mainSize.vec, tex.ColumnHeights, tex.portraitName, tex.portraitSize.vec, tex.PortraitColumnHeights, tex.buttonName, tex.buttonSize.vec, tex.ButtonColumnHeights); } int effectIndex = 0; foreach (TextureXML tex in ConstantHolder.textureLoader.textureCategories[(int)TextureTypes.AbilityEffect]) { ConstantHolder.AbilityEffectSpriteDict.Add(tex.fileName, effectIndex); loadEffect(graphics, effectIndex++, tex.fileName, tex.mainSize.vec, tex.ColumnHeights, tex.iconName, tex.iconSize.vec, tex.IconColumnHeights); } }
//check for colisions public void Update(List<Sprite> collisionArray) { for (int x = 0; x < collisionArray.Count; ++x) { //where the sprite collisions happened Collided_Bottom = null; Collided_Top = null; Collided_Left = null; Collided_Right = null; for (int y = 0; y < collisionArray.Count; ++y) { //check if it contains the bottom center //If bottom left overlaps check if it is more bottom or more left if (x !=y && collisionArray[x].HitBox.Intersects(collisionArray[y].HitBox)) { //CollisionArray returns 0 when the objects should collide normally, 1 if it should ignore collisions //Check if the mid points of figure y touch figure x if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width / 2), (int)(collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height)) && collisionArray[y].HitBox.Y > collisionArray[x].HitBox.Y) Collided_Bottom = collisionArray[y]; if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width / 2), (int)(collisionArray[x].HitBox.Y)) && collisionArray[x].HitBox.Y > collisionArray[y].HitBox.Y) Collided_Top = collisionArray[y]; if (collisionArray[y].HitBox.Contains((int)(collisionArray[x].HitBox.X), (int)(collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height / 2)) && collisionArray[y].HitBox.X < collisionArray[x].HitBox.X) Collided_Left = collisionArray[y]; if (collisionArray[y].HitBox.Contains((int)collisionArray[x].HitBox.X + collisionArray[x].HitBox.Width, (int)collisionArray[x].HitBox.Y + collisionArray[x].HitBox.Height / 2) && collisionArray[x].HitBox.X < collisionArray[y].HitBox.X) Collided_Right = collisionArray[y]; //Adjusts the location of the collisionArray so that they are no longer colliding and changes their velocity AdjustPosition(collisionArray, x); } } } }
public Mask(Sprite spriteMask, Sprite spriteTarget) { _spriteMask = spriteMask; _spriteTarget = spriteTarget; Render.Viewport.ResolutionChanged += Setup; Setup(); _maskStencilState = new DepthStencilState { StencilEnable = true, StencilFunction = CompareFunction.Always, StencilPass = StencilOperation.Replace, ReferenceStencil = 1, DepthBufferEnable = false, }; _targetStencilState = new DepthStencilState { StencilEnable = true, StencilFunction = CompareFunction.LessEqual, StencilPass = StencilOperation.Replace, ReferenceStencil = 1, DepthBufferEnable = false, }; Add(new DrawComponent(Draw)); }
public Actor(Vector2 position, Vector2 size, Sprite sprite) { Position = position; Size = size; Sprite = sprite; facingLeft = false; }
//private BrainMapMarker currentMapMarker = null; public BrainMapManager(SpriteBatch spriteBatch, Soul game, AudioManager audioManager, InputManager controls, Vector2 position) { this.audioManager = audioManager; bg = new Sprite(spriteBatch, game, Constants.BRAIN_MAP_BG); mapList = new List<BrainMapMarker>(); List<BrainMapMarker> tmpList = new List<BrainMapMarker>(); /*mapList.Add(tmpList); tmpList = new List<BrainMapMarker>(); mapList.Add(tmpList); tmpList = new List<BrainMapMarker>(); mapList.Add(tmpList);*/ menuManager = new MenuManager(controls); ImageButton button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f - 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200), Constants.GUI_CLEANSE, "cleanse"); button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress); menuManager.AddButton(button); button = new ImageButton(spriteBatch, game, controls, new Vector2((float)Constants.RESOLUTION_VIRTUAL_WIDTH * 0.5f + 150, (float)Constants.RESOLUTION_VIRTUAL_HEIGHT * 0.5f + 200), Constants.GUI_BACK, "back"); button.onClick += new ImageButton.ButtonEventHandler(OnButtonPress); menuManager.AddButton(button); menuManager.initialize(); fadeinOut = new FadeInOut(spriteBatch, game, 100); this.position = position; offset = new Vector2((float)bg.X * 0.5f, (float)bg.Y *0.5f); this.controls = controls; }
public Goomba(Vector2 initialPosition) : base(initialPosition) { death = new Sprite(Textures.GetTexture(Textures.Texture.goomba), new Rectangle(16, 0 + (16 * World.WorldType), 16, 16)); goomba = new Sprite(Textures.GetTexture(Textures.Texture.goomba), new Rectangle(0, 0 + (16 * World.WorldType), 16, 16)); velocity.X = -walkingSpeed; }
public override void Draw(GameTime gameTime) { //TODO: Keep only one sprite and change it, do not recreate one Sprite s = new Sprite(Texture, new Vector2(_paralaxPosition.X, Transform.Position.Y), Color, Layer) { DrawnPortion = DrawnPortion, Rotation = GameObject.Transform.Rotation, Color = Color, Origin = Origin, Scale = GameObject.Transform.Scale, Layer = Layer }; Engine.SpriteRenderer.Draw(s); //spriteBatch.Draw( // Texture, // new Vector2(_paralaxPosition.X, Transform.Position.Y), // DrawnPortion, // Color, // GameObject.Transform.Rotation, // Origin, // GameObject.Transform.Scale, // SpriteEffects, // Engine.SpriteManager.GetZIndex(this)); }
public void Add(Sprite s) { s.myMapPosition = myMapPosition; s.myPosition = myPosition; s.myScale = myScale; mySprites.Add(s); }
/// <summary> /// Constructs a new tile. /// </summary> public Tile(Sprite sprite, TileCollision collision) { if (sprite != null) Sprite = sprite; else Sprite = new Sprite(); Collision = collision; }
public Entity(Vector2 position, Vector2 velocity, Texture2D texture) { sprite = new Sprite(texture); Velocity = velocity; this.position = position; CombatState = new CombatStats(); Status = new Alive(); }
public Particle(Sprite animation, float timeTillDeath, Vector2 startPosition, float angle) { this.animation = animation; this.timeTillDeath = timeTillDeath; this.animation.setPosX((int)startPosition.X); this.animation.setPosY((int)startPosition.Y); this.angle = angle; }
/// <summary> /// Prepares the selection icon to draw. /// </summary> public static void Initialize() { sprite = new Sprite(ContentStorageManager.Get<Texture2D>("SelectionDisc")); sprite.Origin = (sprite.GetTextureSize() / 2); sprite.Scale = 1f; sprite.Color = Color.White; ClearSelection(); }
public OctorokBullet(Sprite sprite, Collision collision, BaseObject player, Direction direction) { _sprite = sprite; _player = player; _direction = direction; _speed = 1.5f; _collision = collision; }
public Carrot(Texture2D texture, Vector2 position) { sprite = new Sprite<byte>(texture, Vector2.Zero, new Rectangle(0, 0, 36, 36)); configureSprite(); Position = position; }
/// <summary> /// Constructor defaulting to inactive ladder /// </summary> /// <param name="sprite"></param> /// <param name="collision"></param> public LadderTile(Sprite sprite, TileCollision collision) : base(sprite, collision) { activated = sprite.Texture; deactivated = null; isActive = false; this.Sprite = sprite; }
public Wall(Vector2 Position, int Width, int Height) { rect = new Rect(Width, Height, false); rect.Position = Position; rect.IgnoreGravity = true; image = new Sprite(Position); image.Texture = new Texture2D(XNAGame.I.GraphicsDevice, Width, Height); image.Fill(Color.LimeGreen); }
public override void evento_ColisionHorizontalSprite(Sprite objSprite) { if (objSprite is PersonajePrincipal) { TileMap.GetInstance.posSpriteScrollingTileX = 9; TileMap.GetInstance.posSpriteScrollingTileY = 10; TileMap.GetInstance.regenerarMapa(); } }
public override void Update(GameTime gameTime) { if (_Background == null) { _Background = new Sprite(); _Background.AttachTexture(Resources.Instance.Background_Black); _Background._Size = Game1.ScreenSize; _Background._Position = Game1.ScreenSize * 0.5f; } }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; /*Initialize Dictionaries*/ //Sprites spriteDict["player"] = new Sprite("Attack.Block", 1, new Vector2(25, floor)); spriteDict["enemy"] = new Sprite("enemy-attack-block", 0, new Vector2(200, floor)); }
public PauseMenu() { btnBack = new Button("Buttons", new Vector2(200, 400), new Rectangle(0, 120 * 7, 250, 120), false, false); btnResume = new Button("Buttons", new Vector2(600, 400), new Rectangle(0, 120 * 3, 250, 120), false, false); transparentBackground = new Sprite("pixel"); transparentBackground.Source = new Rectangle(0, 0, Stuff.Resolution.X, Stuff.Resolution.Y); transparentBackground.iColor.SetColor(0, 0, 0, 100); transparentBackground.Origin = Vector2.Zero; LoadContent(); }
public Line(Vector2 position, int width, Color color) { Rectangle dimensions = new Rectangle(0, 0, width, defaultLineHeight); LineSprite = new Sprite<byte>(TextureManager.SingleWhitePixel, position, dimensions); LineSprite.Color = color; LineSprite.AddAnimationFrame(0, dimensions); LineSprite.ActiveAnimation = 0; }