1. 伺服器端 - 畫線
import processing.net.*;
Server server=null;
Client client = null;
void setup()
{
size(300,300);
server = new Server(this, 7777);
}
void draw()
{
Client temp = server.available();
if(temp != null)
client = temp;
if(client != null)
{
String now = client.readString();
if(now!=null) print(now);
}
}
---------------------------------------------------------------------------------------------------------------
Clinet端
import processing.net.*;
Client client;
void setup()
{
size(300,300);
client = new Client(this,"127.0.0.1", 7777);
}
void draw()
{
if(mousePressed)
{
line(mouseX, mouseY, pmouseX, pmouseY);
client.write(mouseX + " "+ mouseY + " " +pmouseX +" " + pmouseY);
}
}
import processing.net.*;
Client client;
ArrayList<PVector> points;
void setup()
{
size(300,300);
client = new Client(this,"127.0.0.1", 7777);
points = new ArrayList<PVector>();
}
void draw()
{
background(255);
for(int i=0; i<points.size(); i++)
{
ellipse(points.get(i).x, points.get(i).y, 5,5);
}
}
void mouseDragged()
{
if(mouseButton == LEFT)
{
points.add(new PVector(mouseX, mouseY));
client.write(mouseX + " " + mouseY);
}
if(mouseButton ==RIGHT && points.size()> 0) points.remove(points.size() -1 );
}
---------------------------------------------------------------------------------------------------------------
import processing.net.*;
Server server=null;
Client client = null;
void setup()
{
size(300,300);
server = new Server(this, 7777);
}
void draw()
{
Client temp = server.available();
if(temp != null)
client = temp;
if(client != null)
{
String now = client.readString();
if(now!=null)
{
String [] word = splitTokens(now);
line(int(word[0]), int(word[1]), int(word[2]), int(word[3]));
}
}
}
訂閱:
張貼留言 (Atom)
alanhc 互動技術-week17 [final]
回顧這學期的作品: 期中作業:LANDING:PLANET 賣點&特點: 炫麗的特效 物理(星球重力及降落)及粒子系統(噴射) 世界地圖可根據視角縮放 困難點: 重寫3次最終改寫成物件導向的CLASS寫法...
-
先把上次的程式覆蓋 void setup(){ pinMode(8,OUTPUT); pinMode(2,INPUT_PULLUP); } void loop(){ if(digitalRead(2)== LOW ) tone(8,520,...
-
1. 複習按住boutton可以發出聲音 void setup(){ pinMode(8, OUTPUT); pinMode(2, INPUT_PULLUP); } void loop(){ if(digitalRead(2)==LOW) tone(8,...
-
第一張圖是讓使用者的圈圈可以自己移動 但他有個缺點 就是圈圈會跑出視窗外面 於是加上了if 假使中心大於350就會使整個圓跑出去 於是就讓他往回彈 就變成成功的彈彈球 自己製作迷宮 先畫一張自己設計的地圖 並先試看看能不能匯入 並且...
沒有留言:
張貼留言