This is the key handling for the game and I am planning to implement drop down menus and popups and hints using OpenGL. I know this is extreme, but I wanted something that I could use to change the look and feel of a window and GTK and other things are cool, but I wanted a resource that I could modify in context. I mainly want to learn something about implementing the user interface and I wanted to make some unique features that may or may not be stock in a standard implementation.Mainly just having fun. As you can see from the code I have set up hot keys to allow the application of rule sets using the solver and also a method to clear the possibility and decided arrays along with re-establishing the rules as not applied. I must add a few more keys to do save, restore , pause, and reveal. I make the methods to cheat in the process, but cheating the game is sometimes as much fun as playing it. In the code I use a structure to pass all the window, display and context information around to where it is needed. Everything only exists within the scope of main and so it is somewhat object orinted, but it isn't as elegant in structure as I planned. I guess my next implementation will grow from this. I wanted to implement a bizarre object oriented model next and I will probably do that with the GNUbik conversion to a set theory implementation with matrices and some Markov chains. I hope publishing what I learn can help somebody.
#ifdef Window3 glXMakeCurrent(passVarsA->dpy3, passVarsA->win3, passVarsA->ctx3); while (XPending(passVarsA->dpy3) > 0) { XEvent event;XNextEvent(passVarsA->dpy3, &event);switch (event.type) { case Expose: break; case ConfigureNotify: reshape(event.xconfigure.width, event.xconfigure.height,passVarsA->dpy3,passVarsA->win3, passVarsA->ctx3);break; case KeyPress: { code = XLookupKeysym(&event.xkey, 0); if (code == XK_Left ) {automatic=20;break;} if (code == XK_Right) {automatic=0 ;break;} if (code == XK_Up ) {} if (code == XK_p ) {decideRows(puzzle);} if (code == XK_d ) {decideSingles(puzzle);} if (code == XK_t ) {applyRulesTriplet(puzzle,rules,rules[RULES_LIMIT-1][0]);} if (code == XK_x ) {applyRulesNext(puzzle,rules,rules[RULES_LIMIT-1][0]);} if (code == XK_a ) {applyRulesAssoc(puzzle,rules,rules[RULES_LIMIT-1][0]);} if (code == XK_n ) {applyRulesNear(puzzle,rules,rules[RULES_LIMIT-1][0]);} if (code == XK_i ) {applyRulesID(puzzle,rules,rules[RULES_LIMIT-1][0]);} if (code == XK_c ) {makePossible(puzzle,rules,rules[RULES_LIMIT-1][0]);} else { r=XLookupString(&event.xkey, buffer, sizeof(buffer),NULL, NULL); if (buffer[0] == 27) {printf("\n");return;}} } } } glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); DrawGLScene3(texture, puzzle,rules); glXSwapBuffers(passVarsA->dpy3, passVarsA->win3); #endif
0 comments:
Post a Comment