I appreciate your help RUCCUS. If you can look at this code
for me I will also send you the building glued real quick, but
without the texture so you can kinda see what I am talking about
if you dont mind. Also for some reason I cant position my player
anywhere I've looked and looked and I cant see why I cant move my
player.
Thanks so much for everything you great people do here for people.
`########################################################################################################################
`#*************************************************** Main Source File *************************************************#
`########################################################################################################################
`================================================================================
`=---------------------------DISPLAY--------------------------------------------=
`================================================================================
SYNC ON : SYNC RATE 75
SET NORMALIZATION ON
SET DISPLAY MODE 1024,768,32,1
SET CAMERA RANGE 0,0.1,955000000
SET CAMERA FOV 0,70
BACKDROP OFF
AUTOCAM OFF
HIDE MOUSE
GOSUB stats:
`================================================================================
`=-----------------------SET-DIRECTORIES----------------------------------------=
`================================================================================
SET DIR "C:\Users\OnQue\Desktop\runner\"
`#######################################################################################################################
`#---------------------------------------PLAYER-VARIBLES---------------------------------------------------------------#
`#######################################################################################################################
`--------------------------------------------------
`--------------PLAYER-&-WEAPONS-&-AMMO-------------
`--------------------------------------------------
`-----------------PLAYER-CREATION------------------
PYR = 1 ` Player Object Value
DUMMY = 9000
`########################################################################################################################
`#-------------------------------------ENVIROMENT-&-BEACH-VARIBLE-------------------------------------------------------#
`########################################################################################################################
intBoxNum = 101 `SKY
` #######################################################################################################################
`#---------------------------------------------------levels-------------------------------------------------------------#
`########################################################################################################################
city_1 = 200
` #######################################################################################################################
`#---------------------------------------------------BUILDING-1---------------------------------------------------------#
`########################################################################################################################
building_1 = 201
building_2 = 202
building_3 = 203
building_4 = 204
building_5 = 205
building_6 = 206
building_7 = 207
building_8 = 208
building_9 = 209
building_10 = 210
building_11 = 211
building_12 = 212
building_13 = 213
building_14 = 214
building_15 = 215
building_16 = 216
building_17 = 217
building_18 = 218
building_19 = 219
building_20 = 220
building_21 = 221
building_22 = 222
building_23 = 223
building_24 = 224
`================================================================================
`=--------------------PLAYER,WEAPON-CHANGE-&-RELOAD-----------------------------=
`================================================================================
`-------------------------------PLAYER-------------------------------------------
ANIMATE# = ANIMATE# `JUMP VARIBLE
PHealth# = PlrHealth#
Old_PHealth# = OPlrHealth#
`================================================================================
`=-----------------------GLOBAL-------------------------------------------------=
`================================================================================
GLOBAL RADIUS# AS DOUBLE FLOAT : RADIUS# = 1
Global PRotY# = 2.0
GLOBAL PRotZ# = 2.0
GLOBAL SKYrotY# = 2.0
Global z# = .05
GLOBAL Bro#=bro#
GLOBAL TER = 90
`------------------------------PLAYER-MOVEMENT-VECTOR----------------------------
GLOBAL vx# AS DOUBLE FLOAT
GLOBAL vy# AS DOUBLE FLOAT
GLOBAL vz# AS DOUBLE FLOAT
GLOBAL gravity# AS DOUBLE FLOAT : gravity# = -0.2
GLOBAL slope# AS DOUBLE FLOAT : slope# = 0
GLOBAL ground AS INTEGER : ground = 1
GLOBAL jumptimer AS INTEGER : jumptimer = 0
GLOBAL view as integer : view = 1
`================================================================================
`=--------------------------CHARACTER-LOAD-PLAYER-------------------------------=
`================================================================================
MAKE OBJECT SPHERE PYR,1
HIDE OBJECT PYR
MAKE OBJECT SPHERE DUMMY,radius#
POSITION OBJECT DUMMY ,5500000,550000000,9000000``19092,10000,10451
`OSITION OBJECT PYR , 6874,660000,10370
HIDE OBJECT DUMMY
`SHOW OBJECT BOUNDS DUMMY, 1
SC_SETUPOBJECT dummy,0,1
`T_Dummy = 567
`MAKE OBJECT SPHERE T_Dummy,500
`HIDE OBJECT T_Dummy
`==================================================
`=---------------------SKY------------------------=
`==================================================
LOAD OBJECT "SKYBOX\CIELO.X",INTBOXNUM
YROTATE OBJECT INTBOXNUM,180
SET OBJECT LIGHT INTBOXNUM,0
SET OBJECT TEXTURE INTBOXNUM,2,1
SET OBJECT CULL INTBOXNUM,0
SCALE OBJECT INTBOXNUM, 110000000000000, 110000000000000, 110000000000000
POSITION OBJECT INTBOXNUM, 17090,-900,28934.9980469
`#######################################################################################################################
`#----------------------------------------SCENE-LOADING----------------------------------------------------------------#
`#######################################################################################################################
` LOAD OBJECT "level_1\city_1.x",city_1
` POSITION OBJECT city_1, 7000,-500,9784
` SCALE OBJECT city_1, 1000,1000,1000
`SET OBJECT DIFFUSE city_1,RGB(3,3,3)
`SET OBJECT AMBIENCE city_1,RGB(15,15,15)
` SET OBJECT SMOOTHING CITY_1,85
` SC_SETUPOBJECT city_1,2,2
LOAD OBJECT "level_1\building_1.x",building_1
SCALE OBJECT building_1,100000,100000,100000
SET OBJECT SMOOTHING building_1,100
SC_SETUPOBJECT building_1,2,2
LOAD OBJECT "level_1\building_piece.x",building_2
SET OBJECT SMOOTHING building_2,100
SC_SETUPOBJECT building_2,2,2
LOAD OBJECT "level_1\building_piece_2.x",building_3
SET OBJECT SMOOTHING building_3,100
SC_SETUPOBJECT building_3,2,2
remstart
LOAD OBJECT "level_1\building_2.x",building_2
SCALE OBJECT building_2, 1000,1000,1000
SC_SETUPOBJECT building_2,2,2
LOAD OBJECT "level_1\building_3.x",building_3
SCALE OBJECT building_3, 1000,1000,1000
SC_SETUPOBJECT building_3,2,2
LOAD OBJECT "level_1\building_4.x",building_4
SCALE OBJECT building_4, 1000,1000,1000
SC_SETUPOBJECT building_4,2,2
LOAD OBJECT "level_1\building_5.x",building_5
SCALE OBJECT building_5, 1000,1000,1000
SC_SETUPOBJECT building_1,2,2
LOAD OBJECT "level_1\building_6.x",building_6
SCALE OBJECT building_6, 1000,1000,1000
SC_SETUPOBJECT building_6,2,2
LOAD OBJECT "level_1\building_7.x",building_7
SCALE OBJECT building_7, 1000,1000,1000
SC_SETUPOBJECT building_7,2,2
LOAD OBJECT "level_1\building_8.x",building_8
SCALE OBJECT building_8, 1000,1000,1000
SC_SETUPOBJECT building_8,2,2
LOAD OBJECT "level_1\building_9.x",building_9
SCALE OBJECT building_9, 1000,1000,1000
SC_SETUPOBJECT building_9,2,2
LOAD OBJECT "level_1\building_10.x",building_10
SCALE OBJECT building_10, 1000,1000,1000
SC_SETUPOBJECT building_10,2,2
LOAD OBJECT "level_1\building_11.x",building_11
SCALE OBJECT building_11, 1000,1000,1000
SC_SETUPOBJECT building_11,2,2
LOAD OBJECT "level_1\building_12.x",building_12
SCALE OBJECT building_12, 1000,1000,1000
SC_SETUPOBJECT building_12,2,2
LOAD OBJECT "level_1\building_13.x",building_13
SCALE OBJECT building_13, 1000,1000,1000
SC_SETUPOBJECT building_13,2,2
LOAD OBJECT "level_1\building_14.x",building_14
SCALE OBJECT building_14, 1000,1000,1000
SC_SETUPOBJECT building_14,2,2
LOAD OBJECT "level_1\building_15.x",building_15
SCALE OBJECT building_15, 1000,1000,1000
SC_SETUPOBJECT building_3,2,2
LOAD OBJECT "level_1\building_16.x",building_16
SCALE OBJECT building_16, 1000,1000,1000
SC_SETUPOBJECT building_16,2,2
LOAD OBJECT "level_1\building_17.x",building_17
SCALE OBJECT building_17, 1000,1000,1000
SC_SETUPOBJECT building_17,2,2
LOAD OBJECT "level_1\building_18.x",building_18
SCALE OBJECT building_18, 1000,1000,1000
SC_SETUPOBJECT building_18,2,2
LOAD OBJECT "level_1\building_19.x",building_19
SCALE OBJECT building_19, 1000,1000,1000
SC_SETUPOBJECT building_19,2,2
LOAD OBJECT "level_1\building_20.x",building_20
SCALE OBJECT building_20, 1000,1000,1000
SC_SETUPOBJECT building_20,2,2
LOAD OBJECT "level_1\building_21.x",building_21
SCALE OBJECT building_21, 1000,1000,1000
SC_SETUPOBJECT building_21,2,2
LOAD OBJECT "level_1\building_22.x",building_22
SCALE OBJECT building_22, 1000,1000,1000
SC_SETUPOBJECT building_22,2,2
LOAD OBJECT "level_1\building_23.x",building_23
SCALE OBJECT building_23, 1000,1000,1000
SC_SETUPOBJECT building_23,2,2
LOAD OBJECT "level_1\building_24.x",building_24
SCALE OBJECT building_24, 1000,1000,1000
SC_SETUPOBJECT building_24,2,2
remend
DO
rem if player is jumping or falling then apply 'normal' gravity
rem if not attempt to keep the player stuck to the floor
if shiftkey() = 1
speed = 7
else
speed = 7
endif
yrotate object DUMMY,object angle Y(DUMMY)+mousemovex()/3.0
xrotate object DUMMY,object angle X(DUMMY)+mousemovey()/3.0
IF OBJECT ANGLE X(DUMMY)>90 THEN XROTATE OBJECT DUMMY,90
IF OBJECT ANGLE X(DUMMY)<-90 THEN XROTATE OBJECT DUMMY,-90
yrotate object PYR,object angle Y(DUMMY)
xrotate object PYR,object angle X(DUMMY)
IF vy#=0 AND jumptimer=0 THEN vy# = vy# + 15*gravity# ELSE vy# = vy# + gravity#
IF KEYSTATE(32)=1 THEN vx# = VX# + COS(angy#)*speed : vz# = -VZ# - SIN(angy#)*speed
IF KEYSTATE(30)=1 THEN vx# =-VX# - COS(angy#)*speed : vz# = VZ# + SIN(angy#)*speed
IF KEYSTATE(31)=1 THEN vx# =-VX# - SIN(angy#)*speed : vz# = -VZ# - COS(angy#)*speed
IF MOUSECLICK()=2 THEN vx# = VX# + SIN(angy#)*speed : vz# = VZ# + COS(angy#)*speed
IF MOUSECLICK()=3 THEN vx# = VX# + SIN(angy#)*speed : vz# = VZ# + COS(angy#)*speed
IF KEYSTATE(31)=1 AND MOUSECLICK()=2 THEN vx# =-VX# - SIN(angy#)*speed : vz# = -VZ# - COS(angy#)*speed
IF KEYSTATE(31)=1 AND KEYSTATE(32)=1
vx# =-VX# - SIN(angy#)*speed : vz# = -VZ# - COS(angy#)*speed
vx# = -VX# + COS(angy#)*speed : vz# = VZ# - SIN(angy#)*speed
ENDIF
IF keystate(31)=1 and keystate(30)=1
vx# =-VX# - SIN(angy#)*speed : vz# = -VZ# - COS(angy#)*speed
vx# = VX# - COS(angy#)*speed : vz# = -VZ# + SIN(angy#)*speed
ENDIF
rem only jump if on ground, and a certain time after last jump
IF GROUND = 0 AND KEYSTATE(43)=1
ANIMATE = ANIMATE + 1
IF animate = 1 THEN POSITION CAMERA 0,camx#,CAMY#-0.5,camz# `move object down pyr,.5
IF animate = 4 THEN POSITION CAMERA 0,camx#,CAMY#-1.0,camz# `move object down pyr,.5
IF animate = 7 THEN POSITION CAMERA 0,camx#,CAMY#-1.5,camz# `move object down pyr,.5
IF animate = 10 THEN POSITION CAMERA 0,camx#,CAMY#-2.0,camz# `move object down pyr,.5
IF animate = 15 THEN POSITION CAMERA 0,camx#,CAMY#-1.5,camz# `move object down pyr,.5
IF animate = 18 THEN POSITION CAMERA 0,camx#,CAMY#-1.0,camz# `move object down pyr,.5
IF animate = 21 THEN POSITION CAMERA 0,camx#,CAMY#-0.5,camz# `move object down pyr,.5
IF animate = 22 THEN animate = 0
ENDIF
IF ground=1
IF spacekey()=1 AND jumptimer=0 THEN vy# = vy# + 30 : jumptimer = 10
ENDIF
DX# = OBJECT POSITION X(DUMMY)
DY# = OBJECT POSITION Y(DUMMY)
DZ# = OBJECT POSITION Z(DUMMY)
rem this would be the player's final position without collision
x# = oldx#+vx#
y# = oldy#+vy#
z# = oldz#+vz#
rem first handle gravity - seperated from horizontal movement
rem to achieve a more realistic effect
rem Method: simple - cast a sphere vertically down, if it hits the level then
rem position the object there (sticky collision) then move
rem on to horizontal movement
rem more complex - if we were to only use the simple method the player would be
rem allowed to climb almost vertical slopes. Alternative is to
rem get the normalY direction to work out how flat the gorund
rem below the player is, 0-slope# is flatter, slope#-1 is steeper.
rem if it's flat, use sticky collision, if it's steep slide the
rem player down the slope. Changing slope# determines how steep the
rem player can climb. NOTE: this also effects stairs.
collide = sc_SphereCastGroup(0,oldx#,oldy#,oldz#,oldx#,oldy#+vy#,oldz#,radius#,0)
IF collide>0
rem how flat is this ground
ny# = sc_getCollisionNormalY()
IF ABS(ny#)>slope#
rem FLAT, stick
oldy# = sc_getStaticCollisionY()
ELSE
rem STEEP, slide
x# = x# - oldx# : z# = z# - oldz#
oldx# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
oldz# = sc_getCollisionSlideZ()
x# = x# + oldx# : z# = z# + oldz#
ENDIF
rem ny#<0 means the player has hit a ceiling rather than a floor
IF ny#>slope#
rem only on ground if standing on flat ground
ground = 1
vy# = 0
ELSE
ground = 0
rem if player has hit a flat ceiling then stop vy# movement
IF ny#<-slope# THEN vy# = gravity#
ENDIF
ELSE
rem nothing below player, not on ground, add vertical speed to player
oldy# = oldy# + vy#
ground = 0
ENDIF
rem jumptimer will decrease only when player is back on ground
rem creates a pause between two successive jumps
IF ground = 1 AND jumptimer>0 THEN DEC jumptimer
rem handle horizontal movement as sliding
rem player only collides with group 1 (level) objs and moves freely through others
collide = sc_SphereSlideGroup(0,oldx#,oldy#,oldz#,x#,oldy#,z#,radius#,0)
IF collide>0
rem if hit, reposition player, halt movement vector
x# = sc_getCollisionSlideX()
oldy# = sc_getCollisionSlideY()
z# = sc_getCollisionSlideZ()
vx# = 0
vz# = 0
rem possible code for giving the player a jumping help up stairs...
rem might be useful if slope# is set very high but stairs are still required
ENDIF
POSITION OBJECT DUMMY,x#,OLDY#,z#
POSITION OBJECT PYR,OBJECT POSITION X(DUMMY),OBJECT POSITION Y(DUMMY)+2,OBJECT POSITION Z(DUMMY)
`position object T_Dummy,OBJECT POSITION X(DUMMY),OBJECT POSITION Y(DUMMY),OBJECT POSITION Z(DUMMY)
SC_UPDATEOBJECT DUMMY
POSITION CAMERA 0, OBJECT POSITION X(pyr),OBJECT POSITION Y(pyr),OBJECT POSITION Z(PYR)
ROTATE CAMERA 0,OBJECT ANGLE X(PYR),OBJECT ANGLE Y(PYR),OBJECT ANGLE Z(PYR)
`================================================================================
`=-------------------------------OBJECT-SELECTION-------------------------------=
`================================================================================
IF KEYSTATE( 10)=1 THEN currentobject#=1
IF currentobject#=1
object = city_1
endif
IF keystate(11)=1 then currentobject#=2
IF currentobject#=2
object = palm_1
ENDIF
IF keystate(16)=1 then currentobject#=3
IF currentobject#=3
object = palm_2
ENDIF
IF KEYSTATE(17)=1 THEN currentobject#=4
IF currentobject#=4
object =palm_3
ENDIF
IF keystate(18)=1 then currentobject#=5
IF currentobject#=5
object = palm_4
ENDIF
IF keystate(19)=1 then currentobject#=6
IF currentobject#=6
object = palm_5
ENDIF
IF KEYSTATE(20)=1 THEN currentobject#=7
IF currentobject#=7
object = palm_6
ENDIF
IF keystate(21)=1 then currentobject#=8
IF currentobject#=8
object = palm_7
ENDIF
IF keystate(22)=1 then currentobject#=9
IF currentobject#=9
object = palm_8
ENDIF
`================================================================================
`=------------------------------OBJECT-MANIPULATION-----------------------------=
`================================================================================
`-----------------------------OBJECT-MANIPULATION-(MOVE)------------------------
IF KEYSTATE(13) = 1
scale# = 0
rotate# = 0
move# = 1
ENDIF
IF move# = 1
IF LEFTKEY()=1 THEN MOVE OBJECT LEFT object,.1
IF RIGHTKEY()=1 THEN MOVE OBJECT RIGHT object,.1
IF DOWNKEY()=1 THEN MOVE OBJECT object,-.1
IF UPKEY()=1 THEN MOVE OBJECT object,.1
IF KEYSTATE(14)=1 THEN MOVE OBJECT UP object,.1
IF KEYSTATE(28)=1 THEN MOVE OBJECT DOWN object,.1
ENDIF
` center text sw/10,0,"OPOSX "+str$(OPOSX#)
` center text sw/2,0,"OPOSy "+str$(OPOSy#)
`center text sw/2,25,"OPOSz "+str$(OPOSz#)
`----------------------------OBJECT-MANIPULATION-(ROTATE)-----------------------
IF KEYSTATE(15)=1
rotate# = 1
move# =0
scale#=0
ENDIF
IF rotate# = 1
ROTATE OBJECT OBJECT,rotX#,rotY#,rotZ#
IF LEFTKEY()=1 then INC roty#,1
IF RIGHTKEY()=1 then DEC roty#,1
IF DOWNKEY()=1 then DEC ROTZ#,1
IF UPKEY()=1 then INC ROTZ#,1
IF KEYSTATE(25)=1 THEN INC rotX#,1
IF KEYSTATE(24)=1 THEN DEC rotX#,1
ENDIF
`center text sw/2,125,"rotx "+str$(rotx#)
` center text sw/2,150,"roty "+str$(roty#)
` center text sw/2,175,"rotz "+str$(rotz#)
`-----------------------------OBJECT-MANIPULATION-(SCALE)------------------------
IF Keystate(12)=1
scale# = 1
rotate# = 0
move#= 0
ENDIF
IF Scale# = 1
SCALE OBJECT OBJECT,SCLX#,SCLY#,SCLZ#
IF LEFTKEY()=1 then INC SCLX#,1
IF RIGHTKEY()=1 then DEC SCLX#,1
IF DOWNKEY()=1 then DEC SCLZ#,1
IF UPKEY()=1 then INC SCLZ#,1
IF KEYSTATE(26)=1 THEN INC SCLY#,1
IF KEYSTATE(27)=1 THEN DEC SCLY#,1
endif
`================================================================================
`=------------------------OBJECT-COORDIATE-INFO---------------------------------=
`================================================================================
` center text sw/2,50,"sclx "+str$(sclx#)
` center text sw/2,75,"scly "+str$(scly#)
` center text sw/2,100,"sclz "+str$(sclz#)
PXP# = OBJECT POSITION X(PYR)
PYP# = OBJECT POSITION Y(PYR)
PZP# = OBJECT POSITION Z(PYR)
sx#=OBJECT POSITION X(intboxnum)
sy#=OBJECT POSITION Y(intboxnum)
sz#=OBJECT POSITION Z(intboxnum)
oldx# = OBJECT POSITION X(dummy)
oldy# = OBJECT POSITION Y(dummy)
oldz# = OBJECT POSITION Z(dummy)
camx# = CAMERA POSITION X(0)
camy# = CAMERA POSITION Y(0)
camz# = CAMERA POSITION Z(0) rem apply gravity, and user changes to movement
angy# = OBJECT ANGLE Y(dummy)
vx# = 0
vz# = 0
bx# = 0
bz# = 0
cax# = camera ANGLE X(0)
cay# = camera ANGLE Y(0)
caz# = camera ANGLE Z(0)
text 0,screen height()-75,"city position x: "+str$(PXP#)
text 0,screen height()-50,"city position y: "+str$(PYP#)
text 0,screen height()-25,"city position z: "+str$(PZP#)
remstart
text 0,screen height()-275,"GGpalm2 position y: "+str$(ph6Y#)
text 0,screen height()-250,"GGpalm2 position z: "+str$(ph6z#)
text 0,screen height()-375,"gggpalm3 position x: "+str$(ph7x#)
text 0,screen height()-350,"gggpalm3 position y: "+str$(ph7y#)
text 0,screen height()-325,"gggpalm3 position z: "+str$(ph7z#)
text 0,screen height()-450,"AMMO: "+str$(AMMO#)
text 0,screen height()-150,"out position x: "+str$(p4x#)
text 0,screen height()-125,"out POSITION y: "+str$(p4y#)
text 0,screen height()-100,"out position z: "+str$(p4z#)
text 0,screen height()-225,"house position x: "+str$(bx#)
text 0,screen height()-200,"house position y: "+str$(by#)
text 0,screen height()-175,"house position z: "+str$(bz#)
remend
SYNC
LOOP