Go Down

Topic: Generating display on LCD (Read 347 times) previous topic - next topic


Oct 27, 2010, 05:16 pm Last Edit: Oct 27, 2010, 05:17 pm by PA_Skins Reason: 1
I am making a game where you have to dodge the mines by moving to different sides of the 'road' or lines on the screen (16*2 LCD)

I am using an 8051 microcontroller but the code for this should be the same...

I want to display a track of mines (or *) on an LCD screen. I can print the *s to the LCD but want them to 'scroll' along as if it were a road. I could use the scroll function but I also want a static 'player' on the right of the screen.

So far I have this: http://pastebin.com/kmGKrZab

This is as far as I have got with the generation of the enemy mines:

Code: [Select]

#define ENEMY_SPACES 12                                    // # spaces enemies can exist in
char enemy_track1[20] = {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};      // Sprites of enemies on track 1
char enemy_track2[20] = {1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0};      // Sprites of enemies on track 2
void generate_enemies(void){
     int j,i;
     for(i=0; i<ENEMY_SPACES; i++){
           for(j=0; j<ENEMY_SPACES; j++){
                 lcd_set_xy(i, 0);                  // Set position of line 1 of enemies
                 lcd_set_xy(i, 1);                  // Set position of line 2 of enemies
           speed_delay(1);                              // Delay for enemy speed
           i++                                    // Move enemies up one place on the screen
           if(i=>ENEMY_SPACES){                        // If the next enemy moves past the end position
                 i=0;                              // Start at 0 again

Basically the problem I'm having is refreshing the enemies in the block of 12 spaces they should exist in, to give the illusion of the player scrolling across the road...without losing the player. Or should I scroll the road and just refresh the player?

Thanks for any help  :)
"C++ : Where friends have access to your private members." - Gavin Russell Baker

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131