initial pre-commit!

This commit is contained in:
lee2sman 2021-01-21 03:45:43 -05:00
commit 707a1620f0
5 changed files with 96 additions and 0 deletions

16
index.html Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<!--PLogo-->
<html>
<head>
<meta charset="utf-8" />
<!-- <link rel="stylesheet" href="style.css" /> -->
<script src="lib/p5.min.js"></script>
<script src="lib/p5.sound.min.js"></script>
<title>PLogo</title>
</head>
<body>
<script src="turtle.js"></script>
<script src="sketch.js"></script>
</body>
</html>

3
lib/p5.min.js vendored Normal file

File diff suppressed because one or more lines are too long

28
lib/p5.sound.min.js vendored Normal file

File diff suppressed because one or more lines are too long

46
sketch.js Normal file
View File

@ -0,0 +1,46 @@
let angle,x,y;
function setup(){
createCanvas(windowWidth,windowHeight); //canvas is size of window
resetDefaults();
turtle();
}
function resetDefaults(){
angleMode(DEGREES); //instead of p5.js's default RADIANS
angle=0; //facing up
x = width/2; //start turtle in center
y = height/2;
}
function forward(d,startx=x, starty = y, _angle = angle){
let newX = startx+d*sin(_angle);
let newY = starty+d*cos(_angle);
line(startx,starty,newX,newY);
x=newX
y=newY
}
function back(d,startx=x, starty = y, _angle =360- angle){
let newX = startx+d*sin(_angle);
let newY = starty+d*cos(_angle);
line(startx,starty,newX,newY);
x=newX
y=newY
}
function left(_angle){
angle=180+_angle;
}
function right(_angle){
angle=_angle;
}
function randint(max=100){
//default returns int between 0 and 100
return int(random(max))
}
function windowResized(){ //resizes canvas if window is resized
resizeCanvas(windowWidth, windowHeight);
}

3
turtle.js Normal file
View File

@ -0,0 +1,3 @@
function turtle(){
forward(randint(100));
}