Dec 1, 2008 at 10:14pm UTC
Working on a project for my CPSC class. The project is to recreate a watered down guitar hero game, and the portion I am having problems with deals with the movement of the notes down the track in 4 vertical positions. Here is fragment of code im testing:
#include "std_lib_facilities.h"
#include "Simple_window.h"
#include "Graph.h"
#include <stdio.h>
#include <time.h>
void wait ( int seconds )
{
clock_t endwait;
endwait = clock () + seconds * CLOCKS_PER_SEC ;
while (clock() < endwait) {}
}
int main(){
try {
if(H112 != 200803L)error("Error: incorrect std_lib_facilities.h version ",
H112);
vector<int>notes;
notes[0] = 1;
notes[1] = 2;
notes[2] = 3;
notes[3] = 3;
notes[4] = 2;
notes[5] = 1;
Simple_window win2(Point(100,200),600,400,"Gamelan Hero");
Circle c0(Point(140,350),30);
Circle c1(Point(200,350),10);
Circle c2(Point(250,350),5);
Circle c3(Point(300,350),2);
win2.c0.set_style(Line_style(Line_style::solid,35));
win2.c1.set_style(Line_style(Line_style::solid,25));
win2.c2.set_style(Line_style(Line_style::solid,15));
win2.c3.set_style(Line_style(Line_style::solid,10));
win2.attach(c0);
win2.attach(c1);
win2.attach(c2);
win2.attach(c3);
//bottom = 350, nxt 250, 150, 80
int string;
int z1;
int z2;
int z3;
for(int i = 0; i < notes.size(); i++){
notes[i] = string;
switch(string){
case 0: win2.c3.move(220,80);
case 1: win2.c3.move(240,80);
case 2: win2.c3.move(270,80);
case 3: win2.c3.move(300,80);
case 4: win2.c3.move(330,80);
case 5: win2.c3.move(360,80);
case 6: win2.c3.move(380,80);
}
wait(1);
if(i+1 <= notes.size()) {
z1 = notes[i+1];
}
switch(z1){
case 0: win2.c3.move(220,80);
case 1: win2.c3.move(240,80);
case 2: win2.c3.move(270,80);
case 3: win2.c3.move(300,80);
case 4: win2.c3.move(330,80);
case 5: win2.c3.move(360,80);
case 6: win2.c3.move(380,80);
default: win2.c3.move(1000,1000);
}
switch (string){
case 0: win2.c2.move(200,150);
case 1: win2.c2.move(230,150);
case 2: win2.c2.move(265,150);
case 3: win2.c2.move(300,150);
case 4: win2.c2.move(335,150);
case 5: win2.c2.move(365,150);
case 6: win2.c2.move(400,150);
default: win2.c2.move(1000,1000);
}
wait(1);
if(i+2 <= notes.size()){
z2 = notes[i+2];
}
switch(z2){
case 0: win2.c3.move(220,80);
case 1: win2.c3.move(240,80);
case 2: win2.c3.move(270,80);
case 3: win2.c3.move(300,80);
case 4: win2.c3.move(330,80);
case 5: win2.c3.move(360,80);
case 6: win2.c3.move(380,80);
default: win2.c3.move(1000,1000);
}
switch (z1){
case 0: win2.c2.move(200,150);
case 1: win2.c2.move(230,150);
case 2: win2.c2.move(265,150);
case 3: win2.c2.move(300,150);
case 4: win2.c2.move(335,150);
case 5: win2.c2.move(365,150);
case 6: win2.c2.move(400,150);
default: win2.c2.move(1000,1000);
}
switch (string) {
case 0: win2.c1.move(170,250);
case 1: win2.c1.move(215, 250);
case 2: win2.c1.move(260,250);
case 3: win2.c1.move(300,250);
case 4: win2.c1.move(340,250);
case 5: win2.c1.move(385,250);
case 6: win2.c1.move(430,250);
default: win2.c1.move(1000,1000);
}
wait(1);
if(i+3 <= notes.size()){
z3 = notes[i+3];
}
switch(z3){
case 0: win2.c3.move(220,80);
case 1: win2.c3.move(240,80);
case 2: win2.c3.move(270,80);
case 3: win2.c3.move(300,80);
case 4: win2.c3.move(330,80);
case 5: win2.c3.move(360,80);
case 6: win2.c3.move(380,80);
default: win2.c3.move(1000,1000);
}
switch (z2){
case 0: win2.c2.move(200,150);
case 1: win2.c2.move(230,150);
case 2: win2.c2.move(265,150);
case 3: win2.c2.move(300,150);
case 4: win2.c2.move(335,150);
case 5: win2.c2.move(365,150);
case 6: win2.c2.move(400,150);
default: win2.c2.move(1000,1000);
}
switch (z1) {
case 0: win2.c1.move(170,250);
case 1: win2.c1.move(215, 250);
case 2: win2.c1.move(260,250);
case 3: win2.c1.move(300,250);
case 4: win2.c1.move(340,250);
case 5: win2.c1.move(385,250);
case 6: win2.c1.move(430,250);
default: win2.c1.move(1000,1000);
}
switch (string) {
case 0: win2.c0.move(140,350);
case 1: win2.c0.move(200,350);
case 2: win2.c0.move(250,350);
case 3: win2.c0.move(300,350);
case 4: win2.c0.move(350,350);
case 5: win2.c0.move(400,350);
case 6: win2.c0.move(460,350);
default: win2.c0.move(1000,1000);
}
}
}
catch(exception& e) {
cerr << "exception: " << e.what() << '\n';
return 1;
}
catch (...) {
cerr << "Some exception\n";
return 2;
}
}
Just using an arbitrary set of notes to test with, but when I compile it just gives me loads of errors on the .move lines saying that c(0-3) isn't a member of win2. I'm pretty sure my declaration and attatchment of the circles isn't where the problem is, but if that is the case I am stumped as to where it actually is. Any suggestions? Thanks.