Khaotic Engine Reborn
Loading...
Searching...
No Matches
sprite_class Class Reference

Public Member Functions

 sprite_class (const sprite_class &)
 
bool Initialize (ID3D11Device *, ID3D11DeviceContext *, int, int, char *, int, int)
 
void Shutdown ()
 
bool Render (ID3D11DeviceContext *)
 
void Update (float)
 
int GetIndexCount ()
 
ID3D11ShaderResourceView * GetTexture ()
 
void SetRenderLocation (int, int)
 

Detailed Description

Definition at line 22 of file sprite_class.h.

Constructor & Destructor Documentation

◆ sprite_class() [1/2]

sprite_class::sprite_class ( )

Definition at line 4 of file sprite_class.cpp.

5{
6 m_vertexBuffer = 0;
7 m_indexBuffer = 0;
8 m_Textures = 0;
9}

◆ sprite_class() [2/2]

sprite_class::sprite_class ( const sprite_class & other)

Definition at line 12 of file sprite_class.cpp.

13{
14}

◆ ~sprite_class()

sprite_class::~sprite_class ( )

Definition at line 17 of file sprite_class.cpp.

18{
19}

Member Function Documentation

◆ GetIndexCount()

int sprite_class::GetIndexCount ( )

Definition at line 109 of file sprite_class.cpp.

110{
111 return m_indexCount;
112}

◆ GetTexture()

ID3D11ShaderResourceView * sprite_class::GetTexture ( )

Definition at line 114 of file sprite_class.cpp.

115{
116 return m_Textures[m_currentTexture].GetTexture();
117}

◆ Initialize()

bool sprite_class::Initialize ( ID3D11Device * device,
ID3D11DeviceContext * deviceContext,
int screenWidth,
int screenHeight,
char * spriteFilename,
int renderX,
int renderY )

Definition at line 21 of file sprite_class.cpp.

22{
23 bool result;
24
25
26 // Store the screen size.
27 m_screenWidth = screenWidth;
28 m_screenHeight = screenHeight;
29
30 // Store where the sprite should be rendered to.
31 m_renderX = renderX;
32 m_renderY = renderY;
33
34 // Initialize the frame time for this sprite object.
35 m_frameTime = 0;
36
37 // Initialize the vertex and index buffer that hold the geometry for the sprite bitmap.
38 result = InitializeBuffers(device);
39 if (!result)
40 {
41 return false;
42 }
43
44 // Load the textures for this sprite.
45 result = LoadTextures(device, deviceContext, spriteFilename);
46 if (!result)
47 {
48 return false;
49 }
50
51 return true;
52}

◆ Render()

bool sprite_class::Render ( ID3D11DeviceContext * deviceContext)

Definition at line 67 of file sprite_class.cpp.

68{
69 bool result;
70
71
72 // Update the buffers if the position of the sprite has changed from its original position.
73 result = UpdateBuffers(deviceContext);
74 if (!result)
75 {
76 return false;
77 }
78
79 // Put the vertex and index buffers on the graphics pipeline to prepare them for drawing.
80 RenderBuffers(deviceContext);
81
82 return true;
83}

◆ SetRenderLocation()

void sprite_class::SetRenderLocation ( int x,
int y )

Definition at line 416 of file sprite_class.cpp.

417{
418 m_renderX = x;
419 m_renderY = y;
420 return;
421}

◆ Shutdown()

void sprite_class::Shutdown ( )

Definition at line 55 of file sprite_class.cpp.

56{
57 // Release the textures used for this sprite.
58 ReleaseTextures();
59
60 // Release the vertex and index buffers.
61 ShutdownBuffers();
62
63 return;
64}

◆ Update()

void sprite_class::Update ( float frameTime)

Definition at line 85 of file sprite_class.cpp.

86{
87 // Increment the frame time each frame.
88 m_frameTime += frameTime;
89
90 // Check if the frame time has reached the cycle time.
91 if (m_frameTime >= m_cycleTime)
92 {
93 // If it has then reset the frame time and cycle to the next sprite in the texture array.
94 m_frameTime -= m_cycleTime;
95
96 m_currentTexture++;
97
98 // If we are at the last sprite texture then go back to the beginning of the texture array to the first texture again.
99 if (m_currentTexture == m_textureCount)
100 {
101 m_currentTexture = 0;
102 }
103 }
104
105 return;
106}

The documentation for this class was generated from the following files: