Is it possible to have my character cube push boxes in front of him without using the character controller? I hate the character controller. I'll use sparky's if necessary. I just have a whole bunch of cubes stacked with a for/next and I want to be able to kick them while walking. Here's my code:
`======================================================== <
`=================\//TSA VIDEO GAME DESIGN PROJECT//\==== <<
`===============================07/08==================== <<<
`======================================================== <<<<
`====-Cullin Moran, Christian Persico, Andriy Rusyn,===== <<<
`=====Lucas Neffa-======================================= <<
`======================================================== <
`=========================Special Thanks: Kai Lieth======
sync on
sync rate 60
backdrop off
hide mouse
autocam off
phy start
phy set auto fixed timing
phy enable debug
global NextIDNumber = 0
global newy = 0
`=====Create player object=====
PlayerObject = NextIDNumber()
make object cube PlayerObject,2
scale object PlayerObject,2,5,2
position object PlayerObject,10,2.5,0
move object PlayerObject,-25
sc_setupobject PlayerObject,0,2
hide object PlayerObject
`=====Create player object=====
pbpx#=object position x(PlayerObject)
pbpy#=object position y(PlayerObject)
pbpz#=object position z(PlayerObject)
remstart
`=====Character Controller=====
phy make box character controller PlayerObject,pbpx#,pbpy#,pbpz#,2,20,2,1,1,50
`=====Character Controller=====
remend
`=====Add Level Light 1=====
make light 1
set spot light 1,100,200
position light 1,200,350,100
point light 1,0,0,0
set light range 1,600
color light 1,rgb(255, 0, 0)
`=====Add Level Light 1=====
color light 0,255,255,255
`=====Add Level Light 2=====
make light 2
set spot light 2,100,250
point light 2,0,0,0
set light range 2,600
color light 2,rgb(0, 0, 255)
`=====Add Level Light 2=====
set normalization on
`=====Level Fog=====
`-(Only works if GFX card supports it)
fog on
fog color rgb(000,040,000)
fog distance 350
set ambient light 75.0
color ambient light rgb(255, 0, 0)
`=====Level Fog=====
`=====Load Level=====
LevelObject = NextIDNumber()
load object "level.x", LevelObject
position object LevelObject ,0,0,0
scale object LevelObject,400,400,400
SC_setupTerrainCollision LevelObject,0,999
phy make rigid body static mesh LevelObject
`=====Load Level=====
leveltex=NextIDNumber()
load image "wall_m_35.jpg",leveltex
texture object LevelObject,0,leveltex
`=====TRANSPARENT IMAGE=====
nicebigtransparentimage=NextIDNumber()
planefortransparentimage=NextIDNumber()
load image "transparentimage.jpg",nicebigtransparentimage,1
make object plain planefortransparentimage,40,40
position object planefortransparentimage,0,30,63.9
scale object planefortransparentimage,100,100,100
texture object planefortransparentimage,nicebigtransparentimage
set object transparency planefortransparentimage,5
`=====TRANSPARENT IMAGE=====
`BUMPMAPPING WITH SPECULAR - Only for supported cards,
`textures are killed if unsupported.
remstart
bumpmaptest=NextIDNumber()
bumpmapshader=NextIDNumber()
load image "wall_m_35_bumpmap.jpg",bumpmaptest
texture object LevelObject,1,bumpmaptest
load effect "Bumpmapping-specular.fx",bumpmapshader,0
set object effect LevelObject,bumpmapshader
remend
`=====Load and position crosshair=====
screen_height=screen height()
screen_width=screen width()
screen_center_x=screen_width / 2
screen_center_y=screen_height / 2
CrossHairImage = NextIDNumber()
load image "crosshair.bmp",CrossHairImage,1
CrossHairSprite = NextIDNumber()
`=====Load and position crosshair=====
masscubetex = NextIDNumber()
load image "masscubetex.bmp",masscubetex
`=====STACK OF BRICKS=====
brickspawnid = 4738400
xbrickspawnstart# = -2
ybrickspawnstart# = 2.5
for x = 0 to 10
for y = 0 to 10
make object cube brickspawnid,5
`color object brickspawnid, rgb ( rnd ( 255 ), rnd ( 255 ), rnd ( 255 ) )
texture object brickspawnid,masscubetex
set object specular brickspawnid, rgb (255, 255, 255)
set object specular power brickspawnid, 255
set object ambient brickspawnid, 0
position object brickspawnid, xbrickspawnstart#, ybrickspawnstart#, 0
phy make rigid body dynamic box brickspawnid
phy set rigid body mass brickspawnid,100.0
xbrickspawnstart# = xbrickspawnstart# + 5.0
inc brickspawnid
next y
xbrickspawnstart# = -2
ybrickspawnstart# = ybrickspawnstart# + 5.0
next x
`=====STACK OF BRICKS=====
type BulletType
ObjectNumber as integer
Distance as float
endtype
dim Bullets(10) as BulletType
for b=0 to 10
NewBullet = NextIDNumber()
make object sphere NewBullet,0.2
color object NewBullet,rgb(255,255,0)
` This is the object number.
Bullets(b).ObjectNumber = NewBullet
Bullets(b).Distance = -1.0
hide object NewBullet
position object NewBullet,0,-999,0
next b
sparktex = NextIDNumber()
load image "sparktexture.bmp",sparktex,0
BulletsInFlight = 0
BulletRange# = 150.0
BulletVelocity# = 150.0
MovementSpeed# = 35.0
`Bullethole
BulletHoleImage = NextIDNumber()
load image "bullet hole.bmp", BulletHoleImage,1
OriginalBulletHole = NextIDNumber()
make object plain OriginalBulletHole, 1, 1
texture object OriginalBulletHole, BulletHoleImage
set object transparency OriginalBulletHole, 5
hide object OriginalBulletHole
sparkdeltimer# = 1
cyclecount#=1
`JUMP/CROUCH VARS
`==============
`=======
`===
jumpa#=0
jumpon#=0
jumpmaxheight#=4.0
jumpmaxheightcrouched#=2.0
`===
`=======
`==============
`=======
`===
crouching#=0
crouchamount#=2.0
movementspeedcrouched#=17.0
`===
`=======
`==============
cutscene=NextIDNumber()
load animation "pkdnb.avi",cutscene
cutsceneplayed#=0
phy update 0
sprite CrossHairSprite,screen_center_x - 50,screen_center_y - 50,CrossHairImage
`Begin main loop:
do
PreviousCycleTime = CycleTime
CycleTime = timer()
ElapsedTime = CycleTime - PreviousCycleTime
CyclesPerSecond# = 1000.0 / ElapsedTime
inc sparkdeltimer#
oldx#=object position x(PlayerObject)
oldy#=object position y(PlayerObject)
oldz#=object position z(PlayerObject)
`=====WASD Controls=====
`NOT Crouching
if crouching#=0
if keystate(17)=1 then move object PlayerObject, MovementSpeed# / CyclesPerSecond#
if keystate(30)=1 then move object left PlayerObject, MovementSpeed# / CyclesPerSecond#
if keystate(31)=1 then move object PlayerObject, 0.0 - (MovementSpeed# / CyclesPerSecond#)
if keystate(32)=1 then move object right PlayerObject, MovementSpeed# / CyclesPerSecond#
endif
`Crouching
if crouching#=1
if keystate(17)=1 then move object PlayerObject, movementspeedcrouched# / CyclesPerSecond#
if keystate(30)=1 then move object left PlayerObject, movementspeedcrouched# / CyclesPerSecond#
if keystate(31)=1 then move object PlayerObject, 0.0 - (movementspeedcrouched# / CyclesPerSecond#)
if keystate(32)=1 then move object right PlayerObject, movementspeedcrouched# / CyclesPerSecond#
endif
`=====WASD Controls=====
`=====JUMPING=====
if spacekey()=1 then text 100,60,"Spacebar Down." else text 100,60,"Spacebar Up."
popx#=object position x(PlayerObject)
popy#=object position y(PlayerObject)
popz#=object position z(PlayerObject)
if spacekey()=1 and jumpon#=0
jumpon#=1
prepopy#=object position y(PlayerObject)
endif
if jumpon#=1
gosub jumping
popy#=prepopy#+popynew#
else
popy#=10
endif
gosub jumpposition
text 860,290,"Player Cube Height:"
text 900,300,str$(popy#)
`=====JUMPING=====
`=====CROUCHING=====
if keystate(29)=1
crouching#=1
else
crouching#=0
endif
gosub crouching
text 860,310,"Crouching:"
if crouching#=1
text 900,320,"Yes"
else
text 900,320,"No"
endif
`=====CROUCHING=====
x#=object position x(PlayerObject)
y#=object position y(PlayerObject)
z#=object position z(PlayerObject)
`=====Camera/Player Obj Lock=====
position camera object position x(PlayerObject),object position y(PlayerObject)+2.5,object position z(PlayerObject)
rotate camera camera angle x(),object angle y(PlayerObject),camera angle z()
`=====Camera/Player Obj Lock=====
`=====Camera equal Flashlight=====
cpx#=camera position x()
cpy#=camera position y()
cpz#=camera position z()
position light 2,cpx#,cpy#,cpz#
point light 2,xvec#,yvec#,zvec#
`=====
`=====Camera Controls=====
speed#=0.2
damper#=10.0
camy#=wrapvalue(camy#+mousemovex()*speed#):camx#=wrapvalue(camx#+mousemovey()*speed#)
if camx#<=290 and camx#>180 then camx#=290
if camx#>=70 and camx#<180 then camx#=70
tx#=curvevalue(-camx#,tx#,damper#)
ty#=curvevalue(-camy#,ty#,damper#)
rotate camera camx#,object angle y(PlayerObject),0
yrotate object 1,camy#
`=====Camera Controls=====
if mouseclick()=1
gosub firemahlazer
endif
text 900,700,str$(lazerhitid)
`SPARKY'S SLIDING COLLISION FUNCTION CALL
slidingcollision(oldx#,oldy#,oldz#,x#,y#,z#,3,PlayerObject,LevelObject)
if cutsceneplayed#=0 and keystate(46)=1
cutsceneplayed#=1
goto cutscenemode
endif
text 500,500,"Hit C to go to the cutscene. :D"
phy update 1
phy update 0
sync
loop
`End main loop
`--------------------------------------------------------------------------------------------------
firemahlazer:
camx_lazer#=camera position x()
camy_lazer#=camera position y()
camz_lazer#=camera position z()
move camera 1
xvec# = camera position x() - camx_lazer#
yvec# = camera position y() - camy_lazer#
zvec# = camera position z() - camz_lazer#
move camera -1
lazerhit=phy ray cast closest shape(camera position x(),camera position y(),camera position z(),xvec#,yvec#,zvec#)
if lazerhit=1
lazerhitid=phy get ray cast object()
if lazerhitid=LevelObject
return
else
phy set rigid body position lazerhitid,999,-999,999
phy sleep rigid body lazerhitid
exclude object on lazerhitid
endif
endif
return
`---------------------------------------------------------------------------------------------------
`========<=-=Bullets=-=>========
`---------->-=-Are-=-<----------
`========<=-=Annoying=-=>=======
FireBullet:
` Find the first unused bullet.
for b = 0 to 10
` If the bullet isn't in flight, position it at the point of origin.
if Bullets(b).Distance = -1.0
BulletObject = Bullets(b).ObjectNumber
show object BulletObject
position object BulletObject, camera position x(), camera position y(), camera position z()
rotate object BulletObject, camera angle x(), camera angle y(), camera angle z()
` Annotate this bullet as being in flight.
Bullets(b).Distance = 0.0
inc BulletsInFlight
` We have our bullet, so exit.
exit
endif
next b
return
`---------------------------------------------------------------------------------------
jumping:
`PlayerObject and orig height 10
`NOT Crouching
if crouching#=0
if jumpa#>=0 and jumpa#<=180
popynew#=sin(jumpa#*4)*jumpmaxheight#
inc jumpa#
endif
if jumpa#=45
jumpon#=0
jumpa#=0
endif
if jumpon#=1
text 100,70,"Jumping subroutine running."
endif
endif
`Crouching
if crouching#=1
if jumpa#>=0 and jumpa#<=180
popynew#=sin(jumpa#*4)*jumpmaxheightcrouched#
inc jumpa#
endif
if jumpa#=45
jumpon#=0
jumpa#=0
endif
if jumpon#=1
text 100,70,"Jumping subroutine running. (Crouched)"
endif
endif
return
`---------------------------------------------------------------------------------------
jumpposition:
position object PlayerObject,popx#,popy#,popz#
return
`---------------------------------------------------------------------------------------
crouching:
if crouching#=1
position object PlayerObject,object position x(PlayerObject),object position y(PlayerObject)-crouchamount#,object position z(PlayerObject)
endif
return
`---------------------------------------------------------------------------------------
`Spark Deletion Timer Stuff
sparks:
if sparkdeltimer#>50
if sparkexist#>0
`phy delete emitter particleemitter
endif
sparkdeltimer#=1
endif
return
` --------------------------------------------------------------------------------------------------
`Sparky's Function
function slidingcollision(x1#,y1#,z1#,x2#,y2#,z2#,Radius#,Dyn,Obj)
C = sc_SphereSlide(Obj,x1#,y1#,z1#,x2#,y2#,z2#,Radius#,0)
if C > 0
cx# = sc_getCollisionSlideX()
cy# = sc_getCollisionSlideY()
cz# = sc_getCollisionSlideZ()
position object Dyn, cx#, cy#, cz#
endif
endfunction
delete memblock 1
` --------------------------------------------------------------------------------------------------
function ThreeDimensionDistance#(FromX#, FromY#, FromZ#, ToX#, ToY#, ToZ#)
` calculate the distance between two points in three dimensions
TempX# = abs(FromX# - ToX#)
TempY# = abs(FromY# - ToY#)
TempZ# = abs(FromZ# - ToZ#)
ReturnValue# = sqrt((TempX# * TempX#) + (TempY# * TempY#) + (TempZ# * TempZ#))
endfunction ReturnValue#
` --------------------------------------------------------------------------------------------------
function NextIDNumber()
` determine ID numbers
inc NextIDNumber
endfunction NextIDNumber
function newy()
inc newy
endfunction newy
`------------------------------------------------------------------------------------------
cutscenemode:
sync on
sync rate 60
flush video memory
phy clear
color backdrop black
delete sprite CrossHairSprite
play animation cutscene,0,0,1024,768
do
text 0,0,"Terrible quality = ripped from youtube but w/e."
text 0,20,"Cutscenes are used as transitions because the previous level CANNOT be loaded again correctly,"
text 0,30,"so just hit ESC when you're done."
sync
loop
end
`------------------------------------------------------------------------------------------
Thanks much in advance.