Object oriented Game Development -P8

Object oriented Game Development -P8: 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. | 196 Object-oriented game development nism mentioned above but by having a class rather than a function pointer we can carry state information about on a per-object basis. The loader also has an interface for loading the resource. Once we have a file in memory the data are raw - we have to turn them into something useful a process I call instantiation. Then we typically do something with them. Then we optionally get rid of them. We can think of the lifecycle of a resource as the simple state machine shown in Figure . A resource starts off in a bundle. When the load request comes in it starts loading and is in the Loading state. When loading completes the resource is either in its raw data form or compressed if the latter it gets decompressed and is now in the Raw state. Then the resource is instantiated. This need not occur immediately - some resource types can stay raw until they re needed. At this point the data can be optionally put into a Locked state they cannot be disposed of until they are unlocked. The resource is then Active and considered usable after some time the asset may be disposed of. This state management is handled within the DMGD component see Figure . Now loading a resource can be a time-consuming process. If we get several loads completing on the same frame a whole series of call-backs will be initiated and we could find a drop in performance. One strategy to avoid this is to make the file server aware of how quickly the game is running and scale the number of call-backs it initiates in a frame by that const int MAX_CALLBACKS_60FPS 8 void FileServer Update Time aDeltaT . int iNumCallbacks MAX_CALLBACKS_60FPS Time aDeltaT if iNumCallbacks MAX_CALLBACKS_60FPS iNumCallbacks MAX_CALLBACKS_60FPS Figure State diagram showing the lifecycle of a resource. The component model for game development 197 Figure DEMIGOD and the file server component diagrams. The ResourceManager class drives the show. It is a templated class you

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
32    83    2    21-05-2024
12    246    1    21-05-2024
Đã 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.