1.小畫家大亂鬥
Server 端
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);
}
}
Client 端
import processing.net.*;
Client client;
void setup(){
size(300,300);
client = new Client(this,"127.0.0.6",7777);
}
void draw(){
if(mousePressed){
line(mouseX,mouseY,pmouseX,pmouseY);
client.write(mouseX+" "+mouseY+" "+pmouseX+" "+pmouseY+"\n");
}
}
Client端連線Server端
Server
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 []xyxy = splitTokens(now);
line( int(xyxy[0]), int(xyxy[1]), int(xyxy[2]), int(xyxy[3]));
}
}
}
2019年12月12日 星期四
訂閱:
張貼留言 (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就會使整個圓跑出去 於是就讓他往回彈 就變成成功的彈彈球 自己製作迷宮 先畫一張自己設計的地圖 並先試看看能不能匯入 並且...
沒有留言:
張貼留言