via <- function() { dev.new(xpos=650,ypos=10,width=5.2,height=5.7) plot(c(0,15),c(0,15),type="n",xlab="",ylab="",asp=1) mtext("Batti Svolta (D,S) o batti Passi (1,...,15)",cex=0.8,side=3) abline(h=seq(0,15,1),v=seq(0,15,1),lty=3,col="red") v <- "S"; rect(0,14,1,15,col="grey"); arrows(1/2,15,1/2,14,length=0.1) ruotaD <- function(v) { if(v=="S") v1 <- "O"; if(v=="O") v1 <- "N"; if(v=="N") v1 <- "E"; if(v=="E") v1 <- "S"; v1} ruotaS <- function(v) { if(v=="N") v1 <- "O"; if(v=="E") v1 <- "N"; if(v=="S") v1 <- "E"; if(v=="O") v1 <- "S"; v1} freccia <- function(v) {rect(0,14,1,15,col="grey"); if(v=="N") arrows(1/2,14,1/2,15,length=0.1); if(v=="S") arrows(1/2,15,1/2,14,length=0.1); if(v=="O") arrows(1,14.5,0,14.5,length=0.1); if(v=="E") arrows(0,14.5,1,14.5,length=0.1)} print("Batti x e poi y del punto di partenza"); v <- "S"; x <- scan(file="",n=1); y <- scan(file="",n=1); points(x,y,pch=19); print("Batti D, S o il numero dei passi; premi ESC quando hai finito"); while(TRUE) {d <- scan(file="",what="character",n=1); d <- toupper(d); if(d=="D") {v <- ruotaD(v);freccia(v)} else {if(d=="S") {v <- ruotaS(v);freccia(v)} else { n = strtoi(d); if(v=="O") {x <- x-n; arrows(x+n,y,x,y,length=0.1)}; if(v=="E") {x <- x+n; arrows(x-n,y,x,y,length=0.1)}; if(v=="N") {y <- y+n; arrows(x,y-n,x,y,length=0.1)}; if(v=="S") {y <- y-n; arrows(x,y+n,x,y,length=0.1)} }}; }}