# Generating display on LCD

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:

``````#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
printf_fast(enemy_track1[j]);
lcd_set_xy(i, 1);                  // Set position of line 2 of enemies
printf_fast(enemy_track2[j]);
}
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