All pastes #194121 Raw Edit

Vic

public text v1 · immutable
·published 2006-10-07 15:44 UTC
rendered paste body
    public class GameData
    {

        // declare variables of class scope here

        Sprite playerBall;
        Joystick joystick;

        Sprite rightWall;
        Sprite leftWall;
        Sprite topWall;
        Sprite bottomWall;

        public void Initialize(GameForm form)
        {
            playerBall = sprMan.AddSprite("redball.bmp");
            joystick = inpMan.joystickArray[0];


            float wallScl = 2;

            rightWall = sprMan.AddUntexturedSprite();
            rightWall.colorOperation = Microsoft.DirectX.Direct3D.TextureOperation.SelectArg2;
            rightWall.tintBlue = 255;
            rightWall.sclX = wallScl;
            rightWall.sclY = 20;
            rightWall.x = camera.XEdgeAt(0) - wallScl;

            topWall = sprMan.AddUntexturedSprite();
            topWall.colorOperation = Microsoft.DirectX.Direct3D.TextureOperation.SelectArg2;
            topWall.tintBlue = 255;
            topWall.sclX = 30;
            topWall.sclY = wallScl;
            topWall.y = camera.YEdgeAt(0) - wallScl;

            leftWall = rightWall.Clone();
            sprMan.AddSprite(leftWall);
            leftWall.x = -camera.XEdgeAt(0) + wallScl;

            bottomWall = topWall.Clone();
            sprMan.AddSprite(bottomWall);
            bottomWall.y = -camera.YEdgeAt(0) + wallScl;



            // uncomment this line and pass the qualified string name of the first
            // Screen class that the game should show upon execution.
            //screenManager.Start("NameSpace.Screens.ScreenClassName");
        }


        public void Activity()
        {
            // this can be left uncommented - won't do anything if there are no active Screens
            screenManager.Activity();
            playerBall.xAcceleration = joystick.x / 100;
            playerBall.yAcceleration = joystick.y / 100;

            // cap the velocity:
            playerBall.xVelocity = Math.Min(10, playerBall.xVelocity);
            playerBall.xVelocity = Math.Max(-10, playerBall.xVelocity);

            playerBall.yVelocity = Math.Min(10, playerBall.yVelocity);
            playerBall.yVelocity = Math.Max(-10, playerBall.yVelocity);


            // perform Collisions here:
            Collisions.circleBounceRect(playerBall, topWall);
            Collisions.circleBounceRect(playerBall, bottomWall);
            Collisions.circleBounceRect(playerBall, leftWall);
            Collisions.circleBounceRect(playerBall, rightWall);

        
        }


        public void AfterFrameActivity()
        {
            // usually, the only code that goes here is text printing with the TextManager

            // if drawing text, uncomment the following line:
            // textMan.BeginDrawing();

        }

    }