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
|
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SlugRemix
{
class ClassBalles
{
Rectangle Hitbox;
Texture2D Texture;
int Timer, AnimationSpeed, FrameColone;
public ClassBalles(int x, int y, Texture2D texture)
{
Hitbox = new Rectangle(x, y, texture.Width / 6, texture.Height);
Texture = texture;
}
public ClassBalles()
{
Texture = ClassRessources.pistolBullet;
AnimationSpeed = 10;
}
public void Animate()
{
this.Timer++;
if (this.Timer >= AnimationSpeed)
{
this.Timer = 0;
this.FrameColone++;
if (FrameColone == 6)
FrameColone = 0;
}
}
public void Update()
{
Animate();
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(
Texture,
Hitbox,
new Rectangle((FrameColone) * 18, 0, 18, 18),
Color.White,
0f,
new Vector2(18/2, 18/2),
SpriteEffects.None,
0f);
spriteBatch.DrawString(ClassRessources.font, "Frame " + FrameColone, new Vector2(50, 50), Color.Red);
}
}
} |
Partager