with ada.text_IO,screen; use ada.text_IO,screen; --------------------------------------------------------------------------- -- Autor: Javier Setoain (S5190067) -- Este programa simula en pantalla el comportamiento de una bola que -- recibe un impulso inicial y va rebotando contra las paredes a velocidad -- constante. Supone que la bola siempre parte de la misma posiciŽon y que -- hace el mismo nŽumero de rebotes. -- Mejoras posibles: -- . Se podrŽia haber hecho un cŽodigo mŽas compacto (menos lŽineas) -- . La bola parte de cualquier posiciŽon calculada aleatoriamente. -- . Preguntar las dimensiones donde la bola rebota o mirar las que -- tiene la pantalla en ese momento. -- . Otras? --------------------------------------------------------------------------- procedure bola is c,x,y,xx,yy:integer; FOTOS:constant:=500; begin c:=1; --POSICION INICIAL DEL * -- x:=40; y:=12; --DIRECCION INICIAL DEL *-- xx:=1; yy:=1; clear_screen; while(c<=FOTOS)loop If(x=79)then xx:=-1; end if; If(x=1)then xx:=1; end if; If(y=24)then yy:=-1; end if; If(y=1)then yy:=1; end if; move_cursor(Row=>y,Column=>x); put(' '); x:=x+xx; y:=y+yy; move_cursor(Row=>y,Column=>x); put('*'); c:=c+1; delay(0.03); end loop; end bola;