|
Rockbox mail archiveSubject: Re: snow screensaver (silly me)Re: snow screensaver (silly me)
From: Itai <Itais_at_newmail.net>
Date: Sun, 01 Sep 2002 15:40:43 +0200 silly me...... int the last line of snow_move - particle_exists should get the parameter i... that typo caused the top line of pixels..... [ if (particle_exists(i)) lcd_drawpixel(particles[i][0],particles[i][1]); ] Itai wrote: > works fine for me.... > I did got that top line you mention, but that was before I added the > two last condiotions to particle_exists (to check if a particle has > gone out of the screen) > > anyways, I have changed my code according to the conventions, and > maybe with shorter lines it'll work (who knows.) > > bottom line - works fine for me...... > > Robert Hak wrote: > >> I have played with this and like it. >> >> However, when run, you get a build up of pixels on the very top most >> line >> of the screen. (i can get you a screen shot if you like) >> >> In additions, when you write the code, please try and keep the line >> lengths under 80 chars, and avoid putting the if clause's on the same >> line: >> >> if(true) i++; >> >> should be >> >> if(true) >> i++; >> >> /Adi >> >> >> On Wed, 28 Aug 2002, Itai wrote: >> >> a screen saver (for the recorder, duh) that simulates snow/dust/small >> particles going down the screen >> >> > > >------------------------------------------------------------------------ > >/* >snow screen saver > >by Itai Shaked >*/ > >#include "lcd.h" >#include "config.h" >#include "kernel.h" >#include "menu.h" >#include "button.h" >#include <stdlib.h> > > >short particles[2000][2]; > > >bool particle_exists (int particle) { > if (particles[particle][0]>=0 && particles[particle][1]>=0 && > particles[particle][0]<=111 && particles[particle][1]<=63) > return true; > else return false; >} > > >int create_particle (void) { > int i; > for (i=0; i<1500; i++) { > if (!particle_exists(i)) { > particles[i][0]=(rand()%112); > particles[i][1]=0; > return i; > } > } > return -1; >} > >void snow_move(void) { > int i; > if (!(rand()%2)) create_particle(); > for (i=0; i<2000; i++) { > if (particle_exists(i)) { > lcd_clearpixel(particles[i][0],particles[i][1]); > switch ((rand()%5)) { > case 0: > particles[i][0]++; > break; > case 1: > particles[i][0]--; > break; > case 2: > break; > default: > particles[i][1]++; > break; > } > if (particle_exists) > lcd_drawpixel(particles[i][0],particles[i][1]); > } > } >} > >void snow_init(void) { > int i; > for (i=0; i<2000; i++) { > particles[i][0]=-1; > particles[i][1]=-1; > } > lcd_clear_display(); >} > >Menu snow (void) { > snow_init(); > while (1) { > snow_move(); > lcd_update(); > sleep(HZ/10); > if (button_get(false)==BUTTON_OFF) return MENU_OK; > } >} > Received on 2002-09-01 Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy |