Saturday, 20 February 2010

Engine3.20 released

This is the last release before I do the changes to the collision system only one change (until I decided to add the sprite layer stuff) but important for all those doing shooting (lightgun) style games. Hopefully when I do the collision update I won't completely bork the engine but its a possibility as the entire sprite update code is going to have to change. I've produced a totally new engine project just in case it goes wrong.

Bugs fixed in this release
==========================
none

Changes in this release
=======================

EngineManager
------------
added - PointInFirstSprite(), a further method added (3 in total now) that checks against a range of sprite types, in case you need to check against multiple types.

adjusted - AddSprite(), so it incrementally sets a Z value for each new sprite added (resets when ClearAllSprites called), override by setting a Z position.

added - spriteLayerProperties(), a method for accessing the properties of a specific sprite layer (as detailed below). This is for special effects only collision detection and other systems will not take account (yet!) of the matrices for each of the sprite layers

Here is a quick video showing some square sprites all the squAres are actually the same size but the layers are scaled (Yes I know its a crap example but it's taken from code I was using to test the PointInFirstSprite() code so it was there. I'll do another video to illustrate this better).

SpriteLayerProperties
---------------------
New class added which can globally affect all sprites or text on a specific layer using the following properties. This involved a lot of refactoring which may have introduced some bugs that I haven't picked up (i think I updated all references). This may cause some weird actions (particularly the rotation stuff)

added ScaleFactor - Specifies the scaling effect for the sprite/text layer (float)

added RotationAngle - specifies the rotation angle for the sprite/text layer (float in radians not degrees)

added RotationCentre - Specifies the centre of rotation for the sprite layer (Vector 3)

added DrawMatrix - default matrix which does nothing (as its an identity matrix - look it up)

added CreateMatrix - if true (default is false) creates a transformation matrix for the Sprite/text layer based on the scaleFactor, rotationAngle, rotationCentre values, otherwise the DrawMatrix is used (which defaults to Identity - which does nothing)

access the spriteLayerProperties as follows:

//settings for sprite layer0
//make engine generate matrix
engineM.SpriteLayerProperties(SpriteLayer.layer0).CreateMatrix = true;
//set rotation centre to centre of screen (screen in this case is 800x600)
engineM.SpriteLayerProperties(SpriteLayer.layer0).RotationCentre = new Vector3(400, 300, 0);

//in GameLoop() you can constantly rotate the sprite layer0 at 90 degrees/second:
engineM.SpriteLayerProperties(SpriteLayer.layer0).RotationAngle +=
MathHelper.ToRadians(eventM.ReturnValueForFrame(90));

I've tested this a bit and found a problem with the drawnText (this is where normal text ends up) layer and scaling, scale values over 1.0f stop displaying, I don't know why yet haven't investigated.

No comments:

Post a Comment