I like the idea, because I am the kind of person who forgets stuff like my metrocard, or my phone, etc..., so it definitely has a use.
But I would hesitate to buy it until I was reassured that there were no health issues to having a bunch of RFID tags on my person ALL THE TIME... and some people might have privacy issues, with making themselves so trackable?
Before I bought it, I'd need to know why this was so much better than a piece of paper on my front door reminding me not to forget my keys, etc
I think the alarm would have to be sound. The sound would have to come from the device (not my own phone, which I may have left in my room), and I would have to be able to load my own audio files onto the device, otherwise it would drive me crazy. And I want a different sound for each object it is detecting, so I don't have to spend time working out which object I have not got...
On Oct 23, 2006, at 4:28 PM, Anne Hong wrote:
1. Would you use it? I would definitely give it a try. The most important aspects would be immediacy and priority. Would I recieve this alarm as soon as I open the door, or is it after I'm in the lobby or outside in the subway? If I knew it was my wallet, then it would be worthwhile for me to go back upstairs and get it versus a cellphone. I think it might be a little too late to worry about my keys until after I got back to call the super. I sometimes forget, but I assess if it's worth my time to go back.
2. Would you prefer alarms to be light only, sound only or both alarms? Vibrating cellphone or alarm is sufficient for me.
3. Would you stick the Tags on your wallet, cell, key, etc...? I would use these tags on items that I don't use frequently. Maybe it's a book or a paper I need for a group discussion that I'm more likely to forget at home.
4. Comments?
Tuesday, October 24, 2006
Monday, October 23, 2006
Response from Kunal Gupta
1) hm.. although i like ti the way it is, i think the aesthetics of the object have to be real good, like it has to blend in with environments more .
i think the display works well on a wall.
2) sound is cool, light si cool, ion a wall
3) it's ideal for keys/cell phone/ wallet/medicine etc.
4) medicine? What the fuck am i talking abot?
<3
Kunal
i think the display works well on a wall.
2) sound is cool, light si cool, ion a wall
3) it's ideal for keys/cell phone/ wallet/medicine etc.
4) medicine? What the fuck am i talking abot?
<3
Kunal
Response from Anne Hong
1. Would you use it? I would definitely give it a try. The most important aspects would be immediacy and priority. Would I recieve this alarm as soon as I open the door, or is it after I'm in the lobby or outside in the subway? If I knew it was my wallet, then it would be worthwhile for me to go back upstairs and get it versus a cellphone. I think it might be a little too late to worry about my keys until after I got back to call the super. I sometimes forget, but I assess if it's worth my time to go back.
2. Would you prefer alarms to be light only, sound only or both alarms? Vibrating cellphone or alarm is sufficient for me.
3. Would you stick the Tags on your wallet, cell, key, etc...? I would use these tags on items that I don't use frequently. Maybe it's a book or a paper I need for a group discussion that I'm more likely to forget at home.
4. Comments?
2. Would you prefer alarms to be light only, sound only or both alarms? Vibrating cellphone or alarm is sufficient for me.
3. Would you stick the Tags on your wallet, cell, key, etc...? I would use these tags on items that I don't use frequently. Maybe it's a book or a paper I need for a group discussion that I'm more likely to forget at home.
4. Comments?
Response from J0sh
Your web page made my web browser crawl to a halt, so I can't give you
feedback on that, but I'd love to give you some feedback as I'm really
interested in the project!
1. Would you use it?
Yep.
2. Would you prefer alarms to be light only, sound only or both alarms?
Either, depending on the item (my choice).
3. Would you stick the Tags on your wallet, cell, key, etc...?
Depends on how big they are. If you're talking passive RFID (grain-of-rice-sized) I'd put them everywhere, but if they're key-chain-fob-sized I'd put them on my keys only.
4. Comments?
How configurable, what's the interface, what's the sound/light alarm
like, what size is the fob?
- J0sh
feedback on that, but I'd love to give you some feedback as I'm really
interested in the project!
1. Would you use it?
Yep.
2. Would you prefer alarms to be light only, sound only or both alarms?
Either, depending on the item (my choice).
3. Would you stick the Tags on your wallet, cell, key, etc...?
Depends on how big they are. If you're talking passive RFID (grain-of-rice-sized) I'd put them everywhere, but if they're key-chain-fob-sized I'd put them on my keys only.
4. Comments?
How configurable, what's the interface, what's the sound/light alarm
like, what size is the fob?
- J0sh
Response from rui pereira
hey guys!
luvly project!
i would buy it for sure, actually.. build it fast>>>>> i want one!!!
regarding ur q's::
1. Would you use it? YES!
2. Would you prefer alarms to be light only, sound only or both alarms? both, sometimes(most of the times) i use ipod so light would b great but also sound is great when u just woke up and don´t see anything in front of u...
3. Would you stick the Tags on your wallet, cell, key, etc...? huuum.... wallet.. may b.. keys , ipod!, phone, camera, and may b not only this but also important books or objects i would need in a specific day
4. Comments?
modularity, because of what i've just answered in the previous q, each day is a different day, so there r objects i always carry with me
but there r also some special stuff in specific days that would b great to not forget..
goood luck and great werk!!!!
rui
luvly project!
i would buy it for sure, actually.. build it fast>>>>> i want one!!!
regarding ur q's::
1. Would you use it? YES!
2. Would you prefer alarms to be light only, sound only or both alarms? both, sometimes(most of the times) i use ipod so light would b great but also sound is great when u just woke up and don´t see anything in front of u...
3. Would you stick the Tags on your wallet, cell, key, etc...? huuum.... wallet.. may b.. keys , ipod!, phone, camera, and may b not only this but also important books or objects i would need in a specific day
4. Comments?
modularity, because of what i've just answered in the previous q, each day is a different day, so there r objects i always carry with me
but there r also some special stuff in specific days that would b great to not forget..
goood luck and great werk!!!!
rui
Response from Joshua Fleig
I think its a great idea. What if instead of alarm it said "keys"?? Also what about umbrella?? you could have it check weather.com every morning and remind you to get your umbrella.
Also I have an idea that may fall into a similar catagory that I am looking to do possible for a final project remind me to talk to you about it.
Josh
Also I have an idea that may fall into a similar catagory that I am looking to do possible for a final project remind me to talk to you about it.
Josh
Email sent out
Sent out the following email to ipt-students list - waiting for responses ;)
****
R.U.G. - "Remember Ur Goods"
Reminder device for those out in a hurry
This is our Phys-Comp midTerm project.
We are in dire need of feedback for the usability testing
Since our prototype is not ready, we invite you all to take an incredible
"virtual tour" of our idea!!
http://itp.nyu.edu/~ll1020/pcomp/rug/index.html
And if possible give us some quick feedback!
1. Would you use it?
2. Would you prefer alarms to be light only, sound only or both alarms?
3. Would you stick the Tags on your wallet, cell, key, etc...?
4. Comments?
Thank you!!
Lucas
***
****
R.U.G. - "Remember Ur Goods"
Reminder device for those out in a hurry
This is our Phys-Comp midTerm project.
We are in dire need of feedback for the usability testing
Since our prototype is not ready, we invite you all to take an incredible
"virtual tour" of our idea!!
http://itp.nyu.edu/~ll1020/pcomp/rug/index.html
And if possible give us some quick feedback!
1. Would you use it?
2. Would you prefer alarms to be light only, sound only or both alarms?
3. Would you stick the Tags on your wallet, cell, key, etc...?
4. Comments?
Thank you!!
Lucas
***
Saturday, October 21, 2006
RUG = Remember U Goods
For simplicity, size, and power constraints we decided to go with a rug design instead of yet another portable device for you to forget.
Advantages of the RUG design:
1. Never forget the rug - it is stationary
2. Activate by stepping on it
3. Power source could be larger or even AC power supply from the wall
4. Would fit an RFID reader more easily
5. Can incorporate a better interface for feedback
Now we actually have to build this thing:
HARDWARE NEEDS:
1. LEDs
a) OK - goes off when all items are near
b) Red - Item Missing
c) Green - Missing
d) Blue - Missing
2. Buttons
a) Reset/Start Button - used to collect items that will be tracked
b) Activating Buttons (flat and resistant to place under carpet)
3. Casing
a) Display LEDs
b) Reset/Start Button
c) RFID reader
d) Power supply
4. Speaker
a) OK Sound
b) Item Missing Sound
5. RFID Reader & Tags
6. Battery/Power supply
7. Arduino microcontroller
8. Wires/sodder
SOFTWARE NEEDS:
1. Check to see if RUG is being stepped on
2. Read RFID tags
3. Blink appropriate LEDs
4. Play appropriate sound
Advantages of the RUG design:
1. Never forget the rug - it is stationary
2. Activate by stepping on it
3. Power source could be larger or even AC power supply from the wall
4. Would fit an RFID reader more easily
5. Can incorporate a better interface for feedback
Now we actually have to build this thing:
HARDWARE NEEDS:
1. LEDs
a) OK - goes off when all items are near
b) Red - Item Missing
c) Green - Missing
d) Blue - Missing
2. Buttons
a) Reset/Start Button - used to collect items that will be tracked
b) Activating Buttons (flat and resistant to place under carpet)
3. Casing
a) Display LEDs
b) Reset/Start Button
c) RFID reader
d) Power supply
4. Speaker
a) OK Sound
b) Item Missing Sound
5. RFID Reader & Tags
6. Battery/Power supply
7. Arduino microcontroller
8. Wires/sodder
SOFTWARE NEEDS:
1. Check to see if RUG is being stepped on
2. Read RFID tags
3. Blink appropriate LEDs
4. Play appropriate sound
Saturday, October 14, 2006
MidTerm Prototype halfway there
For our midterm we decided to create a device that would tell you if you have everything you usually carry around - basically a tool that will not let you forget your stuff when you leave the house.
Here is some data we collected to start off with - NYC Bags - click through to see all the data collected.
From we decided that the ideal product would be something small that you could carry with you.
When you squeeze it, it should vibrate telling you that all you want is there... if it is not all there, then LEDs will indicate which item you are missing.
Ideally the squeeze device woul be wireless and you would simply place wireless transmitter stickers on the objects you do not want to forget.
Also - to make the system fool proof, we would install a "missing detector" on the door frame of your house. Your door would tell you if you were forgetting anything as you left the house.
Here is some data we collected to start off with - NYC Bags - click through to see all the data collected.
From we decided that the ideal product would be something small that you could carry with you.
When you squeeze it, it should vibrate telling you that all you want is there... if it is not all there, then LEDs will indicate which item you are missing.
Ideally the squeeze device woul be wireless and you would simply place wireless transmitter stickers on the objects you do not want to forget.
Also - to make the system fool proof, we would install a "missing detector" on the door frame of your house. Your door would tell you if you were forgetting anything as you left the house.
Pong code not working the way I want it to
For some reason the code "half" works...
When I start my Processing code, my gLed is ON... should be off (set both Leds to LOW in the void section)
Also - when I start playing the game, I wanted the LEDS to blink when the ball hit the paddle... but that slows the entire game down tremendously...
My guess is that the lighting of the pins should occur somehow in sync with the serial event part of the code...
Here is the code... put in BOLD the relevant parts...
ARDUINO CODE:
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte
int yLed = 3;
int gLed = 4;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
pinMode(yLed, OUTPUT);
pinMode(gLed, OUTPUT);
digitalWrite(yLed,LOW);
digitalWrite(gLed,LOW);
}
void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:
secondSensor = analogRead(1)/4;
// read switch, multiply by 255
// so that you're sending 0 or 255:
thirdSensor = 255 * digitalRead(2);
// send sensor values:
Serial.print(firstSensor, BYTE);
Serial.print(secondSensor, BYTE);
Serial.print(thirdSensor, BYTE);
//digitalWrite(yLed, HIGH);
digitalWrite(gLed, HIGH);
if (Serial.read() == 66)
{
digitalWrite(yLed, HIGH);
delay(1000);
digitalWrite(yLed, LOW);
}
else if (Serial.read() == 67)
{
digitalWrite(gLed, HIGH);
delay(1000);
digitalWrite(gLed, LOW);
}
}
}
********************************
PROCESSING CODE:
import processing.serial.*;
Serial port; // The serial port
int[] serialInArray = new int[3]; //Array for serial input signals
int serialCount = 0; // A count of how many bytes we receive
float rightControl, leftControl, resetButton; // Controls
boolean firstContact = false; // Whether we've heard from the microcontroller
PFont font;
//Game Initial Settings
int screenW = 800; //Screen Widht
int screenH = 800; //Screen Height
float ballSpeed = 6; //Initial Ball Speed
float ballSize = 50; //Initail Ball Size
//Game initial stats
int scoreL = 0; //Left player score
int scoreR = 0; //Right player score
int previousScore = 0; //Previous moment's score to determine pause or start state
int level = 1; //Game Level
int previousLevel = 0; //Previous moment's leve to determine scoring
int playgame = -1; //Flag to see if game is paused
int started = 0;
Pong pong; //Pong class variable - each level is a new class
void setup() {
size(screenW,screenH);
frameRate(30);
smooth();
font = loadFont("CourierNew36.vlw");
pong = new Pong(1);
// Print a list of the serial ports, for debugging purposes:
//println(Serial.list());
// Open whatever port is the one you're using.
port = new Serial(this, Serial.list()[0], 9600);
port.write(65); // Send a capital A to start the microcontroller sending
}
void draw() {
background(0);
// If no serial data has beeen received, send again until we get some.
if (firstContact == false) {
delay(300);
port.write(65);
}
//Call class to draw the table/game
pong.drawGameTable();
//If score is over 5 go to next level - reset counters on the way
if (scoreR + scoreL > 5)
{
previousLevel = level;
level++;
pong = new Pong(level);
scoreR = 0;
scoreL = 0;
}
}
//------------------------------
void serialEvent(Serial port) {
float[] buttonFlag = new float[1000];
int i = 0;
int flag = 1; //flag to see if any of the buttonFlags are 0
// if this is the first byte received,
// take note of that fact:
if (firstContact == false) {
firstContact = true;
}
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = port.read();
serialCount++;
// If we have 3 bytes:
if (serialCount > 2 ) {
leftControl = serialInArray[0];
rightControl = serialInArray[1];
resetButton = serialInArray[2];
//println(resetButton);
/*
//If button state changes to zero somewhere along the array, reset game
if (i == 1000) //If i hits 1000, reset back to zero
{
i = 0;
}
i++; //Increment i
buttonFlag[i] = resetButton;
for (int c = 0; c < 1000; c++)
{
if (buttonFlag[c] == 0)
{
flag = 0;
}
}
if (flag == 0)
{
playgame = playgame * -1;
flag = 1;
}
*/
// Send a capital A to request new sensor readings:
port.write(65);
// Reset serialCount:
serialCount = 0;
}
}
//------------------------------
void mouseReleased()
{
playgame = playgame * -1;
}
*************************
class Pong
{
//Ball parameters
float ballX = screenW/2;
float ballY = screenH/2;
//Location of players
float leftX = 20, leftY = screenH/2;
float rightX = screenW - 20, rightY = screenH/2;
//Size of stick
float stickW = 10, stickH = 60;
//Direction
int ballXdirection = 1;
int ballYdirection = 1;
Pong(int _level)
{
level = _level;
ballSize = ballSize - level * 1.10;
ballSpeed = ballSpeed + level * 1.001;
playgame = -1;
}
//-----------------------------------------------------------------------------
void drawGameTable()
{
//External Box and middle line
background(0);
rectMode(CORNER);
strokeWeight(2);
stroke(255);
fill(0);
rect(5, 5, screenW-10, screenH-10);
line(screenW/2, 5, screenW/2, screenH-5);
//Game values
rect(screenW/2-65,10,125,40);
textFont(font, 30);
fill(255);
text(scoreR, screenW/2-40, 32);
text(scoreL, screenW/2+25, 32);
text("x",screenW/2-8,32);
textFont(font, 15);
text("Level ", screenW/2-30, 47);
text(level, screenW/2+20, 47);
// If Mouse is pressed play the game - pressed again - reset game
if (playgame < 0)
{
rectMode(CORNERS);
fill(200,200,200,50);
rect(0,0,screenW,screenH);
if ((started == 0) || (level > previousLevel))
{
fill(255);
text("PRESS MOUSE TO START",screenW/2-100,screenH/2);
previousLevel = level;
ballX = screenW/2;
ballY = screenH/2;
}
else if ((started == 1) || (scoreR + scoreL == previousScore))
{
fill(255);
text("PRESS MOUSE TO CONTINUE",screenW/2-100,screenH/2);
}
}
else if (playgame > 0)
{
started = 1;
pong.moveLeftStick();
pong.moveRightStick();
pong.drawBall();
}
}
//-----------------------------------------------------------------------------
void drawBall()
{
// Update the position of the ball
ballX = ballX + ( ballSpeed * ballXdirection );
ballY = ballY + ( ballSpeed * ballYdirection );
//Ball hitting one of the paddles?
if (dist(ballX,ballY,rightX,rightY) < (ballSize/2+stickW-2))
{
ballXdirection *= -1;
port.write(66);
}
//Ball on Comp side and within Comp paddle?
if (dist(ballX,ballY,leftX,leftY) < (ballSize/2+stickW-2))
{
ballXdirection *= -1;
port.write(67);
}
//Dont let ball go of screen vertically
if (ballY > ((screenH - 8) - ballSize/2) || (ballY < ballSize/2 + 6))
{
ballYdirection *= -1;
}
//SCORE POINTS
if (ballX > rightX + ballSize)
{
playgame = -1;
previousScore = scoreR + scoreL;
scoreR++;
ballX = screenW/2;
ballY = screenH/2;
leftY = screenH/2;
rightY = screenH/2;
}
if (ballX < leftX - ballSize)
{
playgame = -1;
scoreL++;
ballX = screenW/2;
ballY = screenH/2;
leftY = screenH/2;
rightY = screenH/2;
}
//Draw Ball
fill(random(255),random(255),random(255));
ellipseMode(CENTER);
ellipse(ballX, ballY, ballSize, ballSize);
}
//-----------------------------------------------------------------------------
void moveRightStick()
{
rectMode(CENTER);
if (rightY+stickH/2-20 > screenH) {
rightY = screenH-stickH/2-20;
}
else if (rightY-stickH/255-20 < 0) {
rightY = stickH/2 + 21;
}
else {
rightY = (rightControl/255)*screenH;
//rightY = ballY;
}
//Draw Right Paddle
fill(0,0,255);
rect(rightX,rightY,stickW,stickH);
}
//-----------------------------------------------------------------------------
void moveLeftStick()
{
rectMode(CENTER);
if (leftY+stickH/2-10 > screenH) {
leftY = screenH-stickH/2;
}
else if (leftY-stickH/2+5 <= 10) {
leftY = stickH/2 + 12;
}
else {
leftY = (leftControl/255)*screenH;
//leftY = ballY;
}
//Draw left paddle
fill(255,0,0);
rect(leftX,leftY,stickW,stickH);
}
}
When I start my Processing code, my gLed is ON... should be off (set both Leds to LOW in the void section)
Also - when I start playing the game, I wanted the LEDS to blink when the ball hit the paddle... but that slows the entire game down tremendously...
My guess is that the lighting of the pins should occur somehow in sync with the serial event part of the code...
Here is the code... put in BOLD the relevant parts...
ARDUINO CODE:
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte
int yLed = 3;
int gLed = 4;
void setup()
{
// start serial port at 9600 bps:
Serial.begin(9600);
pinMode(yLed, OUTPUT);
pinMode(gLed, OUTPUT);
digitalWrite(yLed,LOW);
digitalWrite(gLed,LOW);
}
void loop()
{
// if we get a valid byte, read analog ins:
if (Serial.available() > 0) {
// get incoming byte:
inByte = Serial.read();
// read first analog input, divide by 4 to make the range 0-255:
firstSensor = analogRead(0)/4;
// delay 10ms to let the ADC recover:
delay(10);
// read second analog input, divide by 4 to make the range 0-255:
secondSensor = analogRead(1)/4;
// read switch, multiply by 255
// so that you're sending 0 or 255:
thirdSensor = 255 * digitalRead(2);
// send sensor values:
Serial.print(firstSensor, BYTE);
Serial.print(secondSensor, BYTE);
Serial.print(thirdSensor, BYTE);
//digitalWrite(yLed, HIGH);
digitalWrite(gLed, HIGH);
if (Serial.read() == 66)
{
digitalWrite(yLed, HIGH);
delay(1000);
digitalWrite(yLed, LOW);
}
else if (Serial.read() == 67)
{
digitalWrite(gLed, HIGH);
delay(1000);
digitalWrite(gLed, LOW);
}
}
}
********************************
PROCESSING CODE:
import processing.serial.*;
Serial port; // The serial port
int[] serialInArray = new int[3]; //Array for serial input signals
int serialCount = 0; // A count of how many bytes we receive
float rightControl, leftControl, resetButton; // Controls
boolean firstContact = false; // Whether we've heard from the microcontroller
PFont font;
//Game Initial Settings
int screenW = 800; //Screen Widht
int screenH = 800; //Screen Height
float ballSpeed = 6; //Initial Ball Speed
float ballSize = 50; //Initail Ball Size
//Game initial stats
int scoreL = 0; //Left player score
int scoreR = 0; //Right player score
int previousScore = 0; //Previous moment's score to determine pause or start state
int level = 1; //Game Level
int previousLevel = 0; //Previous moment's leve to determine scoring
int playgame = -1; //Flag to see if game is paused
int started = 0;
Pong pong; //Pong class variable - each level is a new class
void setup() {
size(screenW,screenH);
frameRate(30);
smooth();
font = loadFont("CourierNew36.vlw");
pong = new Pong(1);
// Print a list of the serial ports, for debugging purposes:
//println(Serial.list());
// Open whatever port is the one you're using.
port = new Serial(this, Serial.list()[0], 9600);
port.write(65); // Send a capital A to start the microcontroller sending
}
void draw() {
background(0);
// If no serial data has beeen received, send again until we get some.
if (firstContact == false) {
delay(300);
port.write(65);
}
//Call class to draw the table/game
pong.drawGameTable();
//If score is over 5 go to next level - reset counters on the way
if (scoreR + scoreL > 5)
{
previousLevel = level;
level++;
pong = new Pong(level);
scoreR = 0;
scoreL = 0;
}
}
//------------------------------
void serialEvent(Serial port) {
float[] buttonFlag = new float[1000];
int i = 0;
int flag = 1; //flag to see if any of the buttonFlags are 0
// if this is the first byte received,
// take note of that fact:
if (firstContact == false) {
firstContact = true;
}
// Add the latest byte from the serial port to array:
serialInArray[serialCount] = port.read();
serialCount++;
// If we have 3 bytes:
if (serialCount > 2 ) {
leftControl = serialInArray[0];
rightControl = serialInArray[1];
resetButton = serialInArray[2];
//println(resetButton);
/*
//If button state changes to zero somewhere along the array, reset game
if (i == 1000) //If i hits 1000, reset back to zero
{
i = 0;
}
i++; //Increment i
buttonFlag[i] = resetButton;
for (int c = 0; c < 1000; c++)
{
if (buttonFlag[c] == 0)
{
flag = 0;
}
}
if (flag == 0)
{
playgame = playgame * -1;
flag = 1;
}
*/
// Send a capital A to request new sensor readings:
port.write(65);
// Reset serialCount:
serialCount = 0;
}
}
//------------------------------
void mouseReleased()
{
playgame = playgame * -1;
}
*************************
class Pong
{
//Ball parameters
float ballX = screenW/2;
float ballY = screenH/2;
//Location of players
float leftX = 20, leftY = screenH/2;
float rightX = screenW - 20, rightY = screenH/2;
//Size of stick
float stickW = 10, stickH = 60;
//Direction
int ballXdirection = 1;
int ballYdirection = 1;
Pong(int _level)
{
level = _level;
ballSize = ballSize - level * 1.10;
ballSpeed = ballSpeed + level * 1.001;
playgame = -1;
}
//-----------------------------------------------------------------------------
void drawGameTable()
{
//External Box and middle line
background(0);
rectMode(CORNER);
strokeWeight(2);
stroke(255);
fill(0);
rect(5, 5, screenW-10, screenH-10);
line(screenW/2, 5, screenW/2, screenH-5);
//Game values
rect(screenW/2-65,10,125,40);
textFont(font, 30);
fill(255);
text(scoreR, screenW/2-40, 32);
text(scoreL, screenW/2+25, 32);
text("x",screenW/2-8,32);
textFont(font, 15);
text("Level ", screenW/2-30, 47);
text(level, screenW/2+20, 47);
// If Mouse is pressed play the game - pressed again - reset game
if (playgame < 0)
{
rectMode(CORNERS);
fill(200,200,200,50);
rect(0,0,screenW,screenH);
if ((started == 0) || (level > previousLevel))
{
fill(255);
text("PRESS MOUSE TO START",screenW/2-100,screenH/2);
previousLevel = level;
ballX = screenW/2;
ballY = screenH/2;
}
else if ((started == 1) || (scoreR + scoreL == previousScore))
{
fill(255);
text("PRESS MOUSE TO CONTINUE",screenW/2-100,screenH/2);
}
}
else if (playgame > 0)
{
started = 1;
pong.moveLeftStick();
pong.moveRightStick();
pong.drawBall();
}
}
//-----------------------------------------------------------------------------
void drawBall()
{
// Update the position of the ball
ballX = ballX + ( ballSpeed * ballXdirection );
ballY = ballY + ( ballSpeed * ballYdirection );
//Ball hitting one of the paddles?
if (dist(ballX,ballY,rightX,rightY) < (ballSize/2+stickW-2))
{
ballXdirection *= -1;
port.write(66);
}
//Ball on Comp side and within Comp paddle?
if (dist(ballX,ballY,leftX,leftY) < (ballSize/2+stickW-2))
{
ballXdirection *= -1;
port.write(67);
}
//Dont let ball go of screen vertically
if (ballY > ((screenH - 8) - ballSize/2) || (ballY < ballSize/2 + 6))
{
ballYdirection *= -1;
}
//SCORE POINTS
if (ballX > rightX + ballSize)
{
playgame = -1;
previousScore = scoreR + scoreL;
scoreR++;
ballX = screenW/2;
ballY = screenH/2;
leftY = screenH/2;
rightY = screenH/2;
}
if (ballX < leftX - ballSize)
{
playgame = -1;
scoreL++;
ballX = screenW/2;
ballY = screenH/2;
leftY = screenH/2;
rightY = screenH/2;
}
//Draw Ball
fill(random(255),random(255),random(255));
ellipseMode(CENTER);
ellipse(ballX, ballY, ballSize, ballSize);
}
//-----------------------------------------------------------------------------
void moveRightStick()
{
rectMode(CENTER);
if (rightY+stickH/2-20 > screenH) {
rightY = screenH-stickH/2-20;
}
else if (rightY-stickH/255-20 < 0) {
rightY = stickH/2 + 21;
}
else {
rightY = (rightControl/255)*screenH;
//rightY = ballY;
}
//Draw Right Paddle
fill(0,0,255);
rect(rightX,rightY,stickW,stickH);
}
//-----------------------------------------------------------------------------
void moveLeftStick()
{
rectMode(CENTER);
if (leftY+stickH/2-10 > screenH) {
leftY = screenH-stickH/2;
}
else if (leftY-stickH/2+5 <= 10) {
leftY = stickH/2 + 12;
}
else {
leftY = (leftControl/255)*screenH;
//leftY = ballY;
}
//Draw left paddle
fill(255,0,0);
rect(leftX,leftY,stickW,stickH);
}
}
Friday, October 13, 2006
Tuesday, October 10, 2006
Sunday, October 01, 2006
Subscribe to:
Posts (Atom)