UCSD CSE 125 - EVENT-DRIVEN PROGRAMMING & BOOST SIGNALS (35 pages)

Previewing pages 1, 2, 16, 17, 18, 34, 35 of 35 page document View the full content.
View Full Document

EVENT-DRIVEN PROGRAMMING & BOOST SIGNALS



Previewing pages 1, 2, 16, 17, 18, 34, 35 of actual document.

View the full content.
View Full Document
View Full Document

EVENT-DRIVEN PROGRAMMING & BOOST SIGNALS

193 views

Other


Pages:
35
School:
University of California, San Diego
Course:
Cse 125 - Software System Design & Implementation
Software System Design & Implementation Documents

Unformatted text preview:

EVENT DRIVEN PROGRAMMING BOOST SIGNALS Alex Goldberg Spring 2008 Signals and Slots Signals and Slots is an event driven programming strategy intended to reduce interdependencies without loss of flexibility Several widely used implementations Boost Signals Qt Signals Slots Boost Boost http boost org is an open source collection of C libraries and header files providing many useful utilities Smart pointers Additional data structures circular buffer etc Powerful iterators Callbacks signals Quaternions Threads Much more Boost Contd Most Boost components are implemented entirely in header files Simply add the few required headers to your project Quite a few Boost components will very likely be added to the next C standard library revision see Technical Report 1 Boost Signals Signals Slots and event driven programming are very powerful techniques but it may not be clear how best to use them Most tutorials are centered around GUI widgets or abstract concepts I ll present a game design example that should give you a good start Let s Blow Stuff Up The goal We re making an action game and want some cool explosions Several occurrences trigger explosions Detonated rockets grenades Exploding barrels Destroyed tanks Etc Lot s of things need to happen when an explosion occurs A fancy explosion particle system must be created A sound must play A crater texture must be applied at the blast site Players near the explosion need to take damage Nearby barrels should explode The Explosion Manager A logical approach might involve a singleton class that notifies the appropriate parties about explosions Let s create an explosion manager class ExplosionMgr Objects that trigger explosions call ExplosionMgr triggerExplosion The manager then calls functions on all the objects that care about explosions ExplosionMgr class ExplosionMgr public Receive an explosion message static void triggerExplosion const Vector3 pos float radius handleExplosion pos radius private Notify others about the



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view EVENT-DRIVEN PROGRAMMING & BOOST SIGNALS and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view EVENT-DRIVEN PROGRAMMING & BOOST SIGNALS and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?