All pastes #897094 Raw Edit

practice code

public text v1 · immutable
·published 2008-02-09 06:02 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;

using FlatRedBall;
using FlatRedBall.Graphics;
using FlatRedBall.Gui;
using FlatRedBall.Input;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.ManagedSpriteGroups;
using FlatRedBall.Math;


namespace JTamaraw
{

    public class GameData
    {
        public SpriteGrid grid;
        public AnimationChain animationChain = new AnimationChain();
        public Sprite wood = SpriteManager.AddSprite("woodblock.bmp", "Global");
        public Sprite path1 = SpriteManager.AddSprite("demi_leafy.bmp", "Global");
        public Sprite path2 = SpriteManager.AddSprite("demi_leafy.bmp", "Global");
        public Sprite path3 = SpriteManager.AddSprite("demi_leafy.bmp", "Global");
        public Sprite bg01 = SpriteManager.AddSprite("hillyxp.bmp", "Global");
        public Sprite JT01;
   
        public void Initialize()
        {
            

            AnimationFrame animationFrame = new AnimationFrame();
            animationFrame.Texture = FlatRedBallServices.Load<Texture2D>("smallJT1.png");
            animationFrame.FrameLength = 1f;
            animationChain.Add(animationFrame);

            AnimationFrame animationFrame1 = new AnimationFrame();
            animationFrame1.Texture = FlatRedBallServices.Load<Texture2D>("smallJT2.png");
            animationFrame1.FrameLength = 1f;
            animationChain.Add(animationFrame1);

            AnimationFrame animationFrame2 = new AnimationFrame();
            animationFrame2.Texture = FlatRedBallServices.Load<Texture2D>("smallJT3.png");
            animationFrame2.FrameLength = 1f;
            animationChain.Add(animationFrame2);

            AnimationFrame animationFrame3 = new AnimationFrame();
            animationFrame3.Texture = FlatRedBallServices.Load<Texture2D>("smallJT4.png");
            animationFrame3.FrameLength = 1f;
            animationChain.Add(animationFrame3);

            Sprite blueprintSprite = new Sprite();
            blueprintSprite.Texture = FlatRedBallServices.Load<Texture2D>("redball.bmp");
            grid = new SpriteGrid(SpriteManager.Camera, 'y', blueprintSprite,null);

            /*
            If using FlatRedBall MDX, use a char instead of the Plane enumeration:
            spriteGrid = new SpriteGrid(SpriteManager.Camera, 'y',
                blueprintSprite);
            */


            grid.XLeftBound = -10;
            grid.XRightBound = 10;
            grid.YTopBound = 10;
            grid.YBottomBound = -10;
            blueprintSprite.Texture = FlatRedBallServices.Load<Texture2D>("redball.bmp");

            Sprite JT01 = SpriteManager.AddSprite(animationChain);

            JT01.Animate = true;
            JT01.X = -5;
            JT01.Y = -.6f;
            JT01.ScaleY = 1.6f;
            JT01.ScaleX = 1.3f;
            JT01.PixelSize = .03f;

            bg01.ScaleY = 14;
            bg01.ScaleX = 25f;
            bg01.Y = 4.3f;
            bg01.Z = 5;

            FlatRedBall.Math.Geometry.AxisAlignedRectangle rectangle = new FlatRedBall.Math.Geometry.AxisAlignedRectangle();
            rectangle.ScaleX = JT01.ScaleX;
            rectangle.ScaleY = JT01.ScaleY;
            JT01.SetCollision(rectangle);

            rectangle = new FlatRedBall.Math.Geometry.AxisAlignedRectangle();
            rectangle.ScaleX = path1.ScaleX;
            rectangle.ScaleY = path1.ScaleY;
            path1.SetCollision(rectangle);

            path1.X = -5;
            path1.Y = -3.4f;

            path2.X = -3;
            path2.Y = -3.4f;

            path3.X = -1;
            path3.Y = -3.4f;

            wood.ScaleX = 1f;
            wood.ScaleY = 1f;
            wood.X = -10;
            wood.Y = -8;

            Button button = GuiManager.AddButton();
            button.ScaleX = 5;
            button.ScaleY = 3;

            button.Y = 70;
            button.X = 95;
            button.Text = "Start";

            button.Click += start;

        }
        public void start(Window callingWindow)
        {
            if (JT01.CollideAgainst(path1))     <<<<<<< // this is where it goes wrong
            {
                JT01.XVelocity = 1;
            }
        }
        public void Update()
        {
      

            if (InputManager.Mouse.ButtonPushed(FlatRedBall.Input.Mouse.MouseButtons.LeftButton))
            {
                // See which Sprite the mouse is over
                Sprite spriteOver = null;

                if (InputManager.Mouse.IsOn3D<Sprite>(wood, false))
                {
                    spriteOver = wood;

                }

                InputManager.Mouse.GrabbedPositionedObject = spriteOver;
            }
            if (InputManager.Mouse.ButtonReleased(FlatRedBall.Input.Mouse.MouseButtons.LeftButton))
            {
                InputManager.Mouse.GrabbedPositionedObject = null;
            }
        }
    }
}