Jypeli  9
The simple game programming library
Layer.cs
Siirry tämän tiedoston dokumentaatioon.
1 using System;
2 using System.Collections.Generic;
3 using System.Runtime.CompilerServices;
5 using Jypeli.Effects;
6 
7 
8 namespace Jypeli
9 {
13  public enum DrawOrder
14  {
19  Irrelevant,
20 
25  }
26 
27 
31  public class Layer : Updatable
32  {
36  static readonly Vector[] squareVertices =
37  {
38  new Vector( -0.5, -0.5 ),
39  new Vector( -0.5, 0.5 ),
40  new Vector( 0.5, -0.5 ),
41  new Vector( 0.5, 0.5 )
42  };
43 
47  static readonly Int16[] squareIndices =
48  {
49  0, 1, 2,
50  2, 1, 3
51  };
52 
56  static readonly Vector[] triangleVertices =
57  {
58  new Vector( 0f, 0.5f ),
59  new Vector( 0.5f, -0.5f ),
60  new Vector( -0.5f, -0.5f ),
61  };
62 
66  static readonly Int16[] triangleIndices = { 0, 1, 2 };
67 
69  {
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 ),
74  };
75 
77 
78 //#if !DISABLE_EFFECTS
80 //#endif
81 
82  private List<IGameObject> objectsWithImage = new List<IGameObject>();
83  private List<IGameObject> objectsWithoutImage = new List<IGameObject>();
84  private List<IGameObject> objectsWithDrawMethod = new List<IGameObject>();
85 
86  private Vector _relativeTransition = new Vector( 1, 1 );
87 
88  public bool IsUpdated
89  {
90  get { return true; }
91  }
92 
96  public DrawOrder DrawOrder { get; set; }
97 
103  {
104  get { return _relativeTransition; }
105  set { _relativeTransition = value; }
106  }
107 
111  public bool IgnoresZoom { get; set; }
112 
117  public Grid Grid { get; set; }
118 
119 
120  public Layer()
121  {
122  DrawOrder = DrawOrder.Irrelevant;
123  Objects.ItemAdded += ObjectAdded;
124  Objects.ItemRemoved += ObjectRemoved;
125  }
126 
131  public static Layer CreateStaticLayer()
132  {
133  return new Layer() { RelativeTransition = Vector.Zero, IgnoresZoom = true };
134  }
135 
136  private void ObjectAdded( IGameObject obj )
137  {
138 //#if !DISABLE_EFFECTS
139  if (obj is ParticleSystem)
140  {
141  Effects.Add((ParticleSystem)obj);
142  }
143  else
144 //#endif
145  if (obj is CustomDrawable)
146  {
147  objectsWithDrawMethod.Add(obj);
148  }
149  else if (obj.Image != null)
150  {
151  objectsWithImage.Add(obj);
152  }
153  else
154  {
155  objectsWithoutImage.Add(obj);
156  }
157 
158  ( (IGameObjectInternal)obj ).Layer = this;
159  }
160 
161  private void ObjectRemoved( IGameObject obj )
162  {
163 //#if !DISABLE_EFFECTS
164  if (obj is ParticleSystem)
165  {
167  }
168  else
169 //#endif
170  {
171  objectsWithDrawMethod.Remove(obj);
172  objectsWithImage.Remove(obj);
173  objectsWithoutImage.Remove(obj);
174  }
175 
176  ((IGameObjectInternal)obj).Layer = null;
177  }
178 
179  internal void Add( IGameObject o )
180  {
181  Objects.Add( o );
182  }
183 
184  internal void Remove( IGameObject o )
185  {
186  Objects.Remove( o );
187  }
188 
189  public void Clear()
190  {
191 //#if !DISABLE_EFFECTS
192  Effects.Clear();
193 //#endif
194  Objects.Clear();
195  objectsWithImage.Clear();
196  objectsWithoutImage.Clear();
197  objectsWithDrawMethod.Clear();
198  }
199 
203  public void ApplyChanges()
204  {
206  Objects.UpdateChanges();
207  }
208 
209  public void Update( Time time )
210  {
211  Objects.Update( time );
212 
213 //#if !DISABLE_EFFECTS
214  Effects.Update(time);
215 //#endif
216  }
217 
218  internal void Draw( Camera camera )
219  {
220  var zoomMatrix = IgnoresZoom ? Matrix.Identity : Matrix.CreateScale( (float)( camera.ZoomFactor ), (float)( camera.ZoomFactor ), 1f );
221  var worldMatrix =
222  Matrix.CreateTranslation( (float)( -camera.Position.X * RelativeTransition.X ), (float)( -camera.Position.Y * RelativeTransition.Y ), 0 )
223  * zoomMatrix;
224 
225  switch ( DrawOrder )
226  {
227  case DrawOrder.Irrelevant:
228  DrawEfficientlyInNoParticularOrder( ref worldMatrix );
229  break;
230  case DrawOrder.FirstToLast:
231  DrawInOrderFromFirstToLast( ref worldMatrix );
232  break;
233  default:
234  break;
235  }
236 
237 //#if !DISABLE_EFFECTS
238  Effects.ForEach( e => e.Draw(worldMatrix) );
239 //#endif
240 
241  if ( Grid != null )
242  {
243  DrawGrid( ref worldMatrix );
244  }
245  }
246 
247  private void DrawGrid( ref Matrix matrix )
248  {
249  Graphics.LineBatch.Begin( ref matrix );
250 
251  var camera = Game.Instance.Camera;
252  var screen = Game.Screen;
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 ) );
257 
258  int horizontalCount = (int)Math.Ceiling( ( topRight.X - topLeft.X ) / Grid.CellSize.X );
259  int leftmostLine = (int)Math.Ceiling( topLeft.X / Grid.CellSize.X );
260  double leftmostX = leftmostLine * Grid.CellSize.X;
261 
262  for ( int i = 0; i < horizontalCount; i++ )
263  {
264  double x = leftmostX + i * Grid.CellSize.X;
265  Vector startPoint = new Vector( x, topLeft.Y );
266  Vector endPoint = new Vector( x, bottomLeft.Y );
267  Graphics.LineBatch.Draw( startPoint, endPoint, Grid.Color );
268  }
269 
270  int verticalCount = (int)Math.Ceiling( ( topRight.Y - bottomRight.Y ) / Grid.CellSize.Y );
271  int bottommostLine = (int)Math.Ceiling( bottomRight.Y / Grid.CellSize.Y );
272  double bottommostY = bottommostLine * Grid.CellSize.Y;
273 
274  for ( int i = 0; i < verticalCount; i++ )
275  {
276  double y = bottommostY + i * Grid.CellSize.Y;
277 
278  // Doesn't draw the line when y is 0! Wonder why...
279  if ( y == 0.0 ) y += 0.1;
280 
281  Vector startPoint = new Vector( bottomLeft.X, y );
282  Vector endPoint = new Vector( bottomRight.X, y );
283  Graphics.LineBatch.Draw( startPoint, endPoint, Grid.Color );
284  }
285 
287  }
288 
289  private void DrawInOrderFromFirstToLast( ref Matrix worldMatrix )
290  {
291  Renderer.LightingEnabled = true;
292 
293  foreach ( var o in Objects )
294  {
295  if (o is CustomDrawable)
296  {
297  if (o.IsVisible) ((CustomDrawable)o).Draw(worldMatrix);
298  }
299  else
300  {
301  Renderer.LightingEnabled = !o.IgnoresLighting;
302  Draw(o, ref worldMatrix);
303  }
304  }
305 
306  DrawChildObjects( worldMatrix );
307 
308  Renderer.LightingEnabled = false;
309  }
310 
312  {
313  if ( o1.Image == null || o2.Image == null ) return 0;
314 
315  int hash1 = RuntimeHelpers.GetHashCode( o1.Image );
316  int hash2 = RuntimeHelpers.GetHashCode( o2.Image );
317 
318  if ( hash1 == hash2 )
319  {
320  // Because the sorting algorithm of the List class is not stable,
321  // objects with similar images on top of each other flicker rather
322  // annoyingly. Therefore, compare object references in order to keep
323  // the sorting stable.
324  return RuntimeHelpers.GetHashCode( o1 ) - RuntimeHelpers.GetHashCode( o2 );
325  }
326  return hash1 - hash2;
327  }
328 
329  private void DrawEfficientlyInNoParticularOrder( ref Matrix worldMatrix )
330  {
331  Renderer.LightingEnabled = true;
332  DrawObjectsWithoutImages( worldMatrix );
333  DrawObjectsWithImages( worldMatrix );
334  DrawCustomDrawables( worldMatrix );
335  DrawChildObjects( worldMatrix );
336  Renderer.LightingEnabled = false;
337  }
338 
339  private void DrawObjectsWithoutImages( Matrix worldMatrix )
340  {
341  Graphics.ShapeBatch.Begin( ref worldMatrix );
342  foreach ( var o in objectsWithoutImage )
343  {
344  if ( !o.IsVisible )
345  continue;
346 
347  bool hasChildObjects = o.ObjectCount > 0;
348  bool isSimple = !hasChildObjects && !o.TextureFillsShape;
349 
350  Renderer.LightingEnabled = !o.IgnoresLighting;
351 
352  if ( isSimple && ( o.Image == null ) && ( o.Shape == Shape.Rectangle || o.Shape == Shape.Triangle ) )
353  {
354  DrawShape( o, ref worldMatrix );
355  }
356  else
357  {
358  Draw( o, ref worldMatrix );
359  }
360  }
362  }
363 
364  private void DrawObjectsWithImages( Matrix worldMatrix )
365  {
366  // By sorting the images first, we get objects with same
367  // images in succession. This allows us to use the ImageBatch
368  // class more efficiently.
370 
371  // Passing null for image here does not hurt, because the first
372  // ReferenceEquals-comparison calls End() without drawing a single
373  // image.
374  Graphics.ImageBatch.Begin( ref worldMatrix, null );
375 
376  Image previousImage = null;
377 
378  foreach ( var o in objectsWithImage )
379  {
380  if ( !o.IsVisible )
381  continue;
382 
383  bool hasChildObjects = o.ObjectCount > 0;
384  bool isSimple = !hasChildObjects && !o.TextureFillsShape;
385 
386  Renderer.LightingEnabled = !o.IgnoresLighting;
387 
388  if ( isSimple && ( o.Image != null ) )
389  {
390  if ( !Object.ReferenceEquals( o.Image, previousImage ) )
391  {
392  // Object o has different image than the previous one,
393  // so let's start a new batch with the new image. The objects
394  // should be sorted at this point.
396  Graphics.ImageBatch.Begin( ref worldMatrix, o.Image.XNATexture );
397  previousImage = o.Image;
398  }
399  DrawTexture( o, ref worldMatrix );
400  }
401  else
402  {
403  Draw( o, ref worldMatrix );
404  }
405  }
406 
408  }
409 
410  private void DrawCustomDrawables( Matrix worldMatrix )
411  {
412  foreach ( CustomDrawable o in objectsWithDrawMethod )
413  {
414  if ( o.IsVisible )
415  o.Draw( worldMatrix );
416  }
417  }
418 
419  private void DrawChildObjects( Matrix worldMatrix )
420  {
421  Vector drawScale = new Vector( 1, 1 );
422 
423  for ( int i = 0; i < Objects.Count; i++ )
424  {
425  var go = Objects[i] as GameObject;
426  if ( go == null || go._childObjects == null || go is Window )
427  continue;
428 
429  if ( go.Shape.IsUnitSize )
430  drawScale = go.Size;
431 
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;
435 
436  Matrix childTransformation =
437  Matrix.CreateRotationZ( rotation )
438  * Matrix.CreateTranslation( position.X, position.Y, 0f )
439  * worldMatrix;
440 
441  // light positioning for child objects has not been implemented, so
442  // let's not use it.
443  Renderer.LightingEnabled = false;
444 
445  for ( int j = 0; j < go._childObjects.Count; j++ )
446  {
447  Draw( go._childObjects[j], ref childTransformation );
448  }
449 
450  Renderer.LightingEnabled = true;
451  }
452  }
453 
454  private void DrawTexture( IGameObject o, ref Matrix parentTransformation )
455  {
456  Vector2 position = new Vector2( (float)o.Position.X, (float)o.Position.Y );
457  Vector2 scale = new Vector2( (float)o.Size.X, (float)o.Size.Y );
458  float rotation = o.RotateImage ? (float)o.Angle.Radians : 0;
459 
460  if ( o.IsVisible )
461  {
462  if ( o.TextureWrapSize == Vector.Diagonal )
463  {
464  Graphics.ImageBatch.Draw( defaultCoords, position, scale, rotation );
465  }
466  else
467  {
468  float wx = (float)( Math.Sign( o.TextureWrapSize.X ) );
469  float wy = (float)( Math.Sign( o.TextureWrapSize.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 );
474 
475  TextureCoordinates customCoords = new TextureCoordinates()
476  {
477  TopLeft = new Vector2( left, top ),
478  TopRight = new Vector2( right, top ),
479  BottomLeft = new Vector2( left, bottom ),
480  BottomRight = new Vector2( right, bottom ),
481  };
482 
483  if ( o.TextureWrapSize.X == wx && o.TextureWrapSize.Y == wy )
484  {
485  // Draw only once
486  Graphics.ImageBatch.Draw( customCoords, position, scale, rotation );
487  return;
488  }
489 
490  float topLeftX = -(float)( o.TextureWrapSize.X - 1 ) / 2;
491  float topLeftY = -(float)( o.TextureWrapSize.Y - 1 ) / 2;
492 
493  Vector2 newScale = new Vector2(
494  scale.X / ( wx * (float)o.TextureWrapSize.X ),
495  scale.Y / ( wy * (float)o.TextureWrapSize.Y ) );
496 
497  for ( int y = 0; y < o.TextureWrapSize.Y; y++ )
498  {
499  for ( int x = 0; x < o.TextureWrapSize.X; x++ )
500  {
501  Vector2 newPosition = position + new Vector2( ( topLeftX + x ) * newScale.X, ( topLeftY + y ) * newScale.Y );
502  Graphics.ImageBatch.Draw( customCoords, newPosition, newScale, rotation );
503  }
504  }
505  }
506  }
507  }
508 
509  private void DrawShape( IGameObject o, ref Matrix parentTransformation )
510  {
511  Vector2 position = new Vector2( (float)o.Position.X, (float)o.Position.Y );
512  Vector2 scale = new Vector2( (float)o.Size.X, (float)o.Size.Y );
513  float rotation = (float)o.Angle.Radians;
514 
515  if ( o.IsVisible )
516  {
517  Vector[] vertices;
518  Int16[] indices;
519 
520  if ( o.Shape == Shape.Rectangle )
521  {
522  vertices = squareVertices;
523  indices = squareIndices;
524  }
525  else if ( o.Shape == Shape.Triangle )
526  {
527  vertices = triangleVertices;
528  indices = triangleIndices;
529  }
530  else
531  {
532  vertices = new Vector[] { };
533  indices = new Int16[] { };
534  }
535 
536  Graphics.ShapeBatch.Draw( vertices, indices, o.Color, position, scale, rotation );
537  }
538  }
539 
540  private void Draw( IGameObject o, ref Matrix parentTransformation )
541  {
542  Vector drawScale = new Vector( 1, 1 );
543  if ( o.Shape.IsUnitSize )
544  drawScale = o.Size;
545 
546  Vector2 position = new Vector2( (float)o.Position.X, (float)o.Position.Y );
547  Vector2 scale = new Vector2( (float)drawScale.X, (float)drawScale.Y );
548  float rotation = o.RotateImage ? (float)o.Angle.Radians : 0;
549 
550  if ( o.IsVisible )
551  {
552  Matrix transformation =
553  Matrix.CreateScale( scale.X, scale.Y, 1f )
554  * Matrix.CreateRotationZ( rotation )
555  * Matrix.CreateTranslation( position.X, position.Y, 0f )
556  * parentTransformation;
557 
558  if ( o is CustomDrawable )
559  {
560  ( (CustomDrawable)o ).Draw( parentTransformation );
561  }
562  else if ( o.Image != null && ( !o.TextureFillsShape ) )
563  {
564  Renderer.DrawImage( o.Image, ref transformation, o.TextureWrapSize );
565  }
566  else if ( o.Image != null )
567  {
568  Renderer.DrawShape( o.Shape, ref transformation, ref transformation, o.Image, o.TextureWrapSize, o.Color );
569  }
570  else
571  {
572  Renderer.DrawShape( o.Shape, ref transformation, o.Color );
573  }
574  }
575  }
576 
577  internal void GetObjectsAboutToBeAdded( List<IGameObject> result )
578  {
579  result.AddRange( Objects.GetObjectsAboutToBeAdded() );
580  }
581  }
582 }
Jypeli.CustomDrawable
Rajapinta olioille, joilla on oma Draw-metodi.
Definition: CustomDrawable.cs:9
Jypeli.Layer.ApplyChanges
void ApplyChanges()
Instantly applies changes made to the layer's objects.
Definition: Layer.cs:203
Jypeli.Renderer
Luokka, joka sisältää metodeita kuvioiden ja tekstuurien piirtämiseen 2D-tasossa.
Definition: Renderer.cs:48
Jypeli.ShapeBatch.End
void End()
Definition: ShapeBatch.cs:74
Jypeli.LineBatch.End
void End()
Definition: LineBatch.cs:26
Jypeli.TriggerDirection.Up
@ Up
Mittarin arvo kasvaa.
Jypeli.Layer.ObjectRemoved
void ObjectRemoved(IGameObject obj)
Definition: Layer.cs:161
Jypeli.Layer.Add
void Add(IGameObject o)
Definition: Layer.cs:179
Jypeli.Graphics.ImageBatch
static ImageBatch ImageBatch
Definition: Graphics.cs:45
Jypeli.Matrix
Microsoft.Xna.Framework.Matrix Matrix
Definition: Mouse.cs:36
Jypeli.Renderer.DrawShape
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.
Definition: Renderer.cs:304
Microsoft.Xna
Definition: JypeliContentManager.cs:6
Jypeli.Effects.ParticleSystem
Järjestelmä partikkelien käsittelyyn
Definition: ParticleSystem.cs:19
Jypeli.Grid.Color
Color Color
Definition: Grid.cs:7
Jypeli.Vector.X
double X
Definition: Vector.cs:312
Jypeli.ImageBatch.Begin
void Begin(ref Matrix matrix, Texture2D texture)
Definition: ImageBatch.cs:74
Jypeli.Vector.Zero
static readonly Vector Zero
Nollavektori.
Definition: Vector.cs:63
Jypeli.Graphics.ShapeBatch
static ShapeBatch ShapeBatch
Definition: Graphics.cs:46
Jypeli.Layer.DrawObjectsWithImages
void DrawObjectsWithImages(Matrix worldMatrix)
Definition: Layer.cs:364
Jypeli.Grid.CellSize
Vector CellSize
Definition: Grid.cs:8
Jypeli
Definition: Automobile.cs:5
Jypeli.Graphics.LineBatch
static LineBatch LineBatch
Definition: Graphics.cs:47
Jypeli.Vector.Diagonal
static readonly Vector Diagonal
Diagonaalivektori (1,1)
Definition: Vector.cs:83
Microsoft
Definition: JypeliContentManager.cs:6
Microsoft.Xna.Framework
Definition: JypeliContentManager.cs:6
Jypeli.IGameObject.TextureWrapSize
Vector TextureWrapSize
Definition: IGameObject.cs:41
Jypeli.Camera.ZoomFactor
double ZoomFactor
Kameran zoomauskerroin. Oletuksena 1.0. Mitä suurempi zoomauskerroin, sitä lähempänä kamera on (esim ...
Definition: Camera.cs:99
Jypeli.Layer.DrawCustomDrawables
void DrawCustomDrawables(Matrix worldMatrix)
Definition: Layer.cs:410
Jypeli.SynchronousList.Add
void Add(T item)
Definition: SynchronousList.cs:197
Jypeli.Game.Camera
Camera Camera
Kamera, joka näyttää ruudulla näkyvän osan kentästä. Kameraa voidaan siirtää, zoomata tai asettaa seu...
Definition: Game.cs:118
Jypeli.Layer.Clear
void Clear()
Definition: Layer.cs:189
Jypeli.Layer.CreateStaticLayer
static Layer CreateStaticLayer()
Luo staattisen kerroksen (ei liiku kameran mukana)
Definition: Layer.cs:131
Jypeli.IGameObject
Yhteinen rajapinta kaikille peliolioille.
Definition: IGameObject.cs:11
Jypeli.Shape
Kuvio.
Definition: Shapes.cs:47
Jypeli.DimensionalRW.Size
new Vector Size
Koko.
Definition: Dimensional.cs:72
Jypeli.Layer.defaultCoords
static readonly TextureCoordinates defaultCoords
Definition: Layer.cs:68
Jypeli.Layer.CompareByImageReference
int CompareByImageReference(IGameObject o1, IGameObject o2)
Definition: Layer.cs:311
Jypeli.Grid
Definition: Grid.cs:6
Jypeli.Angle.Radians
double Radians
Palauttaa tai asettaa kulman radiaaneina.
Definition: Angle.cs:85
Jypeli.SynchronousList.Remove
void Remove(T item)
Definition: SynchronousList.cs:202
Jypeli.Renderer.LightingEnabled
static bool LightingEnabled
Definition: Renderer.cs:69
Jypeli.Camera
Kamera. Määrittää mikä osa pelitasosta on kerralla näkyvissä.
Definition: Camera.cs:40
Jypeli.Layer.DrawObjectsWithoutImages
void DrawObjectsWithoutImages(Matrix worldMatrix)
Definition: Layer.cs:339
Jypeli.IGameObject.Image
Image Image
Definition: IGameObject.cs:37
Jypeli.DrawOrder
DrawOrder
Piirtojärjestys.
Definition: Layer.cs:14
Jypeli.Layer.triangleVertices
static readonly Vector[] triangleVertices
Vertices for drawing a filled triangle.
Definition: Layer.cs:56
Jypeli.Updatable
Rajapinta päivittyville olioille.
Definition: Updatable.cs:7
Jypeli.Shape.Rectangle
static readonly Rectangle Rectangle
Suorakulmio.
Definition: Shapes.cs:70
Jypeli.Layer.DrawEfficientlyInNoParticularOrder
void DrawEfficientlyInNoParticularOrder(ref Matrix worldMatrix)
Definition: Layer.cs:329
Jypeli.Layer.DrawInOrderFromFirstToLast
void DrawInOrderFromFirstToLast(ref Matrix worldMatrix)
Definition: Layer.cs:289
Jypeli.Game.Instance
static Game Instance
Käynnissä olevan pelin pääolio.
Definition: Game.cs:90
Jypeli.Layer.DrawChildObjects
void DrawChildObjects(Matrix worldMatrix)
Definition: Layer.cs:419
Jypeli.Layer.IgnoresZoom
bool IgnoresZoom
Jättää kameran zoomin huomiotta jos asetettu.
Definition: Layer.cs:111
Jypeli.TextureCoordinates
Definition: ImageBatch.cs:14
Jypeli.Layer.Effects
SynchronousList< ParticleSystem > Effects
Definition: Layer.cs:79
Jypeli.Layer.Remove
void Remove(IGameObject o)
Definition: Layer.cs:184
Jypeli.Layer
Kerros. Vastaa olioiden piirtämisestä.
Definition: Layer.cs:32
Jypeli.SynchronousList.Clear
void Clear()
Definition: SynchronousList.cs:207
Jypeli.Layer.squareIndices
static readonly Int16[] squareIndices
Indices for the vertex array of the square.
Definition: Layer.cs:47
Jypeli.Time
Sisältää tiedon ajasta, joka on kulunut pelin alusta ja viime päivityksestä.
Definition: Time.cs:14
Jypeli.Game.Screen
static ScreenView Screen
Näytön dimensiot, eli koko ja reunat.
Definition: Graphics.cs:90
Jypeli.Layer.objectsWithImage
List< IGameObject > objectsWithImage
Definition: Layer.cs:82
Jypeli.Renderer.DrawImage
static void DrawImage(Image texture, ref Matrix matrix, Vector wrapSize)
Definition: Renderer.cs:122
Jypeli.Layer.objectsWithoutImage
List< IGameObject > objectsWithoutImage
Definition: Layer.cs:83
Jypeli.Layer.Layer
Layer()
Definition: Layer.cs:120
Jypeli.PositionalRW.Position
new Vector Position
Paikka.
Definition: Positional.cs:32
Jypeli.Layer.Draw
void Draw(Camera camera)
Definition: Layer.cs:218
Jypeli.Layer.ObjectAdded
void ObjectAdded(IGameObject obj)
Definition: Layer.cs:136
Jypeli.IGameObject.IsVisible
bool IsVisible
Definition: IGameObject.cs:19
Jypeli.ImageBatch.Draw
void Draw(TextureCoordinates c, Vector2 position, Vector2 size, float angle)
Definition: ImageBatch.cs:119
Jypeli.Graphics
Contains graphics resources.
Definition: Graphics.cs:36
Jypeli.Layer.GetObjectsAboutToBeAdded
void GetObjectsAboutToBeAdded(List< IGameObject > result)
Definition: Layer.cs:577
Jypeli.ShapeBatch.Draw
void Draw(Vector[] vertices, Int16[] indices, Color color, Vector2 position, Vector2 size, float angle)
Definition: ShapeBatch.cs:103
Jypeli.Layer.DrawTexture
void DrawTexture(IGameObject o, ref Matrix parentTransformation)
Definition: Layer.cs:454
Jypeli.Image
Kuva.
Definition: Image.cs:29
Jypeli.CustomDrawable.IsVisible
bool IsVisible
Definition: CustomDrawable.cs:10
Jypeli.Layer.RelativeTransition
Vector RelativeTransition
Kuinka paljon tämän kerroksen olioiden paikka muuttuu kameran siirtyessä suhteessa muihin kerroksiin....
Definition: Layer.cs:103
Jypeli.Vector
2D-vektori.
Definition: Vector.cs:59
System
Definition: CFFauxAttributes.cs:29
Jypeli.SynchronousList.UpdateChanges
bool UpdateChanges()
Lisää ja poistaa jonossa olevat elementit, mutta ei kutsu elementtien Update-metodia.
Definition: SynchronousList.cs:257
Jypeli.CustomDrawable.Draw
void Draw(Matrix parentTransformation)
Jypeli.ShapeBatch.Begin
void Begin(ref Matrix matrix)
Definition: ShapeBatch.cs:64
Jypeli.Effects
Definition: ExplosionSystem.cs:4
Jypeli.IGameObject.RotateImage
bool RotateImage
Definition: IGameObject.cs:43
Jypeli.IGameObject.Angle
Angle Angle
Definition: IGameObject.cs:27
Jypeli.Layer.DrawGrid
void DrawGrid(ref Matrix matrix)
Definition: Layer.cs:247
Jypeli.Shape.Triangle
static readonly Triangle Triangle
Tasasivuinen kolmio.
Definition: Shapes.cs:75
Jypeli.Layer.Draw
void Draw(IGameObject o, ref Matrix parentTransformation)
Definition: Layer.cs:540
Jypeli.SynchronousList
Synkroninen lista, eli lista joka päivittyy vasta kun sen Update-metodia kutsutaan....
Definition: SynchronousList.cs:15
Jypeli.Layer.Update
void Update(Time time)
Definition: Layer.cs:209
Jypeli.Window
Ikkuna.
Definition: Window.cs:37
Jypeli.GameObject
Pelialueella liikkuva olio. Käytä fysiikkapeleissä PhysicsObject-olioita.
Definition: Appearance.cs:34
Jypeli.LineBatch.Draw
void Draw(Vector startPoint, Vector endPoint, Color color)
Definition: LineBatch.cs:48
Jypeli.IGameObject.Color
Color Color
Definition: IGameObject.cs:38
Jypeli.SynchronousList.ForEach
void ForEach(Action< T > action)
Suorittaa annetun toimenpiteen kaikille (nykyisille) listan alkioille.
Definition: SynchronousList.cs:320
Jypeli.Layer.DrawShape
void DrawShape(IGameObject o, ref Matrix parentTransformation)
Definition: Layer.cs:509
Jypeli.LineBatch.Begin
void Begin(ref Matrix matrix)
Definition: LineBatch.cs:17
Jypeli.Layer.triangleIndices
static readonly Int16[] triangleIndices
Indices for the vertex array of the triangle.
Definition: Layer.cs:66
Jypeli.Camera.Position
Vector Position
Kameran sijainti.
Definition: Camera.cs:53
Jypeli.Layer.squareVertices
static readonly Vector[] squareVertices
Vertices for drawing a filled square.
Definition: Layer.cs:36
Jypeli.Game
Definition: Content.cs:46
Jypeli.Shape.IsUnitSize
abstract bool IsUnitSize
If true, the shape must be scaled by the size of the object that has the shape. Typically,...
Definition: Shapes.cs:53
Jypeli.Layer.IsUpdated
bool IsUpdated
Definition: Layer.cs:89
Jypeli.IGameObject.TextureFillsShape
bool TextureFillsShape
Definition: IGameObject.cs:42
Jypeli.IGameObjectInternal
Jypelin sisäiset metodit ja propertyt joihin käyttäjän ei tarvitse päästä käsiksi kuuluvat tähän luok...
Definition: IGameObject.cs:75
Jypeli.SynchronousList.Update
void Update(Time time)
Lisää ja poistaa jonossa olevat elementit sekä kutsuu niiden Update-metodia.
Definition: SynchronousList.cs:272
Jypeli.IGameObject.Shape
Shape Shape
Definition: IGameObject.cs:40
Jypeli.DrawOrder.Irrelevant
@ Irrelevant
Piirtojärjestyksellä ei ole väliä. Oliot piirretään mahdollisimman tehokkaassa järjestyksessä....
Jypeli.Layer._relativeTransition
Vector _relativeTransition
Definition: Layer.cs:86
Jypeli.Vector.Y
double Y
Definition: Vector.cs:313
Jypeli.Layer.objectsWithDrawMethod
List< IGameObject > objectsWithDrawMethod
Definition: Layer.cs:84
Jypeli.ImageBatch.End
void End()
Definition: ImageBatch.cs:84
Jypeli.Layer.Objects
SynchronousList< IGameObject > Objects
Definition: Layer.cs:76