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 |
class GObject { protected : const BYTE * m_pcodedata; WORD m_address; WORD m_count; public : enum { GO_SetData=1, GO_Draw, GO_DrawS, GO_DrawR, GO_DrawSR, GO_SetDrawMode, GO_Goto, GO_RandomJump, GO_FrameEnd, GO_End, GO_SetCount, GO_IncCount, GO_CountJump, GO_DrawVH, GO_DrawVY, GO_DrawCombo, GO_DrawLine, }; //그리기코드 명령어 목록 GObject(); ~GObject(); bool IsEmpty(); void Init( const BYTE * codedata); void Jump( WORD address); void End(); int Proc( const GSprites* sprs, POINT offset, POINT* data, int vdata); }; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
void GObject::Init( const BYTE * codedata) { m_pcodedata=codedata; } void GObject::Jump( WORD address) { m_address=address; } bool GObject::IsEmpty() { return m_pcodedata==NULL; } void GObject::End() { m_pcodedata=NULL; } |
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 |
int GObject::Proc( const GSprites* sprs, POINT offset, POINT* data, int vdata) { if (!m_pcodedata) return -1; while (1) { switch (m_pcodedata[m_address++]) //첫 바이트를 읽어 명령어 종류를 파악하고 { ... case GO_Draw: { WORD index=*( WORD *)(m_pcodedata+m_address); m_address+=2; short x=*( short *)(m_pcodedata+m_address); m_address+=2; short y=*( short *)(m_pcodedata+m_address); m_address+=2; DWORD color=*( DWORD *)(m_pcodedata+m_address); m_address+=4; //인자를 읽어들이고, if (sprs) sprs->DrawSprite(index, x+offset.x, y+offset.y, color); //그리기를 수행한다. } break ; case GO_DrawS: { WORD index=*( WORD *)(m_pcodedata+m_address); m_address+=2; short x=*( short *)(m_pcodedata+m_address); m_address+=2; short y=*( short *)(m_pcodedata+m_address); m_address+=2; float sx=*( float *)(m_pcodedata+m_address); m_address+=4; float sy=*( float *)(m_pcodedata+m_address); m_address+=4; DWORD color=*( DWORD *)(m_pcodedata+m_address); m_address+=4; if (sprs) sprs->DrawSprite(index, x+offset.x, y+offset.y, sx, sy, color); } break ; case GO_DrawR: { WORD index=*( WORD *)(m_pcodedata+m_address); m_address+=2; short x=*( short *)(m_pcodedata+m_address); m_address+=2; short y=*( short *)(m_pcodedata+m_address); m_address+=2; float rot=*( float *)(m_pcodedata+m_address); m_address+=4; DWORD color=*( DWORD *)(m_pcodedata+m_address); m_address+=4; if (sprs) sprs->DrawSprite(index, x+offset.x, y+offset.y, rot, color); } break ; case GO_Goto: { WORD address=*( WORD *)(m_pcodedata+m_address); m_address=address; } break ; case GO_FrameEnd: return 0; case GO_End: End(); return 1; ... } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
void MPlayGame::OnCreate() { m_obj.Init(&m_codedata[0]); m_obj.Jump(Event_Foo*3); m_obj2.Init(&m_codedata[0]); m_obj2.Jump(Event_Bar*3); } void MPlayGame::OnDraw() { POINT offset={100, 100}; m_obj.Proc(&m_sprs, offset, NULL, 0); POINT offset2={300, 100}; m_obj2.Proc(&m_sprs, offset2, NULL, 0); } |
리듬게임을 만들어보자 9. 그림 글자를 그려보자. (5) | 2010.01.05 |
---|---|
리듬게임을 만들어보자 7. 로직과 디자인을 분리하자1 (0) | 2009.12.06 |
리듬게임을 만들어보자 6. 직선, 사각형 그리기 (1) | 2009.11.29 |
리듬게임을 만들어보자 5. 경우별로 나눠서 관리하기 (2) | 2009.11.26 |
리듬게임을 만들어보자 4. 행렬변환을 통한 회전, 확대/축소 (0) | 2009.11.24 |
리듬게임을 만들어보자 3. 다양한 그리기 효과 (3) | 2009.11.22 |
댓글 영역