Thursday 26 February 2009

Flash game production

Taking some key features from ping-pong, notably the walls, I set about creating a make-shift maze. 



This sample here goes on the principle that a right button push will move the ball 5 pixels to the right if it isn't not touching the right wall. The same is repeated for up, down and left. Note that I only have one type of left wall, one right etc.

Multiple 'left' walls will not acknowledge the ball, meaning it passes straight through. To tackle this would require having several walls all with their own unique instance names and respective line of code. In all, this would mean having a stream of largely repetitive code, and as this is advanced Flash, I am looking to implement short but succint code. 

Not wishing for unnecessary, lengthy code, I had to try another solution. After hours of searching online, I was presented with the option of swapping hitTestObject with hitTestPoint and setting the shape flag to true. This would mean that it is the actual shape that detects a hit, rather than a border surrounding the entire shape. I will use one shape that is construed into warying different angles and shapes.

Unfortunately, I met with problems again. As soon as I hit any part of the shape,  the coding stops keyboard presses being recognised, the key actions became locked. I have tackled this by making it so should the ball hit the wall, it rebounds it by 5 pixels, thereby allowing key presses afterwards.



I can already see improvements are needed. The pixel differences mean that the ball can intersect a little with the wall. This will need to be adjusted and is not difficult.

Furthermore, I am now going to need to focus on implementing a countdown clock, whilst adding in bonus score points. Most important will be the end of level point.

@

No comments: