Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ticks = Ticks + gameTime.ElapsedGameTime.TotalMilliseconds;
- if (Ticks > 50)
- {
- for (int Count = 0; Count < 11; Count++)
- {
- if (Invaders[Count].GetXPos() < 96)
- {
- Invaders[Count].setXPos(96);
- Invaders[Count].setYPos(150);
- }
- else if (Invaders[Count].GetXPos() > 924)
- {
- Invaders[Count].setXPos(924);
- Invaders[Count].setYPos(150);
- }
- if (Invaders[Count].GetYPos()%150 == 0)
- {
- Invaders[Count].MoveHorizontal(2);
- alienDirection *= -1;
- }
- else
- {
- Invaders[Count].MoveHorizontal(alienSpeed * alienDirection);
- }
- // Invaders[Count].MoveHorizontal(alienSpeed * alienDirection);
- }
- Ticks = 0;
- }
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Microsoft.Xna.Framework;
- using Microsoft.Xna.Framework.Audio;
- using Microsoft.Xna.Framework.Content;
- using Microsoft.Xna.Framework.GamerServices;
- using Microsoft.Xna.Framework.Graphics;
- using Microsoft.Xna.Framework.Input;
- using Microsoft.Xna.Framework.Media;
- namespace SpaceInvader
- {
- class Invader
- {
- Vector2 alienPos;
- public Invader()
- {
- alienPos = new Vector2();
- alienPos.X = 0;
- alienPos.Y = 0;
- }
- public void MoveHorizontal(int amount)
- {
- alienPos.X = alienPos.X + amount;
- }
- public void MoveVertical(int amount)
- {
- alienPos.Y = alienPos.Y + amount;
- }
- public void setXPos(int pos)
- {
- alienPos.X = pos;
- }
- public int GetXPos()
- {
- return (int)alienPos.X;
- }
- public void setYPos(int pos)
- {
- alienPos.Y = pos;
- }
- public int GetYPos()
- {
- return (int)alienPos.Y;
- }
- public Vector2 GetPos()
- {
- return alienPos;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement