예제 #1
0
        public void Render()
        {
            Blitz3D.Color(255, 255, 255);
            Blitz3D.Text(0, 0, "Options:");
            string fpsCounter     = "FPS: " + _fps;
            int    fpsStringWidth = Blitz3D.StringWidth(fpsCounter);

            Blitz3D.Text(Blitz3D.GraphicsWidth() - fpsStringWidth, 0, fpsCounter);

            Blitz3D.Text(40, 20, "Enable Rotation:");

            if (_enableRotation)
            {
                Blitz3D.Color(0, 255, 0);
                Blitz3D.Text(170, 20, "ON");
            }
            else
            {
                Blitz3D.Color(255, 0, 0);
                Blitz3D.Text(170, 20, "OFF");
            }

            Blitz3D.Color(0, 0, 255);
            Blitz3D.Rect(10, 10, 100, 100);
            Blitz3D.Color(0, 255, 255);
            Blitz3D.Rect(110, 110, 100, 100);
        }
예제 #2
0
        public void Init()
        {
            Blitz3D.Graphics3D(640, 480);
            //Blitz3D.SetTargetFPS(60);
            Blitz3D.AppTitle("Sample App");

            //Blitz3D.ClsColor(255, 0, 0);

            Entity camera = Blitz3D.CreateCamera();

            Blitz3D.PositionEntity(camera, 0, 0, -5);
            //Blitz3D.CameraClsColor(camera, 255, 0, 0);

            Entity light = Blitz3D.CreateLight();

            Blitz3D.PositionEntity(light, 255, 255, 255);

            _cube = Blitz3D.CreateCube();
            Texture basicTexture = Blitz3D.LoadTexture("data/textures/basicTexture.png");

            if (basicTexture != null)
            {
                Blitz3D.EntityTexture(_cube, basicTexture);
            }

            _onSfx  = Blitz3D.LoadSound("data/sfx/on.wav");
            _offSfx = Blitz3D.LoadSound("data/sfx/off.wav");
            Blitz3D.SoundVolume(_onSfx, 0.2f);
            Blitz3D.SoundVolume(_offSfx, 0.2f);
        }
예제 #3
0
        public void Start()
        {
            if (!Blitz3D.InitBlitz())
            {
                Logger.Error("Failed to initialize Blitz!");
                return;
            }

            Init();

            Run();

            Blitz3D.End();
        }
예제 #4
0
        public void Run()
        {
            _running = true;

            _gameFPS     = 60;
            _framePeriod = 1000 / _gameFPS;
            _frameTime   = Blitz3D.MilliSecs() - _framePeriod;

            while (_running)
            {
                int frameElapsed;
                do
                {
                    frameElapsed = Blitz3D.MilliSecs() - _frameTime;
                } while (frameElapsed == 0);

                int   frameTicks = frameElapsed / _framePeriod;
                float frameTween = frameElapsed % _framePeriod / (float)_framePeriod;

                for (int frameLimit = 1; frameLimit <= frameTicks; frameLimit++)
                {
                    if (frameLimit == frameTicks)
                    {
                        Blitz3D.CaptureWorld();
                    }
                    _frameTime += _framePeriod;

                    Update();

                    Blitz3D.UpdateWorld();
                }

                if (Blitz3D.MilliSecs() - _fpsTimer > 1000)
                {
                    _fpsTimer = Blitz3D.MilliSecs();
                    _fps      = _fpsTicks;
                    _fpsTicks = 0;
                }
                else
                {
                    _fpsTicks++;
                }

                Blitz3D.Cls();
                Blitz3D.RenderWorld(frameTween);
                Render();
                Blitz3D.Flip();
            }
        }
예제 #5
0
        public void Update()
        {
            if (Blitz3D.KeyHit(Keys.ESCAPE))
            {
                Stop();
            }

            if (Blitz3D.KeyHit(Keys.ENTER))
            {
                _enableRotation = !_enableRotation;
                Blitz3D.PlaySound(_enableRotation ? _onSfx : _offSfx);
            }

            if (_enableRotation)
            {
                Blitz3D.TurnEntity(_cube, 2.0f, 1.5f, 4.0f);
            }
            else
            {
                Blitz3D.RotateEntity(_cube, 0.0f, 0.0f, 0.0f);
            }
        }
예제 #6
0
 public Sprite(Entity parent = null) : base(Blitz3D.CreateSprite(parent))
 {
 }
예제 #7
0
 public Plane(int segments = 1, Entity parent = null) : this(Blitz3D.CreatePlane(segments, parent))
 {
 }
예제 #8
0
 public void RotateSprite(float angle) => Blitz3D.RotateSprite(this, angle);
예제 #9
0
 public void ScaleSprite(float xScale, float yScale) => Blitz3D.ScaleSprite(this, xScale, yScale);
예제 #10
0
 public void AnimateMD2(int mode, float speed, int firstFrame, int lastFrame, float transition) => Blitz3D.AnimateMD2(this, mode, speed, firstFrame, lastFrame, transition);
예제 #11
0
 public MD2(string file, Entity parent = null) : base(Blitz3D.LoadMD2(file, parent))
 {
 }
예제 #12
0
 public void Color(float red, float green, float blue) => Blitz3D.LightColor(this, red, green, blue);
예제 #13
0
 public Light(Type type = Type.Directional, Entity parent = null) : base(Blitz3D.CreateLight((int)type, parent))
 {
 }
예제 #14
0
 public Pivot(Entity parent) : base(Blitz3D.CreatePivot(parent))
 {
 }