Well, does not fully work for me, this is my code:
REM Project: RoSoEn
REM Created: 2008-01-11 17:43:58
REM
REM ***** Main Source File *****
REM
`///////////////////////////
`// MOUSE MOVE WITH SINUS //
`///////////////////////////
`// Set screen specifics
sync on
sync rate 60
autocam off
hide light 0
set ambient light 0
make light 1
set light range 1, 500
`// Set up globals
Global terrain = 10
Global plrcube = 1
Global oldaccelx#
Global oldaccely#
Global newaccelx#
Global newaccely#
Global MouseSpeed# = 3.0
Global Strafe AS BOOLEAN
Global StandGround AS BOOLEAN
Global OldGravity AS FLOAT = 0.37
Global Gravity AS FLOAT
Global JumpHeight# = 5.0
Global OldWalkSpeed# = 2.0
`// Resource globals
Global snd_speed = 1
Global obj_tube = 2
`// Load resources
`// Images
load image "texture.bmp", 1
load image "detail.tga", 2
`// Sounds
load_sound( "Speed.wav", snd_speed )
`// Models
load object "Tube.x", obj_tube
load object "Tube.x", 3
`// Set resource parameters
set object 3, 1, 0, 1
position object 3, 100, 70, 100
set object cull obj_tube, 1
position object 3, 120, 70, 120
`// Make objects:
`// Make terrain
`// Make Advanced Terrain
Make object terrain terrain
Set terrain texture terrain, 1, 2
Set terrain heightmap terrain, "hm.bmp"
Set terrain split terrain, 16
Set terrain scale terrain, 10, 0.5, 10
Set terrain tiling terrain, 1
Build terrain terrain
sc_setupcomplexobject terrain, 0, 2
`// Make matrix
remstart This is replaced by Advanced Terrain
Make matrix matrix, 1000, 1000, 20, 20
Randomize matrix matrix, 20
Position matrix matrix, 0, -100, 0
Update matrix matrix
remend
`// Make player cube
Make object cube plrcube, 5
Hide object plrcube
Position object plrcube, 10, 10, 20
`// Position the camera and aim it
position camera 5, 30, 5
point camera 10, 10, 20
`// Start the loop
DO
`// Set vars back because otherwise it won't work properly (constantly moving forward)
TargetSpeed# = 0
Strafe = 0
TargetStrafeSpeed# = 0
`// Set values
inc x#, 1
inc y#, 0.5
inc z#, 0.25
`// Get values
Height# = get terrain ground height(terrain, object position x( plrcube ), object position z( plrcube ) ) + 12
if object position y( plrcube ) =< Height# + 1
StandGround = 1
UpAccel# = 0
Gravity = 0.0
DestinationHeight# = Height#
ypos# = curvevalue(DestinationHeight#, object position y( plrcube ), 10)
yposition_object( plrcube, ypos# )
else
StandGround = 0
dec UpAccel#, Gravity
Gravity = OldGravity
endif
if key = 1
oldypos# = object position y( plrcube )
endif
`// Make smooth walking using the Curvevalue methode
if keystate( 17 ) = 1
key = 1
TargetSpeed# = WalkSpeed#
endif
if keystate( 31 ) = 1
key = 1
TargetSpeed# = -Walkspeed#
endif
if keystate( 30 ) = 1
key = 1
TargetStrafeSpeed# = WalkSpeed#
Strafe = 1
endif
if keystate( 32 ) = 1
key = 1
TargetStrafeSpeed# = -WalkSpeed#
Strafe = 1
endif
if keystate( 57 ) = 1
if keyPressed = 0
if object position y( plrcube ) < Height# + 13
UpAccel# = JumpHeight#
StandGround = 0
endif
endif
endif
if keystate( 42 ) OR keystate( 54 )
if spd_engaged = 1
WalkSpeed# = OldWalkSpeed# + 2
endif
else
pressed = 0
WalkSpeed# = OldWalkSpeed#
endif
if scancode( ) = 0
key = 0
endif
`// Make smooth angles using the Curveangle methode
if mouseclick() <> 4
if oldtaken = 0
TargetAngleX# = TargetAngleX# + ( mousemovey() / MouseSpeed# )
AngleSpeedX#=Curveangle(TargetAngleX#,AngleSpeedX#,5)
TargetAngleY# = TargetAngleY# + ( mousemovex() / MouseSpeed# )
AngleSpeedY#=Curveangle(TargetAngleY#,AngleSpeedY#,5)
endif
if oldtaken = 1
position mouse oldmousex, oldmousey
oldtaken = 2
endif
if oldtaken = 2
position mouse oldmousex, oldmousey
oldtaken = 0
endif
hide mouse
else
if oldtaken = 0
oldmousex = mousex()
oldmousey = mousey()
oldtaken = 1
endif
show mouse
endif
UpSpeed#=Curvevalue(TargetSpeed#,UpSpeed#,10)
StrafeSpeed#=Curvevalue(TargetStrafeSpeed#,StrafeSpeed#,10)
`// Rotate the cube || For some strange reason the X and the Y of mouse movement is messed up
rotate object plrcube, AngleSpeedX#, AngleSpeedY#, 0
rotate object obj_tube, x#, y#, z#
rotate object 3, x#, y#, z#
`// Get rotation values
Oldangx# = object angle x( plrcube )
Oldangy# = object angle y( plrcube )
Oldangz# = object angle z( plrcube )
`// Get position values
Oldposx# = object position x( plrcube )
Oldposy# = object position y( plrcube )
Oldposz# = object position z( plrcube )
`// Position the cube
rotate object plrcube, 0, object angle y( plrcube ), 0
move object plrcube, UpSpeed#
rotate object plrcube, Oldangx#, Oldangy#, Oldangz#
`// Position the light(s)
position light 1, Oldposx#, Oldposy#, Oldposz#
set light to object orientation 1, plrcube
`// Rotate object to left - for strafing
rotate object plrcube, 0, object angle y( plrcube ) - 90, 0
move object plrcube, StrafeSpeed#
rotate object plrcube, Oldangx#, Oldangy#, Oldangz#
`// Set rotation limits
if object angle x( plrcube) > 90 AND object angle x( plrcube ) < 100
xrotate object plrcube, 90
TargetAngleX# = 90
endif
if object angle x( plrcube) < 270 AND object angle x( plrcube ) > 260
xrotate object plrcube, 270
TargetAngleX# = 270
endif
`// Pos object to grnd
if StandGround = 1
position object plrcube, object position x( plrcube ), Height#, object position z( plrcube )
else
position object plrcube, object position x( plrcube ), object position y( plrcube ) + UpAccel#, object position z( plrcube )
endif
`// Rotate the cam to the object
position camera object position x( plrcube ), object position y( plrcube ), object position z( plrcube )
set camera to object orientation plrcube
`// Get terrain angle
xxx# = object position x( plrcube ) + sin( object angle y( plrcube ) )
zzz# = object position z( plrcube ) + cos( object angle y( plrcube ) )
`sc_raycast( 0, object position x( plrcube ), object position y( plrcube ), object position z( plrcube ), object position x( plrcube ), object position y( plrcube )+5, object position z( plrcube ), 0 )
xxx# = AtanFull( SC_GetCollisionNormalY(), SC_GetCollisionNormalZ() );
xxx# = AtanFull( SC_GetCollisionNormalY(), SC_GetCollisionNormalZ() );
angletje# = atanfull( xxx#, zzz# )
`// Debug
if DebugDisabled = 0
set cursor 0, 0
print "Object angle x: "+str$(object angle x( plrcube))
print "Stand Ground: "+str$(StandGround)
print "X: "+str$(object position x( plrcube ))+" || Y: "+str$(object position y( plrcube ))+" || Z: "+str$(object position z( plrcube ))
print "mypos#: "+str$( mypos# )
print "angle(probaly): "+str$( angletje# )
endif
`// Check for menu
decision = ingame_engage_menu()
select decision
case 1
spd_engaged = 1
endcase
endselect
if key = 1
newypos# = object position y( plrcube )
mypos# = newypos# - oldypos#
if token = 0
if mypos# => 1
WalkSpeed# = 0
token = 1
endif
else
token = 0
WalkSpeed# = OldWalkSpeed#
endif
endif
`// Update the terrain
Update terrain terrain
`// Sync the screen
SYNC
`// End the loop
LOOP
Function yposition_object(objectnum, y#)
position object objectnum, object position x( objectnum ), y#, object position z( objectnum )
Endfunction
Function ingame_engage_menu()
if mouseclick() = 4
show mouse
`get image 1, 1, 1, 65, 65
endif
if mouseclick() = 4
`paste image 1, 0, 0
circle screen width() / 2, screen height() / 2, 30
center text screen width() / 2, screen height() / 2, "speed"
if mousex() > screen width() / 2 - 15 AND mousex() < screen width() / 2 + 15 AND mousey() > screen height() / 2 - 15 AND mousey() < screen height() / 2 + 15
decision = 1
play sound snd_speed
endif
endif
hide mouse
Endfunction decision
Function load_sound( SoundId$, SoundNumber )
SoundId$ = "Speed.wav"
if file exist( SoundId$ ) = 1
Load Sound SoundId$, SoundNumber
else
`// Writing to log file or something here..
endif
Endfunction
Function when_do_you_think_this_will_be_called_NEVER()
if memblock exist(255) = 2
poepeeeeeepepepepe = 1
endif
endfunction
A bit long, but can you help me out, please?
Thank you VERY much!!
-Jeff
You're the
'th to view this signature!