-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
72 lines (60 loc) · 2.01 KB
/
Program.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
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Collab11;
namespace MGclb
{
class Program : Game
{
static void Main(string[] args)
{
using(Program game = new Program())
{
game.Run();
}
}
private SpriteBatch batch;
private Particles explosion;
private MouseState prevMouse;
private System.Numerics.Vector2 position = new System.Numerics.Vector2(45, 85);
private Random rand = new Random();
private BasicEffect effect;
public Program()
{
new GraphicsDeviceManager(this);
IsMouseVisible = true;
}
protected override void LoadContent()
{
effect = new BasicEffect(GraphicsDevice);
explosion = Particles.CreateSource(position, rand.Next(10, 101));
explosion.Effect = effect;
base.LoadContent();
}
protected override void Update(GameTime gameTime)
{
MouseState mouse = Mouse.GetState();
if (mouse.LeftButton == ButtonState.Released
&& prevMouse.LeftButton == ButtonState.Pressed)
{
position = new System.Numerics.Vector2(mouse.X, mouse.Y);
}
if (!explosion.IsActive)
{
Particles.ReturnSource(ref explosion);
explosion = Particles.CreateSource(position, rand.Next(10, 101));
explosion.Effect = effect;
}
explosion.Update(gameTime.ElapsedGameTime.TotalMilliseconds);
prevMouse = mouse;
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
explosion.Draw(GraphicsDevice);
base.Draw(gameTime);
}
}
}