Upcoming SlideShare
×

# プログラミング技法特論第7回

625 views
570 views

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
625
On SlideShare
0
From Embeds
0
Number of Embeds
36
Actions
Shares
0
0
0
Likes
0
Embeds 0
No embeds

No notes for slide

### プログラミング技法特論第7回

1. 1. プログラミング技法特論#07<br />N. Shimizu<br />chikoski at kaetsu.ac.jp<br />
2. 2. ある地点へ円を動かす<br />
3. 3. 真横の場合<br />(x1, y1)<br />(x2, y1)<br />x2 – x1<br />
4. 4. 10フレームで近づきたい<br />(x1, y1)<br />(x2, y1)<br />(x2 – x1) / 10<br />
5. 5. プログラム<br />int x1, y1;<br />int x2;<br />intdx;<br />void setup(){<br /> size(400, 400);<br /> x1 = 0;<br /> y1 = 200;<br /> x2 = 200;<br />dx = (x2 – x1) / 10;<br />}<br />void draw(){<br /> background(0, 0, 0, 100);<br /> x1 = x1 + dx;<br /> ellipse(x1, y,1, 10, 10);<br />}<br />
6. 6. 真横の場合<br />(x1, y2)<br />(x1, y1)<br />y2 – y1<br />
7. 7. 10フレームで進む<br />(x1, y2)<br />(y2 – y1) / 10<br />(x1, y1)<br />
8. 8. プログラム<br />int x1, y1;<br />int y2;<br />intdy;<br />void setup(){<br /> size(400, 400);<br /> x1 = 200;<br /> y1 = 300;<br /> y2 = 100;<br />dy = (y2 – y1) / 10;<br />}<br />void draw(){<br /> background(0, 0, 0, 100);<br /> y1 = y1 + dy;<br /> ellipse(x1, y,1, 10, 10);<br />}<br />
9. 9. ある地点へ円を動かす<br />y2 – y1<br />(x2, y2)<br />(x1, y1)<br />x2 – x1<br />
10. 10. プログラム<br />int x1, y1;<br />int x2, y2;<br />intdx, dy;<br />void setup(){<br /> size(400, 400);<br /> x1 = 100;<br /> y1 = 300;<br /> x2 = 300; <br /> y2 = 100;<br />dx = (x2 – x1) / 10;<br />dy = (y2 – y1) / 10;<br />}<br />void draw(){<br /> background(0, 0, 0, 100);<br /> x1 = x1 + dx;<br /> y1 = y1 + dy;<br /> ellipse(x1, y1, 10, 10);<br />}<br />
11. 11. クリックされた点へ動かす<br />クリック<br />mouseY – y1<br />(mouseX, mouseY)<br />(x1, y1)<br />mouseX – x1<br />
12. 12. プログラム<br />int x1, y1;<br />intdx, dy;<br />void setup(){<br /> size(400, 400);<br /> x1 = 100;<br /> y1 = 300;<br />dx = 0;<br />dy = 0;<br />}<br />void draw(){<br />if(mousePressed){<br />dx = (mouseX – x1) / 10;<br />dy = (mouseY - y1) / 10;<br /> }<br /> background(0, 0, 0, 100);<br /> x1 = x1 + dx<br /> y1 = y1 + dy;<br /> ellipse(x1, y,1, 10, 10);<br />}<br />
13. 13. これまでの課題をやってください<br />http://chikoski.info/tagged/sipt2010<br />