コード例 #1
0
ファイル: Ball.cs プロジェクト: japotter4/Project-Games
        //We will need references to the paddles for collision detection, and
        //our Game1 contains these references, our ball should have the
        //reference to the Game1
        public Ball(Game1 g, String texture)
        {
            //set the game1 object
            game1 = g;

            //set the texture of the ball
            this.texture = game1.Content.Load<Texture2D>(texture);

            //we use a random object when randomly setting the balls direction
            rand = new Random();

            //Init
            fireTokenManager = new FireTokenManager(g);

            //the ball should start near at the center of the screen
            //use a size of 20x20
            ball = new Rectangle(
                game1.GraphicsDevice.Viewport.Bounds.Width / 2 - ball.Width / 2,
                game1.GraphicsDevice.Viewport.Bounds.Height / 2 - ball.Height / 2,
                15,
                15);

            reset();

            //font = game1.Content.Load<SpriteFont>(@"ScoreFont");
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: japotter4/Project-Games
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
コード例 #3
0
        public FireTokenManager(Game1 game)
        {
            this.game = game;
            rand = new Random();

            fireTokens = new List<FireToken>();
        }
コード例 #4
0
ファイル: Cursor.cs プロジェクト: japotter4/Project-Games
        public Cursor(Game1 game, MouseState ms, String image)
        {
            posX = ms.X;
            posY = ms.Y;

            this.image = game.Content.Load<Texture2D>(image);
        }
コード例 #5
0
ファイル: FireToken.cs プロジェクト: japotter4/Project-Games
        public FireToken(Game1 game, String image, int x, int y, bool isUp)
        {
            this.image = game.Content.Load<Texture2D>(image);
            position = new Rectangle(x, y, 20, 20);

            if (isUp)
            {
                velocity = -1 * speed;
            }
            else
            {
                velocity = speed;
            }
        }
コード例 #6
0
        public FireBall(Game1 game, String image, paddle Paddle, int MouseX, int MouseY)
        {
            //Get the image
            this.image = game.Content.Load<Texture2D>(image);

            this.MouseX = MouseX - this.image.Bounds.Width / 2;
            this.MouseY = MouseY - this.image.Bounds.Height / 2;
            curX = Paddle.bounds.X + Paddle.bounds.Width / 2 - this.image.Bounds.Width / 2;
            curY = Paddle.bounds.Y - this.image.Bounds.Height / 2;

            //calc current triangle width
            triangleWidth = MouseX - curX;
            //calc current triangle height
            triangleHeight = curY - MouseY;
            //calc current hypotenmoose
            triangleHyp = (int)Math.Sqrt(triangleWidth * triangleWidth + triangleHeight * triangleHeight);

            Update();
        }
コード例 #7
0
ファイル: Paddle.cs プロジェクト: japotter4/Project-Games
        //update is called every frame
        public void Update(Game1 game)
        {
            //get the most recent snapshot of the keyboard.
            //a KeyboardState object is basically a collection of states for each of
            //the keys. a key's state is either up or down
            KeyboardState keyboardState = Keyboard.GetState();

            //check if the paddles upKey is being pressed
            //move the paddle up as long as the paddle stays on screen
            if (keyboardState.IsKeyDown(leftKey) && bounds.X > 0)
            {
                bounds.X -= 5;
            }

            //check if the paddles upKey is being pressed
            //move the paddle down as long as the paddle stays on screen
            if (keyboardState.IsKeyDown(rightKey) && bounds.X + bounds.Width < game.GraphicsDevice.Viewport.Bounds.Width)
            {
                bounds.X += 5;
            }
        }
コード例 #8
0
 public void Fire(Game1 game, String image, paddle p)
 {
     //if (numOfBalls >= 0)
     //{
         fireballs.Add(new FireBall(game, image, p, ms.X, ms.Y));
         //numOfBalls--;
     //}
 }
コード例 #9
0
        public FireBallBar(Game1 game, String image, Rectangle position, MouseState ms)
        {
            this.image = game.Content.Load<Texture2D>(image);
            imageSrc = new Rectangle(0, 0, imageWidth, imageHeight);
            this.position = position;
            this.ms = ms;

            fireballs = new List<FireBall>();
        }