public void Render() { _backgrounds.ForEach(bg => { SwinGame.DrawBitmap(_background, 0, bg); SwinGame.DrawBitmap(_background, SwinGame.BitmapWidth(_background), bg); }); }
// Wrap function helps dog go around the screen public void Wrap() { if (X + 100 < -(SwinGame.BitmapWidth(Bitmap))) { X = SwinGame.ScreenWidth(); } else if (X > SwinGame.ScreenWidth()) { X = -(SwinGame.BitmapWidth(Bitmap)); } }
/// <summary> /// Creates an Entity with an Animation component and adds it to the world. /// This is primarily used for Entities which are just animations so they can be processed /// by the Animation Rendering System. /// </summary> /// <param name="x">The x coordinate the Entity will be created at.</param> /// <param name="y">The y coordinate the Entity will be created at.</param> /// <param name="anim">The name of the animation to be played.</param> /// <param name="img">The Bitmap the animation will operate on.</param> /// <param name="animScript">The animation script containing the animation details.</param> public static void CreateAnimationEntity(float x, float y, Animation anim, Bitmap img, AnimationScript animScript) { //Create Entity and add to world ulong newEntity = _world.NextEntityID; int width = SwinGame.BitmapWidth(img); int height = SwinGame.BitmapHeight(img); //Create components and pass to world to send to Systems List <Component> components = new List <Component>(); components.Add(new CPosition(x, y, width, height)); components.Add(new CAnimation(img, anim, animScript)); _world.AddEntity(newEntity, components); }
/// <summary> /// This wraps the object around the screen. /// </summary> public void WrapObject() { if (XShip < -((SwinGame.BitmapWidth(base.Type)))) { XShip = SwinGame.ScreenWidth(); } else if (XShip > SwinGame.ScreenWidth()) { XShip = -SwinGame.BitmapWidth(base.Type); } if (YShip < (-(SwinGame.BitmapHeight(base.Type)))) { YShip = (SwinGame.ScreenHeight()); } else if (YShip > SwinGame.ScreenHeight()) { YShip = -(SwinGame.BitmapHeight(base.Type)); } }
/// <summary> /// Draw the end of the game screen, shows the win/lose state /// </summary> public static void DrawEndOfGame() { DrawField(ComputerPlayer.PlayerGrid, ComputerPlayer, true); DrawSmallField(HumanPlayer.PlayerGrid, HumanPlayer); if (HumanPlayer.IsDestroyed) { SwinGame.LoadBitmapNamed("loser", "YouLose.png"); Bitmap bmp = SwinGame.BitmapNamed("loser"); float bmpX = (((float)SwinGame.ScreenWidth() / 2) - ((float)SwinGame.BitmapWidth(bmp) / 2)); float bmpY = (((float)SwinGame.ScreenHeight() / 2) - ((float)SwinGame.BitmapHeight(bmp) / 2)); SwinGame.DrawBitmap(bmp, bmpX, bmpY); //SwinGame.DrawTextLines("YOU LOSE!", Color.White, Color.Transparent, GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight()); } else { SwinGame.LoadBitmapNamed("winner", "YouWin.png"); Bitmap bmp = SwinGame.BitmapNamed("winner"); float bmpX = (((float)SwinGame.ScreenWidth() / 2) - ((float)SwinGame.BitmapWidth(bmp) / 2)); float bmpY = (((float)SwinGame.ScreenHeight() / 2) - ((float)SwinGame.BitmapHeight(bmp) / 2)); SwinGame.DrawBitmap(bmp, bmpX, bmpY); //SwinGame.DrawTextLines("-- WINNER --", Color.White, Color.Transparent, GameFont("ArialLarge"), FontAlignment.AlignCenter, 0, 250, SwinGame.ScreenWidth(), SwinGame.ScreenHeight()); } }
public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip) { this.Move(); //このCollisionDetectionをGameObjects List内のすべてのSubmarineに対して行う必要がある。 for (int j = GameObjects.Count - 1; j >= 0; j--) { if (GameObjects[j] is Submarine && this.Disappear == false) { Submarine sub = GameObjects[j] as Submarine; if (this.CollisionDetection(GameObjects[j].PositionX, GameObjects[j].PositionY, SwinGame.BitmapWidth(sub.Image), SwinGame.BitmapHeight(sub.Image))) { sub.Disappear = true; myShip.Hit++; } } } }
public override void Draw() { SwinGame.FillCircle(Color.Blue, (X + (SwinGame.BitmapWidth(Sprite) / 2)), (Y + (SwinGame.BitmapHeight(Sprite) / 2)), Size / 2); SwinGame.DrawBitmap("sprite3", X, Y); //SwinGame.FillCircle(Color.BlueViolet, X, Y, Size/2); }
public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip) { this.Move(); if (_explodeTime == null && this.Disappear == false && this.CollisionDetection(myShip.PositionX, myShip.PositionY, SwinGame.BitmapWidth(myShip.Image), SwinGame.BitmapHeight(myShip.Image))) { myShip.Hp--; } }
public override void WeaponsControll(List <GameObject> GameObjects, Destroyer myShip) { this.Move(); if (myShip.Hp > 0 && this.CollisionDetection(myShip.PositionX, myShip.PositionY, SwinGame.BitmapWidth(myShip.Image), SwinGame.BitmapHeight(myShip.Image))) { myShip.HitEffect(); myShip.Hp = myShip.Hp + 2; myShip.NumOfWeapons = myShip.NumOfWeapons + 2; } }
// BlockData[] BlockArray; public int BlockWidth(BlockData block) { return(SwinGame.BitmapWidth(block.bmp)); }
public int PlayerWidth() { return(SwinGame.BitmapWidth(player.bmp)); }
public int BallWidth(BallData ball) { return(SwinGame.BitmapWidth(ball.bmp)); }