コード例 #1
0
ファイル: Game.cs プロジェクト: Keilerr/csat
        public override void Init()
        {
            Settings.TextureDir = "../../data/texture/";
            string AudioDir = "../../data/";

            back      = Texture2D.Load("bg.jpg");
            img[0]    = Texture2D.Load("head.png", true);
            img[1]    = Texture2D.Load("ball.png", true);
            crosshair = Texture2D.Load("cross.png", true);

            font = BitmapFont.Load("fonts/comic12.png");

            BaseGame.Instance.CursorVisible = false; // hide mouse cursor
            //System.Windows.Forms.Cursor.Hide();

            if (player == null)
            {
                player = new OggPlayerFBN();
                player.SetCurrentFile(AudioDir + "music.ogg");
            }
            player.Play();

            snd1 = new AudioClip(AudioDir + "snd2.ogg");
            snd2 = new AudioClip(AudioDir + "snd1.ogg");

            Camera.Set2D();
            base.Init();
        }
コード例 #2
0
        public override void Init()
        {
            Settings.TextureDir = "../../data/texture/";
            string AudioDir = "../../data/";

            back   = Texture2D.Load("bg.jpg");
            img[0] = Texture2D.Load("head.png");
            font   = BitmapFont.Load("fonts/comic12.png");

            Camera.Set2D();
            base.Init();
        }
コード例 #3
0
ファイル: Billboard.cs プロジェクト: Keilerr/csat
        public static Billboard Load(string fileName, bool softParticle)
        {
            if (Particles.SoftParticles == false)
            {
                softParticle = false;
            }

            Billboard bb = new Billboard();

            bb.billBoard            = Texture2D.Load(fileName, true);
            bb.billBoard.Vbo.Shader = GLSLShader.Load("particles.shader" + (softParticle ? ":SOFT" : ""));
            return(bb);
        }
コード例 #4
0
        public override void Init()
        {
            Settings.TextureDir = "../../data/texture/";

            back      = Texture2D.Load("menu.jpg");
            crosshair = Texture2D.Load("cross.png", true);

            font = BitmapFont.Load("fonts/comic12.png");

            BaseGame.Instance.CursorVisible = false; // hide mouse cursor

            Camera.Set2D();
            base.Init();
        }
コード例 #5
0
ファイル: Test2D.cs プロジェクト: Keilerr/csat
        public override void Init()
        {
            // random positions for images
            for (int q = 0; q < 100; q++)
            {
                x[q] = Rnd.Next(600) + 100;
                y[q] = Rnd.Next(300) + 100;
                z[q] = (float)Rnd.NextDouble();
            }

            BaseGame.Instance.CursorVisible = false;

            back = Texture2D.Load("photo.jpg");
            img  = Texture2D.Load("mousecursor.png", true); // center origo (because rotating cursor)
            font = BitmapFont.Load("fonts/comic12.png");

            Camera.Set2D();
            base.Init();
        }
コード例 #6
0
ファイル: ObjData.cs プロジェクト: Keilerr/csat
        void LoadMesh(string fileName)
        {
            string data = null;

            try
            {
                using (System.IO.StreamReader file = new System.IO.StreamReader(Settings.ModelDir + fileName))
                {
                    // tiedosto muistiin
                    data = file.ReadToEnd();
                }
            }
            catch (Exception e)
            {
                Log.Error(e.ToString());
            }

            //
            string[] lines = data.Split('\n');

            int line = 0;

            while (true)
            {
                // new mesh
                if (lines[line].StartsWith("o"))
                {
                    ObjMesh mesh = new ObjMesh();
                    mesh.Name = lines[line].Split(' ')[1];

                    while (true)
                    {
                        if (lines[line + 1].StartsWith("v ") == false)
                        {
                            break;
                        }

                        string[] vert = lines[line + 1].Split(' ');
                        // [-1,1] -> [screenwidth, screenheight]
                        float x = ((MathExt.GetFloat(vert[1]) + 1) * 0.5f) * Settings.Width;
                        float y = MathExt.GetFloat(vert[2]); // not needed
                        float z = Settings.Height - (((MathExt.GetFloat(vert[3]) + 1) * 0.5f) * Settings.Height);
                        mesh.Vertices.Add(new Vector3(x, y, z));
                        line++;
                    }

                    // seuraava mesh
                    if (lines[line + 1].StartsWith("o "))
                    {
                        Meshes.Add(mesh);
                        continue;
                    }

                    while (lines[line + 1].StartsWith("usemtl ") == false)
                    {
                        line++;
                    }


                    string[] mat = lines[line + 1].Split(' ');
                    if (mat[1].StartsWith("_"))
                    {
                        mesh.UseMat = mat[1].Substring(1);
                    }
                    Meshes.Add(mesh);

                    // luo texture jos meshillä on materiaali
                    if (mesh.UseMat != "")
                    {
                        mesh.Tex = Texture2D.Load(Settings.TextureDir + mesh.UseMat);

                        // lev ja kor
                        float w = mesh.Vertices[0].X - mesh.Vertices[1].X;
                        float h = mesh.Vertices[0].Z - mesh.Vertices[2].Z;

                        // tuo on se koko millä se pitää piirtää esim 20x20
                        // mutta jos oikea kuva on 100x100, se pitää skaalata viidesosaks eli 0.2
                        // eli  20/100 = 0.2 eli  w/img.w

                        mesh.ScaleX = w / (float)mesh.Tex.Width;
                        mesh.ScaleY = h / (float)mesh.Tex.Height;
                    }

                    if (mesh.Name.Contains("START"))
                    {
                        SX = mesh.Vertices[0].X;
                        SY = mesh.Vertices[0].Z;
                    }
                }

                line++;
                if (line == lines.Length)
                {
                    break;
                }
            }
        }
コード例 #7
0
 public override void Init()
 {
     back = Texture2D.Load("bg.jpg");
     Camera.Set2D();
     base.Init();
 }