Beispiel #1
0
void sum_rows(
	matrix_expression<M, Device> const & A, 
	vector_expression<V, Device>& b,
	typename V::value_type alpha,
	unknown_orientation,
	Tag1, Tag2
){
	sum_rows(A,b,alpha,row_major(), Tag1(), Tag2());
}
Beispiel #2
0
//--------------------------------------------------------------
void ofApp::setup(){
  ofSetFrameRate(60.0f);
  ofHideCursor();

  // 读取字体文件
  bool bLoad = Font.loadFont("fonts/vag.ttf",24);

  // 加载音效资源
  ofSoundPlayer P0;
  bool bP0 = P0.loadSound("sounds/tap1.mp3");
  P0.setMultiPlay(true);
  P0.setLoop(false);
  Sounds["ChangeSize"] = P0;
  ofSoundPlayer P1;
  bool bP1 = P1.loadSound("sounds/mario_mainTheme.mp3");
  P1.setLoop(true);
  P1.setVolume(0.3f);
  Sounds["Background"] = P1;	
  P1.play();
  ofSoundPlayer P2;
  bool bP2 = P2.loadSound("sounds/mario_jump.mp3");
  P2.setLoop(false);
  P2.setVolume(1.0f);
  P2.setSpeed(1.25f);
  Sounds["Jump"] = P2;
  ofSoundPlayer P3;
  bool bP3 = P3.loadSound("sounds/mario_fail.mp3");
  P3.setLoop(false);
  P3.setVolume(1.0f);
  P3.setSpeed(1.0f);
  Sounds["Fail"] = P3;
  ofSoundPlayer P4;
  bool bP4 = P4.loadSound("sounds/mario_stepOnEnemy.mp3");
  P4.setLoop(false);
  P4.setVolume(1.0f);
  P4.setSpeed(1.0f);
  P4.setMultiPlay(true);
  Sounds["Eat"] = P4;
  ofSoundPlayer P5;
  bool bP5 = P5.loadSound("sounds/mario_coin.mp3");
  P5.setLoop(false);
  P5.setVolume(1.0f);
  P5.setSpeed(1.0f);
  P5.setMultiPlay(true);
  Sounds["Coin"] = P5;
  ofSoundPlayer P6;
  bool bP6 = P6.loadSound("sounds/error.wav");
  P6.setLoop(false);
  P6.setVolume(1.0f);
  P6.setSpeed(1.0f);
  P6.setMultiPlay(true);
  Sounds["Error"] = P6;
  ofSoundPlayer P7;
  bool bP7 = P7.loadSound("sounds/shrink.mp3");
  P7.setLoop(false);
  P7.setVolume(1.0f);
  P7.setSpeed(1.0f);
  P7.setMultiPlay(true);
  Sounds["Beat"] = P7;
  ofSoundPlayer P8;
  bool bP8 = P8.loadSound("sounds/whip.mp3");
  P8.setLoop(false);
  P8.setVolume(1.0f);
  P8.setSpeed(1.0f);
  P8.setMultiPlay(true);
  Sounds["Beat2"] = P8;
  
  // 初始化键鼠状态
  for(int i=0;i<3;i++)
  {
    MouseKeyState[i] = false;
  } 
  MousePos = ofVec2f(0,0);

  bShowDebug.set("ShowDebugInfo",true);//默认显示调试信息
  FPS.set("FPS",0,0,100);

  //记录默认窗口尺寸
  windowSizeX = ofGetWidth();
  windowSizeY = ofGetHeight();

  // 构造玩家
  pPlayer.reset(new DrawGame::CircleSprite(&Font));   

  // 初始化敌人参数
  EnemyBirthrate.set("EnemyBirthRate",1.0f,0.2f,5.0f);
  EnemyGrowthrate.set("EnemyGrowthRate",10.0f,0.0f,50.0f);
  WhiteEnemyRatio.set("WhiteEnemyRatio",0.3f,0.0f,1.0f);

  // 游戏状态
  bGameRunning = true;
  HP.set("HP",2000.0f,0.0f,10000.0f);
  HPMax.set("HPMax",3500.0f,50.0f,10000.0f); 
  

  // 画布
  Canvas.allocate(windowSizeX,windowSizeY,GL_RGBA);
  Canvas.begin();
  ofClear(ofColor::white);
  Canvas.end();

  // 游戏规则参数
  CoinValue.set("CoinValue",20.0f,0.0f,100.0f);
  HPIncSpd.set("HPIncreaseSpeed",3.0f,0.0f,30.0f);
  HPDecSpd.set("HPDecreaseSpeed",1.0f,0.0f,10.0f);
  HPDecJumpA.set("HPDecJumpA",5.0f,0.0f,50.0f);
  HPDecJumpB.set("HPDecJumpB",2.0f,0.0f,20.0f);
  HPEatAmt.set("HPEatAmount",7.0f,0.0f,200.0f);
  HPBeatAmt.set("HPBeatAmount",15.0f,0.0f,500.0f);
  HPBeatAmt2.set("HPBeatAmount",50.0f,0.0f,500.0f);

  // 初始化调试界面
  Params.setName("Settings");    
  Params.add(EnemyBirthrate);
  Params.add(EnemyGrowthrate);
  Params.add(WhiteEnemyRatio);
  Params.add(HP);
  Params.add(HPMax);
  Params.add(CoinValue);
  Params.add(HPIncSpd);
  Params.add(HPDecSpd);
  Params.add(HPDecJumpA);
  Params.add(HPDecJumpB);
  Params.add(HPEatAmt);
  Params.add(HPBeatAmt);
  Params.add(HPBeatAmt2);
  loadSettings();
  
  BtnReset.setup("Reset Game");
  BtnReset.addListener(this,&ofApp::startGame);
  BtnSaveDrawing.setup("Save Drawing");
  BtnSaveDrawing.addListener(this,&ofApp::saveCanvasImage);
  BtnSaveSettings.setup("Save Settings");
  BtnSaveSettings.addListener(this,&ofApp::saveSettings);
  BtnLoadSettings.setup("Load Settings");  
  BtnLoadSettings.addListener(this,&ofApp::loadSettings);
 
  GUI_Debug.setup("Params");
  GUI_Debug.add(&BtnReset);
  GUI_Debug.add(&BtnSaveDrawing);
  GUI_Debug.add(&BtnSaveSettings);
  GUI_Debug.add(&BtnLoadSettings);
  GUI_Debug.add(bShowDebug);
  GUI_Debug.add(FPS);
  GUI_Debug.add(Params);
  GUI_Debug.setPosition(
    ofGetWidth()-GUI_Debug.getWidth(),0);  

  // 游戏界面初始化
  ofVec2f Ctr(ofGetWidth()/2,ofGetHeight()/2);
  Ctr += ofVec2f(0,ofGetWidth()/6);
  ofPtr<DrawGame::GUITextButton> pBtn;
  pBtn.reset(new DrawGame::GUITextButton(
    "GUI_Retry","Retry",120,40,&Font,Ctr));
  pRetryBtn = pBtn;
  ofAddListener(pRetryBtn->GUIEvent,this,&ofApp::GUICallback);
  pRetryBtn->setScale(1.5f); 
  pRetryBtn->setVisible(false);
  pRetryBtn->setActive(false);

  ofPtr<DrawGame::GUIDataSlot> pHB;
  ofRectangle R(5,5,ofGetWidth()-10,30);
  string Tag2("GUI_HP"),Title2("HP");
  ofParameter<float>* ptrHp= &HP;
  //pHB.reset(new ofPtr<DrawGame::GUIDataBar>(
    //ptrHp,Tag2,Title2,R,800.0f,&Font,2.0f));
  ofTrueTypeFont* ft = &Font;
  pHB.reset(new DrawGame::GUIDataSlot(
    HP,HPMax,Tag2,Title2,R,0.1f,&Font,1000.0f,2.0f));  
  pHpBar = pHB;
}