Object oriented Game Development -P12

Object oriented Game Development -P12: There’s a better than 50% chance that you have picked this title off the shelf in a bookshop and are wondering if it’s going to be another one of those ‘secrets of the inner circle’ type of titles. You know, the ones that promise to tell you unspoken truths on how to write really cool games but in reality offer up a rehash of a manual you may already have for free anyway. | 316 Object-oriented game development Texture GetBulletHoleTexture void Apply GameObject const pObject static char const CLASS_NAME private struct Mark float u float v float fSize std vector Mark m_Marks We choose to use one tag to hold all the bullet marks for an object as opposed to creating a new tag for each mark. This is - probably - a bit more memory-efficient considering how std vector is usually implemented. char const DamageTagBulletHole CLASS_NAME bullet_hole DamageTagBulletHole DamageTagBulletHole DamageTag CLASS_NAME void DamageTagBulletHole AddMark float u float v float fSize Mark aMark u v fSize aMark virtual void DamageTagBulletHole Apply GameObject pObject for int j 0 j j Game objects 317 Mark const aMark m_Marks j float u float v float s pObject- AddDecal u v s s GetBulletHoleTexture When a piece of scenery gets hit by a bullet we add a bullet hole virtual DamageTag Scenery CreateDamageTag return new DamageTagBulletHole virtual void Scenery OnHit Bullet pBullet Kill the bullet add particles make noise GenericBulletStuff pBullet Does a bullet hole tag exist DamageTagBulletHole pTag pTag DamageTagBulletHole GetDamageTag if pTag 0 If not create one. pTag DamageTagBulletHole CreateDamageTag SetDamageTag pTag Work out hole texture coords and size from bullet position and add the mark. float u v fSize Texture pTexture pTag- GetBulletHoleTexture GetBulletHoleTextureData pBullet u v fSize Note that we don t want to add all the existing 318 Object-oriented game development bullet holes multiple times by calling Apply or incur the overhead of removing them all then re adding them so we just add the new bullet hole to the object and adjust the book- keeping. pTag- AddMark u v fSize AddDecal u v fSize fSize pTexture In real life we d probably cap the number of bullet holes that an object can have removing the oldest hole when adding a new one if we re full up. We might also .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.