#47056 - solarwind__ - Mon Jul 04, 2005 5:28 pm
i have created a program which draws a little blue rectange (10x20 px) in the topleft corner of the gba emulator window. I have used user input (currently only two keys, up and down) to move the little blue rectangle up and down on the screen. The program works but to animate the little blue rectangle, i had to repaint the screen black to prevent the blue rectangle from drawing like a pencil =|. If you understand what I mean. Anyway, the screen repainting is very slow and every time i press the down or up key. the block moves but is very slow due to the screen repainting.
If anyone has any suggestions on how to improve speed or even accomplish the same task which is to (create a little blue rectangle and move up or down the screen when the user press the up or down key) using a different method, i would greatly appreciate it.
Here is my code
I would greatly appreciate it if anyone could supply the code to accomplish the same task even with a completly different method but any suggestions are a big help.
THANKS in advace
_________________
#solarwind
If anyone has any suggestions on how to improve speed or even accomplish the same task which is to (create a little blue rectangle and move up or down the screen when the user press the up or down key) using a different method, i would greatly appreciate it.
Here is my code
Code: |
//GBA resolution is 240 x 160 #include "keypad.h" #define RGB16(r,g,b) ((r)+(g<<5)+(b<<10)) int main() { char x; char y; char a; // something like char x char b; // something like char y char v = 0; //variable that keeps track of the little blue square on the vertical line char h = 0; //variable that keeps track of the little blue square on the horizontal line char k = 5; char l = 15; unsigned short* Screen = (unsigned short*)0x6000000; *(unsigned long*)0x4000000 = 0x403; // mode3, bg2 on for (x = 0; x < 240; x++) //starts off with a black screen { for (y = 0; y < 160; y++) { Screen[x+y*240] = RGB16(0,0,0); } } while(1) { if(!((*KEYS) & KEY_DOWN)) { for (x = 0; x < 240; x++) { for (y = 0; y < 160; y++) { Screen[x+y*240] = RGB16(0,0,0); } } k = k + 15; l = l + 15; for (a = 0; a < 20; a++) { for (b = k; b < l; b++) { Screen[a+b*240] = RGB16(0,0,30); } } } // ============================================================================== if(!((*KEYS) & KEY_UP)) { for (x = 0; x < 240; x++) { for (y = 0; y < 160; y++) { Screen[x+y*240] = RGB16(0,0,0); } } k = k - 15; l = l - 15; for (a = 0; a < 20; a++) { for (b = k; b < l; b++) { Screen[a+b*240] = RGB16(0,0,30); } } } } } |
I would greatly appreciate it if anyone could supply the code to accomplish the same task even with a completly different method but any suggestions are a big help.
THANKS in advace
_________________
#solarwind