• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

wabbz111

Members
  • Content count

    61
  • Joined

  • Last visited

Community Reputation

162 Neutral

About wabbz111

  • Rank
    Member
  1. Thanks for the replies I have done the correction but i want it to display the PMenu until i press r || R which will then print the results This program was working without classes but i am now trying to use classes and that is why iam a bit stuck. The original program without classes is below. You can see what iam trying to do with the current class arrangement. Regards #include<cstdlib> #include<iostream> #include<string> #define PI = 3.142 using namespace std; int main() { system("COLOR CE"); char choice,choice2; //for presidents int pa=0,pb=0,pc=0,pTotal=0; //string PName="Wamalwa"; //for senators int sa=0,sb=0,sc=0,sTotal=0; //string SName="Mona"; do { cout<<"\t Presidential Elections\n\n"; cout<<"Candidates \n\n"; //add more presidential candidates here cout<<"<A> Wamalwa \n"; cout<<"<B> Robert\n"; cout<<"\t senators Elections\n\n"; cout<<"Candidates \n\n"; //add more senatorial candidates here cout<<"<D>Mona\n\n"; cout<<"Enter your vote : "; cin>>choice; switch(choice) { case 'A': case 'a': pa++; break; //use new case for other presidential candidates //for senators case 'D': case 'd': sa++; break; //use new case for other senatorial candidates } cout<<"-----------------------\n"; cout<<"Enter <v>vote <r> result and <q> quit : \a"; cin>>choice2; } while(choice2=='V' || choice2=='v'); /// if (choice2=='R' || choice2=='r') { //presidential results cout<<"\t Presidential Elections\n\n"; cout<<"Candidates:"<<"\t results:"<<"\n\n"; cout<<"<A>Wamalwa : "<<pa<<"\a\n"; //_______senatorial results cout<<"\t Senatorial Elections\n\n"; cout<<"Candidates \n\n"; cout<<"<D>Mona: "<<sa<<"\n"; pTotal=pa; //for other presidential canndidates add the variables sTotal=sa;//for other senatorial canndidates add the variables //count total votes cout<<"Total Presidential Votes cast : "<<pTotal<<"\n"; cout<<"Total Senatorial Votes cast : "<<sTotal<<"\n"; cout<<endl; } if (pa > pb && pa > pc) { cout<< " The presidential winner is : Wamalwa " << endl; } //hint use else if for more candiates //for senators if (sa > sb && sa > sc) { cout<< " The senatorial winner is : Mona " << endl; } //hint use else if for more candiates system("pause"); return 0; }
  2. Hi i have an issue with this block of code even though all my braces have been opened and closed. Can someone please help out? Regards expected unqualified-id before 'do' expected '}' at end of input expected unqualified-id at end of input #include<cstdlib> #include<iostream> #include<string> using namespace std; class President { public: //int ca=0,cb=0,cc=0,tv=0; //string sa="Wamalwa",sb="Rotich",sc="Fatima"; int ca,cb,cc,tv; string sa,sb,sc; char pchoice,pchoice2; void PWinner() { if (ca > cb && ca > cc) { cout<< "and the winner is : Wamalwa" << endl; } else if (cb > ca && cb > cc) { cout << "and the winner is : Rotich" << endl; } else if (cc > ca && cc > cb) cout << "and the winner is : Fatima" << endl; else cout << "no winning president go for a runoff" << endl; } //my error is here do { void PMenu() { cout<<"\t Presidential Elections\n\n"; cout<<"Candidates \n\n"; cout<<"<A>Wamalwa \n"; cout<<"<B>Rotich \n"; cout<<"<C>Fatima \n\n"; cout<<"Pick a candidate\n"; cin>>pchoice; switch(pchoice) { case 'A': case 'a': ca++; break; case 'B': case 'b': cb++; break; case 'C': case 'c': cc++; break; } while(pchoice2=='V' || pchoice2=='v'); } if (pchoice2=='R' || pchoice2=='r') { cout<<"\t Chairman Elections\n\n"; cout<<"Candidates:"<<"\t results:"<<"\n\n"; cout<<"<A>Wamalwa : "<<ca<<"\n"; cout<<"<B>Rotich : "<<cb<<"\n"; cout<<"<C>Fatima : "<<cc<<"\n\n"; tv=ca+cb+cc; cout<<"Total Votes : "<<tv<<"\n"; } //private: } }; /* class Senator { public: //int pa=0,pb=0,pc=0,sv=0; //string xa="Mona", xb="Nyachae", xc="Nzuki"; void SWinner() { //for senators if (pa > pb && pa > pc) { cout<< "and the winner is : roto" << endl; } else if (pb > pa && pb > pc) { cout << "and the winner is : maish" << endl; } else if (pc > pa && pc > pb) { cout << "and the winner is : maish" << endl; } else cout << "no winning senator go for a runoff" << endl; } void SMenu() { cout<<"\t senators Elections\n\n"; cout<<"Candidates \n\n"; cout<<"<D>Mona\n"; cout<<"<E>Nyachae\n"; cout<<"<F>Nzuki\n\n"; cout<<"Enter your vote : "; cin>>choice; //for senators case 'D': case 'd': pa++; break; case 'E': case 'e': pb++; break; case 'F': case 'f': pc++; break; } cout<<"-----------------------\n"; cout<<"Enter <v>vote <r> result and <q> quit : "; cin>>schoice2; // private: };*/ int main() { //for senaors //char Schoice, Sechoice; President Wamalwa; Wamalwa.PMenu(); Wamalwa.PWinner(); // do //{ // } //} /*///////senators cout<<"\t Secretary Elections\n\n"; cout<<"Candidates \n\n"; cout<<"<D>Mona"<<pa<<"\n"; cout<<"<E>Nyachae "<<pb<<"\n"; cout<<"<F>Nzuki "<<pc<<"\n"; cout<<"Enter your vote : ";*/ //sv=pa+pb+pc; //} system("pause"); return 0; }  
  3. @SeanMiddleditch I will definetly try this one out. Meanwhile let me do more practice i will also be posting another program(using classes vehicle and bicycle) soon that hopefully can use friend classes beter.
  4. Thanks @Paradigm Shifter i will now try it with the Steer() method private. I added porsche.Steer(); in PorscheSteer(); then in the main method called Cayenne.Steer(car); and it worked.   @SeanMiddleditch  I hear you great advice but if you dont mind how about an example to clear up any lingering concerns.Regards
  5. I am having issues trying to use friend classes. I want the class Porsche to use method Steer() found in vehicle class but i have tried several styles without success could someone point me in the right direction. With the class Lamborghini i used inheritance and it works fine but i wanted to use friend classes for the Porsche class. My code is below  Thanks   <code> #include <cstdlib> #include <iostream> using namespace std; class Vehicle { public: friend class Porsche; //porsche as friend to vehicle void Steer() { vLeft = "steering left"; vRight = "steering right"; // if (vLeft) cout <<vLeft<< endl; //if(steering Right) cout << vRight << endl; //cout } int Accelerate() { vAcceleration = 5.0f; cout<<"acceleration takes "<<vAcceleration<<" seconds "<<endl; return vAcceleration; } int Brake() { cout<<"Brakes applied"<< vBrake<<endl; } private: float vAcceleration; string vBrake; int vTopSpeed; string vLeft; string vRight; //declare porsche as friend to vehicle }; class Porsche { public: friend class Vehicle; //declare vehicle as friend to porsche string pName; int PorscheAccelerate() { cout<<" Porsche accelerates in "<<pAcceleration<<" seconds "<<endl; } int PorscheTopSpeed() { pTopSpeed = 350; cout<<" Porsche Cayenne has a top speed of "<<pTopSpeed<<" KM/H "<<endl; } int PorscheHorsePower() { pHorsePower=460; cout<<" Porsche produces "<<pHorsePower<<endl; } //* void PorscheSteer(Vehicle porsche) { // Steer(); }//*/ private: float pAcceleration; string pBrake; int pTopSpeed; int pHorsePower; }; class Lamborghini : public Vehicle { public: string LamboName; int LamboAccelerate() { cout<<" Lamborghini accelerates in "<<lAcceleration<<" seconds "<<endl; } int LamboTopSpeed() { lTopSpeed = 440; cout<<" Lamborghini has a top speed of "<<lTopSpeed<<" KM/H "<<endl; } int LamboHorsePower() { lHorsePower=1000; cout<<" Lamborghini produces "<<lHorsePower<<" HP"<<endl; } private: float lAcceleration; string lBrake; int lTopSpeed; int lHorsePower; }; int main(int argc, char *argv[]) { //objects for vehicle class cout<<" _________________objects for vehicle________________________"<<endl; Vehicle car; car.Steer(); car.Accelerate(); //cout<<car.vRight; cout<<" _________________objects for porsche________________________"<<endl; cout<<endl; Porsche Cayenne; cout<<Cayenne.pName; Cayenne.PorscheTopSpeed(); Cayenne.PorscheHorsePower(); // Cayenne.Steer(car); cout<<endl; cout<<endl; cout<<" _________________objects for lamborgini________________________"<<endl; cout<<endl; Lamborghini Murcielago; Murcielago.LamboHorsePower(); Murcielago.Steer(); // using steer function found only in vehicle class cout<<endl; //car.vBrake = "Braking"; //use this as private //cout << "Press the enter key to continue ..."; //cin.get(); system("pause"); return EXIT_SUCCESS; } </code>
  6. Alright i will try it and let you know thanks.
  7. I am using lines for trunk and branches, with leaves represented by an octahedron. Since l-system generate the tree recusivelt i get mant branches and leaves. I would like to know if there is a way to approximate how many are on the screen .please look at the picture attached to see what i mean
  8. Hi swiftcoder, Could you please elaborate on the above statement Do i use a counter? if so do i count the vertex buffer? or something else Secondly i have seen info on glfeedback will it achieve the same thing? THanks
  9. Hi people, I would like to know how i can get a polygon count for my 3D scene. It will be purely for statistics so something simple will suffice. My program is an l-system tree generator and i want to know how many polygons are used to draw the various trees. Any help is greatly appreciated.
  10. OpenGL

    Sorry about not reporting the errors. About the missing #includes that is a problem when pasting but the three libraries iam using are: #include <GL/freeglut.h> #include <iostream> #include <stdio> Here is the full error list i will try implement your suggestions. Cheers [source lang="cpp"]shapes.cpp:168: error: expected constructor, destructor, or type conversion before '*' token shapes.cpp:168: error: expected `,' or `;' before '*' token shapes.cpp:170: error: expected constructor, destructor, or type conversion before '(' token shapes.cpp:170: error: expected `,' or `;' before '(' token shapes.cpp:174: error: expected unqualified-id before "for" shapes.cpp:174: error: expected `,' or `;' before "for" shapes.cpp:174: error: expected constructor, destructor, or type conversion before '<' token shapes.cpp:174: error: expected `,' or `;' before '<' token shapes.cpp:174: error: expected constructor, destructor, or type conversion before '++' token shapes.cpp:174: error: expected `,' or `;' before '++' token shapes.cpp:175: error: expected constructor, destructor, or type conversion before '(' token shapes.cpp:175: error: expected `,' or `;' before '(' token make.exe: *** [shapes.o] Error 1 Execution terminated[/source] Here is the source code cube with vertices defined(without the changes reccomended) [source lang="cpp"] #include <GL/freeglut.h> #include <iostream> #include <stdio> bool fullscreen = false; bool mouseDown = false; float xrot = 0.0f; float yrot = 0.0f; float xdiff = 0.0f; float ydiff = 0.0f; void drawBox() { glBegin(GL_QUADS); glColor3f(1.0f, 0.0f, 0.0f); // FRONT glVertex3f(-0.5f, -0.5f, 0.5f); glVertex3f( 0.5f, -0.5f, 0.5f); glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f, 0.5f); // BACK glVertex3f(-0.5f, -0.5f, -0.5f); glVertex3f(-0.5f, 0.5f, -0.5f); glVertex3f( 0.5f, 0.5f, -0.5f); glVertex3f( 0.5f, -0.5f, -0.5f); glColor3f(0.0f, 1.0f, 0.0f); // LEFT glVertex3f(-0.5f, -0.5f, 0.5f); glVertex3f(-0.5f, 0.5f, 0.5f); glVertex3f(-0.5f, 0.5f, -0.5f); glVertex3f(-0.5f, -0.5f, -0.5f); // RIGHT glVertex3f( 0.5f, -0.5f, -0.5f); glVertex3f( 0.5f, 0.5f, -0.5f); glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f, -0.5f, 0.5f); glColor3f(0.0f, 0.0f, 1.0f); // TOP glVertex3f(-0.5f, 0.5f, 0.5f); glVertex3f( 0.5f, 0.5f, 0.5f); glVertex3f( 0.5f, 0.5f, -0.5f); glVertex3f(-0.5f, 0.5f, -0.5f); // BOTTOM glVertex3f(-0.5f, -0.5f, 0.5f); glVertex3f(-0.5f, -0.5f, -0.5f); glVertex3f( 0.5f, -0.5f, -0.5f); glVertex3f( 0.5f, -0.5f, 0.5f); glEnd(); } bool init() { glClearColor(0.93f, 0.93f, 0.93f, 0.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glClearDepth(1.0f); return true; } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt( 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); glRotatef(xrot, 1.0f, 0.0f, 0.0f); glRotatef(yrot, 0.0f, 1.0f, 0.0f); drawBox(); glFlush(); glutSwapBuffers(); } void resize(int w, int h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, w, h); gluPerspective(45.0f, 1.0f * w / h, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void idle() { if (!mouseDown) { xrot += 0.3f; yrot += 0.4f; } glutPostRedisplay(); } void keyboard(unsigned char key, int x, int y) { switch(key) { case 27 : exit(1); break; } } void specialKeyboard(int key, int x, int y) { if (key == GLUT_KEY_F1) { fullscreen = !fullscreen; if (fullscreen) glutFullScreen(); else { glutReshapeWindow(500, 500); glutPositionWindow(50, 50); } } } void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) { mouseDown = true; xdiff = x - yrot; ydiff = -y + xrot; } else mouseDown = false; } void mouseMotion(int x, int y) { if (mouseDown) { yrot = x - xdiff; xrot = y + ydiff; glutPostRedisplay(); } } //* ///save vertices struct THeader{ int vertlen; //amount of vertices you want to save }; struct t3dpoint { float x; float y; float z; }; FILE* f = fopen(filename,"wb+"); fwrite(&header,sizeof(THeader),1,f); //now you can save them //through all vertices in array for (j=0; j < header.vertlen ; j++) fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever) fclose(f); //*/ int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowPosition(50, 50); glutInitWindowSize(500, 500); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("13 - Solid Shapes"); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutSpecialFunc(specialKeyboard); glutMouseFunc(mouse); glutMotionFunc(mouseMotion); glutReshapeFunc(resize); glutIdleFunc(idle); if (!init()) return 1; glutMainLoop(); return 0; } [/source]
  11. OpenGL

    Hi _____, Iam using the first part of your code the error is on this line fwrite(&header,sizeof(THeader),1,f); My full code is below, iam just trying to save the cube vertices into memory please give me any ideas you might have. Thanks [source lang="cpp"] #include <GL/freeglut.h> #include <iostream> #include <stdio.h> bool fullscreen = false; bool mouseDown = false; float xrot = 0.0f; float yrot = 0.0f; float xdiff = 0.0f; float ydiff = 0.0f; void drawBox() { glColor3f(0.0f, 0.0f, 1.0f); glutSolidCube(2); } bool init() { glClearColor(0.93f, 0.93f, 0.93f, 0.0f); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glClearDepth(1.0f); return true; } void display() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt( 0.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f); glRotatef(xrot, 1.0f, 0.0f, 0.0f); glRotatef(yrot, 0.0f, 1.0f, 0.0f); drawBox(); glFlush(); glutSwapBuffers(); } void resize(int w, int h) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); glViewport(0, 0, w, h); gluPerspective(45.0f, 1.0f * w / h, 1.0f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } void idle() { if (!mouseDown) { xrot += 0.3f; yrot += 0.4f; } glutPostRedisplay(); } void keyboard(unsigned char key, int x, int y) { switch(key) { case 27 : exit(1); break; } } //* ///save vertices struct THeader{ int vertlen; //amount of vertices you want to save THeader(); }; struct t3dpoint { float x; float y; float z; }; FILE* f = fopen("vertices.txt","wb+"); fwrite(&header,sizeof(THeader),1,f); //now you can save them //through all vertices in array for (j=0; j < header.vertlen ; j++) fwrite(&verts[j],sizeof(verts[j]),1,f); //or sizeof t3dpoint (whatever) fclose(f); /// /*///Load int length; int j; FILE* f = fopen(filename,"rb"); memset(&header,0,sizeof(THeader)); //do this if header consist more than one var if not ther is no need even to make a struct from header fread(&header,sizeof(THeader),1,f); int j; //set the length of verts - array in excample it can be simple pointer (t3dpoint * verts;) verts = new t3dpoint[header.vertlen]; for (j=0; j < header.vertlen ; j++) { t3dpoint imo; fread(&imo,sizeof(imo),1,f); verts[j] = imo; //something like this i use static arrays so i just assign it like thus if this does not work you will need to write (*verts[i]) = imo; but have no idea if it will work anyway [img]http://public.gamedev.net//public/style_emoticons/default/tongue.png[/img] } fclose(f); } //*/ //*/ int main(int argc, char *argv[]) { glutInit(&argc, argv); glutInitWindowPosition(50, 50); glutInitWindowSize(500, 500); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); glutCreateWindow("13 - Solid Shapes"); glutDisplayFunc(display); glutKeyboardFunc(keyboard); glutReshapeFunc(resize); glutIdleFunc(idle); if (!init()) return 1; glutMainLoop(); return 0; } [/source]
  12. OpenGL

    Thanks for the replies people. This question is addressed to ____ , I have tried using your sample code to save the vertices of an opengl cube to file but i keep getting errors can you please provide a way foward. Thanks
  13. OpenGL

    Thanks GeneralQuery yes saving the mesh is what i am trying to do. I will check out AssImp but if you know a way of writing the geometry in .OBJ format i will really appreciate it.
  14. Hi guys, I am making an L-sytem tree application. I require a way to save the generated models into a text file(.obj seems the best as it saves the vertices). Check [url="http://homepages.cs.ncl.ac.uk/jonathan.hook/lsystems.html"]this[/url] site for the L-system framework I know how read and write to a text with plain C++ but the withOpenGL it is not straight forward. Can someone please provide me with any help on this matter.? Preferablly an example like saving the openGL cube or teapot veryices into a text file. Thanks
  15. Thanks Solano let me try it out.[img]http://public.gamedev.net//public/style_emoticons/default/wink.png[/img]