Saturday, May 28, 2011

Example

Example of how things are shaping up.
using System;
using BadKid;
using BadKid.Engine;
using Core;
using Core.Math;
using Core.Utilities;
namespace Example{
     public class Test : GameEngine{
             private PrimitiveBatch _primitivebatch;
             private SpriteBatch _spritebatch;
             private Surface _surface;
             private Polygon2D _polygon;
             public override bool Initialize(out Process<bool>[] asyncProcesses){
                    _spritebatch = new SpriteBatch(this);
                    _primitivebatch = new PrimitiveBatch(this);
                    _surface = LoadContent<Surface>("Example.back-air.gif"); //As embeded resource
                    _polygon = GeometricGeneratorFactory.CreateKochSnowflake(
                                        new Vertex2D(400, 300), 200, 2, 0, new Color(255,0,0));
                    asyncProcesses = null;
                    FullScreen = true;
                    return true;
             }
             public override IComponent Update(TimeSpan gameTime){return this;}
             public override void Render(TimeSpan gameTime, Camera camera){
                    Clear(Maths.Randomize<Color,Color>());
                    camera.Rotation += 0.05f;
                    camera.Zoom += 0.05f;
                    if (camera.Zoom == 5) camera.Zoom = 0;
                    _spritebatch.Begin(camera);
                    _spritebatch.Draw(_surface, Center);
                    _spritebatch.End();
                    _primitivebatch.Begin(camera);
                    _primitivebatch.FillPath(GeometricGeneratorFactory.CreateRandomHull(
                                        new Vertex2D(400, 300),300,300,20));
                    _primitivebatch.FillPath(GeometricGeneratorFactory.CreateStar(
                                        Center, 10, 50, 200, 0, Maths.Randomize<Color, Color>()));
                    _primitivebatch.End();
             }
             public static void Main(string[] args){
                    new Test();
             }
     }
}

Friday, May 27, 2011

Still Working.

Quick Update.
2 Libraries, Considering I had way to much code for 1 project I have split the whole thing into 2.
There is the Core Lib which contains anything that can be considered generic and re-usable and the BadKid lib which is still the initial goal.
A lot of work has been done and the primitive batch is working but I am noticing some lag so I will be working on optimising that and the sprite batch is also working.
The XNA option params issue has been defeated though not entirely sure how I just kept buggering around with it and now when you extend the GameEngine class you are free to code in C# 4.0 without any annoying issues.
I will publish the Core Lib as soon as I implement Vector3D, Vertex3D and Matrices but only as binary and debug because I am sure this will be worked on further, logic is BadKid is the only other library I have using it and I can find things I want to change.
Anyway would blab more but I'm still working.