Forum to discuss articles which have been published in Matrix Multimedia's article zone. If you have any comments or questions regarding the articles please post them here.
2 posts • Page 1 of 1
The Matrix EB-043 Graphical Colour LCD board provides the user with a screen consisting of 128 x 128 individually addressable pixels, each of which can be set to any one of 256 colours. Communications with the display requires only 4 signal lines.
The availability of colour and graphical capabilities allows system data to be represented in a wide range of formats, including simple animations.
As with most technologies, one of the best ways to demonstrate the capabilities is with a game. This example is a colour version of one the simple, 2-player, bat & ball style games from the 1970s.
This program demonstrates the use of the Flowcode gLCD component line, box, text, and colour control functions to draw the playing surface, animate the bats and ball, and display the scores.
The game currently uses a 5 x 5 pixel resolution for the movement of the bats and ball. The trajectory of the ball is calculated using simple, straight-line geometry and integer maths. The horizontal velocity of the ball remains constant (1 block per cycle) and the trajectory is controlled by adjusting the vertical velocity.
At the start of each game the ball is launched towards the red bat after a 2 second delay. The ball will rebound off the edges of the playing area and the bats. The edges are flat surfaces but the bats act like convex surfaces and will change the rebound angle unless hit in the middle.A point is scored if the ball is at either end of the playing area and the appropriate bat is not correctly positioned to rebound it into play. The microcontroller's decision is final!
The program is set up with the EB-043 connected to Port C and the control switches connected to Port B. This allows the game to be run on most target hardware, including the HP-488 Development Board.
Blue bat: RB7 = UP RB6 = DOWN
Red bat: RB1 = UP RB0 = DOWN
Any of the port settings can be changed if other system configurations are wanted.
The code uses approximately 40% of the available program and data memory of a PIC16F877A, and included a 100ms delay in each cycle of the program, so there are resources available to improve the game play
Β· Split the control buttons onto two ports and provide each player with an EB-007 Switches Board to use as a controller.
Β· Randomise the side and trajectory of the ball launch at the start of the game.
Β· Randomise the trajectory of the ball and select the appropriate launch side after each point is scored.
Β· Improve the resolution of the ball motion (it currently uses the same 5 x 5 pixel resolution as the bats).
Β· Program the microcontroller to control one of the bats.
There are a large number of alternative games that could be developed using the EB-043. Strategy games, making even more use of the colour and graphic capabilities, would be particularly suitable.
- Bat game.fcf
- (29.49 KiB) Downloaded 815 times