Final Assignment

Right. So! I mostly focused on the design aspect of the of the video game. So I used code from HERE as a base.

I then went about sort of copying his sprite sheet, but with my own character. Who just so happens to look like me. But noodle-y-er.

sprites_map_claudius

I’m, too sexy for this game.

AWESOME! But if I left it as it was, it would just be noodle-me. Alone. In a large gray space.

BORING.

So I needed to give my tiny self a world to live in. So considering Baby Shannon is drawn as though she’s facing forward, I thought I’d take a queue from old skewl Nintendo games and give her a village of weird houses that all seem to be facing the sky! Now, I will admit that it embarrassingly took me way to long to figure out how to change the background. Because, I mean, I’ve done it before. And then promptly forgot. Because I’m a genius.

The sidewalk makes sense, but those buildings…

AND FINALLY TWIG-SHANNON HAS A PLACE TO LIVE!

As you may have noticed, Shannon Spaghetti can just magically walk though buildings! And that’s because I did try to limit where she can walk, and I ended up either a) not making her walk anymore, or b) not changing the sketch at all. So, eventually, she will be able to kick, punch, go into house, and not be a wall-walking-wizard. But that day is not today. But soon. Soon…

class Walker
{
PImage image;
PVector position;
int frameRow;
int frameColumn;
float frameTimer;
PVector velocity;
float speed;
}

Walker knight;
float left = 0;
float right = 0;
float down = 0;
float up = 0;
PImage bg;
void setup()
{
size(500, 500);
bg = loadImage(“town.PNG”);
knight = new Walker();
knight.image = loadImage(“sprites_map_claudius.png”);
knight.position = new PVector(275, 275);
knight.velocity = new PVector(0, 0);
knight.frameRow = 0;
knight.frameColumn = 0;
knight.frameTimer = 0;
knight.speed = 2;
}

void draw()
{
background(bg);
bg = loadImage(“town.PNG”);
knight.velocity.x = knight.speed * (left + right);
knight.velocity.y = knight.speed * (up + down);
knight.position.add(knight.velocity);

knight.frameTimer += 0.1;
if (knight.frameTimer >= 6)
{
knight.frameTimer = 1;
}
knight.frameColumn = (int)knight.frameTimer;

if (knight.velocity.x == 0 && knight.velocity.y == 0)
{
knight.frameColumn = 0;
}

if (left != 0)
{
knight.frameRow = 1;
}
if (right != 0)
{
knight.frameRow = 3;
}
if (up != 0)
{
knight.frameRow = 2; // etc.
}
if (down != 0)
{
knight.frameRow = 0; // etc.
}

pushMatrix();
translate(knight.position.x, knight.position.y);
imageMode(CENTER);
PImage frameImage = getSubImage(knight.image, knight.frameRow, knight.frameColumn, 32, 64);
image(frameImage, 0, 0);

popMatrix();
}
PImage getSubImage(PImage image, int row, int column, int frameWidth, int frameHeight)
{
return image.get(column * frameWidth, row * frameHeight, frameWidth, frameHeight);
}

void keyPressed()
{
if (keyCode == RIGHT)
{
right = 1;
}
if (keyCode == LEFT)
{
left = -1;
}
if (keyCode == UP)
{
up = -1;
}
if (keyCode == DOWN)
{
down = 1;
}
}

void keyReleased()
{
if (keyCode == RIGHT)
{
right = 0;
}
if (keyCode == LEFT)
{
left = 0;
}
if (keyCode == UP)
{
up = 0;
}
if (keyCode == DOWN)
{
down = 0;
}
}

Advertisements

Assignment 3 in Processing

Now, this may come as a shock, but I am not particularly well versed in coding languages.

I can hear the surprise.

What I’m really hoping is to try and learn a little bit more. So I’m been trying to think of a project that is actually a project, but is also something that can be used as a stepping stone for understanding Processing. And since I’m a big fan of both video games and pixel art, I thought I would try to make a side-scrolling video game for the web.

Stepping in to this project, I am full confident I will be able to make the pixeled sprites and backgrounds without much problem. However, the difficulty lies in, you know, actually getting it to function like a video game. I worry that this is too basic or not enough of a challenge, but I’m not really a pro at Processing and I’m working on my own. So I wanted something that could be problem solved a little easier using the internet, but was still complex enough that I would have to really work on it.

Processing 2 Assignment 2

Woah boy. Okay. So I started trying to figure out how to import libraries into Processing, then load them once there were in there.
– First, I started off using a basic code to get the fractal noise. I played with the settings a bit to get the blob-ish grayscale effect. (See this post: https://shannwich.wordpress.com/2013/10/12/code-start-1/)
– The next step was to get it to animate. I modified it slightly to split at a slightly higher rate. (See this post: https://shannwich.wordpress.com/2013/10/12/code-middle-02/)
– Finally, I was playing with the layering of several noise effects on top of each other to get the final animation.

import CellNoise.*;

CellNoise cn;
CellDataStruct cd;
float total = 0.0, start = 0.0;
float[] freq = {0.10, 0.20, 0.10};
double[] at = {0, 0, 0};
PImage im;
int frames = 0, t = 0;
double Fs = 0, Fsum = 0;

void setup() {
size(600, 400);
cn = new CellNoise(this);
cd = new CellDataStruct(this, 3, at, cn.MANHATTAN);
start = millis();
}
void draw() {
loadPixels();
at[2] += freq[2];
float diff;

for (int x = 0; x < width; x++) {
at[0] = freq[0]*(x+t);
for (int y = 0; y < height; y++) {
at[1] = freq[1]*(y+t);
cd.at = at;
cn.noise(cd);
pixels[x + y*width] = color(
(float)(cd.F[1]*cd.F[0]) * 50,
(float)cd.F[0]*110,
0
);

pixels[x + y*width] = color((float)cd.F[0] * 350);

pixels[x + y*width] = color((float)cd.F[0] * 150);

Fsum += cd.F[0];
Fs++;
}
}
updatePixels();
}

-I spent a lot of time trying to figure out how to do one of three things: contain the noise into a shape, using the noise as background, or pausing the noise effect when the mouse is clicked. I had no such luck in any of the three fronts. The noise is an effect that affects the entire draw space, and I can’t seem to get it affect only part of the draw space.

Library found at: http://www.carljohanrosen.com/processing/index.php?page=start&topic=1.0

Code Middle 02

shot02

 

import CellNoise.*;
CellNoise cn;
CellDataStruct cd;
float total = 0.0, start = 0.0;
float[] freq = {0.08, 0.08, 0.05};
double[] at = {0, 0, 0};
PImage im;
int frames = 0, t = 0;
double Fs = 0, Fsum = 0;

void setup() {
size(600, 600);
cn = new CellNoise(this);
cd = new CellDataStruct(this, 2, at, cn.MANHATTAN);
start = millis();
}
void draw() {
loadPixels();
at[2] += freq[2];
float diff;

for (int x = 0; x < width; x++) {
at[0] = freq[0]*(x+t);
for (int y = 0; y < height; y++) {
at[1] = freq[1]*(y+t);

cd.at = at;
cn.noise(cd);

//pixel color
pixels[x + y*width] = color((float)(cd.F[1]*cd.F[0]) * 150);

// avrage F[0]
Fsum += cd.F[0];
Fs++;
}
}
updatePixels();
}

Code Start 01

shot01

 

 

CellDataStruct cd;
double[] at = {0, 0};
double t = 0;
PImage im;
int x, y, i;

void setup() {
size(600, 600);
cn = new CellNoise(this);
cd = new CellDataStruct(this, 2, at, cn.MANHATTAN);
}
void draw() {
loadPixels();

t = 0;
for (x = 0; x < width; x++) {
at[0] = 0.01 * ( x + 20);
for (y = 0; y < height; y++) {
at[1] = 0.01 * ( y + 700 );
cd.at = at;
cn.noise(cd);
double sum = 1;
for (int i = 0; i < 4; i++) {
at[0] = 0.01*(i*2+1) * (x + 20);
at[1] = 0.01*(i*2+1) * (y + 700);
cd.at = at;
cn.noise(cd);
sum *= (cd.F[0]);
}
pixels[x + y*width] = color((float)(sum)*255);
}
}
updatePixels();
}

Assignment 1 in Processing 2

Okay. So I’m taking a class that uses Processing 2. I’ve never used Processing before. It’s a little confusing, but I think I’m getting the hang of it? I made a sphere that shifts the camera to the left when you move your mouse down, and to the right when you move your mouse up. When you click, it changes from the default light to a spot light! Whooo!

Code:

void setup(){
size(400,400,P3D);

}

void draw(){
background(45);
translate(200,200,0);
camera(mouseY, height/2, (height/2) / tan(PI/6), mouseY, height/2, 0, 0, 1, 0);
translate(width/2, height/2, -100);
lights();
if (mousePressed) {
pointLight(20, 152, 103, width/2, height/2, 400);
}
fill(20,152,103);
noStroke();
sphere(100);

}