1.infinite loop คือการลืมอัพเดทค่าตัวแปร เช่น
void setup() {
println(sum_number(10));
}
int sum_number(int n) {
int x = 0;
int sum = 0;
while (x <= n) {
sum += x;
x++; <---------------------- ตรงนี้คือการอัพเดทค่าตัวแปร หากลืมตรงนี้ไป จะทำให้เกิด infinite loop ได้
}
return sum;
}
หากเกิด infinite loop จะทำให้โปรแกรมค้าง และในกรณีที่ลืม Save งาน มันช่างน่าเศร้าใจยิ่งนัก
2. ; (Semi colon) เป็นสัญลักษณ์ที่เอาไว้ใส่หลังคำสั่งทุกบรรทัด เมื่อผู้ใช้ลืมใส่ ; จะไม่สามารถรันโปรแกรมได้ วิธีแก้คือการใส่ ; ไปในบรรทัดที่ผู้ใช้ลืมใส่ ก็จะสามารถรันโปรแกรมได้ตามปกติ
void setup(){
int N = 1;
int r = 13;
int x = 8;
while(N<r){
int p = x*N;
println(+x+" x "+N+" = "+p);
N += 1 <<<<<<<<<<<<<<<<<< เราลืมใส่ ; ตรงนี้นะ ถ้าให้โปรแกรมไม่สามารถรันได้
}
}
วิธีแก้คือการเติม ; เข้าไป เราก็จะสามารถรันโปรแกรมได้ตามปกติ
3. ( ) วงเล็บ ไว้ใส่ครอบตำแหน่ง ขนาด โค้ดสี หรือคำพูด เช่น background() Size() textSize() text( ) เป็นต้น บางครั้งผู้ใช้ อาจเปิดแล้วลืมปิด เช่น
void setup() {
println(sum_number(10); <<<<<<<<<<< ตรงนี้เราใส่ ) ขาดไป 1 ตัวนะเนี่ย บ้าจริงพี่ชาย
}
int sum_number(int n) {
int x = 0;
int sum = 0;
while (x <= n) {
sum += x;
x++;
}
return sum;
}
วิธีแก้คือ เติม ) ไปให้ครบคู่ของมัน เราก็จะสามารถรันโปรแกรมได้ตามปกติ
แสดงบทความที่มีป้ายกำกับ Lab 4 แสดงบทความทั้งหมด
แสดงบทความที่มีป้ายกำกับ Lab 4 แสดงบทความทั้งหมด
วันศุกร์ที่ 11 กันยายน พ.ศ. 2558
วันพฤหัสบดีที่ 10 กันยายน พ.ศ. 2558
Loan money.
void setup(){
loan_money(5000,0.12,1);
}
void loan_money(float amount, float rate, int year){
int month = year*12;
float ratepermonth = rate/12;
float paypermonth = amount*(ratepermonth/(1-pow(1+ratepermonth,-month)));
float principal = paypermonth;
float unpaid = amount;
float interest_total = 0;
int x = 1;
println("Num. Interest Principal Unpaid Interest total");
while(x <= month){
print(nf(x, 2)); //Num
print(" "+nf(ratepermonth*unpaid, 2, 2)); //Interest
interest_total+=ratepermonth*unpaid;
principal=paypermonth-(ratepermonth*unpaid);
unpaid -= principal;
if(unpaid < 0){
unpaid = 0;
}
print(" "+nf(principal, 3, 2)); //Principal
print(" "+nf(unpaid, 4, 2)); //Unpaid
print(" "+nf(interest_total, 3, 2)); //Total
println();
x++;
}
}
loan_money(5000,0.12,1);
}
void loan_money(float amount, float rate, int year){
int month = year*12;
float ratepermonth = rate/12;
float paypermonth = amount*(ratepermonth/(1-pow(1+ratepermonth,-month)));
float principal = paypermonth;
float unpaid = amount;
float interest_total = 0;
int x = 1;
println("Num. Interest Principal Unpaid Interest total");
while(x <= month){
print(nf(x, 2)); //Num
print(" "+nf(ratepermonth*unpaid, 2, 2)); //Interest
interest_total+=ratepermonth*unpaid;
principal=paypermonth-(ratepermonth*unpaid);
unpaid -= principal;
if(unpaid < 0){
unpaid = 0;
}
print(" "+nf(principal, 3, 2)); //Principal
print(" "+nf(unpaid, 4, 2)); //Unpaid
print(" "+nf(interest_total, 3, 2)); //Total
println();
x++;
}
}
วันพุธที่ 9 กันยายน พ.ศ. 2558
ฺBi Potato.
int cp = #FFD700;
int co1 = #00FF00;
int co2 = #FFA54F;
int ccpre = #4169E1;
int ct1 = #FF0066;
int ca = #800080;
int ct2 = #003300;
int co3 = #FF4500;
int co4 = #FFFFFF;
void setup() {
size(500, 500);
}
void draw() {
background(#99CCFF);
float yy = 0;
if (mouseX <= width/2) {
while (yy < mouseY) {
potato(mouseX, yy);
yy += 125;
}
} else {
potato(mouseX, mouseY);
}
}
void keyPressed() {
if (key == 'p') {
cp = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 'o') {
co1 = color(random(0, 225), random(0, 225), random(0, 225));
co2 = color(random(0, 225), random(0, 225), random(0, 225));
co3 = color(random(0, 225), random(0, 225), random(0, 225));
co4 = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 't') {
ct1 = color(random(0, 225), random(0, 225), random(0, 225));
ct2 = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 'a') {
ca = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == '0') {
ccpre = color(random(0, 225), random(0, 225), random(0, 225));
}
}
//Potato
void potato(float x, float y) {
int n = 0;
int m = 0;
while (n < 2) {
fill(cp);
textSize(120);
text("P", x+m, y);
fill(co1);
ellipse(x+125+m, y-45, 90, 90); //วงกลมเขียว
fill(co2);
ellipse(x+125+m, y-45, 60, 60); //วงกลมส้มอ่อน
fill(ccpre);
textSize(18);
text("Cpr.E", x+100+m, y-40);
fill(ct1);
rect(x+35+m, y+25, 15, 100); //แกนตัวที1
rect(x+7+m, y+25, 75, 15); //หัวตัวที1
fill(ca);
textSize(140);
text("A", x+80+m, y+125);
fill(ct2);
rect(x+35+m, y+155, 15, 100); //แกนตัวที2
rect(x+7+m, y+155, 75, 15); //หัวตัวที2
fill(co3);
ellipse(x+135+m, y+210, 110, 110); //วงกลมส้มเข้ม
fill(co4);
ellipse(x+135+m, y+210, 10, 60); //วงรีขาว
n++;
m += 200;
}
}
int co1 = #00FF00;
int co2 = #FFA54F;
int ccpre = #4169E1;
int ct1 = #FF0066;
int ca = #800080;
int ct2 = #003300;
int co3 = #FF4500;
int co4 = #FFFFFF;
void setup() {
size(500, 500);
}
void draw() {
background(#99CCFF);
float yy = 0;
if (mouseX <= width/2) {
while (yy < mouseY) {
potato(mouseX, yy);
yy += 125;
}
} else {
potato(mouseX, mouseY);
}
}
void keyPressed() {
if (key == 'p') {
cp = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 'o') {
co1 = color(random(0, 225), random(0, 225), random(0, 225));
co2 = color(random(0, 225), random(0, 225), random(0, 225));
co3 = color(random(0, 225), random(0, 225), random(0, 225));
co4 = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 't') {
ct1 = color(random(0, 225), random(0, 225), random(0, 225));
ct2 = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == 'a') {
ca = color(random(0, 225), random(0, 225), random(0, 225));
} else if (key == '0') {
ccpre = color(random(0, 225), random(0, 225), random(0, 225));
}
}
//Potato
void potato(float x, float y) {
int n = 0;
int m = 0;
while (n < 2) {
fill(cp);
textSize(120);
text("P", x+m, y);
fill(co1);
ellipse(x+125+m, y-45, 90, 90); //วงกลมเขียว
fill(co2);
ellipse(x+125+m, y-45, 60, 60); //วงกลมส้มอ่อน
fill(ccpre);
textSize(18);
text("Cpr.E", x+100+m, y-40);
fill(ct1);
rect(x+35+m, y+25, 15, 100); //แกนตัวที1
rect(x+7+m, y+25, 75, 15); //หัวตัวที1
fill(ca);
textSize(140);
text("A", x+80+m, y+125);
fill(ct2);
rect(x+35+m, y+155, 15, 100); //แกนตัวที2
rect(x+7+m, y+155, 75, 15); //หัวตัวที2
fill(co3);
ellipse(x+135+m, y+210, 110, 110); //วงกลมส้มเข้ม
fill(co4);
ellipse(x+135+m, y+210, 10, 60); //วงรีขาว
n++;
m += 200;
}
}
Horror Mickey mouse.
int c1 = 0;
int c2 = 0;
int c3 = 0;
int c4 = 0;
int c5 = 0;
int c6 = 0;
int c7 = 0;
int c12 = 0;
void setup()
{
size(500, 550);
}
void draw() {
background(0);
int x = mouseX;
int y = mouseY;
mickey(x, y);
}
void mickey(int xx, int yy) {
int w = 10;
int h = 10;
int n = 0;
int m = 0;
while (n<2) {
fill(c1);
ellipse(xx+150+m, yy+150+m, w+200, h+200); //วงกลมดำหน้า
fill(c2);
ellipse(xx+50+m, yy+m, w+55, h+55); //วงกลมดำหูขวา
fill(c3);
ellipse(xx+250+m, yy+m, w+55, h+55); //วงกลมดำหูซ้าย
fill(c4);
ellipse(xx+150+m, yy+180+m, w+170, h+150); //วงกลมแดงหน้า
fill(c5);
arc(xx+150+m, yy+150+m, w+170, h+150, PI/6, PI-PI/6); //ปากยิ้ม
fill(c6);
arc(xx+35+m, yy+190+m, w-70, h-50, PI/6, PI-PI/6); //มุมปากยิ้มขวา
fill(c7);
arc(xx+263+m, yy+190+m, w-70, h-50, PI/6, PI-PI/6); //มุมปากยิ้มซ้าย
fill(c12);
ellipse(xx+148+m, yy+210+m, w-50, h-50); //จมูก
n++;
m += 200;
}
}
void mousePressed() {
c1 = color(random(0, 225), random(0, 225), random(0, 225));
c2 = color(random(0, 225), random(0, 225), random(0, 225));
c3 = color(random(0, 225), random(0, 225), random(0, 225));
c4 = color(random(0, 225), random(0, 225), random(0, 225));
c5 = color(random(0, 225), random(0, 225), random(0, 225));
c6 = color(random(0, 225), random(0, 225), random(0, 225));
c7 = color(random(0, 225), random(0, 225), random(0, 225));
c12 = color(random(0, 225), random(0, 225), random(0, 225));
}
int c2 = 0;
int c3 = 0;
int c4 = 0;
int c5 = 0;
int c6 = 0;
int c7 = 0;
int c12 = 0;
void setup()
{
size(500, 550);
}
void draw() {
background(0);
int x = mouseX;
int y = mouseY;
mickey(x, y);
}
void mickey(int xx, int yy) {
int w = 10;
int h = 10;
int n = 0;
int m = 0;
while (n<2) {
fill(c1);
ellipse(xx+150+m, yy+150+m, w+200, h+200); //วงกลมดำหน้า
fill(c2);
ellipse(xx+50+m, yy+m, w+55, h+55); //วงกลมดำหูขวา
fill(c3);
ellipse(xx+250+m, yy+m, w+55, h+55); //วงกลมดำหูซ้าย
fill(c4);
ellipse(xx+150+m, yy+180+m, w+170, h+150); //วงกลมแดงหน้า
fill(c5);
arc(xx+150+m, yy+150+m, w+170, h+150, PI/6, PI-PI/6); //ปากยิ้ม
fill(c6);
arc(xx+35+m, yy+190+m, w-70, h-50, PI/6, PI-PI/6); //มุมปากยิ้มขวา
fill(c7);
arc(xx+263+m, yy+190+m, w-70, h-50, PI/6, PI-PI/6); //มุมปากยิ้มซ้าย
fill(c12);
ellipse(xx+148+m, yy+210+m, w-50, h-50); //จมูก
n++;
m += 200;
}
}
void mousePressed() {
c1 = color(random(0, 225), random(0, 225), random(0, 225));
c2 = color(random(0, 225), random(0, 225), random(0, 225));
c3 = color(random(0, 225), random(0, 225), random(0, 225));
c4 = color(random(0, 225), random(0, 225), random(0, 225));
c5 = color(random(0, 225), random(0, 225), random(0, 225));
c6 = color(random(0, 225), random(0, 225), random(0, 225));
c7 = color(random(0, 225), random(0, 225), random(0, 225));
c12 = color(random(0, 225), random(0, 225), random(0, 225));
}
Bi Titanic.
float sx = 100;
float sy = 100;
int colour = 0;
void setup()
{
size(550, 550);
frameRate(1000000000);
}
void draw() {
background(0);
sx = sx-1;
titanic(sx, sy);
if (sx < -600) {
sx = 600;
sy = random(0, 400);
}
float x=0;
int y=0;
float step=30;
while (x < mouseX) {
line(x, mouseX, width/2, y);
x = x + step;
}
}
void titanic(float sx, float sy) {
float w = 25;
float h = 25;
int n = 0;
int m = 0;
while (n < 2) {
stroke(153);
strokeWeight(4);
line(sx+30+m, sy+300+m, sx+430+m, sy+300+m); //เส้นล่าง
line(sx-70+m, sy+200+m, sx+29+m, sy+300+m); //เส้นหน้าเรือล่าง
line(sx+430+m, sy+200+m, sx+430+m, sy+300+m); //เส้นหลังเรือล่าง
line(sx-70+m, sy+200+m, sx+430+m, sy+200+m); //เส้นบนเรือล่าง
line(sx+105+m, sy+100+m, sx+85+m, sy+200+m); //เส้นปล่องเรือ1หน้า
line(sx+155+m, sy+100+m, sx+135+m, sy+200+m); //เส้นปล่องเรือ1หลัง
line(sx+105+m, sy+100+m, sx+155+m, sy+100+m); //เส้นปล่องเรือ1บน
line(sx+102+m, sy+120+m, sx+151+m, sy+120+m); //เส้นปล่องเรือ1ล่าง
line(sx+200+m, sy+100+m, sx+180+m, sy+200+m); //เส้นปล่องเรือ2หน้า
line(sx+250+m, sy+100+m, sx+230+m, sy+200+m); //เส้นปล่องเรือ2หลัง
line(sx+200+m, sy+100+m, sx+250+m, sy+100+m); //เส้นปล่องเรือ2บน
line(sx+197+m, sy+120+m, sx+246+m, sy+120+m); //เส้นปล่องเรือ2ล่าง
line(sx+295+m, sy+100+m, sx+275+m, sy+200+m); //เส้นปล่องเรือ3หน้า
line(sx+345+m, sy+100+m, sx+325+m, sy+200+m); //เส้นปล่องเรือ3หลัง
line(sx+295+m, sy+100+m, sx+345+m, sy+100+m); //เส้นปล่องเรือ3บน
line(sx+292+m, sy+120+m, sx+341+m, sy+120+m); //เส้นปล่องเรือ3ล่าง
line(sx+50+m, sy+150+m, sx-10+m, sy+200+m); //เส้นหน้าเรือบน
line(sx+50+m, sy+150+m, sx+390+m, sy+150+m); //เส้นบนเรือบน
line(sx+390+m, sy+150+m, sx+390+m, sy+200+m); //เส้นหลังเรือบน
line(sx+5+m, sy+275+m, sx+430+m, sy+275+m); //เส้นกลางเรือ
fill(colour);
ellipse(sx+100+m, sy+250+m, w, h); //หน้าต่าง1
ellipse(sx+150+m, sy+250+m, w, h); //หน้าต่าง2
ellipse(sx+200+m, sy+250+m, w, h); //หน้าต่าง3
ellipse(sx+250+m, sy+250+m, w, h); //หน้าต่าง4
ellipse(sx+300+m, sy+250+m, w, h); //หน้าต่าง5
ellipse(sx+350+m, sy+250+m, w, h); //หน้าต่าง6
ellipse(sx+400+m, sy+250+m, w, h); //หน้าต่าง7
ellipse(sx+m, sy+252+m, w-15, h-15); //วงกลมสมอ
fill(225);
arc(sx+m, sy+230+m, w-5, h+15, PI/6, PI-PI/6); //โค้งสมอ
line(sx+m, sy+230+m, sx+m, sy+255+m); //เส้นสมอ
n++;
m += 250;
}
}
void mousePressed() {
colour = color(random(0, 225), random(0, 225), random(0, 225));
}
float sy = 100;
int colour = 0;
void setup()
{
size(550, 550);
frameRate(1000000000);
}
void draw() {
background(0);
sx = sx-1;
titanic(sx, sy);
if (sx < -600) {
sx = 600;
sy = random(0, 400);
}
float x=0;
int y=0;
float step=30;
while (x < mouseX) {
line(x, mouseX, width/2, y);
x = x + step;
}
}
void titanic(float sx, float sy) {
float w = 25;
float h = 25;
int n = 0;
int m = 0;
while (n < 2) {
stroke(153);
strokeWeight(4);
line(sx+30+m, sy+300+m, sx+430+m, sy+300+m); //เส้นล่าง
line(sx-70+m, sy+200+m, sx+29+m, sy+300+m); //เส้นหน้าเรือล่าง
line(sx+430+m, sy+200+m, sx+430+m, sy+300+m); //เส้นหลังเรือล่าง
line(sx-70+m, sy+200+m, sx+430+m, sy+200+m); //เส้นบนเรือล่าง
line(sx+105+m, sy+100+m, sx+85+m, sy+200+m); //เส้นปล่องเรือ1หน้า
line(sx+155+m, sy+100+m, sx+135+m, sy+200+m); //เส้นปล่องเรือ1หลัง
line(sx+105+m, sy+100+m, sx+155+m, sy+100+m); //เส้นปล่องเรือ1บน
line(sx+102+m, sy+120+m, sx+151+m, sy+120+m); //เส้นปล่องเรือ1ล่าง
line(sx+200+m, sy+100+m, sx+180+m, sy+200+m); //เส้นปล่องเรือ2หน้า
line(sx+250+m, sy+100+m, sx+230+m, sy+200+m); //เส้นปล่องเรือ2หลัง
line(sx+200+m, sy+100+m, sx+250+m, sy+100+m); //เส้นปล่องเรือ2บน
line(sx+197+m, sy+120+m, sx+246+m, sy+120+m); //เส้นปล่องเรือ2ล่าง
line(sx+295+m, sy+100+m, sx+275+m, sy+200+m); //เส้นปล่องเรือ3หน้า
line(sx+345+m, sy+100+m, sx+325+m, sy+200+m); //เส้นปล่องเรือ3หลัง
line(sx+295+m, sy+100+m, sx+345+m, sy+100+m); //เส้นปล่องเรือ3บน
line(sx+292+m, sy+120+m, sx+341+m, sy+120+m); //เส้นปล่องเรือ3ล่าง
line(sx+50+m, sy+150+m, sx-10+m, sy+200+m); //เส้นหน้าเรือบน
line(sx+50+m, sy+150+m, sx+390+m, sy+150+m); //เส้นบนเรือบน
line(sx+390+m, sy+150+m, sx+390+m, sy+200+m); //เส้นหลังเรือบน
line(sx+5+m, sy+275+m, sx+430+m, sy+275+m); //เส้นกลางเรือ
fill(colour);
ellipse(sx+100+m, sy+250+m, w, h); //หน้าต่าง1
ellipse(sx+150+m, sy+250+m, w, h); //หน้าต่าง2
ellipse(sx+200+m, sy+250+m, w, h); //หน้าต่าง3
ellipse(sx+250+m, sy+250+m, w, h); //หน้าต่าง4
ellipse(sx+300+m, sy+250+m, w, h); //หน้าต่าง5
ellipse(sx+350+m, sy+250+m, w, h); //หน้าต่าง6
ellipse(sx+400+m, sy+250+m, w, h); //หน้าต่าง7
ellipse(sx+m, sy+252+m, w-15, h-15); //วงกลมสมอ
fill(225);
arc(sx+m, sy+230+m, w-5, h+15, PI/6, PI-PI/6); //โค้งสมอ
line(sx+m, sy+230+m, sx+m, sy+255+m); //เส้นสมอ
n++;
m += 250;
}
}
void mousePressed() {
colour = color(random(0, 225), random(0, 225), random(0, 225));
}
วันอังคารที่ 8 กันยายน พ.ศ. 2558
Number sum.
void setup() {
println(sum_number(10));
}
int sum_number(int n) {
int x = 0; //เลขโดด
int sum = 0; //ผลรวม
while (x <= n) {
sum += x;
x++;
}
return sum;
}
println(sum_number(10));
}
int sum_number(int n) {
int x = 0; //เลขโดด
int sum = 0; //ผลรวม
while (x <= n) {
sum += x;
x++;
}
return sum;
}
Prime number.
void setup() {
println(sum_prime(10));
}
int sum_prime(int n) {
int x = 2; //จำนวนเฉพาะตัวแรก
int sum = 0; //ผลรวม
while (x <= n) {
if (prime(x)) {
sum += x;
}
x++;
}
return sum;
}
boolean prime(int p) { boolean result = true; //ค่าเริ่มต้น int x = 2; while (x<p) { if (p%x == 0) { result = false; } x++; } if (p==1){ result=false; } return result; }
println(sum_prime(10));
}
int sum_prime(int n) {
int x = 2; //จำนวนเฉพาะตัวแรก
int sum = 0; //ผลรวม
while (x <= n) {
if (prime(x)) {
sum += x;
}
x++;
}
return sum;
}
boolean prime(int p) { boolean result = true; //ค่าเริ่มต้น int x = 2; while (x<p) { if (p%x == 0) { result = false; } x++; } if (p==1){ result=false; } return result; }
วันจันทร์ที่ 7 กันยายน พ.ศ. 2558
Flock birds.
int wing;
void setup() {
size(500, 500);
strokeWeight(5);
}
void draw() {
background(#FF1493);
wing = mouseY;
if (frameCount%40>20) {
wing+=40;
} else {
wing-=50;
}
if (mouseY > 0 && mouseY < 500) {
wing+= 0;
} else {
wing-= 60;
}
draw_bird(mouseX, mouseY, 3, 3);
}
//bird
void draw_bird(float x, float y, int row, int flocks) {
int rx = 10;
int ry = 10;
int mx = 0;
int my = 0;
int n = 0;
int f = 0;
int k = 70; //ค่าคงที่ ระยะห่างของแต่ละแถว
while (n<row) {
while (f < flocks) {
fill(#000080);
ellipse(x+mx, y+my, rx, ry); //หัว
line(x+10+mx, y+my, x+20+mx, wing+my); //ปีกขวา
line(x-10+mx, y+my, x-20+mx, wing+my); //ปีกซ้าย
f++;
mx += 150;
}
f=0;
mx=k;
k+=70;
n++;
my+=50;
}
}
void setup() {
size(500, 500);
strokeWeight(5);
}
void draw() {
background(#FF1493);
wing = mouseY;
if (frameCount%40>20) {
wing+=40;
} else {
wing-=50;
}
if (mouseY > 0 && mouseY < 500) {
wing+= 0;
} else {
wing-= 60;
}
draw_bird(mouseX, mouseY, 3, 3);
}
//bird
void draw_bird(float x, float y, int row, int flocks) {
int rx = 10;
int ry = 10;
int mx = 0;
int my = 0;
int n = 0;
int f = 0;
int k = 70; //ค่าคงที่ ระยะห่างของแต่ละแถว
while (n<row) {
while (f < flocks) {
fill(#000080);
ellipse(x+mx, y+my, rx, ry); //หัว
line(x+10+mx, y+my, x+20+mx, wing+my); //ปีกขวา
line(x-10+mx, y+my, x-20+mx, wing+my); //ปีกซ้าย
f++;
mx += 150;
}
f=0;
mx=k;
k+=70;
n++;
my+=50;
}
}
balloons.
void setup()
{
size(500, 500);
}
void draw() {
background(225);
int xx = mouseX;
int yy = mouseY;
//mousemove
if (xx < 75) {
xx = 75;
} else if (xx > 425)
xx = 425;
if ( yy < 75) {
yy = 75;
fill(#FF0000);
} else if (yy > 300) {
fill(#0000FF);
} else {
fill(#FFFF00);
}
if (yy > 325) {
yy = 325;
}
draw_ballon(xx, yy);
}
//draw_ballon
void draw_ballon(int x, int y) {
int n = 0; //จำนวนบอลลูน
int m = 0; //ระยะห่างของบอลลูนแต่ละลูก
while (n<3) {
ellipse(x+m, y, 150, 150);
line(x+m, y+75, x+m, y+175);
n++;
m += 170;
}
}
{
size(500, 500);
}
void draw() {
background(225);
int xx = mouseX;
int yy = mouseY;
//mousemove
if (xx < 75) {
xx = 75;
} else if (xx > 425)
xx = 425;
if ( yy < 75) {
yy = 75;
fill(#FF0000);
} else if (yy > 300) {
fill(#0000FF);
} else {
fill(#FFFF00);
}
if (yy > 325) {
yy = 325;
}
draw_ballon(xx, yy);
}
//draw_ballon
void draw_ballon(int x, int y) {
int n = 0; //จำนวนบอลลูน
int m = 0; //ระยะห่างของบอลลูนแต่ละลูก
while (n<3) {
ellipse(x+m, y, 150, 150);
line(x+m, y+75, x+m, y+175);
n++;
m += 170;
}
}
Multiplication table.
void setup(){
int N = 1; //เลขโดด
int r = 13; //จำนวนคูณ
int x = 8; //แม่สูตรคูณ
while(N<r){
int p = x*N;
println(+x+" x "+N+" = "+p);
N += 1;
}
}
int N = 1; //เลขโดด
int r = 13; //จำนวนคูณ
int x = 8; //แม่สูตรคูณ
while(N<r){
int p = x*N;
println(+x+" x "+N+" = "+p);
N += 1;
}
}
สมัครสมาชิก:
บทความ (Atom)
Link Video Presentation Resort Managemant System Project.
Video Presentation Resort Managemant System Project. จัดทำโดย พากษ์เสียง: คุณาสิน ทองมณี 5801012620011 ลำดับภาพ: สุพิชชา ศรีศิริ...
-
- 1NF หรือ Fisrt Normal Form มีเงื่อนไขอยู่ว่า ต้องไม่มีคอลลัมน์ใดในตารางที่มีค่ามากกว่า 1 ค่า หรือที่เรียกว่า Atomic ซึ่งหมายถึง ข้อมูลที่...
-
เนื่องจากวันที่ 27 กุมภาพันธ์ ถึง 22 มีนาคม 2561 เป็นช่วงเวลาของการสอบกลางภาค ซึ่งทำให้ต้องแบ่งเวลาในการทำงานและอ่านหนังสือสอบอย่างหนัก จึง...