Beispiel #1
0
 //if the space clicked is too far away change the destination to something inside the move range
 protected void NormalizeByMove(Ship newShip, Vector2 dest)
 {
     if (ManhattanDist(newShip.getPosition(), dest) <= newShip.getMove())
     {
         newShip.destination = dest;
         return;
     }
     if (newShip.getPosition().X > dest.X)
     {
         dest.X = dest.X + 1;
     }
     else if (newShip.getPosition().X < dest.X)
     {
         dest.X = dest.X - 1;
     }
     else
     {
         if (newShip.getPosition().Y > dest.Y)
         {
             dest.Y = dest.Y + 1;
         }
         else if (newShip.getPosition().Y < dest.Y)
         {
             dest.Y = dest.Y - 1;
         }
     }
     NormalizeByMove(newShip, dest);
     return;
 }
Beispiel #2
0
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     shipPos.X = (2);
     shipPos.Y = (2);
     spriteBatch = new SpriteBatch(GraphicsDevice);
     spacetiled = Content.Load<Texture2D>("space_emptytiled");
     space = Content.Load<Texture2D>("space_empty");
     sun = Content.Load<Texture2D>("star_red");
     ship_tex = Content.Load<Texture2D>("scoutship");
     ship1_tex = Content.Load<Texture2D>("ship1");
     shiplist.Add(ship = new Ship(1,1, shipPos, ship1_tex));
     shiplist.Add(ship2 = new Ship(2,2, new Vector2(4, 4), ship_tex));
     shiplist.Add(ship3 = new Ship(3,1, new Vector2(6, 6), ship1_tex));
     objectboard[4, 4] = ship2;
     objectboard[2, 2] = ship;
     objectboard[6, 6] = ship3;
     angle = 0;
     // TODO: use this.Content to load your game content here
 }