Skip to content

Instantly share code, notes, and snippets.

@tboydar
Created October 11, 2013 03:08
Show Gist options
  • Save tboydar/6928995 to your computer and use it in GitHub Desktop.
Save tboydar/6928995 to your computer and use it in GitHub Desktop.
//由左到右畫圓 xx, 畫面上到下yy 顯示設定frameRate
//由左到右畫圓 xx, 畫面上到下yy 顯示設定frameRate
int xx = 200; //設定xx 給人使用
int yy = 200; //設定yy 給人使用
//設定一次功能
void setup() {
size(300, 300); //畫面尺寸
background(255);//背景白色
frameRate(100); //設定畫面更新速度
}
//開始重複做畫
void draw()
{
background(255);//背景白色
if (xx > 100)
{
if (xx < 150)
{
fill(0, 255, 0); //畫圖填滿綠色
}
}
if (xx > 100 && xx < 150)
{
fill(0, 255, 0); //畫圖填滿綠色
}
else
{
fill(255, 0, 0); //畫圖填滿紅色
}
if (yy > 100 && yy < 200)
{
rect(xx, yy, 60, 50); //xx位置畫方塊
}
else
{
ellipse(xx, yy, 60, 50); //xx位置畫圓
}
line(xx, 0, xx, height);//畫線
line(0, yy, width, yy);//畫線
//xx = int(random(0, width));//xx 為亂數0-width
yy = yy + 1; //yy的數值累加1,
xx = xx + 3; //xx的數值累加3,
println("yy:"+yy); //顯示給人看yy的數值
if (yy > height) yy =0; //如果yy 數值大於螢幕的高 就等於零
if (xx > width) xx =0; //如果xx 數值大於螢幕的高 就等於零
println("frameRate:"+frameRate);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment