This should fix the error which happens once you reach the end of the AudioData read.
Replace the generateAudioOut method in the Viewspace class with this code.
if(abs(world.audioData[readHead2]) > 0.8 && wait > 8000) { // checking if the frequency of the readhead is above 0.4 , therefore detecting a beat readHead += world.speed; // set the speed of the music } void generateAudioOut(float[] buffer) {
if (volume) {
audioThread.volumeController();
}
for (int i=0;i
// println("do something interesting");
inc = 10 * (world.audioData[readHead2]);
//wait =0; // resetting the wait
// println(abs(audioData[readHead]));
}
// copy data from the audio we read from the file (audioData)
// into the buffer that gets sent to the sound card
buffer[i] = audioData[readHead];
// BEAT DETECTION HERE!!!!!! //
// if(abs(audioData[readHead2]) > 0.8 && wait > 8000) {
// }
// move the read head along one, resetting to zero
// if it goes to the end of the audioData array
//if (readHead >= audioData.length) {
//}
// or do it the clever way with the modulo operator
readHead = (readHead) % audioData.length;
if(readHead % audioData.length >= audioData.length - 5000){
readHead = 0;
readHead2 = 0;
}
else{
readHead2 = (readHead) % audioData.length +4096;
}
wait++;
}
Okay, so i’ve added a few additional methods for the visualiser, this will help keep things together as opposed to in a complete mess. It was hard enough having to restructure everything into proper classes as they were kinda everywhere. Although that is to be expected, we now have a format
Viewspace is the so called parent of everything it will handle a lot of the generation of the tiles, player etc. There are a few methods in here so take a look they have been commented.
Joe if you want to add more visualizers call the method in the main draw – also note DO NOT ADD ANYTHING LIKE POSITIONING IN THE CONSTRUCTOR this will cause a recursion overflow as the Tiles class is extending the ViewSpace the last thing we want is several million tiles appearing.
Mike
Link to download: http://www.argentgray.com/downloads/project_fireball_alpha_v0006.zip
Here is version 2.0!!!
hacked in some of matthew’s classes and coded some crazy stuff that changes based on the sound yeahh.
here is the slightly reworked tunnel with boxes tunnel needed reworking because the boxes were not aligning properly.
http://www.projectfireball.com/wp-content/uploads/group_project_working_tunnel.zip
The tunnel uses the camera to create all four sides. The camera is rotated and a side is drawn. Simple and keeps the code small and compact.
heres the download link: http://www.projectfireball.com/wp-content/uploads/project_fireball_alpha_v0004.zip
cheers,
Joe.
Okay, so here’s the simplified tunnel,
It basically removes the blocks at the back of the camera and puts them at the end of the tunnel, this means we will no longer have to worry about memory overflows etc.
One of you can rotate and add three more vertices to the game, adding a block to the surface is easy. Place the box and subtract its Z position like so: translate(x,y,z-(blockHeight)/2);
as the block will be placed EXACTLY half way between the viewspace and the void (outside the walls).
http://www.argentgray.com/downloads/latest_rev.zip
float hite=70.0; // camera heightint[][] tiles; // types of tilesfloat xp,yp; // x and y positions void setup() { size(512,512,P3D); reset();} void reset() { tiles=new int[30][6]; for (int row=0;row<30;row++) { for (int col=0;col<6;col++) { tiles[row][col]=1; } } frameCount=0;} void draw () { int ypos=(frameCount%60); camera(0,ypos,hite,0,(ypos+400),0,0,-1,0); lightFalloff(1.0, 0.0, 0.0) ; background(0); for (int col=0;col<6;col++) { int x=-60+(20*col); for (int row=0;row<30;row++) { int y=20*row; fill(255,255-((y-ypos)/2)); rect(x,y,20,20); } } fill(127); }
We now have a domain name!
http://www.projectfireball.com
changed the banner and website icon.
Looks a bit classier now. yeahh
Oh wow how amazing here is the Class layout for all you guys!
I zipped it and uploaded it so grab it from this link:
http://www.bicshare.com/fireball/wp-content/uploads/project_fireball_alpha_v0001.zip
lololol!
any changes or amendments you make please upload!
remember the link to the file you upload will be: http://www.bicshare.com/fireball/wp-content/uploads/your_file_name.extension.
Of course tell us if you upload something!
/joe out.
Okay, first things first guys, please don’t put anything in the Viewspace class yet… as i’m still working on fixing the “Light at the end of the tunnel” crap going on. thinking of adding a gradient to the lines to get rid of it. But for polymorphism reasons, i’m not strictly adding it straight into the class yet.
Anyway, heres the game sketch:
import processing.opengl.*;Viewspace world;int z = -2000;void setup(){size(600, 480, OPENGL);background(0);world = new Viewspace(); // ALWAYS PUT THIS AFTER SIZE.}void draw(){background(0);world.DRAW_FLOOR_PLANE();world.step();}import damkjer.ocd.*;import processing.opengl.*;
Viewspace world;
int z = -2000;
void setup(){size(600, 480, OPENGL);background(0);world = new Viewspace(); // ALWAYS PUT THIS AFTER SIZE.}
void draw(){ background(0); world.DRAW_FLOOR_PLANE(); world.step();}
Here is the class called “Viewspace” please keep it the same name to avoid confusion
// Class created by michael gray
// Description:
// The view space class handles the four sides of the world… although at the moment this only handles the general view model of the world,
// you will need to put any “global” mechanics in here. For example, physics related to the world (NOT THE PLAYER!!)
// Usage: If you have a general “method/rule” that the player takes from the world space, please extend that class from this and add the attributes here.
class Viewspace{
int depth = 10000; // how many rows of tiles we will have…
// Constructor
Viewspace(){
//translate(width*0.5, height*0.5, 0);
}
public void DRAW_FLOOR_PLANE() {
int ypos= depth – (frameCount%20000); // the y’s current position.
println(ypos);
camera(width*0.5, height*0.5, ypos, width/2.0, height/2.0, 0, 0, 1, 0);
beginShape(QUADS);
noFill();
strokeWeight(0.001);
stroke(255);
for(int x = 200; x < 400; x += 20){
for(int z = -1000; z < depth; z += 20){
vertex(x, 300, z);
vertex(x, 300, z+20);
vertex(x+20, 300, z+20);
vertex(x+20, 300, z);
}
}
endShape(QUADS);
beginShape(QUADS);
strokeWeight(0.001);
stroke(255);
noFill();
for(int x = 200; x < 400; x += 20){
for(int z = -1000; z < depth; z += 20){
vertex(x, 100, z);
vertex(x, 100, z+20);
vertex(x+20, 100, z+20);
vertex(x+20, 100, z);
}
}
endShape(QUADS);
beginShape(QUADS);
stroke(255);
strokeWeight(0.001);
noFill();
for(int y = 100; y < 300; y += 20){
for(int z = -1000; z < depth; z += 20){
vertex(200, y, z);
vertex(200, y, z+20);
vertex(200, y+20, z+20);
vertex(200, y+20, z);
}
}
endShape(QUADS);
beginShape(QUADS);
stroke(255);
strokeWeight(0.001);
noFill();
for(int y = 100; y < 300; y += 20){
for(int z = -1000; z < depth; z += 20){
vertex(400, y, z);
vertex(400, y, z+20);
vertex(400, y+20, z+20);
vertex(400, y+20, z);
}
}
endShape(QUADS);
}
// This moves us per frame through the world.
void step() {
}
}
Finally, note to jack. please remember to close your for loops as your original code although working, screwed up when I implemented it into the class. Anyway, all should work now. Comment here or gimme a bell if it doesn’t work.