140 likes | 269 Views
GTECH 731 Lab Session 10 11/2/10. Lab 9 – ArcObjects Pseudo-code Example. Lab 9 – ArcObjects. Questions?. Designing Your Project. Have programming project in mind with geographic aspect Agent model More extensive drawing package Raster image manipulation
E N D
GTECH 731Lab Session 10 11/2/10 Lab 9 – ArcObjects Pseudo-code Example
Lab 9 – ArcObjects • Questions?
Designing Your Project • Have programming project in mind with geographic aspect • Agent model • More extensive drawing package • Raster image manipulation • First step might be to visualize or imagine what you want to see happen on the screen • What happens when button “X” is clicked? • What happens when the mouse moves over object in scene? • What happens if mouse is clicked in image? • Describe, using plain language, what happens when you use your program • Then outline of steps needed to make your vision happen • Keep it abstract – don’t focus on minute programming steps • Map out high level, abstract steps to accomplish your goal
Example – Nautical Navigation Game • A player guides a ship from a “Home Port” to a “Destination Port” while avoiding being pulled into a “Whirlpool”
What is the Functionality of the Game • Click mouse to create “puff of wind” to “blow” the ship • Wind comes from click point and moves out in all directions • Ship moves in opposite direction or away from mouse click position • “Power” of wind is inversely proportional to distance of click point to ship • Whirlpool has “attractive power” pulling ship into the center • Power is inversely proportional to whirlpool distance to ship • Ship is “docked” at a port until clicks of “wind” move it away so that it no longer touches the port • When the ship is not “docked”, theWhirlpool pulls it to the center • Can move ship back and forth from port to port • Game ends when ship is pulled into whirlpool • Click “Restart Button”
What are the basic steps for this or any game? • Setup the Game • Play the Game • End the Game
Basic Steps Broken Down • Setup the Game • Build the Scene • Add Home Port • Add Destination Port • Add Whirlpool • Add Ship • Play the Game (based on events) • When mouse is clicked • If ship not stuck in whirlpool • Move ship away from mouse click position • Else • Restart game • At each time step • If ship is not docked and ship not stuck in whirlpool • Move ship toward whirlpool center • End the Game • Close program with click of “X” in upper right corner of window
Outline Gives Clues to Coding Requirements • Setup the Game • Build the Scene • Add Home Port • Add Destination Port • Add Whirlpool • Add Ship • Play the Game • When mouse is clicked • If ship not stuck in whirlpool • Move ship away from mouse position • Else • Restart game • At each time step • If ship is not docked and ship not stuck • Move ship toward whirlpool • End the Game • Program closes with click of “X” in upper right corner of window Port Object Port Object Whirlpool Object Ship Object MouseUp Event Handler Boolean Variable “stuck”: interaction with Whirlpool Ship Object “Move” Method Rebuild the Scene Clock Tick Event Handler Boolean variables Stuck, Docked: interact Whirlpool Ports Ship Object “Move” Method Ship object interacts with Whirlpool object
Outline Suggests Other Requirements • Setup the Game • Build the Scene • Add Home Port • Add Destination Port • Add Whirlpool • Add Ship • Draw the Scene • Play the Game • When mouse is clicked • If ship not stuck • Move ship away from mouse position • Check to see if ship docked • Redraw the Scene • Else • Restart game • At each time step • If ship is not docked and ship not stuck • Move ship toward whirlpool • Redraw the Scene • End the Game • Program closes with click of “X” in upper right corner of window
More Detailed Requirements • Setup the Game • Build the Scene • Add Home Port • Create Port Class (may need initial information such as location relative to scene) • Information about size and position • Geometric object (Polygon) • Draw method • Add Destination Port • Ditto above(with different initial information such as location relative to scene) • Add Whirlpool • Create Whirlpool Class(may need initial information such as location and size relative to scene) • Information about attractive force and size • Geometric object (Point) • Draw method ?
More Detailed Requirements • Add Ship • Create Ship Class(may need initial information such as direction and location relative to scene) • Information about travel direction and current position • Geometric object (Polygon) • Draw method • Move method (one for Wind and one for Whirlpool?) • Draw the Scene • Draw Home Port • Use Draw method • Draw Destination Port • Use Draw method • Draw Whirlpool • Use Draw method • Draw Ship • Use Draw method
More Detailed Requirements • Play the Game • When mouse is clicked • If ship not stuck • Move ship away from mouse position • Calculate distance and direction from “wind” position to ship position • Move Ship according to direction and distance of mouse click to ship • Change Ship direction according to direction and distance of mouse click to ship • Check to see if ship docked • If Ship object overlaps Port object • Ship becomes docked • Redraw the Scene (as above) • Else • Restart game
More Detailed Requirements • At each time step • If ship is not docked (ship stuck condition moved below ) • If Ship object overlaps buffer around Whirlpool center • Ship becomes stuck • If ship not stuck • Move ship toward whirlpool • Calculate distance and direction from Whirlpool to ship • Move Ship according to direction and distance to Whirlpool • Redraw the Scene (as above)