Time for action – building a new Sprite class
Add a new class called
Sprite
to the Robot Rampage project.Add declarations to the
Sprite
class:#Region "Declarations" Public Texture As Texture2D Private _frames As List(Of Rectangle) = new List(Of Rectangle)() Private _currentFrame As Integer Private _frameTime As Single = 0.1 Private _timeForCurrentFrame As Single = 0.0 Private _rotation as Single = 0.0 #End Region
Add position-related properties to the
Sprite
class:#Region "Positional Properties" Public Property WorldLocation as Vector2 = Vector2.Zero Public Property Velocity as Vector2 = Vector2.Zero Public ReadOnly Property ScreenLocation As Vector2 Get Return Camera.Transform(WorldLocation) End Get End Property Public ReadOnly Property WorldRectangle as Rectangle Get return new Rectangle( CInt(Int(WorldLocation.X)), CInt(Int(WorldLocation.Y)), FrameWidth, FrameHeight) End Get End Property Public ReadOnly Property ScreenRectangle As Rectangle ...