 |
Jypeli
9
The simple game programming library
|
Siirry tämän tiedoston dokumentaatioon.
2 using System.Collections.Generic;
3 using System.Runtime.CompilerServices;
60 new Vector( -0.5f, -0.5f ),
70 TopLeft =
new Vector2( 0.0f, 0.0f ),
71 TopRight =
new Vector2( 1.0f, 0.0f ),
72 BottomLeft =
new Vector2( 0.0f, 1.0f ),
73 BottomRight =
new Vector2( 1.0f, 1.0f ),
149 else if (obj.
Image !=
null)
253 Vector topLeft = camera.ScreenToWorld(
new Vector( screen.Left, screen.Top ) );
254 Vector topRight = camera.ScreenToWorld(
new Vector( screen.Right, screen.Top ) );
255 Vector bottomLeft = camera.ScreenToWorld(
new Vector( screen.Left, screen.Bottom ) );
256 Vector bottomRight = camera.ScreenToWorld(
new Vector( screen.Right, screen.Bottom ) );
258 int horizontalCount = (int)Math.Ceiling( ( topRight.
X - topLeft.
X ) /
Grid.
CellSize.
X );
259 int leftmostLine = (int)Math.Ceiling( topLeft.
X /
Grid.
CellSize.
X );
262 for (
int i = 0; i < horizontalCount; i++ )
270 int verticalCount = (int)Math.Ceiling( ( topRight.
Y - bottomRight.
Y ) /
Grid.
CellSize.
Y );
271 int bottommostLine = (int)Math.Ceiling( bottomRight.
Y /
Grid.
CellSize.
Y );
274 for (
int i = 0; i < verticalCount; i++ )
279 if ( y == 0.0 ) y += 0.1;
302 Draw(o, ref worldMatrix);
313 if ( o1.
Image ==
null || o2.
Image ==
null )
return 0;
315 int hash1 = RuntimeHelpers.GetHashCode( o1.
Image );
316 int hash2 = RuntimeHelpers.GetHashCode( o2.
Image );
318 if ( hash1 == hash2 )
324 return RuntimeHelpers.GetHashCode( o1 ) - RuntimeHelpers.GetHashCode( o2 );
326 return hash1 - hash2;
347 bool hasChildObjects = o.ObjectCount > 0;
348 bool isSimple = !hasChildObjects && !o.TextureFillsShape;
358 Draw( o, ref worldMatrix );
376 Image previousImage =
null;
383 bool hasChildObjects = o.ObjectCount > 0;
384 bool isSimple = !hasChildObjects && !o.TextureFillsShape;
388 if ( isSimple && ( o.Image !=
null ) )
390 if ( !Object.ReferenceEquals( o.Image, previousImage ) )
397 previousImage = o.Image;
403 Draw( o, ref worldMatrix );
415 o.
Draw( worldMatrix );
423 for (
int i = 0; i <
Objects.Count; i++ )
426 if ( go ==
null || go._childObjects ==
null || go is
Window )
429 if ( go.Shape.IsUnitSize )
432 Vector2 position =
new Vector2( (
float)go.Position.X, (
float)go.Position.Y );
433 Vector2 scale =
new Vector2( (
float)drawScale.
X, (
float)drawScale.
Y );
434 float rotation = go.RotateImage ? (float)go.Angle.Radians : 0;
436 Matrix childTransformation =
437 Matrix.CreateRotationZ( rotation )
438 *
Matrix.CreateTranslation( position.X, position.Y, 0f )
445 for (
int j = 0; j < go._childObjects.Count; j++ )
447 Draw( go._childObjects[j], ref childTransformation );
457 Vector2 scale =
new Vector2( (
float)o.
Size.
X, (
float)o.
Size.
Y );
470 float left = (float)( -wx / 2 + 0.5 );
471 float right = (float)( wx / 2 + 0.5 );
472 float top = (float)( -wy / 2 + 0.5 );
473 float bottom = (float)( wy / 2 + 0.5 );
477 TopLeft =
new Vector2( left, top ),
478 TopRight =
new Vector2( right, top ),
479 BottomLeft =
new Vector2( left, bottom ),
480 BottomRight =
new Vector2( right, bottom ),
493 Vector2 newScale =
new Vector2(
501 Vector2 newPosition = position +
new Vector2( ( topLeftX + x ) * newScale.X, ( topLeftY + y ) * newScale.Y );
512 Vector2 scale =
new Vector2( (
float)o.
Size.
X, (
float)o.
Size.
Y );
532 vertices =
new Vector[] { };
533 indices =
new Int16[] { };
547 Vector2 scale =
new Vector2( (
float)drawScale.
X, (
float)drawScale.
Y );
553 Matrix.CreateScale( scale.X, scale.Y, 1f )
554 *
Matrix.CreateRotationZ( rotation )
555 *
Matrix.CreateTranslation( position.X, position.Y, 0f )
556 * parentTransformation;
566 else if ( o.
Image !=
null )
579 result.AddRange(
Objects.GetObjectsAboutToBeAdded() );
Rajapinta olioille, joilla on oma Draw-metodi.
void ApplyChanges()
Instantly applies changes made to the layer's objects.
Luokka, joka sisältää metodeita kuvioiden ja tekstuurien piirtämiseen 2D-tasossa.
@ Up
Mittarin arvo kasvaa.
void ObjectRemoved(IGameObject obj)
static ImageBatch ImageBatch
Microsoft.Xna.Framework.Matrix Matrix
static void DrawShape(Shape shape, ref Matrix transformation, ref Matrix textureTransformation, Image texture, Vector textureWrapSize, Color color)
Piirtää kuvion niin, että tekstuuri täyttää sen.
Järjestelmä partikkelien käsittelyyn
void Begin(ref Matrix matrix, Texture2D texture)
static readonly Vector Zero
Nollavektori.
static ShapeBatch ShapeBatch
void DrawObjectsWithImages(Matrix worldMatrix)
static LineBatch LineBatch
static readonly Vector Diagonal
Diagonaalivektori (1,1)
double ZoomFactor
Kameran zoomauskerroin. Oletuksena 1.0. Mitä suurempi zoomauskerroin, sitä lähempänä kamera on (esim ...
void DrawCustomDrawables(Matrix worldMatrix)
Camera Camera
Kamera, joka näyttää ruudulla näkyvän osan kentästä. Kameraa voidaan siirtää, zoomata tai asettaa seu...
static Layer CreateStaticLayer()
Luo staattisen kerroksen (ei liiku kameran mukana)
Yhteinen rajapinta kaikille peliolioille.
static readonly TextureCoordinates defaultCoords
int CompareByImageReference(IGameObject o1, IGameObject o2)
double Radians
Palauttaa tai asettaa kulman radiaaneina.
static bool LightingEnabled
Kamera. Määrittää mikä osa pelitasosta on kerralla näkyvissä.
void DrawObjectsWithoutImages(Matrix worldMatrix)
DrawOrder
Piirtojärjestys.
static readonly Vector[] triangleVertices
Vertices for drawing a filled triangle.
Rajapinta päivittyville olioille.
static readonly Rectangle Rectangle
Suorakulmio.
void DrawEfficientlyInNoParticularOrder(ref Matrix worldMatrix)
void DrawInOrderFromFirstToLast(ref Matrix worldMatrix)
static Game Instance
Käynnissä olevan pelin pääolio.
void DrawChildObjects(Matrix worldMatrix)
bool IgnoresZoom
Jättää kameran zoomin huomiotta jos asetettu.
SynchronousList< ParticleSystem > Effects
void Remove(IGameObject o)
Kerros. Vastaa olioiden piirtämisestä.
static readonly Int16[] squareIndices
Indices for the vertex array of the square.
Sisältää tiedon ajasta, joka on kulunut pelin alusta ja viime päivityksestä.
static ScreenView Screen
Näytön dimensiot, eli koko ja reunat.
List< IGameObject > objectsWithImage
static void DrawImage(Image texture, ref Matrix matrix, Vector wrapSize)
List< IGameObject > objectsWithoutImage
new Vector Position
Paikka.
void ObjectAdded(IGameObject obj)
void Draw(TextureCoordinates c, Vector2 position, Vector2 size, float angle)
Contains graphics resources.
void GetObjectsAboutToBeAdded(List< IGameObject > result)
void Draw(Vector[] vertices, Int16[] indices, Color color, Vector2 position, Vector2 size, float angle)
void DrawTexture(IGameObject o, ref Matrix parentTransformation)
Vector RelativeTransition
Kuinka paljon tämän kerroksen olioiden paikka muuttuu kameran siirtyessä suhteessa muihin kerroksiin....
bool UpdateChanges()
Lisää ja poistaa jonossa olevat elementit, mutta ei kutsu elementtien Update-metodia.
void Draw(Matrix parentTransformation)
void Begin(ref Matrix matrix)
void DrawGrid(ref Matrix matrix)
static readonly Triangle Triangle
Tasasivuinen kolmio.
void Draw(IGameObject o, ref Matrix parentTransformation)
Synkroninen lista, eli lista joka päivittyy vasta kun sen Update-metodia kutsutaan....
Pelialueella liikkuva olio. Käytä fysiikkapeleissä PhysicsObject-olioita.
void Draw(Vector startPoint, Vector endPoint, Color color)
void ForEach(Action< T > action)
Suorittaa annetun toimenpiteen kaikille (nykyisille) listan alkioille.
void DrawShape(IGameObject o, ref Matrix parentTransformation)
void Begin(ref Matrix matrix)
static readonly Int16[] triangleIndices
Indices for the vertex array of the triangle.
Vector Position
Kameran sijainti.
static readonly Vector[] squareVertices
Vertices for drawing a filled square.
abstract bool IsUnitSize
If true, the shape must be scaled by the size of the object that has the shape. Typically,...
Jypelin sisäiset metodit ja propertyt joihin käyttäjän ei tarvitse päästä käsiksi kuuluvat tähän luok...
void Update(Time time)
Lisää ja poistaa jonossa olevat elementit sekä kutsuu niiden Update-metodia.
@ Irrelevant
Piirtojärjestyksellä ei ole väliä. Oliot piirretään mahdollisimman tehokkaassa järjestyksessä....
Vector _relativeTransition
List< IGameObject > objectsWithDrawMethod
SynchronousList< IGameObject > Objects