-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrainchunk.cs
More file actions
110 lines (75 loc) · 2.31 KB
/
brainchunk.cs
File metadata and controls
110 lines (75 loc) · 2.31 KB
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
110
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Vector2 = Microsoft.Xna.Framework.Vector2;
namespace monowizard
{
internal class brainchunk : Entity
{
public int maxVel = 25;
public int hitVel = 5;
public Rectangle croprect;
public SpriteEffects spriteEffects;
CollisionCheck check;
Player player;
ParticleManager particleManager;
public brainchunk(CollisionCheck check,Player player, ParticleManager particleManager)
{
id = 101;
this.player = player;
this.check = check;
spriteEffects = SpriteEffects.None;
hitbox.X = 200;
hitbox.Y = 200;
hitbox.Width = 32;
hitbox.Height = 32;
drawrect = new Rectangle(0, 0, 64, 64);
croprect = new Rectangle(128, 0, 128, 128);
bounce = 5;
this.particleManager = particleManager;
}
public override void update()
{
//gravity
yvel += (player.frameCounter.frame % 2);
colliding = false;
grounded = false;
check.checkTile(this);
if (grounded)
{
particleManager.items.Remove(this);
}
//limit physics
if (xvel > maxVel)
{
xvel = maxVel;
}
else if (xvel < -maxVel)
{
xvel = -maxVel;
}
if (yvel > maxVel)
{
yvel = maxVel;
}
else if (yvel < -maxVel)
{
yvel = -maxVel;
}
//applie sphysiocs
hitbox.X += xvel;
hitbox.Y += yvel;
}
public override void draw(SpriteBatch _spriteBatch)
{
drawrect.X = (int)hitbox.X - 16 - player.centerWorldX + player.centerX;
drawrect.Y = (int)hitbox.Y - 16 - player.centerWorldY + player.centerY;
_spriteBatch.Draw(texture, drawrect, croprect, Color.White, 0, Vector2.Zero, spriteEffects, 1);
}
}
}