This week added some hit detection methods to the SnapActor class:
This makes it possible to determine whether a given actor overlaps (or “hit”) another actor and will be useful for most games. Additionally, we updated the KeyDown and KeyClicked functionality to handle multiple down/clicked keys at once – because it turns out that real gameplay often involves this (head-smack).
Early next week I’ll release our test case – a JavaFX/SnapCode version of asteroids. Below is the full list of improvements made to SnapCode this week.
– SnapActor: Added getIntersectingActor/getIntersectingActors
– SnapActor: Added getActorsInRange
– SnapScene: Fixed KeyDown to be a Set of KeyCodes instead of just one
– SnapActor: Fixed to have X/Y be at center of actor
– SnapAnimator: Fixed to animate X/Y instead of LayoutX/Y
– SnapAnimator: Added moveTo()
– SnapScene: Made default scene have main() and act() methods
– SnapPartStmt: Fixed dropNode on bottom of block statement
– SnapActor: Fixed setWidth/setHeight to preserve x/y
– SnapActor: Added getDistance(actor)
– SnapScene: Added removeActor()
– SnapScene: Made playSound() check /sounds directory
– SnapScene, SnapActor: Renamed MousePressed/KeyPressed methods to be MouseDown/KeyDown.