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); }
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); }
public void Start() { if (!Blitz3D.InitBlitz()) { Logger.Error("Failed to initialize Blitz!"); return; } Init(); Run(); Blitz3D.End(); }
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(); } }
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); } }
public Sprite(Entity parent = null) : base(Blitz3D.CreateSprite(parent)) { }
public Plane(int segments = 1, Entity parent = null) : this(Blitz3D.CreatePlane(segments, parent)) { }
public void RotateSprite(float angle) => Blitz3D.RotateSprite(this, angle);
public void ScaleSprite(float xScale, float yScale) => Blitz3D.ScaleSprite(this, xScale, yScale);
public void AnimateMD2(int mode, float speed, int firstFrame, int lastFrame, float transition) => Blitz3D.AnimateMD2(this, mode, speed, firstFrame, lastFrame, transition);
public MD2(string file, Entity parent = null) : base(Blitz3D.LoadMD2(file, parent)) { }
public void Color(float red, float green, float blue) => Blitz3D.LightColor(this, red, green, blue);
public Light(Type type = Type.Directional, Entity parent = null) : base(Blitz3D.CreateLight((int)type, parent)) { }
public Pivot(Entity parent) : base(Blitz3D.CreatePivot(parent)) { }