//Environment Constructor public AngryBallsEnvironment() { //Initialize the Buttons playPauseButton = new PlayPauseButton(gameState); builderButton = new BuilderButton(gameState); background = Game1.environmentBackground; border = Game1.borderImage; bigCog = Game1.bigCog; clawOpen = Game1.clawOpen; Input = new InputManager(); map = new Map(); //justClicked = false; toolBox = new ToolBox(); gameState = GameState.run; angryBall = new FarseerBall(ballStartPose); //Physics Bodies for Walls leftWall = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(10), UnitConverter.toSimSpace(2450), 1.0f, leftWallPosition); leftWall.BodyType = BodyType.Static; rightWall = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(10), UnitConverter.toSimSpace(2550), 1.0f, rightWallPosition); rightWall.BodyType = BodyType.Static; ceiling = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(960), UnitConverter.toSimSpace(10), 1.0f, ceilingPosition); ceiling.BodyType = BodyType.Static; floor = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(960), UnitConverter.toSimSpace(10), 1.0f, floorPosition); floor.BodyType = BodyType.Static; }
public void initialize() { if (!initialized) { if (Game1.world == null) { Game1.world = new World(Vector2.UnitY * 9.8f); } else { Game1.world.Clear(); } initialized = true; map.Initialize(gameState, name); //Physics Bodies for Walls leftWall = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(10), UnitConverter.toSimSpace(2450), 1.0f, leftWallPosition); leftWall.BodyType = BodyType.Static; rightWall = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(10), UnitConverter.toSimSpace(2550), 1.0f, rightWallPosition); rightWall.BodyType = BodyType.Static; ceiling = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(960), UnitConverter.toSimSpace(10), 1.0f, ceilingPosition); ceiling.BodyType = BodyType.Static; floor = BodyFactory.CreateRectangle(Game1.world, UnitConverter.toSimSpace(960), UnitConverter.toSimSpace(10), 1.0f, floorPosition); floor.BodyType = BodyType.Static; angryBall = new FarseerBall(ballStartPose); clawopenPosition = clawStartPosition; messageTimer1 = 5; initializeTimer = 1; } initializeTimer -= 0.025f; if(initializeTimer <= 0) { gameState = GameState.pause; initialized = false; } }