Author Archives: Chris

Final Project: Tale of Seven

http://a.parsons.edu/~rayw188/DemoCopy/Tale%20of%20Seven7.html

Final Project

A webcomic made using parallax scrolling and Vogler’s Seven Archetypes. Please See Website Above and powerpoint for explanation.

Leave a comment

Filed under Homework, Presentations

OpenFrameworks Homework

For my OpenFrameworks project I decided to play around with the QuaternionArcballExample and make more spheres out of the globally positioned sphere. Nothing to dramatic, just recreating the different spheres in a revolving position around the main sphere.

https://www.youtube.com/watch?v=cN-KmuVs7Os&feature=youtube_gdata_player

CODE:

 

/**
*
* OFDevCon Example Code Sprint
* Quaternion Example for rotating a sphere as an arcball
* Dragging the mouse up down left right to apply an intuitive rotation to an object.
*
* Created by James George on 2/23/2012
*/

#include “testApp.h”

//————————————————————–
void testApp::setup(){
ofNoFill();
ofSetFrameRate(30);
ofBackground(0,20,122);

//this slows down the rotate a little bit
dampen = .8;
}

//————————————————————–
void testApp::update(){

}

//————————————————————–
void testApp::draw(){

//translate so that 0,0 is the center of the screen
glPushMatrix();
ofTranslate(ofGetWidth()/2, ofGetHeight()/2, 40);
//Extract the rotation from the current rotation
ofVec3f axis;
float angle;
curRot.getRotate(angle, axis);

//apply the quaternion’s rotation to the viewport and draw the sphere
ofRotate(angle, axis.x, axis.y, axis.z);
ofSphere(0, 0, 0, 300);
ofSphere(0, 0, 0, 120);
ofSphere(175, 0, 0, 120);
ofSphere(0, -175, 0, 120);
ofSphere(0, 175, 0, 120);
ofSphere(0, 0, 175, 120);
ofSphere(0, 0, -175, 120);
ofSphere(-175, 0, 0, 120);

ofPopMatrix();
}

//————————————————————–
void testApp::keyPressed(int key){
}

//————————————————————–
void testApp::keyReleased(int key){

}

//————————————————————–
void testApp::mouseMoved(int x, int y ){

}

//————————————————————–
void testApp::mouseDragged(int x, int y, int button){

//every time the mouse is dragged, track the change
//accumulate the changes inside of curRot through multiplication
ofVec2f mouse(x,y);
ofQuaternion yRot((x-lastMouse.x)*dampen, ofVec3f(0,1,0));
ofQuaternion xRot((y-lastMouse.y)*dampen, ofVec3f(-1,0,0));
curRot *= yRot*xRot;
lastMouse = mouse;
}

//————————————————————–
void testApp::mousePressed(int x, int y, int button){
//store the last mouse point when it’s first pressed to prevent popping
lastMouse = ofVec2f(x,y);
}

//————————————————————–
void testApp::mouseReleased(int x, int y, int button){

}

//————————————————————–
void testApp::windowResized(int w, int h){

}

//————————————————————–
void testApp::gotMessage(ofMessage msg){

}

//————————————————————–
void testApp::dragEvent(ofDragInfo dragInfo){

Leave a comment

Filed under Homework

Arduino Class Two HW: Sensor and Keyboard Input to LED

https://www.youtube.com/watch?v=3cl2bjT84zY&feature=youtube_gdata_player Sensor to LED

https://www.youtube.com/watch?v=AT8t9pa-Gx8&feature=youtube_gdata_player keyboard to LED

 

20131020_222940.jpg20131020_222954.jpg20131020_232916.jpg

Leave a comment

Filed under Homework

Midterm Project: Game and Controller

For my midterm project I decided to combine my final code project during Bootcamp with what we have been working on in CCLab.

Building off what we learned in the Coding Class of Bootcamp and the Dorkshop on object oriented game development I created a game based on the Old windows game Oregon Trail. For this recreation I decided to focus on one specific aspect of the game which was the hunting part. Using Illustrator I recreated the artwork with vector based sprites instead of bitmaps. While I converted this back into bitmap form via still image GIFs, the quality was much higher then the original game could hold. After getting these images I imported them into a processing Sketch.

Inline image 8Inline image 7Inline image 6Inline image 4Inline image 5Inline image 2Inline image 1Inline image 3

Using the methods taught in the object oriented I correlated each of these sprites to different tabs and made it so that they populated randomly each time the game was started. In essence this randomized the environment by changing the amount and location of the bushes and trees.

Screengrab

CCLAB:

For the purposes of the midterm, my problem was two fold. Making sure this code worked properly and connecting this code to the arduino to make a functional controller for my game.

I began with the code for the game it self. The major thing I solved was adding the location change to the player so that he would also “spawn” randomly at a different point in the game environment. While this was similar to the spawning of the plants  inside the environment this needed to be tweeked for a character that would be controlled by the user. Next was the hard part, getting the game to speak to the controller. Since I could not get Node.Js to work properly between the Microsoft oriented machine to the arduino  I searched for another method of creating serial communication with the Arduino. After an extensive search on the web I found a couple methods  (the most helpful of which is noted below in the references section) as to how to create this communication.  With minimal tweeking I pulled together these two formulas for processing and arduino sketches. (see sketches section)

The Final projectet had several issues as far as functionality. I managed to get the programs to communicate by having the sketch uploaded into the arduino continually pulse out the letter “A” until processing received it through serial communication and responded. This “handshake” between programs theoretically should allow me to export button presses on the arduino via serial com to the processing sketch as text, and this text would act as a prompt for the button. Unfortunately, while the handshake was made, processing habitually over read or dismissed the text from the arduino. In the cases of the over reading it would simply recieve a long string of text of the same phrase that was not read. Further work is neccessary to resolve these issues.

Arduino Breadboard:

SKETCHES

PROCESSING SKETCH ————————————————————

import processing.serial.*; //import the Serial library
Serial myPort; //the Serial port object
String val;

float angle = 0;
int numFoliage;
int numFoliage2;
int numFoliage3;
Tree [] treePop;
Bush1 [] bush1Pop;
Bush2 [] bush2Pop;
Festus MMF;
Bullet bshot;

void setup() {
size(800, 800, P3D);
rectMode(CENTER);

myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(‘\n’);

numFoliage = int (random(1, 5));
numFoliage2 = int (random(1, 5));
numFoliage3 = int (random(1, 5));
treePop = new Tree[numFoliage3];
bush1Pop = new Bush1[numFoliage];
bush2Pop = new Bush2[numFoliage2];
MMF = new Festus(1);
bshot = new Bullet(1);

for (int i = 0; i < numFoliage; i++) {
bush1Pop[i] = new Bush1(i);
}
for (int i = 0; i < numFoliage2; i++) {
bush2Pop[i] = new Bush2(i);
}
for (int i = 0; i < numFoliage3; i++) {
treePop[i] = new Tree(i);
}
}
void draw() {
angle += 0.005;
background(150, 150, 200);
fill(110, 230, 140);

rect(width/2, height/2, width, height);
// for (int i = 0; i < numFoliage; i++) {
// bush1Pop[i].update();
// bush2Pop[i].update();
// treePop[i].update();
// }
for (int i = 0; i < numFoliage; i++) {
bush1Pop[i].update();
}
for (int i = 0; i < numFoliage2; i++) {
bush2Pop[i].update();
}
for (int i = 0; i < numFoliage3; i++) {
treePop[i].update();
}
bshot.fire();
MMF.update();
MMF.display();
println(bshot.shoot);
// pushMatrix();
// translate(width/2, height/2);
// rotateX(-200);

// popMatrix();
// fill(55, 89, 22);
// rect(100, 100, 50, 50);
// rect(290, 230, 50, 50);
// rect(300, 400, 50, 50);
// popMatrix();
}
void keyPressed() {

if (key==CODED) {
if (keyCode==UP) {
MMF.p1UP = true;
MMF.festate = 0;
}
if (keyCode==DOWN) {
MMF.p1DOWN = true;
MMF.festate = 1;
}
if (keyCode==LEFT) {
MMF.p1LEFT = true;
MMF.festate = 2;
}
if (keyCode==RIGHT) {
MMF.p1RIGHT = true;
MMF.festate = 3;
}
}
if (key == ‘ ‘) {
bshot.xPos = MMF.xPos;
bshot.yPos = MMF.yPos;
bshot.state = MMF.festate;
bshot.shoot = true;
}
}
void keyReleased() {

if (key==CODED) {
if (keyCode==UP) {
MMF.p1UP = false;
}
if (keyCode==DOWN) {
MMF.p1DOWN = false;
}
if (keyCode==LEFT) {
MMF.p1LEFT = false;
}
if (keyCode==RIGHT) {
MMF.p1RIGHT = false;
}
}
}
void serialEvent( Serial myPort) {

val = myPort.readString();
println(val);

if (val.equals(“button1”)) {
bshot.xPos = MMF.xPos;
bshot.yPos = MMF.yPos;
bshot.state = MMF.festate;
bshot.shoot = true;
}

}

ARDUINO SKETCH ——————————————————————

// constants won’t change. They’re used here to
// set pin numbers:
int buttonPin = 2; // the number of the pushbutton pin
int ledPin = 13; // the number of the LED pin

// variables will change:
int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
Serial.begin(9600);
establishContact();
}

void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(buttonPin);

// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
Serial.println(“Button1”); //send back a hello world
delay(50);
}
else {
// turn LED off:
digitalWrite(ledPin, LOW);
}
}

void establishContact() {
while (Serial.available() <= 0) {
Serial.println(“A”); // send a capital A
delay(300);
}
}

References:

https://learn.sparkfun.com/tutorials/connecting-arduino-to-processing/tips-and-tricks

https://npmjs.org/package/serialport

Leave a comment

Filed under Homework

Arduino Class One Homework

http://www.youtube.com/watch?v=19NnOU4urRk&feature=youtu.be

http://www.youtube.com/watch?v=7Z0nUGNFCe0&feature=youtu.be

20131013_140900 20131013_140847 20131013_134305 20131013_134241

Leave a comment

Filed under Homework

API Homework

Finally getting the hang of this. Thank you for going over it again Master P, really helped.
For anyone in the class who missed it and is looking for it here is what we went over in the review friday:

http://cssdeck.com/labs/ke0mp2in

Here is the code, I got my own key and pulled the weather forecast for my Home town of Wagram North Carolina:

Raw Data link:

http://api.wunderground.com/api/dc48a9b9b5d76b6a/forecast/q/NC/Wagram.json

Script:

<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8″>
<title>JSON WITH API: Astronomy 1</title>

<script type=”text/javascript” src=”js/jquery-1.10.2.min.js”></script>

<script type=”text/javascript”>

/*Standard request URL format =
http://api.wunderground.com/api/b79e3040f6431025/features/settings/q/query.format
where
features=> type of data, here astronomy
settings=> lang or personal data
query=> location of data
*/

$(document).ready(function(){
$.ajax({
url: “http://api.wunderground.com/api/dc48a9b9b5d76b6a/forecast/q/NC/Wagram.json&#8221;,
dataType : “jsonp”, //jsonp for cross-origin files
success : function(parsed_json) {
console.log(‘success!!’);
//each nested object goes in []
var wagramWeather = parsed_json[‘forecast’][‘txt_forecast’][‘forecastday’][1][‘fcttext’];
var wagramWeatherday2 = parsed_json[‘forecast’][‘txt_forecast’][‘forecastday’][3][‘fcttext’];

$(“#container”).append(“Here is the forecast for the place I was born and raised(Wagram, NC): “+wagramWeather);

$(“#container2”).append(“Wednesday in Wagram will be: “+wagramWeatherday2);

} //end of success
}); //end of ajax
}); //end of doc ready

 
</script>

</head>

<body>
<section id=”container”>
<
</section>
<section id=”container2″>

</section>
</body>
</html>

Leave a comment

Filed under Homework

Homework Week2

Screen shot 2013-09-17 at 3.28.48 PM

 

 

<!DOCTYPE html>
<html>
<head><meta http-equiv=”Content-Type” content=”text/html; charset=ISO-8859-1″>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0px;
}
</style>
</head>
<body>
<canvas id=”myCanvas” width=”500″ height=”500″></canvas>
<script>
var context;
var x=500;
var y=50;
var x2=500;
var x3=500;
var x4=500;
var x5=500;
var x6=500;
var x7=500;
var x8=500;
var xx=65
var yy=250
var dx=2;
function init()
{
context= myCanvas.getContext(‘2d’);
setInterval(draw,10);
}

function draw()
{

context.clearRect(0,0,500,500);
context.beginPath();
context.strokeStyle=”black”;
context.fillStyle=”white”
context.arc(x,y,10,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.beginPath();
context.arc(x2,y+200,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.arc(x3,y+400,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.arc(x4,y+300,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.arc(x5,y+250,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.arc(x6,y+100,10,0,Math.PI*2,true);
context.closePath();
context.stroke();
context.beginPath();

context.arc(x7,y+350,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.arc(x8,y+470,10,0,Math.PI*2,true);
context.closePath();
context.stroke();

context.beginPath();
context.fillStyle=”black”
context.arc(xx,yy,50,0*Math.PI,1.5*Math.PI)
context.closePath();
context.stroke();

context.beginPath();
context.fillStyle=”black”
context.arc(xx,yy,20,0*Math.PI,Math.PI,false)
context.closePath();
context.stroke();

context.beginPath();
context.fillStyle=”black”
context.arc(xx+25,yy-25,30,1.3*Math.PI,0.2*Math.PI)
context.closePath();
context.stroke();

if(x<0) x=500;
x-=dx+3;

if(x2<0) x2=500;
x2-=dx+2;

if(x3<0) x3=500;
x3-=dx+1;

if(x4<0) x4=500;
x4-=dx+3;

if(x5<0) x5=500;
x5-=dx+5;

if(x6<0) x6=500;
x6-=dx;

if(x7<0) x7=500;
x7-=dx+4;

if(x8<0) x8=500;
x8-=dx+2;

}
</script>
<body onLoad=”init();”>
</body>

</html>

Leave a comment

Filed under Uncategorized

Week1 Madlib HW

<!DOCTYPE html>
<html>
<head>
<title> My Basic HTML</title>
</head>
<body>
<script type=”text/javascript”>
// this is where javascript lives
// console.log(“This is javascripts println();”);
var namex = “Chris”;
var person = “Batman”;
var place = “The Phantom Zone”;
var day = “On Hump Day”;
var action1 = “rescue “;
var action2 = ” threw “;
var thing = “money”;
var adj = “ballerific”;
var a1 = “Hello, my name is “;
var p1 = “. “;
var p2 = “! “;
var b1 = ” I Went to go see my friend and personal confidant “;
var c1 = ” was very “;
var c2 = ” and felt like partying in “;
var d1 = “After we got there I had to “;
var d2 = ” because they partyed to hearty!”;
var e1 = “Finally, “;
var e2 = ” all of their “;
var e3 = ” away because they wanted to go home.”;
console.log(a1 + namex + p1 + day + b1 + person + p1 + person + c1 + adj + c2 + place + p2 + d1 + action1 + person + d2 + e1 + person + action2 + e2 + thing + e3);
</script>

</body>
</html>

1 Comment

Filed under Homework