using System; using FRB; using FRB.GUI; using FRB.Text; using FRB.Particle; using FRB.Collections; using FRB.MSG; using FRB.Audio; using Math2D; using Microsoft.DirectX.DirectInput; using Microsoft.DirectX; namespace GameName { public class GameData { #region reference to engine managers and data public GameForm form; public GuiData guiData; public InputManager inpMan; public SpriteManager sprMan; public TextManager textMan; public GuiManager guiMan; public Camera camera; public Cursor cursor; public Random random; #endregion // declare variables of class scope here Sprite MyBall; Sprite myGround; public void Initialize(GameForm form) { #region initialize engine managers and data this.form = form; guiData = new GuiData(); sprMan = GameForm.sprMan; inpMan = GameForm.inpMan; textMan = GameForm.textMan; guiMan = GameForm.guiMan; camera = GameForm.camera; cursor = GameForm.cursor; random = GameForm.random; #endregion MyBall = sprMan.AddSprite("redball.bmp"); myGround = sprMan.AddSprite("redball.bmp"); myGround.y = -10; myGround.sclX = 10; myGround.rotZ = -.1f; } float ElasticCollisionCoefficient = 0.6f; Vector3 mVector1 = new Vector3(); Vector3 mVector2 = new Vector3(); Vector3 mVector3 = new Vector3(); public void Activity() { MyBall.yAcceleration = -9.8f; mVector1.X = myGround.rotationMatrix.M21; mVector1.Y = myGround.rotationMatrix.M22; mVector1.Z = myGround.rotationMatrix.M23; mVector2 = MyBall.velocity; if (Collisions.rectCollisionAllowanceRotation(MyBall, myGround)) { mVector1.Normalize(); mVector3 = mVector2 - 2 * mVector1 * (Vector3.Dot(mVector1, mVector2)); mVector3 = mVector3 * ElasticCollisionCoefficient; MyBall.xVelocity = mVector3.X; MyBall.yVelocity = mVector3.Y; MyBall.zVelocity = mVector3.Z; } } 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(); } } }