Download Paper
Transcript
3.10 Special types iterations is determined at the starting point of the loop and cannot be increased or decreased. 3.9.5.4 foreach For built-in collection types (see Section 3.8) there is support for foreach loops (foreach iterator in collection where...[,where...]) with collection iterators. According to our results from reverse engineering, the foreach loop can have only a single where guard, which contains an additional criterion that are imposed on every iterated collection item. The recently published alternative language specification (Horspool et al. [March, 2012]) indicates support for multiple where keywords in the latest version. These conditions are executed in a lazy way: as long as a certain condition returns false, the iterator automatically moves to the next item in the collection without evaluating the remaining conditions. For collection iterators it is possible to modify the properties of collection items if the items support it. The collection itself cannot be modified within the loop body: doing so would result in an error message. 3.10 Special types To support easy script authoring and sharing by hobby developers TouchDevelop provides several types with simple API and hidden implementation details. GameBoard allows user to implement 2D board games with smooth animation without manual redrawing of every single frame. Wall servers as a substitute for system console as regards basic input and output operations. 3.10.1 Game Board GameBoard is a special feature-rich, instantiatable type in TouchDevelop, which provides APIs useful for 2D game development. The properties of the GameBoard type can be classified in the following groups: 1. Board API represents the properties necessary for creating GameBoard and SpriteSet objects and iterators over SpriteSet collections associated with the board variable. An important part of the Board API are the board events: tapping, swiping, and dragging. These events can be resolved at the board level (if there is no internal object at the screen position where the event took place) or directly at the sprite level. Therefore, every sprite within the SpriteSet can be seen as having its own events with a unified event handler on the board level. 2. Sprite and SpriteSet API contains the functionality to output and manipulate a sprite’s position, color, and rotation angle. 3. Physics Engine API is useful to implement games simulating real-world physics. GameBoard provides the methods for adding obstacles and walls with different elasticity along with the methods for setting gravity and friction of the medium. The position of single sprites is automatically calculated on every next step using a 57