Version of Robotron arcade game using LPC1768, a Gameduino shield, a serial EEPROM (for high scores), two microswitch joysticks and two buttons plus a box to put it in. 20 levels of mayhem.
Dependencies: 25LCxxx_SPI CommonTypes Gameduino mbed
Diff: CharFrame.cpp
- Revision:
- 2:bb0f631a6068
- Child:
- 16:d0b142ba4362
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CharFrame.cpp Thu Jun 06 20:11:28 2013 +0000 @@ -0,0 +1,57 @@ +/* + * SOURCE FILE : CharFrame.cpp + * + * For drawing rectangular frames using characters. + * + */ + +#include "CharFrame.h" +#include "GDConst.h" // a few Gameduino constants +#include "CharCodes.h" // character set codes + +/****************/ +/* DRAW A FRAME */ +/****************/ +// Pass Gameduino to draw on in gd. +// Pass x coordinate of top left in x. +// Pass y coordinate of top left in y. +// Pass width in w. +// Pass height in h. +void CharFrame::Draw( Gameduino *gd, UInt8 x, UInt8 y, UInt8 w, UInt8 h ) { + // Calculate address for top left. + unsigned int rowStart = Gameduino::RAM_PIC + y * SCREEN_CHAR_WIDTH + x; + unsigned int address = rowStart; + UInt8 count; + // Draw top left corner. + gd->wr( address++, TopLeft ); + // Draw top edge. + if( w > 2 ) { + for( count = w - 2; count > 0; --count ) { + gd->wr( address++, Top ); + } + } + // Draw top right corner. + gd->wr( address, TopRight ); + // Draw left and right edges. + rowStart += SCREEN_CHAR_WIDTH; + if( h > 2 ) { + for( count = h - 2; count > 0; --count ) { + gd->wr( rowStart, Left ); + gd->wr( rowStart + w - 1, Right ); + rowStart += SCREEN_CHAR_WIDTH; + } + } + // Draw bottom edge. + address = rowStart; + // Draw bottom left corner. + gd->wr( address++, BottomLeft ); + // Draw bottom edge. + if( w > 2 ) { + for( count = w - 2; count > 0; --count ) { + gd->wr( address++, Bottom ); + } + } + // Draw bottom right corner. + gd->wr( address, BottomRight ); +} +