コード例 #1
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.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Movement   m    = new Movement();
            animlinker al1  = new animlinker();
            Animation  test = new Animation();

            test.framenumber = 2;
            test.framesize   = new Vector2(90, 90);
            test.offset      = 0;
            test.row         = 1;
            test.rowamount   = 2;
            test.tex         = Content.Load <Texture2D>("Plankton_Pepe");
            al1.links.Add(Fighter.State.walking, test);

            main = new Fighter();
            ms.add(main);
            main.Components.Add(al1);


            dummy = new Fighter();
            ms.add(dummy);

            Movement fads = (Movement)dummy.getcomponent(typeof(Movement));

            fads.x = -10;
            ds.fighters.Add(dummy);
            ds.fighters.Add(main);
        }
コード例 #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }


            // TODO: Add your update logic here

            ms.update_mo();

            /*
             * if(main.mystate == Fighter.State.punching)
             * {
             *  //insert code to see if other fighter is in range, if they are :
             * var damage_system.damage(other fighter, getpowerforstate(main.mystate));
             *
             * }
             */
            animlinker temp = (animlinker)main.getcomponent(typeof(animlinker));

            if (temp.links[Fighter.State.walking].currentframe < 2)
            {
                temp.links[Fighter.State.walking].currentframe += 1;
            }
            else
            {
                temp.links[Fighter.State.walking].currentframe = 0;
            }

            ds.update();
            base.Update(gameTime);
        }
コード例 #3
0
 public void drawfighter(SpriteBatch sb, Fighter f)
 {
     //turn this into a switch soon
     if (f.mystate == Fighter.State.walking)
     {
         //get the animlinker to find the animation for the current state,
         animlinker al = (animlinker)f.getcomponent(typeof(animlinker));
         //get the movement to get the position of the dudeman
         Movement m = (Movement)f.getcomponent(typeof(Movement));
         //get the animation
         Animation a = al.links[Fighter.State.walking];
         //Draw it baby
         sb.Draw(a.tex, new Rectangle(m.x, m.y, 100, 100), findsourcerect(a), Color.White);
     }
 }