-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game1.cs
109 lines (84 loc) · 3.25 KB
/
Game1.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace MonoGame.Benchmark;
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
SpriteFont Font;
int maxLols = 0;
Random random = new Random ();
const int MAXLOLS = 500000;
struct VertexPositionAndRotation {
public Vector2[] Position = new Vector2[MAXLOLS];
public Vector2[] Rotation = new Vector2[MAXLOLS];
public Color[] Color = new Microsoft.Xna.Framework.Color[MAXLOLS];
public VertexPositionAndRotation()
{
}
public void Update (GameTime gameTime, int count)
{
for (int i=0; i < count; i++) {
Rotation[i].X += Rotation[i].Y * (float)gameTime.ElapsedGameTime.TotalMilliseconds;
if (Rotation[i].X > 360f)
Rotation[i].X = 0f;
}
}
}
VertexPositionAndRotation lols = new VertexPositionAndRotation ();
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
// run at full speed
IsFixedTimeStep = false;
_graphics.SynchronizeWithVerticalRetrace = false;
}
protected override void Initialize()
{
// TODO: Add your initialization logic here
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
Font = Content.Load<SpriteFont> ("Arial");
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
Exit();
// TODO: Add your update logic here
if (gameTime.ElapsedGameTime < TimeSpan.FromMilliseconds(33)) {
int c = maxLols;
maxLols += 1000;
for (int i = c; i < maxLols; i++) {
lols.Position[i] = new Vector2 (random.NextSingle () * 800f, random.NextSingle () * 600f);
lols.Rotation[i] = new Vector2(random.NextSingle (), random.NextSingle ());
lols.Color[i] = new Color (random.Next (0, 255), random.Next (0, 255), random.Next (0, 255));
}
Console.WriteLine ($"DEBUG: {maxLols}");
}
lols.Update (gameTime, maxLols);
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
// TODO: Add your drawing code here
_spriteBatch.Begin ();
for (int i=0; i < maxLols; i++) {
_spriteBatch.DrawString (Font, "LOL?", lols.Position[i], lols.Color[i], MathHelper.ToRadians (lols.Rotation[i].X), new Vector2 (.5f, .5f), 1f, SpriteEffects.None, 1f );
}
_spriteBatch.End ();
_spriteBatch.Begin (SpriteSortMode.Immediate);
_spriteBatch.DrawString (Font, $"Total: {maxLols}", new Vector2 (10, 10), Color.Red);
_spriteBatch.End ();
base.Draw(gameTime);
}
}