public override void Load() { color_shader = Content.Get <ShaderProgram>("color_shader"); scanlines_shader = Content.Get <ShaderProgram>("scanlines"); current_shader = color_shader; colors_shader_tint_color = color_shader.GetParameter("tint_color"); colors_shader_tint_color.SetValue(Color.White); scanlines_shader_params = scanlines_shader.GetParameter("params"); scanlines_params = new Vector4( 1.0f, // Amount 0.5f, // Intensity 0.0f, // Time 0.0f ); scanlines_shader_params.SetValue(scanlines_params); sprite = new Sprite(Content.Get <Texture2D>("cat")); sprite.SetOrigin(0.5f, 0.5f); sprite2 = new Sprite(Content.Get <Texture2D>("seiken")); sprite.SetOrigin(0.5f, 0.5f); timer = new Timer(); timer.Every(20, UpdateColor); }
private void SpecialPower() { if (_time_passed == 0) { Sprite _blueWave = new Sprite("Data/Sprites/blue_wave.png"); if (_mirrorX) { _blueWave.x = _blueWave.width * (-_specialPowerIndex); _blueWave.SetOrigin(20, 0); } else { _blueWave.x = _blueWave.width * _specialPowerIndex; _blueWave.SetOrigin(-40, 0); } _xRelativePosition = _blueWave.x + this.x; _blueWave.y = 15; _spritesSpecialPower.Add(_blueWave); AddChild(_blueWave); _specialPowerIndex++; } if (Math.Floor((_xRelativePosition) / 800) != Math.Floor(this.x / 800)) { //Delete wave after some time if (_time_passed >= 200) { foreach (Sprite sprite in _spritesSpecialPower) { if (sprite != null) { sprite.Destroy(); } } _specialPowerInUse = false; _specialPowerIndex = 0; _time_passed = 0; } if (_specialPowerInUse) { _time_passed += Time.deltaTime; } } }
public Pause(NeonArkanoidGame game, Level.Level level) { _level = level; _game = game; x = -500; var background = new Sprite(UtilStrings.SpritesPause + "background_pause.png"); background.SetOrigin(0, background.height / 2); background.y = game.height / 2; var header = new Sprite(UtilStrings.SpritesPause + "header_pause.png"); header.SetOrigin(header.width / 2, header.height / 2); header.SetXY(background.width / 2, 200); _buttons = new[] { new Button(UtilStrings.SpritesPause + "button_resume.png", 2, background.width / 2, 350, "Resume"), new Button(UtilStrings.SpritesPause + "button_restart.png", 2, background.width / 2, 450, _level.GetLevelName()), new Button(UtilStrings.SpritesPause + "button_exit.png", 2, background.width / 2, 550, "MainMenu") }; AddChild(background); AddChild(header); foreach (var button in _buttons) { AddChild(button); } _selectedSound = new Sound(UtilStrings.SoundsMenu + "sound_selected.wav"); _openSound = new Sound(UtilStrings.SoundsMenu + "sound_pause.wav"); }
private void SetHeader() { _header = new Sprite(UtilStrings.SpritesOther + "gameover/header_gameover.png"); _header.SetOrigin(_header.width/2, _header.height/2); _header.SetXY(game.width/2, 250); AddChild(_header); }
//------------------------------------------------------------------------ // makeFoodCan //------------------------------------------------------------------------ private void makeFoodCan() { foodCan = new Sprite("fish_food_can.png"); foodCan.SetOrigin(foodCan.width / 4, 0); foodCan.width /= 5; foodCan.height /= 5; }
public Pause(TimeGuardianGame game, LevelBase level) { _level = level; _game = game; x = -500; Sprite background = new Sprite(UtilStrings.SpritesPause + "background_pause.png"); background.SetOrigin(0,background.height/2); background.y = game.height/2; Sprite header = new Sprite(UtilStrings.SpritesPause + "header_pause.png"); header.SetOrigin(header.width/2, header.height/2); header.SetXY(background.width/2, 200); _buttons = new[] { new Button(UtilStrings.SpritesPause + "button_resume.png", 2, background.width/2, 350, "Resume"), new Button(UtilStrings.SpritesPause + "button_restart.png", 2, background.width/2, 450, _level.GetLevelName()), new Button(UtilStrings.SpritesPause + "button_exit.png", 2, background.width/2, 550, "MainMenu") }; AddChild(background); AddChild(header); foreach (Button button in _buttons) { AddChild(button); } _selectedSound = new Sound(UtilStrings.SoundsMenu + "sound_selected.wav"); _openSound = new Sound(UtilStrings.SoundsMenu + "sound_pause.wav"); }
private void SetHeader() { _header = new Sprite(UtilStrings.SpritesOther + "levelbeaten/level_complete.png"); _header.SetOrigin(_header.width / 2, _header.height / 2); _header.SetXY(game.width / 2, 250); AddChild(_header); }
//------------------------------------------------------------------------------------------------------------ // menuSetup //------------------------------------------------------------------------------------------------------------ private void menuSetup() { AddChild(_menuBackGround); AddChild(_menuText); _menuText.SetXY(width - width / 4 - 50, height - height / 4); _menuText.SetOrigin(_menuText.width / 2, _menuText.height / 2); AddChild(_menuIdleBill); }
//------------------------------------------------------------------------ // makeTextSound //------------------------------------------------------------------------ private void makeTextSound() { textSound = new Sprite("sound_icon.png"); textSound.SetOrigin(textSound.width / 2, textSound.height / 2); textSound.SetXY(game.width / 3 * 2 - 130, game.height / 3 * 2); textSound.width /= 3; textSound.height /= 3; }
//------------------------------------------------------------------------ // private void makeHomeIcon() //------------------------------------------------------------------------ private void makeHomeIcon() { home = new Sprite("home_icon.png"); home.SetOrigin(home.width / 2, home.height / 2); home.SetXY(game.width / 13, game.height - 150); home.width /= 3; home.height /= 3; }
//------------------------------------------------------------------------ // makeMusicIcon //------------------------------------------------------------------------ private void makeMusicIcon() { musicIcon = new Sprite("music.png"); musicIcon.SetOrigin(musicIcon.width / 2, musicIcon.height / 2); musicIcon.SetXY(game.width / 3 + 130, game.height / 3); musicIcon.width /= 3; musicIcon.height /= 3; }
//------------------------------------------------------------------------ // makeSoundIcon //------------------------------------------------------------------------ private void makeSoundIcon() { soundIcon = new Sprite("sound.png"); soundIcon.SetOrigin(soundIcon.width / 2, soundIcon.height / 2); soundIcon.SetXY(game.width / 3 + 130, game.height / 3 * 2); soundIcon.width /= 3; soundIcon.height /= 3; }
//------------------------------------------------------------------------ // makeCross1 //------------------------------------------------------------------------ private void makeCross1() { cross1 = new Sprite("cross2.png"); cross1.SetOrigin(cross1.width / 2, cross1.height / 2); cross1.SetXY(game.width / 3 + 130, game.height / 3); cross1.width /= 4; cross1.height /= 4; }
//------------------------------------------------------------------------ // makeTextMusic //------------------------------------------------------------------------ private void makeTextMusic() { textMusic = new Sprite("music_icon.png"); textMusic.SetOrigin(textMusic.width / 2, textMusic.height / 2); textMusic.SetXY(game.width / 3 * 2 - 130, game.height / 3); textMusic.width /= 3; textMusic.height /= 3; }
public void SetSprite(string file, Vector2 pos, Vector2 size) { Sprite s = new Sprite(file, false, false); s.SetOrigin(s.width / 2, s.height / 2); //center origin s.SetScaleXY(size.x, size.y); //set size s.SetXY(pos.x, pos.y); //set position AddChild(s); }
//------------------------------------------------------------------------------------------------------------ // createGameWin //------------------------------------------------------------------------------------------------------------ private void createGameWin() { if (_isEndScreenOn == false) { _timer = new Timer(); _timer.PauseTime(); _timer.SetTime(_level.GetTime()); _timer.SetXY(width / 2 - 25, height - height / 3 - 15); _timer.width += _timer.width / 2; _timer.height += _timer.height / 2; RemoveChild(_level); AddChild(_winGameScreen); AddChild(_endText); _endText.SetXY(width / 2, height - height / 10); _endText.SetOrigin(_endText.width / 2, _endText.height / 2); AddChild(_timer); _isEndScreenOn = true; } }
//------------------------------------------------------------------------ // makeIconsForFish //------------------------------------------------------------------------ private void makeIconsForFish(int i, int j, Fish fish) { Sprite fishIcon = new Sprite(fish.GetFishName() + "-icon.png"); AddChild(fishIcon); fishIcon.SetOrigin(fishIcon.width / 2, fishIcon.height / 2); fishIcon.width /= 8; fishIcon.height /= 8; fishIcon.x = i * game.width / 4; fishIcon.y = j * game.height / 3 - fishIcon.height / 2 + 20; }
public static int finalLevel = 2; //currently final level public Menu() { _instructions = new Sprite("How_to_play.png"); _firstGo = true; //fonts fonts.AddFontFile("Gingerbread_House.ttf"); fonts.AddFontFile("hazel_grace.ttf"); font = new Font(fonts.Families[0], 40); numberFont = new Font(fonts.Families[1], 50); menuPress = new Sound("menu.wav", false, false); _menuBack = new Sound("menuBack.wav", false, false); _hasStarted = false; _hasEnded = false; ////////////////////////// Menu Art ////////////////////////////// _menu = new Sprite("menu_screen.png"); AddChild(_menu); _logo = new Sprite("logo.png"); AddChild(_logo); _logo.SetOrigin(_logo.width / 2f, _logo.height / 2f); //_logo.SetScaleXY(0.5f, 0.5f); _logo.x = (game.width) / 2; _logo.y = 110; ///////////////////////// Buttons /////////////////////////////// _startButton = new Button(); AddChild(_startButton); _startButton.x = 356; _startButton.y = 880; _startButton.SetOrigin(_startButton.width / 2f, _startButton.height / 2f); _exitButton = new Button(); AddChild(_exitButton); _exitButton.x = 915; _exitButton.y = 880; _exitButton.SetOrigin(_exitButton.width / 2f, _exitButton.height / 2f); ///////////////////////// Text /////////////////////////////// _text = new Canvas(1280, 1005); AddChild(_text); _text.graphics.DrawString("Start", font, Brushes.White, 310, 847); _text.graphics.DrawString("Quit", font, Brushes.White, 870, 847); }
public LoopAnimOnce(Sprite sprite, int animFrames, float rotaSpeed, float currentScale, float scaleMultiplier) : base() { this.sprite = sprite; this.animFrames = animFrames; this.rotaSpeed = rotaSpeed; sprite.scale = currentScale; this.scaleMultiplier = scaleMultiplier; x = 200; y = 200; sprite.SetOrigin(sprite.width / 2, sprite.height / 2); AddChild(sprite); }
protected Sprite CreateHand() { Sprite hand = new Sprite("assets\\enemy_sprite\\HitSprite.png"); hand.SetOrigin(32, 32); hand.width = 32; hand.height = 32; AddChild(hand); hand.x = -40; hand.y = -75; hand.visible = false; hand.alpha = .8f; return(hand); }
public FishStand(float givenX, float givenY, float givenRotation) : base(givenX, givenY, "fishShop.png", givenRotation) { _buyMenu = new Sprite("buyScreen.png"); _buyMenu2 = new Sprite("buyScreen2.png"); _exitButton = new Sprite("exitCross.png"); _buyMenu.SetOrigin(_buyMenu.width / 2, _buyMenu.height / 2); _buyMenu.SetXY(game.width - _buyMenu.width + 150, game.height - _buyMenu.height + 150); _buyMenu2.SetOrigin(_buyMenu.width / 2, _buyMenu.height / 2); _buyMenu2.SetXY(game.width - _buyMenu.width + 150, game.height - _buyMenu.height + 150); _exitButton.SetXY(_buyMenu.x + 500, _buyMenu.y - 325); _menuShown = false; scale = 0.85f; _boughtItem = new EasyDraw(1920, 1080); _boughtItem.TextSize(16); _boughtItem.SetColor(0, 0, 0); }
public override void Load() { paste = Pixmap.Create(16, 16, Color.Orange); Blitter.Begin(paste); Blitter.Rect(0, 0, 8, 8, Color.Blue); Blitter.Rect(8, 8, 8, 8, Color.Blue); Blitter.End(); surface = new Sprite(Texture2D.Create(512, 512, Color.White)); surface.SetOrigin(0, 0); surface.SetPosition(Engine.Canvas.Width / 2 - surface.Width / 2, Engine.Canvas.Height / 2 - surface.Height / 2); Input.OnKeyPress += Input_OnKeyPress; }
//------------------------------------------------------------------------------------ // backgroundSetup //------------------------------------------------------------------------------------ private void backgroundSetup() { _backgroundDark = new Sprite("New Background Blurred Arcade Size2 copy.png"); _backgroundDark.SetOrigin(_backgroundDark.width / 2, _backgroundDark.height / 2); _backgroundDark.SetXY(this._width / 2, this._height / 2); AddChild(_backgroundDark); _backgroundLight = new Sprite("New Background Blurred Arcade Size.png"); _backgroundLight.SetOrigin(_backgroundLight.width / 2, _backgroundLight.height / 2); _backgroundLight.SetXY(this._width / 2, this._height / 2); AddChild(_backgroundLight); _backgroundLine = new Sprite("New_Background_Lines_Arcade_Size.png"); _backgroundLine.SetOrigin(_backgroundLine.width / 2, _backgroundLine.height / 2); _backgroundLine.SetXY(this._width / 2, this._height / 2); AddChild(_backgroundLine); }
public Shelf(Vec2 nostart, Vec2 noend, float shelfRotation, string filename) : base(nostart, noend) { end.RotateAroundDegrees(shelfRotation, nostart); //start.RotateAroundDegrees(trampRotation, noend); shelf = new Sprite(filename, false, false); _middle = (start + end) * 0.5f; AddChild(shelf); shelf.SetOrigin(shelf.width / 2, 0); shelf.rotation = shelfRotation; shelf.SetXY(_middle.x, _middle.y); }
/// <summary> /// Sets the position, rotation and scale of a sprite based on the data in a TiledObject, /// and then sets the origin of the sprite. /// </summary> /// <param name="newSprite">The sprite to be changed</param> /// <param name="obj">The Tiled Object with the transform data</param> /// <param name="normalizedOriginX">the new x-origin, normalized (=typically between 0 and 1)</param> /// <param name="normalizedOriginY">the new y-origin, normalized (=typically between 0 and 1)</param> public static void SetPositionRotationScaleOrigin(Sprite newSprite, TiledObject obj, float normalizedOriginX = 0.5f, float normalizedOriginY = 0.5f) { newSprite.scale = 1; // SetOrigin according to Tiled's weird and inconsistent conventions: float originY = obj.ImageID >= 0 ? 1 : 0; newSprite.SetOrigin(0, originY * newSprite.height); // Set transform data using this origin: newSprite.x = obj.X; newSprite.y = obj.Y; newSprite.rotation = obj.Rotation; newSprite.scaleX = obj.Width / newSprite.width; newSprite.scaleY = obj.Height / newSprite.height; // Set the desired origin: ChangeOrigin(newSprite, normalizedOriginX, normalizedOriginY, 0, originY); }
/// <summary> /// Changes the origin of a (possibly scaled and rotated) sprite, without changing the position. /// </summary> /// <param name="spr">The sprite</param> /// <param name="newOriginRelativeX">The new x origin, normalized (typically a value between 0 and 1)</param> /// <param name="newOriginRelativeY">The new y origin, normalized (typically a value between 0 and 1)</param> /// <param name="oldOriginX">The old x origin, normalized (typically a value between 0 and 1; GXP default is 0)</param> /// <param name="oldOriginY">The old y origin, normalized (typically a value between 0 and 1; GXP default is 0)</param> public static void ChangeOrigin(Sprite spr, float newOriginRelativeX = 0.5f, float newOriginRelativeY = 0.5f, float oldOriginX = 0, float oldOriginY = 0) { GameObject parent = spr.parent; spr.parent = null; // unparent, to avoid recursive TransformPoint float imageWidth = spr.width / spr.scaleX; float imageHeight = spr.height / spr.scaleY; Vector2 newCenter = spr.TransformPoint((newOriginRelativeX - oldOriginX) * imageWidth, (newOriginRelativeY - oldOriginY) * imageHeight); //Console.WriteLine("Setting origin. x={0} y={1} w={2} h={3} r={4} tx={5} ty={6}. nO={7},{8}", // spr.x,spr.y,spr.width,spr.height,spr.rotation,newCenter.x,newCenter.y,newOriginRelativeX,newOriginRelativeY); spr.x = newCenter.x; spr.y = newCenter.y; spr.SetOrigin(newOriginRelativeX * imageWidth, newOriginRelativeY * imageHeight); spr.parent = parent; }
public Player(float x, float y, float width, float height, PlayerSelection state = PlayerSelection.PLAYER_ONE) : base("img/objects/player-spritesheet.png", 4, 6, 24) { SetXY(x, y); this.width = (int)width; this.height = (int)height; this.state = state; playerState = PlayerState.IDLE; jumpingPower = -25f; lives = 1; SetPlayerFrame(); hitbox = new Sprite("img/objects/colors.png"); hitbox.alpha = 0f; hitbox.width = this.width / 2; hitbox.SetOrigin(this.width / 2, 0); hitbox.x = this.width / 2; AddChild(hitbox); }
public WinScreen(NeonArkanoidGame game) : base() { _game = game; tm = new TweenManager(); Tween.RegisterAccessor(typeof(Sprite), new SpriteAccessor()); mySprite = new Sprite("../assets/sprite/ui/W1.png"); mySprite.SetOrigin(mySprite.width / 2, mySprite.height / 2); AddChild(mySprite); mySprite2 = new Sprite("../assets/sprite/ui/W2.png"); mySprite2.SetOrigin(0, 0); AddChild(mySprite2); myTimelime.Push(Tween.To(mySprite, SpriteAccessor.XY, 2000).Target(_game.width / 2, _game.height / 2).Ease(TweenEquations.easeInExpo)); myTimelime.Start(tm); myTimelime2.Push(Tween.From(mySprite2, SpriteAccessor.XY, 2000).Target(_game.width, _game.height).Ease(TweenEquations.easeInExpo)); myTimelime2.Start(tm); }
public Ball(int pRadius, Vec2 pPosition, Level level) : base(pRadius * 2 + 1, pRadius * 2 + 1) { _radius = pRadius; position = pPosition; //_speed = pSpeed; _levelinfo = level; _skin = new Sprite("ball.png"); _skin.SetOrigin(_radius, _radius); acceleration = new Vec2(0, 1.5f); UpdateScreenPosition(); SetOrigin(_radius, _radius); velocity.SetXY(0, 0); //Draw (255, 255, 255); oldPosition = new Vec2(0, 0); AddChild(_skin); }
public Magnit(Vec2 noStart, Vec2 noEnd, float magnetRotation, string filename) : base(noStart, noEnd) { end.RotateAroundDegrees(magnetRotation, noStart); //Console.WriteLine(end); //Console.WriteLine(start); magnet = new Sprite(filename, false, false); //lineSegment = new NLineSegment(noStart, noEnd, 0xff00ff00, 3); magnet.SetXY(start.x, start.y); magnet.SetOrigin(magnet.width / 2, magnet.height / 2); //_collisionZone = lineSegment.start - lineSegment.end; AddChild(magnet); magnet.rotation = magnetRotation; //Console.WriteLine(magnet.rotation); }
public Ball(Vec2 vPosition, float width, float height, BallState state = BallState.IDLE) : base("img/objects/ball-spritesheet.png", 4, 2, 8) { position = vPosition; velocity = new Vec2(0, 0); this.width = (int)width; this.height = (int)height; this.state = state; radius = 32; SetFrame(1); SetXY(position.x, position.y); hitbox = new Sprite("img/objects/colors.png"); hitbox.SetOrigin(this.width / 2, this.height / 2); hitbox.x = this.width / 2; hitbox.y = this.height / 2; hitbox.width = this.width / 2; hitbox.height = this.height / 2; hitbox.alpha = 0f; AddChild(hitbox); }
public Tank(int playerIndex, Vector2 position, int team, ControlScheme controlScheme, Rectangle screenBounds) : base("Sprites", position, Map.TileSize, Map.TileSize, true, SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.Middle)) { _playerIndex = playerIndex; _team = team; _screenBounds = screenBounds; _usedControlScheme = controlScheme; if ((int)_usedControlScheme > 2) { _gamePadIndex = (PlayerIndex)_usedControlScheme - 3; } //Cannon SetOrigin(16, 16); cannon = new Sprite("Sprites", position, 26, 16, false, SpriteHelper.GetDefaultDepth(SpriteHelper.SpriteDepth.Middle) + 0.1f); cannon.SetTextureRectangle(new Rectangle(96 + (32 * _team), 64, 26, 16)); cannon.SetOrigin(8f, 8f); cannon.position = position; _spriteOverlays.Add(cannon); //Animation AddAnimationState(new SpriteState("MovingHorizontal", SpriteHelper.GetSpriteRectangleStrip(32, 32, 0, 3 + _team, 3 + _team, 0, 2), _animationSpeed)); _orientation = new Vector2(1, 0); _currentAnimationState = "MovingHorizontal"; SetCurrentAnimationState(_currentAnimationState); InitiateAnimationStates(); //Statbar statsBarPosition = new Vector2(20 + (playerIndex * 290), 24); if (playerIndex > 1) { statsBarPosition.X += 200; } tankSprite = new Sprite("Sprites", (int)statsBarPosition.X, (int)statsBarPosition.Y, new Rectangle(96 + (32 * team), 112, 32, 32), 1); _healthBar = new HealthBar((int)statsBarPosition.X + 42, (int)statsBarPosition.Y, 116, 30, Color.Green, Color.Red, Color.Black); powerupRectangle = new Sprite("Sprites", _healthBar.x + 100 + 32, 21, 1); powerupRectangle.SetTextureRectangle(new Rectangle(0, 176, 36, 36)); }
private void SetHeader() { _header = new Sprite(UtilStrings.SpritesMenu + "header_logo.png"); _header.SetOrigin(_header.width/2, _header.height/2); _header.SetXY(game.width / 2, 120); AddChild(_header); }
public Cursor(int x, int y, string filename) { sprite = new Sprite(filename); sprite.SetOrigin(sprite.width / 2, sprite.height / 2); AddChild(sprite); }