All posts by Wuji Cao

Elevator

I was waiting for the elevator going to SC.

This building is very weird. There’s no stair going to SC apart from the emergency one. Though there’s two elevators, only one could really go to SC. It seemed that if a person is unlucky enough he or she would probably can’t go to the SC forever since the elevator that pick him/her up would always be the one that don’t go to. And this did happened to me once when I’m trying to get the access of the printer at lounge.

Later, a friend of mine told me that if I really want to go to sc, I should press down at 1F. It seemed weird since between 1F and SC there’s -1F and the elevator which have no access do go to -1F. But following this rule, I could really go to SC when ever I want. In that case, the elevator has been set an exception that if it’s clicked at 1F the elevator which goes to SC would have very high priority to pick people up first.

This is one representation of algorithms in our life. In this cases, elevator is designed to do some math sequences according to the orders it already received. If elevator 1 is at 1F and elevator 2 is at 5 F, some one at  2F would usually picked up by elevator 1. And in special cases, it would do special logic like going to the sc.

Final Project

https://www.youtube.com/watch?v=2iz91X_GDlk&feature=youtu.be

What is it?

This is a 2d shooting survival game. The target in this game is too survive as long as possible. The  unique part of this game comparing to other games of the same type is that apart from shooting all those enemies, you can choose to transform your self and let those enemies looks like npc and communicate with them which is also a good way to survive as well.

Why made this?

The original thoughts is just to make a game. In the game, we wanted to give player the chance to decided how he or she interacted with the game npcs. There’s already many games that you could choose to be a good or bad people and that influence the ending. But all of them were either fixed (only having the options to kill some key characters or not), or too irrelevant (killing people or not just influence your crime level). So in our one, we want to let player the freedom to choose and also great responses to their actions. The responses are not from the plot but instead the player them self. They will learned that those enemies could be nice person who would be glad to help you if you look at them in another perspective.

How do we make this?

Using unity and processing

Unity is responsible for all the game part, while processing in charge of the sound control. When the processing received the signal of laughing, it would output a “Space” key press. Then , the game mechanic would be triggered.

 

Some inspiration

Toby Fox who created “Undertale” would be a great inspiration of the game play part of my project.

One alternative decision I made on my game play is that the size of player not only decide the armor and fire rate of player, but also the action of the npc/enemies. Combing with the story in hypercenema, the player would camouflage into robot form and the robot would treat him as another robot and take great care of him. My target is to let the player decide wether those “could be friendly robot” could be treated as friend or not.

“Undertale” did a really great job at this part. It let player choose weather to treat npc as friends or kill them all to gain exp. The player’s action would of course influence the plot. And most importantly, unlike many other game in which most morality choice were bounded with story telling part, “Undertale” ‘s greatest improvement is combined that with the game play. You can go through the game without killing (in some game, “defeat” replced slain)anyone which seemed impossible in a RPG game in the past.

“Undertale ” let players do morality decision by linking npc’s life to plot. No kills rewarded good plot while killing rewarded stronger strength. Since I don’t have enough time to to such precise works, I may need to balance the reward of killing a friendly robot and saving one. If doing both thing would have the same influence to the player, the player then only need to do what ever they want according to their heart.

 

Arrary and for loop

The game already used both of them.

The array stores the bullets and enemies

The for loop checked out them each draw and asked them to work.

https://editor.p5js.org/cwj/full/rJItmRDcm

let i_fly
let i_bb
let i_em
function setup() {
createCanvas(400, 400);
hardslider = createSlider(1, 3, 1);
textSize(20);
textAlign(CENTER, CENTER);
input = createInput();
input.position(135, 300);
button = createButton(‘start’);
button.position(input.x + input.width, 300);
i_fly = loadAnimation(‘images/spaceship.png’,’images/spaceship2.png’)
i_bb = loadAnimation(‘images/bullet.png’)
i_em = loadAnimation(‘images/enemy.png’)
}
let score=0;
let hname=”none”;
let hscore=0;
let page =1;
let x = 200;
let y = 350;
let b = false;
let W;
let A;
let S;
let D;
let J;
let timer1 = 0;
let timer2 = 0;
let timer3 = 0;
let action = 5;
let pspeed = 4;
let espeed = 3;
let gspeed = 60;
let sspeed = 20;
let army = [];
let army_s= [];
let bullets = [];
let bullets_s = [];
let hp = 3;
let hard=1;
let avatar;
let aangle;

function keyPressed() {
if (key === “w”) {
W = true;
}
if (key === “a”) {
A = true;
}
if (key === “s”) {
S = true;
}
if (key === “d”) {
D = true;
}
if (key === “j”) {
J = true;
}
}

function keyReleased() {
if (key === “w”) {
W = false;
}
if (key === “a”) {
A = false;
}
if (key === “s”) {
S = false;
}
if (key === “d”) {
D = false;
}
if (key === “j”) {
J = false;
}
}

function actionCheck() {
if (A === true) {
if (W === true) {
action = 7;
} else if (S === true) {
action = 1;
} else {
action = 4;
}
} else if (D === true) {
if (W === true) {
action = 9;
} else if (S === true) {
action = 3;
} else {
action = 6;
}
} else {
if (W === true) {
action = 8;
} else if (S === true) {
action = 2;
} else {
action = 5;
}
}
}

function enemy(x, y, number) {
army_s[number]=createSprite(x,y,40,20);
army_s[number].addAnimation(‘1’,i_em)
this.speed = espeed;
army_s[number].setVelocity(0,espeed)

this.move = function() {
if (army_s[number].position.y>390) {
hp -= 1;
// print(‘hp = ‘+hp)
this.destroy();

}
for (let i = 0; i < bullets.length; i++) {//collision check
/* let j= bullets[i].checkx()
let w= bullets[i].checky()
if (j > x-20 && j < x + 20 && w < y&& w > y-40)*/
if(army_s[number].collide(bullets_s[i]))
{
bullets[i].destroy();
this.destroy();
score=score+1*hard;
}
}
drawSprite(army_s[number])
//rect(x-10, y-10, 20, 20);
// y = y + this.speed;
}

this.destroy = function() {
army_s[number].remove();
army.splice(this.number, 1);
}
}

function bullet(x, y,number) {
bullets_s[number]=createSprite(x,y,10,100)
// bullets_s[number].addAnimation(‘1’,i_bb)
this.speed = 10;
bullets_s[number].setVelocity(0,-this.speed)
this.move = function() {
// ellipse(x, y, 10, 10);
drawSprite(bullets_s[number])
/* print(‘length ‘+bullets_s.length)
print(‘indext ‘+number)
print*/
if (bullets_s[number].position.y < 0) {
this.destroy();
}
// y = y – this.speed
}
/* this.checkx =function()
{
return x;
}
this.checky =function()
{
return y;
}*/
this.destroy = function() {
bullets_s[number].remove();
bullets.splice(this.number, 1);
}

}
function start()
{
avatar=createSprite(x,y,20,30)
avatar.addAnimation(“1”,i_fly)
hard=hardslider.value()
gspeed=60/hard
score=0;
input.hide()
button.hide()
hardslider.hide()
hp=3;
timer1=0;
timer2=0;
timer3=0;
bullets.splice(0);
bullets_s.splice(0);
army.splice(0);
army_s.splice(0);
page=2;
}

function draw() {
actionCheck(); //control start
if(page===1)// in manu
{
textSize(20)
fill(255)
background(140);
text(“use WASD to control the spaceship”,200,50);
text(“press J to shot”,200,100);
text(“If enemy hit the ground three times,”,200,150)
text(“you die”,200,200)
text(“Please enter your name and start”,200,250)
text(“High score :”,100,350)
text(hname,200,350)
text(hscore,250,350)
textSize(15)
text(“Drag the bar to change difficulty”,200,375)
button.mousePressed(start);
}
if(page===2)// if in game
{

if (action === 4) {
//avatar.position.x = avatar.position.x – pspeed;
aangle=180
}
if (action === 1) {
//avatar.position.x = avatar.position.x – sqrt(2*pspeed);
// avatar.position.y = avatar.position.y + sqrt(2*pspeed);
aangle=135
}
if (action === 3) {
//avatar.position.x = avatar.position.x + sqrt(2*pspeed);
//avatar.position.y = avatar.position.y + sqrt(2*pspeed);
aangle=45
}
if (action === 7) {
//avatar.position.x = avatar.position.x – sqrt(2*pspeed);
//avatar.position.y = avatar.position.y – sqrt(2*pspeed);
aangle=225
}
if (action === 9) {
//avatar.position.x = avatar.position.x + sqrt(2*pspeed);
//avatar.position.y = avatar.position.y – sqrt(2*pspeed);
aangle=315
}
if (action === 6) {
//avatar.position.x = avatar.position.x + pspeed;
aangle=0
}
if (action === 8) {
//avatar.position.y = avatar.position.y – pspeed;
aangle=270
}
if (action === 2) {
//avatar.position.y = avatar.position.y + pspeed;
aangle=90
}
if (J === true) {
if (b === false) {
b = true;
bullets.push(new bullet(avatar.position.x, avatar.position.y – 15,bullets.length))
}

}

if (avatar.position.x < 0) {
avatar.position.x = 0;
}
if (avatar.position.x > 400) {
avatar.position.x = 400;
}
if (avatar.position.y < 0) {
avatar.position.y = 0;
}
if (avatar.position.y > 365) {
avatar.position.y = 365;
} //controll end

background(70); //characer and ground generation
fill(150);
//triangle(x – 10, y + 10, x + 10, y + 10, x, y – 20);
if(action!=5){avatar.setSpeed(pspeed,aangle)}
else{avatar.setSpeed(0)}
drawSprite(avatar)
fill(255, 0, 0);
rect(0, 375, 400, 25);

fill(255, 255, 0); //bullet generation
for (let i = 0; i < bullets.length; i++) {
bullets[i].move();
}
if (b === true) { //bullet reload
if (timer1 < sspeed) {
timer1 += 1;
} else {
timer1 = 0;
b = false;
}
}

fill(0, 0, 255); //enemy generation
for (let i = 0; i < army.length; i++) {

army[i].move();
}
timer2 += 1; //enemy reload
if (timer2 === gspeed) {
army.push(new enemy(random(40, 360), 0, army.length))
timer2 = 0;
}
fill(0,255,0)//draw hp
rect(0,0,20,hp*20)
if(hp<=0)
{
page=3;
}
}// end of gaming loop

if(page === 3)//game over
{
if(score>hscore)
{
hscore=score;
hname=input.value();
}
fill(255,0,0)
background(140);
textSize(30)
text(“Game over”,200,200);
text(“Your score is”,200,250)
text(score,200,300)
timer3=timer3+1
if(timer3===120)
{
page=1
button.show()
input.show()
hardslider.show()
}
}
}

Happy Space Trip

Finally I still decided to make a space shooting game.

But it would be a brand new one, isolated from the existed one.

The most significant change is that you can change the spaceship’s scale now!

By dragging the bar, can change the scale. At different scale, the space ship would have different features.

The control would be different as well, instead of forced to face up, you can now control the angle of the space craft yourself by rotating it.

Also, you are no longer shooting the infinite enemies coming from the up. You can go where very you want, the world would be infinite. But there’s a limitation of fuel apart from health point. While hp would recover over time, fuel loses over as time past. So you have to pick the fuel up through your trip (the blue ball)

There would be three types of npc that generated randomly. Green ones that helps you, red ones that attacks you, and yellow one that would change into green or red depends on which side attacks them first.

01

02

GB

Globalization is strongly connected with the development of technology. The discovery of American continent  is based on the evolution of sealing technology. The steam boat boosted the global trading. And the invention of aircraft connected made long ranged travel easier. At  modern age, the invention of internet is the most significant one that developed globalization. The information exchange became far cheaper and faster. People from different time zones can discuss the same topic under one sub-reddit with out messing their biological clock.

Globalization is a good thing. I cant imagine a world where I cant play Japanese video games at American. There’s countless advantages globalization brought but there’s still some little troubles. Some cultural conflicts always occurred when people with distinct background met. And for the in developed countries their chances of develop were greatly reduced since countries strong enough would prevent them from growing easily through globalization.

Ideas…

001

  1. The sensor that detect the strength that hit on them. The strength would determine how powerful you are on the one on one pushing game on the computer.

 

002

 

2. alter joystick.

use card paper to make a larger joystick to replace this one. And attach four buttons on it so you can control the game on the computer with one hand.

003

3. physical pang controller.

Control the pang game on the computer with two sensor that works like parameter.

spider web

I think my thinking is non-linear in many of the times. Though I have the chances to drain into one question and think for a long time, in most of the cases my thought jumps around from one topic to another (and waste a lot times in exams). I think in some way this is very similar to the hypertext reading: you went into one article for A, and there’s a term B that you are not farmiliar with then you clicked the hyper text of it. Then you moves to B’s explnation where C attracts you. This would also happens if your reading books or newspaper, but the hypertext strongly increased the frequency.

In that case, there is the possiblity to build everything with a URL. By infinite hypertext you can make everything sharing simliarities connected  with hypertext. Since there’s nothing on the world that are totally unrelated to the others(When this happen, it becomes realted by the characteristic of “unrelated”), you can include everything then.

A game with high score record, and you can change the difficulty with the bar

https://editor.p5js.org/full/rJItmRDcm

All insturctions are already inside the game

The current issue is that it could not store the high score when you exsit, also there’s so game play bugs to be solved.

probabely going to make a cellphone version if I have time

code:

function setup() {
createCanvas(400, 400);
hardslider = createSlider(1, 3, 1);
textSize(20);
textAlign(CENTER, CENTER);
input = createInput();
input.position(135, 300);
button = createButton(‘start’);

button.position(input.x + input.width, 300);

}
let score=0;
let hname=”none”;
let hscore=0;
let page =1;
let x = 200;
let y = 350;
let b = false;
let W;
let A;
let S;
let D;
let J;
let timer1 = 0;
let timer2 = 0;
let timer3 = 0;
let action = 5;
let pspeed = 4;
let espeed = 3;
let gspeed = 60;
let sspeed = 20;
let army = [];
let bullets = [];
let hp = 3;
let hard=1;

function keyPressed() {
if (key === “w”) {
W = true;
}
if (key === “a”) {
A = true;
}
if (key === “s”) {
S = true;
}
if (key === “d”) {
D = true;
}
if (key === “j”) {
J = true;
}
}

function keyReleased() {
if (key === “w”) {
W = false;
}
if (key === “a”) {
A = false;
}
if (key === “s”) {
S = false;
}
if (key === “d”) {
D = false;
}
if (key === “j”) {
J = false;
}
}

function actionCheck() {
if (A === true) {
if (W === true) {
action = 7;
} else if (S === true) {
action = 1;
} else {
action = 4;
}
} else if (D === true) {
if (W === true) {
action = 9;
} else if (S === true) {
action = 3;
} else {
action = 6;
}
} else {
if (W === true) {
action = 8;
} else if (S === true) {
action = 2;
} else {
action = 5;
}
}
}

function enemy(x, y, number) {
this.speed = espeed;
this.move = function() {
if (y === 390) {
this.destroy();
hp = hp – 1;
}
for (let i = 0; i < bullets.length; i++) {//collision check
let j= bullets[i].checkx()
let w= bullets[i].checky()
if (j > x-20 && j < x + 20 && w < y&& w > y-40)
{
bullets[i].destroy();
this.destroy();
score=score+1*hard;
}
}
rect(x-10, y-10, 20, 20);
y = y + this.speed;
}

this.destroy = function() {
army.splice(this.number, 1);
}
}

function bullet(x, y,number) {
this.speed = 10;
this.move = function() {
if (y < 0) {
this.destroy();
}
// xb[number]=x;
// yb[number]=y;
ellipse(x, y, 10, 10);
y = y – this.speed
}
this.checkx =function()
{
return x;
}
this.checky =function()
{
return y;
}
this.destroy = function() {
bullets.splice(this.number, 1);
}

}
function start()
{
hard=hardslider.value()
gspeed=60/hard
score=0;
input.hide()
button.hide()
hardslider.hide()
hp=3;
timer1=0;
timer2=0;
timer3=0;
bullets.splice(0);
army.splice(0);
page=2;
}

function draw() {
actionCheck(); //control start
if(page===1)// in manu
{
fill(255)
background(140);
text(“use WASD to control the spaceship”,200,50);
text(“press J to shot”,200,100);
text(“If enemy hit the ground three times,”,200,150)
text(“you die”,200,200)
text(“Please enter your name and start”,200,250)
text(“High score :”,100,350)
text(hname,200,350)
text(hscore,250,350)
button.mousePressed(start);
}
if(page===2)// if in game
{

if (action === 4) {
x = x – pspeed;
}
if (action === 1) {
x = x – sqrt(pspeed);
y = y + sqrt(pspeed);
}
if (action === 3) {
x = x + sqrt(pspeed);
y = y + sqrt(pspeed);
}
if (action === 7) {
x = x – sqrt(pspeed);
y = y – sqrt(pspeed);
}
if (action === 9) {
x = x + sqrt(pspeed);
y = y – sqrt(pspeed);
}
if (action === 6) {
x = x + pspeed;
}
if (action === 8) {
y = y – pspeed;
}
if (action === 2) {
y = y + pspeed;
}
if (J === true) {
if (b === false) {
b = true;
bullets.push(new bullet(x, y – 15,bullets.length))
}

}

if (x < 0) {
x = 0;
}
if (x > 400) {
x = 400;
}
if (y < 0) {
y = 0;
}
if (y > 365) {
y = 365;
} //controll end

background(70); //characer and ground generation
fill(150);
triangle(x – 10, y + 10, x + 10, y + 10, x, y – 20);
fill(255, 0, 0);
rect(0, 375, 400, 25);

fill(255, 255, 0); //bullet generation
for (let i = 0; i < bullets.length; i++) {
bullets[i].move();
}
if (b === true) { //bullet reload
if (timer1 < sspeed) {
timer1 += 1;
} else {
timer1 = 0;
b = false;
}
}

fill(0, 0, 255); //enemy generation
for (let i = 0; i < army.length; i++) {

army[i].move();
}
timer2 += 1; //enemy reload
if (timer2 === gspeed) {
army.push(new enemy(random(40, 360), 0, army.length))
timer2 = 0;
}
fill(0,255,0)//draw hp
rect(0,0,20,hp*20)
if(hp===0)
{
page=3;
}
}// end of gaming loop

if(page === 3)//game over
{
if(score>hscore)
{
hscore=score;
hname=input.value();
}
fill(255,0,0)
background(140);
text(“Game over”,200,200);
text(“Your score is”,200,250)
text(score,200,300)
timer3=timer3+1
if(timer3===120)
{
page=1
button.show()
input.show()
hardslider.show()
}
}
}

Cultural evolution

In cultural evolution, a good language is constructed by features that help human to communicate. And people developed them to help our selves. Biological evolution, oppositely, is not directed by the nature. As long as you can survive, you can continued to spread. And how it actually evolve could not be controlled by the species them self either. Its just random mutations that created the diversity. One pattern of different communications systems is of course every words could be presented. Another the universality of construction (alphabet or radical). In that case, a individual which is foreign to the language have the chance to study it.

Communication would today is very convenient due to two factors: one the technology gave us the chance to transform the datas very quick. This is the advance in media. Another factor is that the data base is great enough to translate one language to another so the language barrier is reduced. I can not imagine the change of language itself in the future, but the technology would definitely be improved a lot. There’s possibility of the reading nerve action in a longer term future. In short term the internet access speed would be improved.

 

Digital Selfie

001

Code:

function setup() {
createCanvas(400, 400);
}

function draw() {
background(255,0,0);
fill(252,212,183);//meat
stroke(252,212,183);
ellipse(200,200,195,250);
fill(0);//Black
stroke(0);
triangle(90,200,110,75,150,75);
triangle(150,175,110,75,175,75);

rect(110,73,179,50);

triangle(310,200,290,75,250,75);
triangle(250,175,290,75,225,75);

ellipse(200,120,100,50);

quad(140,200,180,200,180,195,140,190);
quad(260,200,220,200,220,195,260,190);

ellipse(170,200,10,10);
ellipse(230,200,10,10);

quad(170,290,230,290,230,285,170,285);

fill(255,0,0);//erase
stroke(255,0,0);
triangle(50,180,200,0,0,0);
triangle(350,180,200,0,400,0);
triangle(0,400,190,400,100,220);
triangle(400,400,210,400,300,220);

/*fill(0);//reference
stroke(0);
line(100,0,100,400);
line(200,0,200,400);
line(300,0,300,400);
line(0,100,400,100);
line(0,200,400,200);
line(0,300,400,300);
*/
}

Our understanding of the world is based on the “sensors”: eyes for light, nose for smell, ears for sound, mouse for taste, skin for temperature and pressure. Those Sensors gained informations and transferred it to our brain through nerve system. The brain processed those information and then we could learn how the world looks like.

Emotions, in some cases, are the part of our default setting of our body. For example, anger would be activated if something very bad happened and the source of the bad thing is very obvious, and the reaction of anger would be violent actions. Of course, emotion and not control your conscious. But this system would produce hormone to effect your conscious. Then we are effected by emotion with out realizing it.

Computer could reach our body easily: the graphic to the eye, the sound to the ear, the vibration to the skin. Nose and mouse could be reach as well with some more expensive devices. But emotion is another story. If a computer want to reach one’s emotion, it have to calculate different factors of the human to estimate what is the emotion at that moment. So that would require many biology research basic.

Moral Machine?

Those question I’ve thought about for long times but did not see clear solutions. What is moral? Who decides what is moral? What is machines? Those question would have many different answers with the change of time and space.

The definitions could not be very general. For example, in Isaac Asimov’s novel, robots were supposed to follow the three role of robotics in which include a robot should do no injuries to human. However, one clever robot decided that the human here should not be the individuals but the whole human beings so he killed two man who’s threatening the human races. This robot did a good for the whole human beings, but he obeyed the original definition of human. But how could we know, when the robot is killing people for the second time, is it killing the right one?

The definitions could also not be to specific. In the history, people ruled each other by calling others slaves which is no longer a human. If the definition is to restricted, there would be many cases in which the computer recognized human non human.

Thus, in my opinion it would never be a good idea to let machines involve moral things. I would be glad to let them do everything else, but not moral which even human beings themselves can not figure out.

LED base dodge game

GAME PLAY

This is a LED base dodge game.

In this game, you are controlling the green light at the button with the joystick. 003

 

You have to avoid the red light at the top.002

It would be fine if they are still light. But when they dimmed, that means they are attacking. So dodge before the LED dim.

 

The game would become faster as you avoid more attacks.

If you get hit, your LED would become dimmer at the first time and game over for the second hit.

004 

If the games over, all game play LED would be turned off. And a yellow LED would be turned on.

001

Press up to try again.

Unfortunately, no score recording at this moment.

https://youtu.be/qpFWHdmYs3s (Second game play)

Process

I used digital write pin for the Red LED

analog write for the green so I can control the brightness.

code:

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
pinMode(8,OUTPUT);
pinMode(2,INPUT);
digitalWrite(2,HIGH);
}
boolean s1=true; //start of the variables
boolean s2=false;
int x1=analogRead(0);
int y1=analogRead(1);
int xy2=0; // the input of joystick
int xy1;
const int led1=8;
const int led2=12;
const int led3=13;
const int ledu[]={led1,led2,led3};
const int led4=3;
const int led5=5;
const int led6=6;
const int ledd[]={led4,led5,led6};
int hp=255;
int safe;
int ledn;
int ledp=led6;
int hard=1000;
unsigned long t1=millis();// end of the variables

void loop() {
// put your main code here, to run repeatedly:
int x2=analogRead(0);// start of the input
int y2=analogRead(1);
if(x2<350)
{
if(y2<350){xy2=7;}
else if(y2>650){xy2=1;}
else {xy2=4;}
}
else if(x2>650)
{
if(y2<350){xy2=9;}
else if(y2>650){xy2=3;}
else {xy2=6;}
}
else
{
if(y2<350){xy2=8;}
else if(y2>650){xy2=2;}
else {xy2=5;}
} //end the input

if (hp<0){hp=0;}//start of the gameplay;
if (hp!=0)
{
if(millis()-t1>=hard)//start of the red light loop
{
if(s1== true)
{
for(int i=0;i<3;i++)
{
digitalWrite(ledu[i],HIGH);
}
s1=false;
safe=(int)(random(0,3));
digitalWrite(ledu[safe],LOW);
}
else if(s1==false )
{
for(int i=0;i<3;i++)
{
digitalWrite(ledu[i],LOW);
}
s1=true;
if((xy2-4)!=safe)
{
hp=hp-230;
}
else
{
if(hard>350)
{
hard=hard-50;
}
}
}
t1=millis();
}// end if the red light loop

if(xy2==4){ledn=led4;}// start of the output
else if(xy2==5){ledn=led5;}// there would be a very intersting bug if I use the array here
else if(xy2==6){ledn=led6;}
analogWrite(ledn,hp);
if(ledn!=ledp){analogWrite(ledp,0);}
ledp=ledn;// end of ouput
}//if game not end
else
{
for(int i=0;i<3;i++)
{
digitalWrite(ledu[i],LOW);
}
for(int i=0;i<3;i++)
{
analogWrite(ledd[i],0);
}
analogWrite(9,255);
if(xy2==8)
{
analogWrite(9,0);
hp=255;
s1=true;
t1=millis;
hard=1000;
}//if the games end

}

x1=x2;
y1=y2; // store this term’s input
xy1=xy2;
}

liquid trigger advance

Comparing with the last version in witch the liquid trigger and light bulb were in series, this time they are separated and the light bulb is controlled by code instead of physical connection.

There’s two challenge I faced making this one. The first one is totally handless. At the end I picked a straw to do that. Another challenge is how to turn off the bulb immediately after the switch is triggered. At the beginning, I was using delay to let the led blink. But that means even if you triggered the switch during the light period, it would not turns into dark immediately due to the delay. In that case, I used millis which would count who long it took already from the beginning. I set a variable which usually are fixed but when the differences between it and millis are over 500, makes it equal to millis and ask the light bulb to switch its status. I used unsigned long instead of int to avoid overflow.

This is the code while testing with normal button. I think it’s actually more complex comparing to the liquid switch one since  int this one the clicking the button change the status. In liquid one, the trigger is the status it self.

void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(12,OUTPUT);
digitalWrite(13,HIGH);
pinMode(7,INPUT);
}
boolean s1=true; //timer
boolean s2=true; //button
unsigned long t1=millis();
void loop() {

while(s2==true) //on status
{
if(millis()-t1>=500) //time reset;
{
s1-=1;
t1=millis();
}
if(s1==true){digitalWrite(13,HIGH);}
else{digitalWrite(13,LOW);}
if(digitalRead(7)==1) //button pressed
{
while(digitalRead(7)==1){} //you can hold button now
s2=false;
digitalWrite(13,LOW);

}
}
while(s2==false) //off status
{
if(digitalRead(7)==1) //button pressed
{
while(digitalRead(7)==1){} //you can hold button now
s2=true;
t1=millis();

}
}
}

liquid one:

void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
pinMode(7,INPUT);
}
boolean s1=true; //timer
boolean s2=true; //button
unsigned long t1=millis();
void loop() {

while(digitalRead(7)==1) //on status
{
if(millis()-t1>=500) //time reset;
{
s1-=1;
t1=millis();
}
if(s1==true){digitalWrite(13,HIGH);}
else{digitalWrite(13,LOW);}
}
while(digitalRead(7)==0) //off status
{
digitalWrite(13,LOW);
}
}

testing the input from the trigger001

Stimulating when the liquid is very conductive

002

in water

003

the test

https://youtu.be/Yu9xsA6rqrU

final

https://youtu.be/qsFPrTaDrEE

 

 

Interaction

From my point of view, the greatest change that computational media have is the introduction of interaction. I’m not saying that there’s not interaction at all in the classic medias, but computational media brings it onto the stage formally an systematically.

I think interaction provide the story a brand new layer, like the  change from 2d to 3d, black and white to colors, mute movie to the one with voice.  Games are the most easy example I can pick to talk about how it works. There’s many games that have options in their story and different option player took would alter the ending or even the rest of the whole story. One part is that “Player making choices” helps to drag audience deeper into the story. But the more important one is the “alter”, meaning  that more than one possibility could be stored in a single work and this is the new layer I’m talking about. A book can be read by times, and so does a game. After a player tried different options in a single game, he or she can accept more thoughts and ideas from the author.

Nearly everyone who have a device containing a computer is consuming there media forms. Many people do not play games, but they search with searching engine, then it’s interaction. They scan QR code one advertisement, then its interaction. It’s really hard to do interaction in modern society. At the stage, the producer of these are usually tech related people. I think we’ll see more art people getting involved in very near future.

I do not think there would be a universal machine for “interaction” in computational media. It could be a button, could be camera, could be a microphone, could be anything that could create a message and transfer the message into digital form.

Liquid as a switch

liquid

What I made here is a switch that could test if the water is pure enough. Everyone knows that water is conductive. However, 100% water is not. Water around us is  usually conductive due to the impurity. The more impurity water has, the better conductivity it would gain. So the LED would be very bright if the water is not pure. On contrast it would be darken when the water is pure.

testing if the led works

It works!

checking cables

cables also work!

The LED shows little light while there’s water in the cup

The LED become brighter using juice

Switch to 5V so the light would be easier to be observed

about computer

When I was a kid, I had imagined creating many interesting things but actually did nothing since I was just a lazy kid. Years later, I got the permission to touch computer (mom wanted to protect my eyes), I found that this is world that creation is than real life and started to create things. Mainly the things I’ve created here are all simple games and programs. To me, as an individual, computer is a place where I could transfer my imagination and ideas into “reality”, or into something the other people can understand.

However, I think computer is a totally different thing when it comes to the society. At the beginning, it is the tool to help people do calculation faster. When it started to become more complex, people can use it to process some fundamental thoughts. I think its actually going well. There’s many places that computer already replaced human: auto checkin parking, auto check out,  even some auto driving. What I think what is missing now a days is the auto traffic system. monitoring the whole city as a whole including all public and private transportation. Manage the road and the traffic light to make every individual travel as efficient as possible. If that is possible, there whole city could run more efficiently and could save many times and energies.

However, there’s some problem about this idea. First of all, there’s not always a solution that would make every one efficient. Sometimes making one car go fast would cause the delay of another car. So there must be a level of priority while registering the cars on the computer’s list(Police and ambulance first, working cars second, leisure car third ). But some people may abuse this feature by getting  the priority that do not belong to them then sometimes it would be not fair for ordinary people. Secondly this system requires the information of all the traffics in a city or it would not function as expected. However, people may not want the government to tract them everyday. If the amount of non-registered car is too high, the whole system  just don’t work since the information it gains is quite different from the reality. In conclusion, if a system like that really appears in the future, the form of society must have been changed drastically.