Ejemplo n.º 1
0
 protected Entity(Mesh mesh, float angle, Vector2 position, Vector2 size, float moveSpeed)
 {
     this.mesh = mesh;
     this.angle = angle;
     this.position = position;
     prevPos = position;
     this.size = size;
     this.moveSpeed = moveSpeed;
     UpdateModelMatrix();
 }
Ejemplo n.º 2
0
        public Player()
            : base(new Mesh(64, 64, Resources.Textures["Miner.png"]), 0, new Vector2(2000, 1500), new Vector2(64, 64), 256)
        {
            drawShadow = true;

            const int lightVerticesCount = 16;
            const float lightFoV = MathHelper.PiOver2;
            const float lightRadius = 400;

            List<float> lightVertList = new List<float>();
            lightVertList.Add(0);
            lightVertList.Add(0); //starts at the origin of player space.

            for (int i = 0; i < lightVerticesCount; i++)
            {
                float angle = (lightFoV * (float)i / ((float)lightVerticesCount - 1)) - (lightFoV * 0.5f) + MathHelper.PiOver2;
                lightVertList.Add((float)Math.Cos(angle) * lightRadius);
                lightVertList.Add((float)Math.Sin(angle) * lightRadius);
            }

            lightVertices = lightVertList.ToArray();

            animTime = 0.2f;

            animTextures = new Texture[]
            {
                Resources.Textures["Miner_walk1.png"],
                Resources.Textures["Miner_walk2.png"]
            };

            shadow = new Mesh(1024, 768, Resources.Textures["shadow.png"]);

            health = 5;

            walkSource = new Source();
            //walkSource.Position = new Vector3(position);
            walkSource.Relative = true;
            walkSource.Looping = true;
            walkSource.Buffer = Resources.Audio["walk.wav"];
        }
Ejemplo n.º 3
0
        public void OnLoad(EventArgs e)
        {
            camera = new Camera();
            camera.LoadProjection();
            entities = new List<Entity>();

            player = new Player();
            map = new LevelMap(new Texture("Resources/Levels/" + level + ".png"), new Texture("Resources/Levels/" + level + "_col.png"));

            helpFont = new QFont("Resources/Fonts/anarchysans.ttf", 22);
            helpFont.Options.Colour = Color4.DarkRed;

            using (StreamReader reader = new StreamReader("Resources/Levels/" + level + ".txt"))
            {
                while (!reader.EndOfStream)
                {
                    string line = reader.ReadLine();
                    string[] values = line.Split(' ');
                    Vector2 pos = new Vector2(int.Parse(values[1]), int.Parse(values[2]));

                    switch (values[0])
                    {
                        case "Spawn":
                            player.Position = pos;
                            player.Position = pos;
                            break;
                        case "Generator":
                            generator = new Generator(pos);
                            entities.Add(generator);
                            break;
                        case "Lift":
                            lift = new Lift(pos);
                            entities.Add(lift);
                            break;
                        case "Pickaxe":
                            entities.Add(new Pickaxe(pos, 0, true));
                            break;
                        case "PickaxeB":
                            entities.Add(new Pickaxe(pos, 0, false));
                            break;
                        case "Skeleton":
                            entities.Add(new Skeleton(0, pos));
                            break;
                        case "Goblin":
                            entities.Add(new Goblin(pos));
                            break;
                        case "GameEnd":
                            entities.Add(new Endgame(pos));
                            break;
                    }
                }
            }

            fadeIn = new Mesh(1024, 768, Texture.Zero);
            fadePercent = 1f;
            fadingIn = true;

            GL.Enable(EnableCap.Blend);
            GL.Enable(EnableCap.Texture2D);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        }