# Jacobs, Lara, and Jeffery # representation of the PLEASE Lab #*******all textures are updated, but unicon************************************************* #*****is not showing them, using wall texture for everything after a certain point************ #Please 9 includes a few new rooms to wander around in with new textures #And the correct doors open when you are close enough to open it link cve #Room(name,x,y,z,w,h,d,wall texture) procedure make_cooridoor() cooridoor := Room("cooridoor", -54, 0, 3, 89, 5, 3, "wall512.gif") put(Rooms, cooridoor) return cooridoor end procedure make_SH167(cooridoor) SH167 := Room("SH 167", -5, 0, 0, 10, 5, 6) SH167.floor := Wall("LightFloor512.gif",-5,0,0, -5,0,-6, 5,0,-6, 5,0,0) d := Door(3, 0, 0) SH167.add_door(d) cooridoor.add_door(d) # PILLAR -- should redo as a single (cube) object pillar := Box() pillar.mkwall(4,0,-6,4,5,-6, 4,5,-5.5,4,0,-5.5) pillar.mkwall(4,0,-5.5,3.5,0,-5.5,3.5,5,-5.5,4,5,-5.5) pillar.mkwall(3.5,0,-5.5,3.5,5,-5.5,3.5,5,-6,3.5,0,-6) SH167.add_obstacle(pillar) pleasewindow := Wall("blinds2.gif", -5,5,-5.9,5,5,-5.9,5,1.5,-5.9,-5,1.5,-5.9) SH167.add_decoration(pleasewindow) whiteboard := Wall("whiteboardray.gif", -4.95,1.5,-.5,-4.95,4,-.5,-4.95,4,-5.5,-4.95,1.5,-5.5) SH167.add_decoration(whiteboard) #light light := Wall("Light.gif", -.5,4.9,-5,-.5,4.9,-1,.5,4.9,-1,.5,4.9,-5) SH167.add_decoration(light) #poster poster := Wall("poster.gif", -2,2,-.1,-2,3,-.1,0,3,-.1,0,2,-.1) SH167.add_decoration(poster) #fake "default?" door1 door1poster := Wall("wooddoor.gif", -2,0,-.1,-2,3.5,-.1,-3.5,3.5,-.1,-3.5,0,-.1) SH167.add_decoration(door1poster) #fake "sh167" door2 door2poster := Wall("Doortest.gif", -3.5,0,-.1,-3.5,3.5,-.1,-5,3.5,-.1,-5,0,-.1) SH167.add_decoration(door2poster) put(Rooms, SH167) return SH167 end # #Begin room 168 # procedure make_SH168(cooridoor) SH168 := Room("SH 168", 5, 0, 0, 4, 5, 6) SH168.floor := Wall("LightFloor512.gif",5,0,0, 5,0,-6, 9,0,-6, 9,0,0) d := Door(5.5, 0, 0) SH168.add_door(d) cooridoor.add_door(d) put(Rooms, SH168) return SH168 end #13 new rooms=====add pillars later from my(brandon's)map================ # #Begin room 154 # procedure make_SH154(cooridoor) SH154 := Room("SH 154", 50, 0, 0, 7.5, 5, 6) SH154.floor := Wall("LightFloor512.gif",-50,0,0, -50,0,-6, -42.5,0,-6, -42.5,0,0) d := Door(-44.5, 0, 0) SH154.add_door(d) cooridoor.add_door(d) put(Rooms, SH154) return SH154 end # #Begin room 155 # procedure make_SH155(cooridoor) SH155 := Room("SH 155", -42.5, 0, 0, 7.5, 5, 6) SH155.floor := Wall("LightFloor512.gif",-42.5,0,0, --42.5,0,-6, -35,0,-6, -35,0,0) d := Door(-42, 0, 0) SH155.add_door(d) cooridoor.add_door(d) put(Rooms, SH155) return SH155 end # #Begin room 157 # procedure make_SH157(cooridoor) SH157 := Room("SH 157", -35, 0, 0, 7.5, 5, 6) SH157.floor := Wall("LightFloor512.gif",-35,0,0, -35,0,-6, -27.5,0,-6, -27.5,0,0) d := Door(-29.5, 0, 0) SH157.add_door(d) cooridoor.add_door(d) put(Rooms, SH157) return SH157 end # #Begin room 161 # procedure make_SH161(cooridoor) SH161 := Room("SH 161", -27.5, 0, 0, 7.5, 5, 6) SH161.floor := Wall("LightFloor512.gif",-27.5,0,0, -27.5,0,-6, -20,0,-6, -20,0,0) d := Door(-27, 0, 0) SH161.add_door(d) cooridoor.add_door(d) put(Rooms, SH161) return SH161 end # #Begin room 163 # procedure make_SH163(cooridoor) SH163 := Room("SH 163", -20, 0, 0, 7.5, 5, 6) SH163.floor := Wall("LightFloor512.gif",-20,0,0, -20,0,-6, -12.5,0,-6, -12.5,0,0) d := Door(-14.5, 0, 0) SH163.add_door(d) cooridoor.add_door(d) put(Rooms, SH163) return SH163 end # #Begin room 165 # procedure make_SH165(cooridoor) SH165 := Room("SH 165", -12.5, 0, 0, 7.5, 5, 6) SH165.floor := Wall("LightFloor512.gif",-12.5,0,0, -12.5,0,-6, -5,0,-6, -5,0,0) d := Door(-12, 0, 0) SH165.add_door(d) cooridoor.add_door(d) put(Rooms, SH165) return SH165 end # #Begin room 170 # procedure make_SH170(cooridoor) SH170 := Room("SH 170", 9, 0, 0, 7.5, 5, 6) SH170.floor := Wall("LightFloor512.gif",9,0,0, 9,0,-6, 16.5,0,-6, 16.5,0,0) d := Door(14.5, 0, 0) SH170.add_door(d) cooridoor.add_door(d) put(Rooms, SH170) return SH170 end # #Begin room 171 # procedure make_SH171(cooridoor) SH171 := Room("SH 171", 16.5, 0, 0, 7.5, 5, 6) SH171.floor := Wall("LightFloor512.gif",16.5,0,0, 16.5,0,-6, 24,0,-6, 24,0,0) d := Door(17, 0, 0) SH171.add_door(d) cooridoor.add_door(d) put(Rooms, SH171) return SH171 end # #Begin room 172 # procedure make_SH172(cooridoor) SH172 := Room("SH 172", 24, 0, 0, 7.5, 5, 6) SH172.floor := Wall("LightFloor512.gif",24,0,0, 24,0,-6, 31.5,0,-6, 31.5,0,0) d := Door(29.5, 0, 0) SH172.add_door(d) cooridoor.add_door(d) put(Rooms, SH172) return SH172 end # #Begin room 173 # procedure make_SH173(cooridoor) SH173 := Room("SH 173", 31.5, 0, 0, 7.5, 5, 6) SH173.floor := Wall("LightFloor512.gif",31.5,0,0, 31.5,0,-6, 39,0,-6, 39,0,0) d := Door(32, 0, 0) SH173.add_door(d) cooridoor.add_door(d) put(Rooms, SH173) return SH173 end # #Begin room 156 # procedure make_SH156(cooridoor) SH156 := Room("SH 156", -40, 0, 9, 7.5, 5, 6) SH156.floor := Wall("LightFloor512.gif",-40,0,9, -40,0,3, -32.5,0,3, -32.5,0,9) d := Door(-39.5, 0, 3) SH156.add_door(d) cooridoor.add_door(d) put(Rooms, SH156) return SH156 end # #Begin room 166 # procedure make_SH166(cooridoor) SH166 := Room("SH 166", -11, 0, 13, 6.5, 5, 10) SH166.floor := Wall("LightFloor512.gif",-11,0,13, -11,0,3, -4.5,0,3, -4.5,0,13) d := Door(-5, 0, 3) SH166.add_door(d) cooridoor.add_door(d) put(Rooms, SH166) return SH166 end # #Begin room 169 # procedure make_SH169(cooridoor) SH169 := Room("SH 169", 12, 0, 18, 16, 5, 15) SH169.floor := Wall("LightFloor512.gif",12,0,18, 12,0,3, 28,0,3, 28,0,18) d := Door(12.5, 0, 3) d2 := Door(25.5,0,3) SH169.add_door(d) SH169.add_door(d2) cooridoor.add_door(d) cooridoor.add_door(d2) put(Rooms, SH169) return SH169 end #end of rooms=============================== #CONTROLS: #up arrow - move foward #down arrow - move backward #left arrow - rotate camera left #right arrow - rotate camera right # ' w ' key - look up # ' s ' key - look down # ' d ' key - toggle door open/closed #if you get lost in space (may happen once in a while) #just restart the program $include "keysyms.icn" #GLOBAL variables global posx, posy, posz # current eye x,y,z position global lookx, looky, lookz # current look x position and so on global cam_lx, cam_lz, cam_angle # eye angles for orientation global avatar, avax, avay, avaz global Rooms, curr_room procedure main() &window := open("PLEASE Lab", "gl", "size=800,750", "bg=grey", "inputmask=k") WAttrib("texmode=on") #initialize globals posx := 0.0; posy := 2.75; posz := -3.0 lookx := avax := lookz := avaz := 0.0; looky := avay := 2.5 cam_lx := cam_angle := 0.0; cam_lz := -1.0 Fg("white") # render graphics #sphere for avatar, couldn't get jose's avatar working WAttrib("texmode=auto","texture=smile2.gif") avatar := DrawSphere(avax, avay-0.4,avaz, 0.1) Rooms := [ ] cooridoor := make_cooridoor() curr_room := make_SH167(cooridoor) make_SH168(cooridoor) make_SH154(cooridoor) make_SH155(cooridoor) make_SH157(cooridoor) make_SH161(cooridoor) make_SH163(cooridoor) make_SH165(cooridoor) make_SH170(cooridoor) make_SH171(cooridoor) make_SH172(cooridoor) make_SH173(cooridoor) make_SH156(cooridoor) make_SH166(cooridoor) make_SH169(cooridoor) every (!Rooms).render() # event processing loop camera() end ############### #Set up the camera procedure camera() xdelta := ydelta := lookdelta := 0 i := 1 cam_move(0.01) Eye(posx,posy,posz,lookx,looky,lookz) repeat { i := 1 if *Pending() = 0 then { if xdelta ~= 0 then cam_move(xdelta) if ydelta ~= 0 then cam_orient_yaxis(ydelta) if lookdelta ~= 0 then looky +:= lookdelta #NEW NEW NEW NEW num_exits := *curr_room.exits while i <= num_exits do{ if (\((dor := curr_room.exits[i]).delt)) ~=== 0 then { if not (dor.delta()) then dor.done_opening() else Refresh() } i := i + 1 }#End While #-------------------------- } else { case ev := Event() of { Key_Up: cam_move(xdelta := 0.05) # Move Foward Key_Down: cam_move(xdelta := -0.05) # Move Backward Key_Left: { ydelta := -0.05 while Pending()[1] === -Key_Left-128 & Pending()[4] === Key_Left do { Event(); Event(); ydelta -:= 0.05 } cam_orient_yaxis(ydelta) # Turn Left } Key_Right: { ydelta := 0.05 while Pending()[1] === -Key_Right-128 & Pending()[4] === Key_Right do { Event(); Event(); ydelta +:= 0.05 } cam_orient_yaxis(ydelta) # Turn_Right } "w": looky +:= (lookdelta := 0.05) #Look Up "s": looky +:= (lookdelta := -0.05) #Look Down "q": exit(0) "d": { #NEW NEW NEW NEW #Open a door # #Find out which door(s) we should open i := 1 #initialize a counter Doors := [ ] #this will hold the list of indicies to which door(s) to open Doors := which_door() #this function returns the list of indicies to which door(s) to open while i <= *Doors do{ #Store the index of the door to open index := Doors[i] dor := curr_room.exits[index] if \ (dor.delt) === 0 then { dor.start_opening() } else dor.done_opening() dor.delta() i := i+1 #increment the counter }#End While loop } #--------------------------------------- -166 | -168 | (-(Key_Up|Key_Down) - 128) : xdelta := 0 -165 | -167 | (-(Key_Left|Key_Right) - 128) : ydelta := 0 -215 | -211 : lookdelta := 0 } } avatar.x := lookx avatar.z := lookz Eye(posx,posy,posz,lookx,looky,lookz) } end procedure cam_move(dir) local deltax := dir * cam_lx, deltaz := dir * cam_lz if curr_room.disallows(posx+deltax,posz+deltaz) then { deltax := 0 if curr_room.disallows(posx+deltax,posz+deltaz) then { deltaz := 0; deltax := dir*cam_lx if curr_room.disallows(posx+deltax,posz+deltaz) then { fail } } } #calculate new position posx +:= deltax posz +:= deltaz #update look at spot lookx := posx + cam_lx lookz := posz + cam_lz end ############### #Orient the camera procedure cam_orient_yaxis(turn) #update camera angle cam_angle +:= turn if abs(cam_angle) > 2 * &pi then cam_angle := 0.0 cam_lx := sin(cam_angle) cam_lz := -cos(cam_angle) lookx := posx + cam_lx lookz := posz + cam_lz end #NEW NEW NEW NEW ############## #Returns a index list of exits to open or close procedure which_door() i := 1 Doors := [ ] while i <= *curr_room.exits do{ #Open the correct door x := curr_room.exits[i].x - lookx y := curr_room.exits[i].y - looky z := curr_room.exits[i].z - lookz #to find the actual distance we would just take the square #root of this number but since the square root function is so expensive #we will work with the distance_sqrd distance_sqrd := x*x + y*y + z*z #if we are close enough to the door then store it so that we may open it later #3 units seems to be a good distance so thats what will be used if distance_sqrd <= 9 then{ put(Doors,i) } i := i + 1 }#End While Loop #Return the list of door indices return Doors end #--------------------------------