Пример #1
0
        //Initialise game objects and create the level here. Need to more camera create to GameWorld and this function.
        public void loadLevel(Game game)
        {
            //Create static objects
            for (int i = 0; i < level.size; i++)
            {
                for (int j = 0; j < level.size; j++)
                {
                    Vector3 pos = level.centerOfCell(i, j);
                    pos.Y = groundHeight + 1;
                    switch (level.map[i, j])
                    {
                    //Player
                    case 1:
                        createPlayer(game, pos);
                        break;

                    //Enemy
                    case 2:
                        createEnemy(game, pos);
                        break;

                    //Obstacle
                    case 3:
                        createObstacle(game, pos);
                        break;
                    }
                }
            }

            BasicModel floor = createBasicModel("cube", "floor");

            floor.scale      *= Matrix.CreateScale(64, 1, 64);
            floor.translation = Matrix.CreateTranslation(32, -2.5f, 32);

            //Collision events between player and enemy
            physworld.addCollisionEvent(enemy.body.physobj, player.fist.physobj);
            physworld.addCollisionEvent(player.body.physobj, enemy.fist.physobj);
        }