課題

Similar documents
課題

課題

課題

課題

もう少し数学っぽい関数もあります 関数名 abs(x) sqrt(x) sq(x) pow(x,n) exp(x) log(x) dist(x1, y1, x2, y2) constrain(v, m0, m1) lerp(v0,v1,t) map(v, low1, high1, low2, hig

スライド 1

挙動チェックポイントなどセミコロン ; を忘れていませんか? 黄色なんだか動かないで表示されている部分またはその少し前 Syntax error, maybe a missing にセミコロンを忘れている場所はありま semicolon? などと表示されます せんか? なんだか動作がおかしい の部分

Processing入門マニュアル17

課題

Processingをはじめよう


問 1 図 1 の図形を作るプログラムを作成せよ 但し ウィンドウの大きさは と し 座標の関係は図 2 に示すものとする 図 1 作成する図形 原点 (0,0) (280,0) (80,0) (180,0) (260,0) (380,0) (0,160) 図 2 座標関係 問 2

r3.dvi

10K pdf

<4D F736F F D B B83578B6594BB2D834A836F815B82D082C88C60202E646F63>

Java演習(9) -- クラスとメソッド --

JavaプログラミングⅠ

Java学習教材

Processing による ポーカーゲームについて 八神孝嗣

情報システム設計論II ユーザインタフェース(1)

r3.dvi


Processingをはじめよう

Microsoft PowerPoint P演習 第10回 関数.ppt [互換モード]

CG

K227 Java 2

情報システム設計論II ユーザインタフェース(1)

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

: : : TSTank 2

情報システム設計論II ユーザインタフェース(1)

I java A

JavaプログラミングⅠ

19 3!! (+) (>) (++) (+=) for while 3.1!! (20, 20) (1)(Blocks1.java) import javax.swing.japplet; import java.awt.graphics;

Java 基礎問題ドリル ~ メソッドを理解する ~ 次のプログラムコードに 各設問の条件にあうメソッドを追加しなさい その後 そのメソッドが正しく動作することを検証するためのプログラムコードを main メソッドの中に追加しなさい public class Practice { // ここに各設問

p5.js p5.js p5.js Tetris Tetris

第117期報告書

Java演習(4) -- 変数と型 --

Javaプログラムの実行手順

ch31.dvi

プログラミング演習 Ⅰ 第 14 回 2017/6/5( 月 ) ゲームを作る クイズ 担当 : 紅林林

アルゴリズムとデータ構造1

スライド 1

ALG ppt

2009 T

スライド 1

問 次の Fortran プログラムの説明及びプログラムを読んで、設問に答えよ。

明解Javaによるアルゴリズムとデータ構造

アルゴリズムとデータ構造1

cpp4.dvi

piyo0702a.rtfd

8 if switch for while do while 2

Microsoft PowerPoint - chap10_OOP.ppt

人工知能入門

Java言語 第1回

新・明解Java入門

ALG2012-A.ppt

0720

Transcription:

float xball;// 円の中心の X 座標 float yball; // 円の中心の Y 座標 float rball; // 円の半径 color cball; // 円の色 // 円を移動させる void updateball(){ yball -= 1; if(yball+rball< 0){ yball = height+rball; // 円を描く void drawball(){ stroke(cball); fill(cball); ellipse(xball,yball,2*rball,2*rball); colormode(hsb,359,99,99); // 円の初期状態の決定 rball = random(10,20); xball = random(rball,width-rball); yball = height+rball; cball =color(random(360), random(50,100), random(50,100)); background(0,0,99); updateball(); drawball(); 1 class Ball { (a) x;// 円の中心の X 座標 (b) y;// 円の中心の Y 座標 (c) r;// 円の半径 (d) c; // 円の色 (e) (){ // コンストラクタの設定 r = random(10,20); x = random(r,width-r); y = height+r; c = color(random(360), random(50,100), random(50,100)); (f) myball; // 円を移動させる void updateball(){ (g) -= 1; if( (h) + (i) < 0){ (j) = height+ (k) ; // 円を描く void drawball(){ stroke( (l) ); fill( (m) ); (n) ; colormode(hsb,359,99,99); myball = new (o) ();

background(0,0,99); updateball(); drawball(); class Ball { (a) x;// 円の中心の X 座標 (b) y;// 円の中心の Y 座標 (c) r;// 円の半径 (d) c; // 円の色 (e) (){ // コンストラクタの設定 r = random(10,20); x = random(r,width-r); y = height+r; c = color(random(360), random(50,100), random(50,100)); // 円を移動させる void update(){ (g) -= 1; if( (h) + (i) < 0){ (j) = height+ (k) ; // 円を描く stroke( (l) ); fill( (m) ); (n) ; (f) myball; colormode(hsb,359,99,99); myball = (o) ; background(0,0,99); (p).update(); (q).draw(); 2

class Ball { (a) x;// 円の中心の X 座標 (b) y;// 円の中心の Y 座標 (c) r;// 円の半径 (d) c; // 円の色 // コンストラクタの設定 (e) (float x0,float y0, float r0,color c0){ x = x0; y = y0; r = r0; c = c0; // 円を移動させる void update(){ (g) -= 1; if( (h) + (i) < 0){ (j) = height+ (k) ; // 円を描く stroke( (l) ); fill( (m) ); (n) ; 3 (f) myball; colormode(hsb,359,99,99); myball = new Ball(width/2, height, 20, color(0,99,99)); background(0,0,99); (p).update(); (q).draw(); (f) myball; colormode(hsb,359,99,99); myball = new Ball(width/2, height, 20, (z) );

background(0,0,99); (p).update(); (q).draw(); color c; int xpos; int ypos; int xspeed; size(200,200); c = color(255); xpos = width/2; ypos = height/2; xspeed = 1; void display(){ rectmode(center); stroke(c); fill(c); rect(xpos,ypos,20,10); (a) Car (b) color c; int (c) ; int (d) ; int (e) ; Car(){ // デフォルトコンストラクタ c = color( (f) ); xpos = (g) ; ypos = (h) ; xspeed = 1; void display(){ rectmode(center); stroke( (i) ); fill( (j) ); rect( (k), (l),20,10); void drive(){ (m) += (n) ; if( (o) > (p) ){ (r) = 0; void drive(){ xpos += xspeed; if(xpos > width){ xpos = 0; 4

background(0); drive(); display(); Car (r) ; size(200,200); // Car オブジェクトを作る mycar = (r) ; background(0); (s) (); (t) (); (a) Car (b) color c; int (c) ; int (d) ; int (e) ; // デフォルトコンストラクタ Car(){ c = color( (f) ); xpos = (g) ; ypos = (h) ; xspeed = 1; // 引数付きのコンストラクタ Car (color carcolor,int x,int y,int s){ c = carcolor; xpos = x; ypos = y; xspeed = s; void display(){ rectmode(center); stroke( (i) ); fill( (j) ); rect( (k), (l),20,10); void drive(){ (m) += (n) ; if( (o) > (p) ){ (r) = 0; Car (s) ; Car (t) ; mycar1 = (u) ; mycar2 = new (v) (color( (w) ), width/2,height/4,1); background(0); (x).drive(); (y).display(); (z).drive(); (aa).display(); 5

float x = 100; float y = 0; float speed = 3; float gravity = 0.5; size(200,400); background(100); fill(255); nostroke(); rectmode(center); rect(x,y,10,20); y = y+speed; speed = speed + gravity; if(y+10 > height){ speed = -0.95*speed; y = height-10; 6

float xcenter; // 円の中心の X 座標 float ycenter; // 円の中心の Y 座標 float xspeed; // X 軸方向の移動速度 float yspeed; // Y 軸方向の移動速度 float radius; // 円の半径 radius = 10; xcenter = -radius; ycenter = -radius; xspeed = 0.5; yspeed = 1.2; class (a) { float xcenter; // 円の中心の X 座標 float ycenter; // 円の中心の Y 座標 float xspeed; // X 軸方向の移動速度 float yspeed; // Y 軸方向の移動速度 float radius; // 円の半径 // デフォルトコンストラクタ (b) (float vx0,float vy0){ radius = 10; xcenter = radius; ycenter = radius; xspeed = vx0; yspeed = vy0; 7

background(255); // move xcenter += xspeed; ycenter += yspeed; // draw stroke(0); fill(0); ellipse(xcenter,ycenter,2*radius,2*radius); void move(){ xcenter += xspeed; ycenter += yspeed; stroke(0); fill(0); ellipse(xcenter,ycenter,2*radius,2*radius); (c) aball; aball = new (d) ( (e), (f) ); background(255); aball.move(); aball.draw(); 8

float xcenter; // 円の中心の X 座標 float ycenter; // 円の中心の Y 座標 float xspeed; // X 軸方向の移動速度 float yspeed; // Y 軸方向の移動速度 float radius; // 円の半径 radius = 10; xcenter = -radius; ycenter = -radius; xspeed = 0.5; yspeed = 1.2; background(255); if(isoutofrange()){ xcenter = -radius; ycenter = -radius; xspeed = random(0.4,2.0); yspeed = random(0.4,2.0); // move xcenter += xspeed; ycenter += yspeed; // draw stroke(0); fill(0); ellipse(xcenter,ycenter,2*radius,2*radius); class (a) { float xcenter; // 円の中心の X 座標 float ycenter; // 円の中心の Y 座標 float xspeed; // X 軸方向の移動速度 float yspeed; // Y 軸方向の移動速度 float radius; // 円の半径 // デフォルトコンストラクタ (b) (float vx0,float vy0){ radius = 10; xcenter = radius; ycenter = radius; xspeed = vx0; yspeed = vy0; void move(){ xcenter += xspeed; ycenter += yspeed; stroke(0); fill(0); ellipse(xcenter,ycenter,2*radius,2*radius); (c) isoutofrange(){ if(xcenter-radius > width){ return true; else if(ycenter-radius > height){ return true; return false; 9

boolean isoutofrange(){ if(xcenter-radius > width){ return true; else if(ycenter-radius > height){ return true; return false; (d) aball; aball = new (e) ( (f), (g) ); if(aball.isoutofrange()){ aball.xcenter = (h) ; aball.ycenter = (i) ; aball.xspeed = (j) ; aball.yspeed = (k) ; aball.move(); aball.draw(); 10