public Platform(ProjectGame game) { // Avoid null reference, it changes on the first update if (standing_platform == null) { standing_platform = this; next_standing_platform = this; } // Less tiles if the difficulty is higher min_extra_tiles = (int)(max_extra_tiles - game.difficulty); type = GameObjectType.Platform; //Load textures textureName = "Platform_Textures"; texture = game.Content.Load<Texture2D>(textureName); // Store information of the platform and create information for the next one platform = next_platform; next_platform = create_platform(platform); // Create the vertices based on the platform information VertexPositionNormalTexture[] platform_vertices = create_vertices(platform, last_platform, next_platform); last_platform = platform; // Set the platform Z position of the intance and uptade the new Z position for the next one z_position_start = z_position; z_position -= tile_depth; z_position_end = z_position; // Calculates midpoint and base platfom_midpoint = (platform.GetLength(0) * tile_width) - tile_width/2; platform_base = Levels[0] - base_offset; //Load effects effect = game.Content.Load<Effect>("Phong"); lightManager = new LightManager(game); lightManager.SetLighting(effect); // Pass the vertices data vertices = Buffer.Vertex.New(game.GraphicsDevice, platform_vertices); inputLayout = VertexInputLayout.FromBuffer(0, vertices); this.game = game; }
void SetGameObjects() { // Initialise game object containers. gameObjects = new List<GameObject>(); addedGameObjects = new Stack<GameObject>(); removedGameObjects = new Stack<GameObject>(); lightManager = new LightManager(this); // Create the first platform and get the height Platform first_platform = new Platform(this); int level = first_platform.platform[2, 0]; init_pos = new Vector3(first_platform.platfom_midpoint, first_platform.Levels[level], 0); //Number of platforms to render on screen at any time gameObjects.Add(first_platform); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); gameObjects.Add(new Platform(this)); // Create the player player = new Player(this, init_pos); gameObjects.Add(player); // Create game objects. gameObjects.Add(new EnemyController(this)); spriteBatch = ToDisposeContent(new SpriteBatch(GraphicsDevice)); }