From de766399e2442fbc438123c1c8763e0ae90e6158 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Fri, 20 Apr 2012 03:36:39 +0100 Subject: numerous problems --- gaunt01/src/testApp.cpp | 334 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 263 insertions(+), 71 deletions(-) (limited to 'gaunt01/src/testApp.cpp') diff --git a/gaunt01/src/testApp.cpp b/gaunt01/src/testApp.cpp index 8a8f65d..fe8b28f 100644 --- a/gaunt01/src/testApp.cpp +++ b/gaunt01/src/testApp.cpp @@ -33,16 +33,16 @@ void testApp::setup(){ } accumImg.allocate(640,480); - + bgImg.allocate(640,480); bgImg.setUseTexture(true); - + colorImg.allocate(640,480); - colorImg.setUseTexture(true); + colorImg.setUseTexture(true); grayImage.allocate(640,480); grayBg.allocate(640,480); - + blobsManager.normalizePercentage = 0.7; blobsManager.giveLowestPossibleIDs = false; blobsManager.maxUndetectedTime = 500; @@ -66,11 +66,17 @@ void testApp::setup(){ cam.cacheMatrices(); //stop error messages testpts=new ofVec3f[4]; - + bounds=new ofPlane[4]; - trapDoor=trapdoor(screen2plane(ofVec2f(ofGetWidth(),0)),screen2plane(ofVec2f(ofGetWidth(),ofGetHeight())),ofVec2f(35,35)); - updatePlane(); + //trapDoor=trapdoor(screen2plane(ofVec2f(ofGetWidth(),0)),screen2plane(ofVec2f(ofGetWidth(),ofGetHeight())),35); + trapdoorSize=35; + trapdoorSlotSize=50; + + + trapdoorTime=10.0; //time per trapdoor; + + mode=PLAY; @@ -94,19 +100,29 @@ void testApp::setup(){ billboards[i].setAnchorPercent(0.5,0.5); } scaleFactor=ofVec2f(ofGetWidth()/1280.0f,ofGetHeight()/768.0f); - + gameState=TITLES; - + segTimes[TITLES]=4.0; segTimes[CREDIT]=2.5; segTimes[EXPLAIN]=5.0; segTimes[PLAYING]=60.0; - segTimes[GOTCHA]=2.0; - + segTimes[GOTCHA]=4.0; + gameStart=ofGetElapsedTimef(); - + sounds=new ofSoundPlayer[1]; sounds[0].loadSound("arp5.mp3"); //game start + + + doorsounds=new ofSoundPlayer[4]; + doorsounds[0].loadSound("creeky door short1.wav"); + doorsounds[1].loadSound("creeky door short2.wav"); + doorsounds[2].loadSound("creeky door short3.wav"); + doorsounds[3].loadSound("voice falling down hole.wav"); + + updatePlane(); + } ofVec2f testApp::screen2plane(ofVec2f screenpos){ @@ -137,38 +153,183 @@ bool testApp::rectsCross(ofRectangle rect1,ofRectangle rect2) { return overlap; } +void testApp::makeGround(int doornumber){ + //updates ground and makes texture coords; + /* + ground=ofMesh(); + tess.tessellateToMesh(groundlines,OF_POLY_WINDING_ODD,ground,true); + for (int i=0;i corners=trapdoors[doornumber].getCorners(); + ofVec2f screenCorners[4]; + + for (int i=0;i trapdoors; +// float trapdoorSize; +// float trapdoorSlotSize; +// int numtrapdoorSlots; +//create all trapdoors at once, deactivated. +//shuffle them +//at each timeout, pick the next door to activate (check if within bounds) and rebuild ground with holes +//on update, check all active doors against all players +//when a falling in sequence is over, start again + + trapdoors.clear(); + + l=ofVec2f(ofGetWidth()/2,19*ofGetHeight()/20); + r=projector.castPixel(l.x,l.y); + plane.intersect(r,p); + float closestY=p.rotated(cam_angle,ofVec3f(-1,0,0)).y; + numtrapdoorSlots=closestY/trapdoorSlotSize; + + //get middle position in the slot on the ground visible at front of screen + ofVec3f rp=ofVec3f(ofGetWidth()/2,closestY-(0.5*trapdoorSlotSize),0); + //translate to the screen + ofVec3f sp=cam.worldToScreen(rp.rotated(cam_angle,ofVec3f(1,0,0))); + + printf("front slot: %f,%f to %f,%f,%f\n",rp.x,rp.y,sp.x,sp.y,sp.z); + + //get point at left of this line + //project back on ground + ofVec2f gb=screen2plane(ofVec2f(ofGetWidth()/8,sp.y)); + r=projector.castPixel(sp.x,sp.y); + plane.intersect(r,p); + float range=(((ofGetWidth()/2)-p.x)*2); + + for (int i=0;i corners=trapdoors[0].getCorners(); + ofPolyline pol2; + for (int i=0;i corners=trapDoor.getCorners(); + vector corners=trapdoors[0].getCorners(); ofVec2f screenCorners[4]; for (int i=0;isecond.active=true; } } - if (trapDoor.checkUpdate(players)) { - if (gameState=PLAYING) { - gameState=GOTCHA; - gameStart=ofGetElapsedTimef(); + for (int i=0;itrapdoorTime) { + if (trapdoors.size()>trapdoorCounter+1) { + trapdoorCounter++; + trapdoorTimer=ofGetElapsedTimef(); + } + else updatePlane(); + } + + + //should be in front with holes being recreated for activated trapdoors ofSetHexColor(0xffffff); bindTexture(bgImg); ground.draw(); unbindTexture(bgImg); + + ofSetHexColor(0xffffff); + ofPushMatrix(); + ofRotate(cam_angle,1,0,0); + //trapDoor.draw(); + for (int i=0;i::iterator it; for(int i=0;i