[ Pobierz całość w formacie PDF ]
.bmp , NULL);scoredisp->priority(100);scoredisp->newpos(TIMEPOS, 20);scoredisp->id(10*SCOREDISP);proc = (DRAWPROC) MakeProcInstance((FARPROC) disp_score,GetApplication()->hInstance);scoredisp->drawproc(proc, blockade_frame);scoredisp->active();scoredisp->update();anim->add(scoredisp);continues419 Programming Windows Games with Borland C++Listing 9.18.continued// Remember to release the DCReleaseDC(HWindow, hdc);// Reset cursor to arrowSetCursor(LoadCursor(NULL, IDC_ARROW));ReleaseCapture();}//--------------------------------------------------------------// InfoWindow:: W M L B u t t o n D o w n// Handle button down events in the InfoWindowvoid InfoWindow::WMLButtonDown(RTMessage msg){short x = msg.LP.Lo;short y = msg.LP.Hi;Sprite *s = anim->sprite_at(x, y);if(s != NULL){short type = s->id() / 10;short index = s->id() - 10*type;switch(type){case SIMSPEED: // Simulation speed selectionif(index % 2 == 0){// Set new simulation speed.short speed = 5*index;if(index == 0) speed = 1;set_simspeed(speed);}break;case CONSELECT: // Select contacts to be displayedshort maxsensor =blockade_frame->scenario()->our_ship()->numsensor();if(Scenario::sensor_index move(0,0);break;420 ChapterBLOCKADE A Game of Modern Naval Simulation9case WPNSELECT: // Weapon selectionshort maxweapon =blockade_frame->scenario()->our_ship()->numweapon();if(Scenario::weapon_index move(0,0);break;case HDGPICK: // Move the marker.spr_current = s;spr_current->active();xlast = x;ylast = y;xlo = HDGPOS;xhi = HDGPOS + 96;SetCapture(HWindow);mouse_captured = 1;break;case SPDPICK: // Move the marker.spr_current = s;spr_current->active();xlast = x;ylast = y;xlo = SPDPOS;xhi = blockade_frame->scenario()->our_ship()->max_speed() * PIXPERKT + SPDPOS;SetCapture(HWindow);mouse_captured = 1;break;case ENGAGE: // Engage weapon (only in polar window)if(!blockade_frame->polar_window_visible()){// Clear the status messageLPSTR msgtxt = blockade_frame->status_window()->get_msgbuf(1);short len = sprintf(msgtxt, Engage weapons from Polar window! );blockade_frame->status_window()->set_text(msgtxt, len, 1);break;}continues421 Programming Windows Games with Borland C++Listing 9.18.continuedspr_current = s;xlast = x;ylast = y;xlo = spr_current->xpos();ylo = spr_current->ypos();xhi = xlo + spr_current->width();yhi = ylo + spr_current->height();SetCapture(HWindow);mouse_captured = 1;engbtn->inactive();engbdn->active();anim->set_refresh(1);break;}}}//--------------------------------------------------------------// InfoWindow:: W M M o u s e M o v e// Handle mouse move eventsvoid InfoWindow::WMMouseMove(RTMessage msg){if(!mouse_captured) return;short x = msg.LP.Lo;short y = msg.LP.Hi;if(spr_current->id() == 10*ENGAGE){if(x > xlo && x ylo && y inactive();engbdn->active();engbdn->move(0,0);}else{engbdn->inactive();engbtn->active();engbtn->move(0,0);}return;}// Don t let the marker move out of the specified xlo/xhi areashort xs = spr_current->xpos();short xdel = x - xlast;422 ChapterBLOCKADE A Game of Modern Naval Simulation9if(xs + xdel = xhi) xdel = 0;// Move spritespr_current->move(xdel, 0);xlast = xlast + xdel;// Update the heading or speedif(spr_current->id() == 10*HDGPICK){float hdg = (xlast - HDGPOS) * DEGPERPIX;if(hdg > 180) hdg -= 180;else hdg += 180;blockade_frame->scenario()->our_ship()->heading(hdg);hdgdisp->move(0,0); // Move forces update}if(spr_current->id() == 10*SPDPICK){float spd = (xlast - SPDPOS) * KTPERPIX;blockade_frame->scenario()->our_ship()->speed(spd);spddisp->move(0,0); // Move forces update}}//--------------------------------------------------------------// InfoWindow:: W M L B u t t o n U p// Handle button up eventvoid InfoWindow::WMLButtonUp(RTMessage msg){if(!mouse_captured) return;short x = msg.LP.Lo;short y = msg.LP.Hi;if(spr_current->id() == 10*ENGAGE){if(x > xlo && x ylo && y scenario()->engage_ownship_weapon();}engbdn->inactive();engbtn->active();engbtn->move(0,0);anim->set_refresh(1);continues423 Programming Windows Games with Borland C++Listing 9.18.continued// Deselect the Sprite.and release the mousespr_current = NULL;ReleaseCapture();mouse_captured = 0;return;}// Don t let the marker image move out of the window [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • czarkowski.pev.pl
  •