public override void copy(cCritter pcritter) { /*We need to overload the cCritter copy because if I have * cCritterWallRobot which is a cCritterWall, and it gets split in two * by a replicate call, then I want the new copy to have all the same * shooting behavior as the old one. In general, I should * overload copy for each of my critter child classes, but for now this * one is the most important. The overload does the regular copy, then * looks if the thing being copied is a cCritterWall, and if it is then * it copies the additional fields. */ base.copy(pcritter); if (!(pcritter is cCritterWall)) { return; //You're done if pcritter isn't a cCritterWall*. } cCritterWall pcritterwall = (cCritterWall)(pcritter); /* I know it is a cCritterWall at this point, but I need * to do a cast, so the compiler will let me * access cCritterWall methods and fields. */ cRealBox3 r = new cRealBox3(); r.copy(pcritterwall.Skeleton); Skeleton = r; _defaultfillcolor = pcritterwall._defaultfillcolor; }
public cSpriteTextureBox(cRealBox3 pskeleton, int resourceID, int xtilecount ) { _pskeleton = new cRealBox3( pskeleton.LoCorner, pskeleton.HiCorner); _initialize(); setAllSidesTexture( resourceID, xtilecount ); }
public cCritterWall(cVector3 enda, cVector3 endb) : base(null) { _pskeleton = null; _defaultfillcolor = WALLFILLCOLOR; initialize(enda, endb, THICKNESS, WALLPRISMDZ, null); }
public cCritterWall(cVector3 enda, cVector3 endb, float thickness, cGame pownergame) : base(pownergame) { _pskeleton = null; _defaultfillcolor = WALLFILLCOLOR; initialize(enda, endb, thickness, WALLPRISMDZ, pownergame); }
/// <summary> /// Sets a default SkyBox, which is a box aligned with the border of the world. The SkyBox is needed /// so that you can set the walls, ceiling or floor to different colors using setSideSolidColor or to /// different textures using setSideTexture. You use these functions on the SkyBox. /// </summary> public virtual void fixSkyBox() { cRealBox3 skeleton = _border; if (skeleton.ZSize < 0.5f) { skeleton.setZRange(cGame.BACKGROUNDOFFSET, 1.0f); /* Move LOZ down to * avoid z-fighting with sprites in the xy plane. MOve HIZ up to make * walls around the world.*/ } setSkyBox(skeleton.LoCorner, skeleton.HiCorner, -1); //Make the walls four shades. SkyBox.setSideSolidColor(cRealBox3.LOX, Color.FromArgb(180, 30, 200)); SkyBox.setSideSolidColor(cRealBox3.HIX, Color.FromArgb(30, 10, 180)); SkyBox.setSideSolidColor(cRealBox3.LOY, Color.FromArgb(255, 200, 200)); SkyBox.setSideSolidColor(cRealBox3.HIY, Color.FromArgb(10, 255, 200)); //Make floor be almost black SkyBox.setSideSolidColor(cRealBox3.LOZ, Color.FromArgb(15, 15, 15)); //Make the top side transparent SkyBox.setSideInvisible(cRealBox3.HIZ); /* Means make it gray and * don't draw it. */ SkyBox.Edged = false; //Turns off edges for the filled faces. SkyBox.LineColor = Color.DarkGray; SkyBox.LineWidthWeight = cColorStyle.LW_IGNORELINEWIDTHWEIGHT; SkyBox.LineWidth = 1; }
public override int clamp(cRealBox3 border) { /* We don't change _pskeleton as it has the geometric info. We * just change _position. */ if (_baseAccessControl == 1) { return(base.clamp(border)); } cRealBox3 effectivebox = border; cVector3 oldcorner; cVector3 newcorner = new cVector3(); int outcode = 0; int totaloutcode = 0; for (int i = 0; i < 8; i++) //Step through the wall's corners { oldcorner = _pskeleton.corner(i) + _position; newcorner.copy(oldcorner); outcode = effectivebox.clamp(newcorner); if (outcode != cRealBox3.BOX_INSIDE) //corner was moved { _position += newcorner - oldcorner; /* As long at the wall is small enough to * fit inside the border, the successive * corrections won't cancel each other out. */ totaloutcode |= outcode; } } _wrapposition1.copy(_position); _wrapposition2.copy(_position); _wrapposition3.copy(_position); /* So it won't think it wrapped. */ return(outcode); }
public cRealBox3 border() { cRealBox3 b = new cRealBox3(); b.copy(_pgame.Border); return(b); }
public cRealBox3 border() { cRealBox3 bord = new cRealBox3(); bord.copy(pgame().Border); return(bord); }
public cSpriteTextureBox( cVector3 locorner, cVector3 hicorner, int resourceID = -1 ) { _pskeleton = new cRealBox3( locorner, hicorner ); _initialize(); if ( resourceID != -1 ) setAllSidesTexture( resourceID, 1 ); }
} /* Don't bother doing anything as this is only * used in copy and serialize. */ public cCritterViewer(ACView pview) { _pownerview = pview; _proportionofworldtoshow = PROPORTIONOFWORLDTOSHOW; _aspect = (4.0f / 3.0f); //Start with standard screen aspect. _fieldofviewangle = STARTFIELDOFVIEWANGLE; _trackplayer = false; /* Depending on the game, you might want to start with either FALSE * or TRUE for _trackplayer. In general the place where your game can make adjustments * to the critterviewer is in the cGame.initializeView method. */ _perspective = false; //Will be reset by setViewer, _foveaproportion = FOVEAPROPORTION; _movebox = new cRealBox3(Game.Border.Center, MOVEBOXTOGAMEBORDERRATIO * Game.Border.MaxSize); /* Put the * viewer in a cube (or square in the 2D case) whose edge is a multiple * of the world's largest dimension. */ _dragbox = new cRealBox3(); _dragbox.copy(_movebox); _wrapflag = cCritter.CLAMP; /* I had WRAP, which was a big mistake, * as sometimes I'd back way up above the world and then suddenly be * under it. */ //We will set _znear and _zfar in the cCritterViewer.setZClipPlanes call. setViewpoint(); /* Default viewpoint is up the z axis looking down at the origin. * This call also initializes some of the remaining vairables. */ /* Don't bother to set a listener, as the various cGame.initializeView will do * that indirectly via a setGraphicsClass call, and then possibly with a * direct call to change the listener again. */ Density = 0.0f; //so you don't move things you bump into. AbsorberFlag = true; //So you don't bounce when you bump things. Sprite.Radius = 0.1f; /* Although this guy is invisible, it seems to be * good to have a radius of 1.0 for use in the COLLIDEVIEWER code. */ _lastgoodplayeroffset = new cVector3(); }
public cCritterWall() : base(null) { _pskeleton = null; _defaultfillcolor = WALLFILLCOLOR; initialize(new cVector3(-0.5f, 0.0f), new cVector3(0.0f, 0.5f), THICKNESS, WALLPRISMDZ, null); }
public void setHeight(float newheight = 0.0f) { Skeleton = new cRealBox3(Length, Thickness, newheight); Sprite.PrismDz = newheight; Sprite.SpriteAttitude = cMatrix3.translation(new cVector3(0.0f, 0.0f, -Height / 2.0f)); /* This corrects for the fact that we always draw the ppolygon with its bottom face in the xy plane and its top in the plane z = height. We shift it down so it's drawn to match the skeleton positon. */ }
/* This * method unprojects to the near and far possiblities for the pixel position, draws the "sight * line" between the two (I call it a "sight line" because these are all positions that * get projected into the same pixel), and finds the point where the line crosses the plane. * This method is useful if you know what plane you are trying to pick in; often, for instance, * you want to pick a point in the plane of the player. It uses the virtual pixelToSightLine * method. */ public CRect realBoxToCRect(cRealBox3 realbox) { int intlox, intloy, inthix, inthiy; float zbuff; //dummy to ignore vectorToPixel(new cVector3(realbox.Lox, realbox.Loy), out intlox, out intloy, out zbuff); vectorToPixel(new cVector3(realbox.Hix, realbox.Hiy), out inthix, out inthiy, out zbuff); return(new CRect(intlox, inthiy, inthix, intloy)); /* The CRect constructor expects * args in the left, top, right, bottom order. */ }
//Mutators public void setEndsThicknessHeight(cVector3 enda, cVector3 endb, float thickness = THICKNESS, float height = WALLPRISMDZ) { _position = (enda + endb) * 0.5f; _wrapposition1.copy(_position); _wrapposition2.copy(_position); _wrapposition3.copy(_position); /* This line is important, as otherwise the * cCritter.draw will thing this thing was wrapped, * and it'll get drawn in two places. */ _tangent = endb - enda; float length = _tangent.Magnitude; _tangent.normalize(); _oldtangent.copy(_tangent); _normal = _tangent.defaultNormal(); /* We orient so that * the normal is oriented to the tangent as the "y-axis" * is to the the "x-axis".*/ _binormal = _tangent.mult(_normal); _attitude = new cMatrix3(_tangent, _normal, _binormal, _position); Skeleton = new cRealBox3(length, thickness, height); Speed = 0.0f; /* Also sets _velocity to ZEROVECTOR, * but doesn't wipe out _direction. */ /*In looking at these settings, think of the wall as aligned horizontally with endb - enda pointing to the right and the normal pointing into the screen*/ cShape ppolygon = new cShape(4); ppolygon.Edged = true; ppolygon.FillColor = Color.Gray; ppolygon.LineWidthWeight = cColorStyle.LW_IGNORELINEWIDTHWEIGHT; ppolygon.LineWidth = 1; //Means draw a one-pixel edge line. ppolygon.setVertex(0, new cVector3(0.5f * length, 0.5f * thickness)); ppolygon.setVertex(1, new cVector3(-0.5f * length, 0.5f * thickness)); ppolygon.setVertex(2, new cVector3(-0.5f * length, -0.5f * thickness)); ppolygon.setVertex(3, new cVector3(0.5f * length, -0.5f * thickness)); ppolygon.fixCenterAndRadius(); /* Use this call after a bunch * of setVertex if points are just where you want. */ ppolygon.SpriteAttitude = cMatrix3.translation(new cVector3(0.0f, 0.0f, -height / 2.0f)); /* This corrects for the fact that we always draw the ppolygon with its * bottom face in the xy plane and its top in the plane z = height. We * shift it down so it's drawn to match the skeleton positon. */ Sprite = ppolygon; /* Also sets cSprite._prismdz to * cCritter._defaultprismdz, which we set to * CritterWall.WALLPRISMDZ in our cCritterWall * constructor. */ }
//setRoom1 creates a new room when the player runs through the previous door public void setRoom1( ) { //remove critters and wall Biota.purgeCritters("cCritterWall"); Biota.purgeCritters("cCritter3Dcharacter"); setBorder(64.0f, 16.0f, 64.0f); // size of the world //create new room 'shell' cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); //set textures and graphics SkyBox.setSideTexture(cRealBox3.HIZ, BitmapRes.Wall3); //Make the near HIZ transparent SkyBox.setSideTexture(cRealBox3.LOZ, BitmapRes.Wall3); //Far wall SkyBox.setSideTexture(cRealBox3.LOX, BitmapRes.Wall3); //left wall SkyBox.setSideTexture(cRealBox3.HIX, BitmapRes.Wall3); //right wall SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Concrete); //floor SkyBox.setSideTexture(cRealBox3.HIY, BitmapRes.Concrete); //ceiling //set number of critters to be created. Adjust numbers for increasing difficulty between rooms _seedcount = 7; WrapFlag = cCritter.BOUNCE; setPlayer(new cCritter3DPlayer(this)); _ptreasure = new cCritterTreasure(this); //create a door at a new position in the room cCritterDoor pdwall = new cCritterDoor( new cVector3(_border.Lox, _border.Loy, _border.Midz), new cVector3(_border.Lox, _border.Midy - 3, _border.Midz), 0.1f, 2, this); cSpriteTextureBox pspritedoor = new cSpriteTextureBox(pdwall.Skeleton, BitmapRes.Door); pdwall.Sprite = pspritedoor; //move player to new position in next room Player.moveTo(new cVector3(0.0f, -10.0f, 32.0f)); //set collision flag and reset age of new room wentThrough = true; startNewRoom = Age; }
public void setTestRoom() { Biota.purgeCritters("cCritterWall"); Biota.purgeCritters("cCritter3Dcharacter"); setBorder(50.0f, 20.0f, 100.0f); cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); SkyBox.setSideTexture(cRealBox3.BOX_HIX, BitmapRes.Wood2); SkyBox.setSideTexture(cRealBox3.BOX_LOX, BitmapRes.Graphics2); SkyBox.setSideTexture(cRealBox3.BOX_HIY, BitmapRes.Sky); SkyBox.setSideTexture(cRealBox3.BOX_LOY, BitmapRes.Metal); SkyBox.setSideTexture(cRealBox3.BOX_HIZ, BitmapRes.Wall1); SkyBox.setSideTexture(cRealBox3.BOX_LOZ, BitmapRes.Graphics3); _seedcount = 0; Player.setMoveBox(new cRealBox3(50.0f, 20.0f, 100.0f)); }
public void setRoom3() { Biota.purgeCritters("cCritterWall"); Biota.purgeCritters("cCritter3Dcharacter"); Biota.purgeCritters("cCritterBoss"); setBorder(50.0f, 20.0f, 50.0f); cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); SkyBox.setAllSidesTexture(BitmapRes.Graphics3, 2); SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Concrete); SkyBox.setSideSolidColor(cRealBox3.HIY, Color.Blue); _seedcount = 0; Player.setMoveBox(new cRealBox3(50.0f, 20.0f, 50.0f)); wentThrough = true; startNewRoom = Age; cCritterDoor pdwall = new cCritterDoor( new cVector3(_border.Midx, _border.Loy, _border.Loz), new cVector3(_border.Midx, _border.Midy - 3, _border.Loz), 2.0f, 2, this); cSpriteTextureBox pspritedoor = new cSpriteTextureBox(pdwall.Skeleton, BitmapRes.Door); pdwall.Sprite = pspritedoor; float height = 0.1f * _border.YSize; float ycenter = -_border.YRadius + height / 2.0f; float wallthickness = cGame3D.WALLTHICKNESS + 1.0f; cCritterSlideWall pwall = new cCritterSlideWall(new cVector3(_border.Midx, ycenter - 10, _border.Midz + 10), new cVector3(_border.Hix + 50, ycenter - 10, _border.Midz + 10), height, wallthickness, this, cCritterSlideWall.TYPE.HARMFUL, new cVector3(0.0f, -0.05f, 0.0f), false, 200); cSpriteTextureBox pspritebox = new cSpriteTextureBox(pwall.Skeleton, BitmapRes.Wood2, 16); pwall.Sprite = pspritebox; seedCritters(); _ptreasure = new cCritterMedpack(this, new cVector3(_border.Midx, _border.Midy - 2.0f, _border.Loz - 1.5f * cGame3D.TREASURERADIUS)); cCritterBossDragonKnight boss = new cCritterBossDragonKnight(this, new cVector3(_border.Midx, _border.Loy, _border.Midz - 5), new DragonBullet(1.0f)); }
public cGame3D() { doorcollision = false; _menuflags &= ~cGame.MENU_BOUNCEWRAP; _menuflags |= cGame.MENU_HOPPER; //Turn on hopper listener option. _spritetype = cGame.ST_MESHSKIN; setBorder(64.0f, 16.0f, 64.0f); // size of the world cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); /* In this world the coordinates are screwed up to match the screwed up * listener that I use. I should fix the listener and the coords. * Meanwhile... * I am flying into the screen from HIZ towards LOZ, and * LOX below and HIX above and * LOY on the right and HIY on the left. */ SkyBox.setSideTexture(cRealBox3.HIZ, BitmapRes.Wall3); //Make the near HIZ transparent SkyBox.setSideTexture(cRealBox3.LOZ, BitmapRes.Wall3); //Far wall SkyBox.setSideTexture(cRealBox3.LOX, BitmapRes.Wall3); //left wall SkyBox.setSideTexture(cRealBox3.HIX, BitmapRes.Wall3); //right wall SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Concrete); //floor SkyBox.setSideTexture(cRealBox3.HIY, BitmapRes.Concrete); //ceiling WrapFlag = cCritter.BOUNCE; _seedcount = 7; setPlayer(new cCritter3DPlayer(this)); _ptreasure = new cCritterTreasure(this); cCritterDoor pdwall = new cCritterDoor( new cVector3(_border.Lox, _border.Loy, _border.Midz), new cVector3(_border.Lox, _border.Midy - 3, _border.Midz), 0.1f, 2, this); cSpriteTextureBox pspritedoor = new cSpriteTextureBox(pdwall.Skeleton, BitmapRes.Door); pdwall.Sprite = pspritedoor; }
public void setRoom1( ) { Biota.purgeCritters <cCritterWall>(); Biota.purgeCritters <cCritter3Dcharacter>(); Biota.purgeCritters <cCritterShape>(); setBorder(10.0f, 15.0f, 10.0f); cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); SkyBox.setAllSidesTexture(BitmapRes.Graphics1, 2); SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Concrete); SkyBox.setSideSolidColor(cRealBox3.HIY, Color.Blue); _seedcount = 0;;; Player.setMoveBox(new cRealBox3(10.0f, 15.0f, 10.0f)); float zpos = 0.0f; /* Point on the z axis where we set down the wall. 0 would be center, * halfway down the hall, but we can offset it if we like. */ float height = 0.1f * _border.YSize; float ycenter = -_border.YRadius + height / 2.0f; float wallthickness = cGame3D.WALLTHICKNESS; cCritterWall pwall = new cCritterWall( new cVector3(_border.Midx + 2.0f, ycenter, zpos), new cVector3(_border.Hix, ycenter, zpos), height, //thickness param for wall's dy which goes perpendicular to the //baseline established by the frist two args, up the screen wallthickness, //height argument for this wall's dz goes into the screen this); cSpriteTextureBox pspritebox = new cSpriteTextureBox(pwall.Skeleton, BitmapRes.Wall3, 16); //Sets all sides /* We'll tile our sprites three times along the long sides, and on the * short ends, we'll only tile them once, so we reset these two. */ pwall.Sprite = pspritebox; wentThrough = true; startNewRoom = Age; }
//Constructors public cGame() { _seedcount = COUNTSTART; _gameover = false; _maxscore = MAXSCORE; _scorecorrection = 0; _wrapflag = cCritter.WRAP; _bDragging = false; _pfocus = null; _pplayer = null; _border = new cRealBox3(cGame.WORLDWIDTH, cGame.WORLDHEIGHT); //Default no zsize, computes faster. _pskybox = null; _cursorpos = new cVector3(0.0f, 0.0f); _level = 1; _spritetype = cGame.ST_SPRITETYPENOTUSED; _menuflags = (cGame.MENU_ALL & ~cGame.MENU_AUTOPLAY & ~cGame.MENU_HOPPER); _newgame = true; //Fix the static readonlys /* Reset the various static readonlys that may have been set to different values by previously * running some other game. */ cCritter.Maxspeed = cGame.CRITTERMAXSPEED; cCritter.MinRadius = cGame.CRITTERMINRADIUS; cCritter.MaxRadius = cGame.CRITTERMAXRADIUS; cCritter.BulletRadius = cGame.BULLETRADIUS; //Allocate the pointer variables. _pbiota = new cBiota(this); _pcollider = new cCollider(); _pcontroller = Framework.Keydev; _plightingmodel = new cLightingModel(true); //Default lighting model enables lights. setBorder(cGame.WORLDWIDTH, cGame.WORLDHEIGHT, 0.0f); // setBorder initializes _pskybox as well //Set the player, we want to make sure a game always has a player setPlayer(new cCritterPlayer(this)); //Sets _pplayer AND adds it to _pbiota. }
public cGame(cBiota pbiota) { _pcollider = new cCollider(); _pcontroller = Framework.Keydev; _pbiota = pbiota; _pbiota.setGame(this); _pfocus = new cCritter(); _border = new cRealBox3(); _pskybox = new cSpriteTextureBox(); _plightingmodel = new cLightingModel(); _cursorpos = new cVector3(); //Deleting the _pbiota killed off your _pplayer, so you need to get a new one. if (_pbiota.Size > 0) // use the first member of pbiota if there is one. { _pplayer = _pbiota.GetAt(0); } else //otherwise make a dummy. { _pplayer = new cCritter(); cCritter pdummyplayer = new cCritter(); setPlayer(pdummyplayer); } }
public cSpriteTextureBox( cVector3 locorner ) { _pskeleton = new cRealBox3( locorner, new cVector3( 1.0f, 1.0f, 1.0f ) ); _initialize(); }
/* Uses _foveaproportion which lies between 0.0 and 1.0. We say something is visible if it * appears on the inner _foveaproportion central box of the viewer's image screen, * which is what you see in the view window. */ //overloads //Use _pownerview to get the CpopDoc and get the cGame from that. public override void update(ACView pactiveview, float dt) { base.update(pactiveview, dt); ZClipPlanes = Game.Border.outerBox(cSprite.MAXPRISMDZ); if (_trackplayer && !((Listener != null) && Listener.RuntimeClass == "cListenerViewerRide")) /* The meaning of the visibleplayer() condition is that it doesn't make sense * to track the player if it's not an onscreen player. The reason for the * listener condition is that you don't want to stare at the player when * riding it. */ /* I should explain that the goal here is to not bother turning when the player * is moving around in the middle of the veiw area, and only to turn when he's near * the edge, but to have the turning when he's near the edge be smoooth. * The use of the 0.85 foveaproportion parameter means that you react before the player * gets right up to the edge. The reactproportion factor in lookAtProportional and * moveToProportional is delicate and should probably be adjusted according to the * current player speed relative to the visible window. The issue is that (a) if I make * reactproportion too small, like 0.01, then the viewer doesn't turn (or move) fast * enough to catch up with the player and keep it in view, but (b) if I make reactpropotion * too big, like 0.5, then the turning or moving is such an abrupt jump that the visual * effect is jerky. The goal is to do turns that are just big enough to not look jerky, * but to have the turns be big enough so you aren't turning more often than you really * have to. Another downside of a toosmall reactproportion, by the way, is that it can be * computationally expensive to react. * The way we finally solved this is to do a while loop to turn just * far enough, moving just a little at a time so as to not overshoot. */ { if (isVisible(Game.Player.Position)) // Uses _foveaproportion { _lastgoodplayeroffset = Position - Game.Player.Position; } /*I'm not sure about constantly changing _lastgoodplayeroffset. On the * one hand, the offset I set in setViewpoint was a standard good one, so why * not keep it. On the other, if I want to move my viewpoint around then I * do want to be able to get a new value here. It seems ok for now.*/ else //not visible, so do somehting about it. { int loopcount = 0; /* Never have a while loop without a loopcount * to make sure you don't spin inside the while forever under some * unexpected situation like at startup. */ cVector3 lookat = Game.Player.Position; cVector3 viewerpos = lookat + _lastgoodplayeroffset; if (Game.worldShape() == cGame.SHAPE_XSCROLLER) { lookat = new cVector3(Game.Player.Position.X, Game.Border.Midy, Game.Player.Position.Z); viewerpos = new cVector3(lookat.X, Position.Y, Position.Z); } if (Game.worldShape() == cGame.SHAPE_YSCROLLER) { lookat = new cVector3(Game.Border.Midx, Game.Player.Position.Y, Game.Player.Position.Z); viewerpos = new cVector3(Position.X, lookat.Y, Position.Z); } if (_perspective) { while (!isVisible(lookat) && loopcount < 100) // Uses _foveaproportion { moveToProportional(viewerpos, cCritterViewer.TURNPROPORTION); loopcount++; } } else //ortho case { while (!isVisible(lookat) && loopcount < 100) // Uses _foveaproportion { moveToProportional(lookat + Game.Player.Binormal * 10.0f, cCritterViewer.TURNPROPORTION); loopcount++; } } } } //Possibly ride the player. if (Listener is cListenerViewerRide) { cCritter pplayer = Game.Player; cVector3 offset = ((cListenerViewerRide)Listener).Offset; moveTo(pplayer.Position + pplayer.AttitudeTangent * offset.X + pplayer.AttitudeNormal * offset.Y + pplayer.AttitudeBinormal * offset.Z); cRealBox3 skeleton = pplayer.MoveBox; if (skeleton.ZSize < 0.5f) { skeleton.setZRange(0.0f, offset.Z); } if (skeleton.YSize < 0.5f) { skeleton.setYRange(0.0f, offset.Z); } skeleton.clamp(_position); for (int i = 0; i < Game.Biota.count(); i++) { cCritter pother = Game.Biota.GetAt(i); if (pother is cCritterWall) { pother.collide(this); } } /* colliding with the wall may have twisted the viwer's orientation, * so align it once again. */ Attitude = pplayer.Attitude; /* Before we call lookAt, * make sure your attitude matches the player. For one thing, * you may have gotten twisted around in the COLLIDEVIEWER code. */ lookAt(pplayer.Position + pplayer.AttitudeTangent * cListenerViewerRide.PLAYERLOOKAHEAD * pplayer.Radius); /* This has the effect that as offset gets large you change your * looking direction see right in front of the player. The multiplier * cCritterViewer.PLAYERLOOKAHEAD is tweaked to work well * with the default cCritterViewer.OFFSET. */ } }
/// <summary> /// Used to set the SkyBox, a box set around the player and critters, which allows colors and textures to /// be added to the walls, ceiling and floor (on the SkyBox object, use setSideSolidColor or setSideTexture, /// for example). The SkyBox is set by passing in a cRealBox3 object as the first parameter. /// </summary> /// <param name="pskeleton">The cRealBox3 object to use as the SkyBox.</param> /// <param name="resourceID">You can use this to set textures to all sides (individual sides can be changed later). /// Use BitmapRest to select the texture to use. This paramater is set to -1 by default, which means just /// use plain rectangles initially for the faces.</param> public void setSkyBox(cRealBox3 pskeleton, int resourceID = -1) { setSkyBox(pskeleton.LoCorner, pskeleton.HiCorner, resourceID); }
public virtual void setRealBox(cRealBox3 border) { }
public cGame3D() { doorcollision = false; _menuflags &= ~cGame.MENU_BOUNCEWRAP; _menuflags |= cGame.MENU_HOPPER; //Turn on hopper listener option. _spritetype = cGame.ST_MESHSKIN; setBorder(64.0f, 16.0f, 64.0f); // size of the world cRealBox3 skeleton = new cRealBox3(); skeleton.copy(_border); setSkyBox(skeleton); /* In this world the coordinates are screwed up to match the screwed up * listener that I use. I should fix the listener and the coords. * Meanwhile... * I am flying into the screen from HIZ towards LOZ, and * LOX below and HIX above and * LOY on the right and HIY on the left. */ SkyBox.setSideSolidColor(cRealBox3.HIZ, Color.Aqua); //Make the near HIZ transparent SkyBox.setSideSolidColor(cRealBox3.LOZ, Color.Aqua); //Far wall SkyBox.setSideSolidColor(cRealBox3.LOX, Color.DarkOrchid); //left wall SkyBox.setSideTexture(cRealBox3.HIX, BitmapRes.Wall2, 2); //right wall SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Graphics3); //floor SkyBox.setSideTexture(cRealBox3.HIY, BitmapRes.Sky); //ceiling WrapFlag = cCritter.BOUNCE; _seedcount = 7; setPlayer(new cCritter3DPlayer(this)); _ptreasure = new cCritterTreasure(this); shape = new cCritterShape(this); shape.Sprite = new cSphere(3, Color.DarkBlue); shape.moveTo(new cVector3(Border.Midx, Border.Hiy, Border.Midz)); /* In this world the x and y go left and up respectively, while z comes out of the screen. * A wall views its "thickness" as in the y direction, which is up here, and its * "height" as in the z direction, which is into the screen. */ //First draw a wall with dy height resting on the bottom of the world. float zpos = 0.0f; /* Point on the z axis where we set down the wall. 0 would be center, * halfway down the hall, but we can offset it if we like. */ float height = 0.1f * _border.YSize; float ycenter = -_border.YRadius + height / 2.0f; float wallthickness = cGame3D.WALLTHICKNESS; cCritterWall pwall = new cCritterWall( new cVector3(_border.Midx + 2.0f, ycenter, zpos), new cVector3(_border.Hix, ycenter, zpos), height, //thickness param for wall's dy which goes perpendicular to the //baseline established by the frist two args, up the screen wallthickness, //height argument for this wall's dz goes into the screen this); cSpriteTextureBox pspritebox = new cSpriteTextureBox(pwall.Skeleton, BitmapRes.Wall3, 16); //Sets all sides /* We'll tile our sprites three times along the long sides, and on the * short ends, we'll only tile them once, so we reset these two. */ pwall.Sprite = pspritebox; //Then draw a ramp to the top of the wall. Scoot it over against the right wall. float planckwidth = 0.75f * height; pwall = new cCritterWall( new cVector3(_border.Hix - planckwidth / 2.0f, _border.Loy, _border.Hiz - 2.0f), new cVector3(_border.Hix - planckwidth / 2.0f, _border.Loy + height, zpos), planckwidth, //thickness param for wall's dy which is perpenedicualr to the baseline, //which goes into the screen, so thickness goes to the right wallthickness, //_border.zradius(), //height argument for wall's dz which goes into the screen this); cSpriteTextureBox stb = new cSpriteTextureBox(pwall.Skeleton, BitmapRes.Wood2, 2); pwall.Sprite = stb; cCritterDoor pdwall = new cCritterDoor( new cVector3(_border.Lox, _border.Loy, _border.Midz), new cVector3(_border.Lox, _border.Midy - 3, _border.Midz), 0.1f, 2, this); cSpriteTextureBox pspritedoor = new cSpriteTextureBox(pdwall.Skeleton, BitmapRes.Door); pdwall.Sprite = pspritedoor; }
} /* In sophisticated graphics * implementations, if _activeDisplayListIDIsReady is FALSE, we close the list and * add it to the _map_SpriteIDToDisplayListID. And then in any case we call * a graphics method to call the list. */ //Other graphics overloads public virtual void setClipRegion(cRealBox3 pclipbox) { }
public cSpriteTextureBox( ) { _pskeleton = new cRealBox3( new cVector3( -1.0f, -1.0f, -1.0f ), new cVector3( 1.0f, 1.0f, 1.0f ) ); _initialize(); }
public cSpriteTextureBox(cRealBox3 pskeleton, Color color) { _pskeleton = new cRealBox3(pskeleton.LoCorner, pskeleton.HiCorner); _initialize(); setSideColors(color); }
public cSpriteTextureBox(cVector3 locorner, cVector3 hicorner, Color color) { _pskeleton = new cRealBox3(locorner, hicorner); _initialize(); setSideColors(color); }