SPROA.CPP
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:23k
源码类别:

Windows编程

开发平台:

Visual C++

  1. //---------------------------------------------------------------------------
  2. // SprOA.cpp
  3. //---------------------------------------------------------------------------
  4. // Sprite handler, OLE Automation support
  5. //---------------------------------------------------------------------------
  6. // (C) Copyright 1992-1997 by Microsoft Corporation.  All rights reserved.
  7. //
  8. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  9. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  10. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  11. // PARTICULAR PURPOSE.
  12. //---------------------------------------------------------------------------
  13. #include "Main.h"
  14. #pragma hdrstop
  15. #include "Spr.h"
  16. #include "DispIDs.h"
  17. #include <math.h>
  18. //---------------------------------------------------------------------------
  19. // DEBUG info
  20. //---------------------------------------------------------------------------
  21. SZTHISFILE
  22. //***************************************************************************
  23. //***************************************************************************
  24. //**
  25. //**  SpriteClass Class
  26. //**
  27. //***************************************************************************
  28. //***************************************************************************
  29. //***************************************************************************
  30. // Fire ISpriteClassEvents Events
  31. //***************************************************************************
  32. //---------------------------------------------------------------------------
  33. // 
  34. //---------------------------------------------------------------------------
  35. void CSpriteClass::FireInit
  36. (
  37.   CSprite *pspr,
  38.   VARIANT *pvarUser
  39. )
  40. {
  41.   IDispatch **ppdisp = m_cp.m_rgpdisp;
  42.   VARIANTARG  var[2];
  43.   VariantInit(&var[1]);
  44.   var[1].vt = VT_DISPATCH;
  45.   var[1].pdispVal = pspr->GetDispatch();
  46.   pspr->AddRef();
  47.   VariantInit(&var[0]);
  48.   VariantCopy(&var[0], pvarUser);
  49.   for (; ppdisp < &m_cp.m_rgpdisp[SC_cADVISE]; ppdisp++)
  50.     if (*ppdisp)
  51.       InvokeEvent(*ppdisp, DISPID_SpriteClassEvents_Init, var, 2);
  52.   pspr->Release();    // For var[1].pdispVal
  53.   VariantClear(&var[0]);
  54. }
  55. //---------------------------------------------------------------------------
  56. // 
  57. //---------------------------------------------------------------------------
  58. void CSpriteClass::FireTick
  59. (
  60.   CSprite *pspr
  61. )
  62. {
  63.   IDispatch **ppdisp = m_cp.m_rgpdisp;
  64.   VARIANTARG  var[1];
  65.   VariantInit(&var[0]);
  66.   var[0].vt = VT_DISPATCH;
  67.   var[0].pdispVal = pspr->GetDispatch();
  68.   pspr->AddRef();
  69.   for (; ppdisp < &m_cp.m_rgpdisp[SC_cADVISE]; ppdisp++)
  70.     if (*ppdisp)
  71.       InvokeEvent(*ppdisp, DISPID_SpriteClassEvents_Tick, var, 1);
  72.   pspr->Release();    // For var[0].pdispVal
  73. }
  74. //---------------------------------------------------------------------------
  75. // 
  76. //---------------------------------------------------------------------------
  77. void CSpriteClass::FireBorder
  78. (
  79.   CSprite *pspr,
  80.   BRD      brd
  81. )
  82. {
  83.   IDispatch **ppdisp = m_cp.m_rgpdisp;
  84.   VARIANTARG  var[2];
  85.   VariantInit(&var[1]);
  86.   var[1].vt = VT_DISPATCH;
  87.   var[1].pdispVal = pspr->GetDispatch();
  88.   pspr->AddRef();
  89.   VariantInit(&var[0]);
  90.   var[0].vt = VT_I4;
  91.   var[0].lVal = brd;
  92.   for (; ppdisp < &m_cp.m_rgpdisp[SC_cADVISE]; ppdisp++)
  93.     if (*ppdisp)
  94.       {
  95.       BOOL f;
  96.       HRESULT hr = InvokeEvent(*ppdisp, DISPID_SpriteClassEvents_Border, var, 2);
  97.       if (hr)
  98.         f = TRUE;
  99.       }
  100.   pspr->Release();    // For var[1].pdispVal
  101. }
  102. //---------------------------------------------------------------------------
  103. // 
  104. //---------------------------------------------------------------------------
  105. void CSpriteClass::FireTerm
  106. (
  107.   CSprite *pspr
  108. )
  109. {
  110.   IDispatch **ppdisp = m_cp.m_rgpdisp;
  111.   VARIANTARG  var[1];
  112.   VariantInit(&var[0]);
  113.   var[0].vt = VT_DISPATCH;
  114.   var[0].pdispVal = pspr->GetDispatch();
  115.   pspr->AddRef();
  116.   for (; ppdisp < &m_cp.m_rgpdisp[SC_cADVISE]; ppdisp++)
  117.     if (*ppdisp)
  118.       InvokeEvent(*ppdisp, DISPID_SpriteClassEvents_Term, var, 1);
  119.   pspr->Release();    // For var[0].pdispVal
  120. }
  121. //---------------------------------------------------------------------------
  122. // 
  123. //---------------------------------------------------------------------------
  124. void CSpriteClass::FireLastTerm
  125. (
  126.   void
  127. )
  128. {
  129.   IDispatch **ppdisp = m_cp.m_rgpdisp;
  130.   for (; ppdisp < &m_cp.m_rgpdisp[SC_cADVISE]; ppdisp++)
  131.     if (*ppdisp)
  132.       InvokeEvent(*ppdisp, DISPID_SpriteClassEvents_LastTerm, NULL, 0);
  133. }
  134. //***************************************************************************
  135. // ISpriteClass Interface
  136. //***************************************************************************
  137. //---------------------------------------------------------------------------
  138. // 
  139. //---------------------------------------------------------------------------
  140. STDMETHODIMP CSpriteClass::get_Application
  141. (
  142.   ISpruuidsApp** ppRet
  143. )
  144. {
  145.   if (!ppRet)
  146.     return E_INVALIDARG;
  147.   return g_punkApplicationNA->QueryInterface(IID_ISpruuidsApp, (void **)ppRet);
  148. }
  149. //---------------------------------------------------------------------------
  150. // 
  151. //---------------------------------------------------------------------------
  152. STDMETHODIMP CSpriteClass::get_Parent
  153. (
  154.   IGame** ppRet
  155. )
  156. {
  157.   if (!ppRet)
  158.     return E_INVALIDARG;
  159.   return m_pdisp->m_punkParent->QueryInterface(IID_IGame, (void **)ppRet);
  160. }
  161. //---------------------------------------------------------------------------
  162. // 
  163. //---------------------------------------------------------------------------
  164. STDMETHODIMP CSpriteClass::CreateSprite
  165. (
  166.   int       x,
  167.   int       y,
  168.   VARIANT   arg,
  169.   ISprite **ppRet
  170. )
  171. {
  172.   CSprite *pspr = new CSprite(this, x, y, NULL, &arg);
  173.   if (!pspr)
  174.     return E_OUTOFMEMORY;
  175.   *ppRet = pspr;
  176.   (*ppRet)->AddRef();
  177.   return S_OK;
  178. }
  179. //---------------------------------------------------------------------------
  180. // 
  181. //---------------------------------------------------------------------------
  182. STDMETHODIMP CSpriteClass::get_Tag
  183. (
  184.   VARIANT* pRet
  185. )
  186. {
  187.   if (!pRet)
  188.     return E_INVALIDARG;
  189.   VariantInit(pRet);
  190.   return VariantCopy(pRet, &m_varTag);
  191. }
  192. //---------------------------------------------------------------------------
  193. // 
  194. //---------------------------------------------------------------------------
  195. STDMETHODIMP CSpriteClass::put_Tag
  196. (
  197.   VARIANT val
  198. )
  199. {
  200.   return VariantCopy(&m_varTag, &val);
  201. }
  202. //---------------------------------------------------------------------------
  203. // 
  204. //---------------------------------------------------------------------------
  205. STDMETHODIMP CSpriteClass::get_Image
  206. (
  207.   int* pRet
  208. )
  209. {
  210.   if (!pRet)
  211.     return E_INVALIDARG;
  212.   *pRet = m_iimg;
  213.   return S_OK;
  214. }
  215. //---------------------------------------------------------------------------
  216. // 
  217. //---------------------------------------------------------------------------
  218. STDMETHODIMP CSpriteClass::put_Image
  219. (
  220.   int val
  221. )
  222. {
  223.   if (val > 0 && val < m_pdisp->m_cimg)
  224.     m_iimg = val;
  225.   return S_OK;
  226. }
  227. //---------------------------------------------------------------------------
  228. // 
  229. //---------------------------------------------------------------------------
  230. STDMETHODIMP CSpriteClass::get_Border
  231. (
  232.   int* pRet
  233. )
  234. {
  235.   if (!pRet)
  236.     return E_INVALIDARG;
  237.   *pRet = m_brd;
  238.   return S_OK;
  239. }
  240. //---------------------------------------------------------------------------
  241. // 
  242. //---------------------------------------------------------------------------
  243. STDMETHODIMP CSpriteClass::put_Border
  244. (
  245.   int val
  246. )
  247. {
  248.   m_brd = val;
  249.   return S_OK;
  250. }
  251. //---------------------------------------------------------------------------
  252. // 
  253. //---------------------------------------------------------------------------
  254. STDMETHODIMP CSpriteClass::get_Collide
  255. (
  256.   int* pRet
  257. )
  258. {
  259.   if (!pRet)
  260.     return E_INVALIDARG;
  261.   *pRet = m_maskCollide;
  262.   return S_OK;
  263. }
  264. //---------------------------------------------------------------------------
  265. // 
  266. //---------------------------------------------------------------------------
  267. STDMETHODIMP CSpriteClass::put_Collide
  268. (
  269.   int val
  270. )
  271. {
  272.   m_maskCollide = val;
  273.   return S_OK;
  274. }
  275. //---------------------------------------------------------------------------
  276. // 
  277. //---------------------------------------------------------------------------
  278. STDMETHODIMP CSpriteClass::get_MaximumVelocity
  279. (
  280.   FLOAT* pRet
  281. )
  282. {
  283.   if (!pRet)
  284.     return E_INVALIDARG;
  285.   *pRet = FLOATOFFULL(m_vFullMax);
  286.   return S_OK;
  287. }
  288. //---------------------------------------------------------------------------
  289. // 
  290. //---------------------------------------------------------------------------
  291. STDMETHODIMP CSpriteClass::put_MaximumVelocity
  292. (
  293.   FLOAT val
  294. )
  295. {
  296.   m_vFullMax = FULLOFFLOAT(val);
  297.   return S_OK;
  298. }
  299. //---------------------------------------------------------------------------
  300. // 
  301. //---------------------------------------------------------------------------
  302. STDMETHODIMP CSpriteClass::get_Friction
  303. (
  304.   FLOAT* pRet
  305. )
  306. {
  307.   if (!pRet)
  308.     return E_INVALIDARG;
  309.   *pRet = m_friction;
  310.   return S_OK;
  311. }
  312. //---------------------------------------------------------------------------
  313. // 
  314. //---------------------------------------------------------------------------
  315. STDMETHODIMP CSpriteClass::put_Friction
  316. (
  317.   FLOAT val
  318. )
  319. {
  320.   m_friction = val;
  321.   return S_OK;
  322. }
  323. //---------------------------------------------------------------------------
  324. // 
  325. //---------------------------------------------------------------------------
  326. STDMETHODIMP CSpriteClass::get_MaximumAcceleration
  327. (
  328.   FLOAT* pRet
  329. )
  330. {
  331.   if (!pRet)
  332.     return E_INVALIDARG;
  333.   *pRet = FLOATOFFULL(m_aFullMax);
  334.   return S_OK;
  335. }
  336. //---------------------------------------------------------------------------
  337. // 
  338. //---------------------------------------------------------------------------
  339. STDMETHODIMP CSpriteClass::put_MaximumAcceleration
  340. (
  341.   FLOAT val
  342. )
  343. {
  344.   m_aFullMax = FULLOFFLOAT(val);
  345.   return S_OK;
  346. }
  347. //---------------------------------------------------------------------------
  348. // 
  349. //---------------------------------------------------------------------------
  350. STDMETHODIMP CSpriteClass::get_AccelerationFriction
  351. (
  352.   FLOAT* pRet
  353. )
  354. {
  355.   if (!pRet)
  356.     return E_INVALIDARG;
  357.   *pRet = m_frictionAccel;
  358.   return S_OK;
  359. }
  360. //---------------------------------------------------------------------------
  361. // 
  362. //---------------------------------------------------------------------------
  363. STDMETHODIMP CSpriteClass::put_AccelerationFriction
  364. (
  365.   FLOAT val
  366. )
  367. {
  368.   m_frictionAccel = val;
  369.   m_fFrictionAccel = (val != (FLOAT)1.0);
  370.   return S_OK;
  371. }
  372. //---------------------------------------------------------------------------
  373. // 
  374. //---------------------------------------------------------------------------
  375. STDMETHODIMP CSpriteClass::get_SpriteCount
  376. (
  377.   int* pRet
  378. )
  379. {
  380.   if (!pRet)
  381.     return E_INVALIDARG;
  382.   *pRet = m_cspr;
  383.   return S_OK;
  384. }
  385. //***************************************************************************
  386. //***************************************************************************
  387. //**
  388. //**  Sprite Class
  389. //**
  390. //***************************************************************************
  391. //***************************************************************************
  392. //***************************************************************************
  393. // ISprite Interface
  394. //***************************************************************************
  395. //---------------------------------------------------------------------------
  396. // 
  397. //---------------------------------------------------------------------------
  398. STDMETHODIMP CSprite::get_Application
  399. (
  400.   ISpruuidsApp** ppRet
  401. )
  402. {
  403.   if (!ppRet)
  404.     return E_INVALIDARG;
  405.   return g_punkApplicationNA->QueryInterface(IID_ISpruuidsApp, (void **)ppRet);
  406. }
  407. //---------------------------------------------------------------------------
  408. // 
  409. //---------------------------------------------------------------------------
  410. STDMETHODIMP CSprite::get_Parent
  411. (
  412.   ISpriteClass** ppRet
  413. )
  414. {
  415.   if (!ppRet)
  416.     return E_INVALIDARG;
  417.   return m_psc->QueryInterface(IID_ISpriteClass, (void **)ppRet);
  418. }
  419. //---------------------------------------------------------------------------
  420. // 
  421. //---------------------------------------------------------------------------
  422. STDMETHODIMP CSprite::MoveTo
  423. (
  424.   FLOAT x,
  425.   FLOAT y
  426. )
  427. {
  428.   this->MoveToFull(FULLOFFLOAT(x), FULLOFFLOAT(y), TRUE);
  429.   return S_OK;
  430. }
  431. //---------------------------------------------------------------------------
  432. // 
  433. //---------------------------------------------------------------------------
  434. STDMETHODIMP CSprite::MoveBy
  435. (
  436.   FLOAT dx,
  437.   FLOAT dy
  438. )
  439. {
  440.   this->MoveByFull(FULLOFFLOAT(dx), FULLOFFLOAT(dy), TRUE);
  441.   return S_OK;
  442. }
  443. //---------------------------------------------------------------------------
  444. //
  445. //---------------------------------------------------------------------------
  446. STDMETHODIMP CSprite::MoveAtSprite
  447. (
  448.   ISprite* sprite,
  449.   float    dMax,
  450.   float    scale,
  451.   long     flags
  452. )
  453. {
  454.   if (!sprite)
  455.     return E_INVALIDARG;
  456.   // Store parameters & do every tickMove ticks if MAS_REMEMBER set.
  457.   if (flags & MAS_REMEMBER)
  458.     {
  459.     if (m_psprAt)
  460.       {
  461.       m_psprAt->Release();
  462.       m_psprAt = NULL;
  463.       }
  464.     m_psprAt = (CSprite *)(void *)sprite;
  465.     if (!m_psprAt)
  466.       return S_OK;
  467.     m_psprAt->AddRef();
  468.     m_dMaxAt = dMax;
  469.     m_scaleAt = scale;
  470.     m_flagsAt = flags;
  471.     return S_OK;
  472.     }
  473.   // Otherwise, do this right now.
  474.   this->DoMoveAt((CSprite *)(void *)sprite, dMax, scale, flags, FALSE);
  475.   return S_OK;
  476. }
  477. //---------------------------------------------------------------------------
  478. // 
  479. //---------------------------------------------------------------------------
  480. STDMETHODIMP CSprite::Remove
  481. (
  482.   void 
  483. )
  484. {
  485.   this->MarkFree();
  486.   return S_OK;
  487. }
  488. //---------------------------------------------------------------------------
  489. // 
  490. //---------------------------------------------------------------------------
  491. STDMETHODIMP CSprite::Refresh
  492. (
  493.   void 
  494. )
  495. {
  496.   this->_FDraw(FALSE);
  497.   return S_OK;
  498. }
  499. //---------------------------------------------------------------------------
  500. // 
  501. //---------------------------------------------------------------------------
  502. STDMETHODIMP CSprite::IgnoreMove
  503. (
  504.   void 
  505. )
  506. {
  507.   m_fIgnoreMove = TRUE;
  508.   return S_OK;
  509. }
  510. //---------------------------------------------------------------------------
  511. // 
  512. //---------------------------------------------------------------------------
  513. STDMETHODIMP CSprite::get_Left
  514. (
  515.   FLOAT* pRet
  516. )
  517. {
  518.   if (!pRet)
  519.     return E_INVALIDARG;
  520.   *pRet = FLOATOFFULL(m_xFull);
  521.   return S_OK;
  522. }
  523. //---------------------------------------------------------------------------
  524. // 
  525. //---------------------------------------------------------------------------
  526. STDMETHODIMP CSprite::put_Left
  527. (
  528.   FLOAT val
  529. )
  530. {
  531.   m_xFull = FULLOFFLOAT(val);
  532.   return S_OK;
  533. }
  534. //---------------------------------------------------------------------------
  535. // 
  536. //---------------------------------------------------------------------------
  537. STDMETHODIMP CSprite::get_Top
  538. (
  539.   FLOAT* pRet
  540. )
  541. {
  542.   if (!pRet)
  543.     return E_INVALIDARG;
  544.   *pRet = FLOATOFFULL(m_yFull);
  545.   return S_OK;
  546. }
  547. //---------------------------------------------------------------------------
  548. // 
  549. //---------------------------------------------------------------------------
  550. STDMETHODIMP CSprite::put_Top
  551. (
  552.   FLOAT val
  553. )
  554. {
  555.   m_yFull = FULLOFFLOAT(val);
  556.   return S_OK;
  557. }
  558. //---------------------------------------------------------------------------
  559. // 
  560. //---------------------------------------------------------------------------
  561. STDMETHODIMP CSprite::get_Vx
  562. (
  563.   FLOAT* pRet
  564. )
  565. {
  566.   if (!pRet)
  567.     return E_INVALIDARG;
  568.   *pRet = FLOATOFFULL(m_vxFull);
  569.   return S_OK;
  570. }
  571. //---------------------------------------------------------------------------
  572. // 
  573. //---------------------------------------------------------------------------
  574. STDMETHODIMP CSprite::put_Vx
  575. (
  576.   FLOAT val
  577. )
  578. {
  579.   m_vxFull = FULLOFFLOAT(val);
  580.   return S_OK;
  581. }
  582. //---------------------------------------------------------------------------
  583. // 
  584. //---------------------------------------------------------------------------
  585. STDMETHODIMP CSprite::get_Vy
  586. (
  587.   FLOAT* pRet
  588. )
  589. {
  590.   if (!pRet)
  591.     return E_INVALIDARG;
  592.   *pRet = FLOATOFFULL(m_vyFull);
  593.   return S_OK;
  594. }
  595. //---------------------------------------------------------------------------
  596. // 
  597. //---------------------------------------------------------------------------
  598. STDMETHODIMP CSprite::put_Vy
  599. (
  600.   FLOAT val
  601. )
  602. {
  603.   m_vyFull = FULLOFFLOAT(val);
  604.   return S_OK;
  605. }
  606. //---------------------------------------------------------------------------
  607. // 
  608. //---------------------------------------------------------------------------
  609. STDMETHODIMP CSprite::get_Ax
  610. (
  611.   FLOAT* pRet
  612. )
  613. {
  614.   if (!pRet)
  615.     return E_INVALIDARG;
  616.   *pRet = FLOATOFFULL(m_axFull);
  617.   return S_OK;
  618. }
  619. //---------------------------------------------------------------------------
  620. // 
  621. //---------------------------------------------------------------------------
  622. STDMETHODIMP CSprite::put_Ax
  623. (
  624.   FLOAT val
  625. )
  626. {
  627.   m_axFull = FULLOFFLOAT(val);
  628.   return S_OK;
  629. }
  630. //---------------------------------------------------------------------------
  631. // 
  632. //---------------------------------------------------------------------------
  633. STDMETHODIMP CSprite::get_Ay
  634. (
  635.   FLOAT* pRet
  636. )
  637. {
  638.   if (!pRet)
  639.     return E_INVALIDARG;
  640.   *pRet = FLOATOFFULL(m_ayFull);
  641.   return S_OK;
  642. }
  643. //---------------------------------------------------------------------------
  644. // 
  645. //---------------------------------------------------------------------------
  646. STDMETHODIMP CSprite::put_Ay
  647. (
  648.   FLOAT val
  649. )
  650. {
  651.   m_ayFull = FULLOFFLOAT(val);
  652.   return S_OK;
  653. }
  654. //---------------------------------------------------------------------------
  655. // 
  656. //---------------------------------------------------------------------------
  657. STDMETHODIMP CSprite::get_FrictionX
  658. (
  659.   FLOAT* pRet
  660. )
  661. {
  662.   if (!pRet)
  663.     return E_INVALIDARG;
  664.   *pRet = m_fx;
  665.   return S_OK;
  666. }
  667. //---------------------------------------------------------------------------
  668. // 
  669. //---------------------------------------------------------------------------
  670. STDMETHODIMP CSprite::put_FrictionX
  671. (
  672.   FLOAT val
  673. )
  674. {
  675.   m_fx = val;
  676.   m_fFriction = (m_fx != 1.0) || (m_fy != 1.0);
  677.   return S_OK;
  678. }
  679. //---------------------------------------------------------------------------
  680. // 
  681. //---------------------------------------------------------------------------
  682. STDMETHODIMP CSprite::get_FrictionY
  683. (
  684.   FLOAT* pRet
  685. )
  686. {
  687.   if (!pRet)
  688.     return E_INVALIDARG;
  689.   *pRet = m_fy;
  690.   return S_OK;
  691. }
  692. //---------------------------------------------------------------------------
  693. // 
  694. //---------------------------------------------------------------------------
  695. STDMETHODIMP CSprite::put_FrictionY
  696. (
  697.   FLOAT val
  698. )
  699. {
  700.   m_fy = val;
  701.   m_fFriction = (m_fx != 1.0) || (m_fy != 1.0);
  702.   return S_OK;
  703. }
  704. //---------------------------------------------------------------------------
  705. // 
  706. //---------------------------------------------------------------------------
  707. STDMETHODIMP CSprite::get_Width
  708. (
  709.   int* pRet
  710. )
  711. {
  712.   if (!pRet)
  713.     return E_INVALIDARG;
  714.   *pRet = m_pimg->cx;
  715.   return S_OK;
  716. }
  717. //---------------------------------------------------------------------------
  718. // 
  719. //---------------------------------------------------------------------------
  720. STDMETHODIMP CSprite::get_Height
  721. (
  722.   int* pRet
  723. )
  724. {
  725.   if (!pRet)
  726.     return E_INVALIDARG;
  727.   *pRet = m_pimg->cy;
  728.   return S_OK;
  729. }
  730. //---------------------------------------------------------------------------
  731. // 
  732. //---------------------------------------------------------------------------
  733. STDMETHODIMP CSprite::get_Image
  734. (
  735.   int* pRet
  736. )
  737. {
  738.   if (!pRet)
  739.     return E_INVALIDARG;
  740.   *pRet = m_iimg;
  741.   return S_OK;
  742. }
  743. //---------------------------------------------------------------------------
  744. // 
  745. //---------------------------------------------------------------------------
  746. STDMETHODIMP CSprite::put_Image
  747. (
  748.   int val
  749. )
  750. {
  751.   if (val >= 0 && val < m_pdisp->m_cimg)
  752.     {
  753.     PIMG pimgCur = m_pimg;
  754.     if (!m_fHidden)
  755.       this->_Erase();
  756.     m_iimg = val;
  757.     m_pimg = &(m_pdisp->m_prgimg[m_iimg]);
  758.     // Keep image centered, if Visible
  759.     if (!m_fHidden)
  760.       {
  761.       m_x += (pimgCur->cx - m_pimg->cx) >> 1;
  762.       m_y += (pimgCur->cy - m_pimg->cy) >> 1;
  763.       this->_FDraw(FALSE);
  764.       }
  765.     }
  766.   return S_OK;
  767. }
  768. //---------------------------------------------------------------------------
  769. // 
  770. //---------------------------------------------------------------------------
  771. STDMETHODIMP CSprite::get_TickMove
  772. (
  773.   int* pRet
  774. )
  775. {
  776.   if (!pRet)
  777.     return E_INVALIDARG;
  778.   *pRet = m_tickMoveMax;
  779.   return S_OK;
  780. }
  781. //---------------------------------------------------------------------------
  782. // 
  783. //---------------------------------------------------------------------------
  784. STDMETHODIMP CSprite::put_TickMove
  785. (
  786.   int val
  787. )
  788. {
  789.   m_tickMoveMax = val;
  790.   if (m_tickMove > m_tickMoveMax)
  791.     m_tickMove = m_tickMoveMax;
  792.   return S_OK;
  793. }
  794. //---------------------------------------------------------------------------
  795. // 
  796. //---------------------------------------------------------------------------
  797. STDMETHODIMP CSprite::get_TickEvent
  798. (
  799.   int* pRet
  800. )
  801. {
  802.   if (!pRet)
  803.     return E_INVALIDARG;
  804.   *pRet = m_tickEvtMax;
  805.   return S_OK;
  806. }
  807. //---------------------------------------------------------------------------
  808. // 
  809. //---------------------------------------------------------------------------
  810. STDMETHODIMP CSprite::put_TickEvent
  811. (
  812.   int val
  813. )
  814. {
  815.   m_tickEvtMax = val;
  816.   if (m_tickEvt > m_tickEvtMax)
  817.     m_tickEvt = m_tickEvtMax;
  818.   return S_OK;
  819. }
  820. //---------------------------------------------------------------------------
  821. // 
  822. //---------------------------------------------------------------------------
  823. STDMETHODIMP CSprite::get_Visible
  824. (
  825.   VARIANT_BOOL* pRet
  826. )
  827. {
  828.   if (!pRet)
  829.     return E_INVALIDARG;
  830.   *pRet = m_fHidden ? 0 : -1;
  831.   return S_OK;
  832. }
  833. //---------------------------------------------------------------------------
  834. // 
  835. //---------------------------------------------------------------------------
  836. STDMETHODIMP CSprite::put_Visible
  837. (
  838.   VARIANT_BOOL val
  839. )
  840. {
  841.   if (m_fLinked)
  842.     {
  843.     m_fHidden = !val;
  844.     if (!m_fHidden)
  845.       this->_Erase();
  846.     else
  847.       this->_FDraw(FALSE);
  848.     }
  849.   return S_OK;
  850. }
  851. //---------------------------------------------------------------------------
  852. // 
  853. //---------------------------------------------------------------------------
  854. STDMETHODIMP CSprite::get_Tag
  855. (
  856.   VARIANT* pRet
  857. )
  858. {
  859.   if (!pRet)
  860.     return E_INVALIDARG;
  861.   VariantInit(pRet);
  862.   return VariantCopy(pRet, &m_varTag);
  863. }
  864. //---------------------------------------------------------------------------
  865. // 
  866. //---------------------------------------------------------------------------
  867. STDMETHODIMP CSprite::put_Tag
  868. (
  869.   VARIANT val
  870. )
  871. {
  872.   return VariantCopy(&m_varTag, &val);
  873. }
  874. //--- EOF -------------------------------------------------------------------