I could, but I would still need my character to fall, otherwise the player could just keep pressing spacebar and cling to the ceiling
anyways I have yet another dilemma, by changing it to inc number_of_jumps, my character again only jumps twice and stops being able to jump, here is my entire code now:
Rem Project: "Instinct"
Rem Created: Sunday November, 27 2011
Rem ***** Main Source File *****
Sync on
Sync rate 65
backdrop on
color backdrop rgb(0,0,0)
load dll "user32.dll",1
Sw=call dll(1,"GetSystemMetrics",0)
Sh=call dll(1,"GetSystemMetrics",1)
set display mode Sw,Sh,32,1
delete dll 1
maximize window
hide mouse
set cursor 0,0
Fog On
CameraRadius# = 1
CAX# = 25
CAY# = 0
jspd# = .30
fall_speed_jump_limit# = -1.0
max_number_of_jumps = 2
global collided as boolean = 0
load object "Twitch_animations.x",1
set object speed 1,100
loop object 1,1,100
scale object 1,32,32,32
load image "Twitch_2easyuv.png" ,2
texture object 1,2
load object "level_alpha1.x" ,2
position object 2,2,-5,3
sc_setupcomplexobject 2,1,1
load image "building 5.png" ,1
texture object 2,1
load object "LEVEL_BACKFGROUND.x" ,3
position object 3,0,-8,0
scale object 3,1500,1500,1500
load object "skysphere1.x" ,4
load image "sky_texture.jpg" , 3
scale object 4,50000,55000,50000
position object 4,0,-25,0
texture object 4,3
Set object ambient 4, 0
set object light 4, 0
load effect "Toon.fx",1,0
set object effect 1,1
vec = make vector4 (1)
set object effect 2,1
rem main loop
do
MMX = MouseMoveX()
MMY = MouseMoveY()
rem get previous position
oldx# = object position x(1)
oldy# = object position y(1)+0.4
oldz# = object position z(1)
if keystate(17) = 1 then move object 1,-0.07: loop object 1,120,160
if keystate(30) = 1 then y=wrapvalue(y-1)
if keystate(31) = 1 then move object 1,0.07
if keystate(32) = 1 then y=wrapvalue(y+1)
yrotate object 1,y
if (ScanCode() = 0) then loop object 1,1,100
if keystate(42) = 1 then loop object 1,1,100
if keystate(42) = 1 and keystate(17) = 1 then move object 1, -0.08:loop object 1,180,220
rem Make skysphere move
Yrotate object 4,object angle Y(4)+0.01
position object 4,camera position x(0),object position y(4),camera position z(0)
rem get updated positions
X# = object position x(1)
Y# = object position y(1)+0.4
Z# = object position z(1)
if CameraRadius# > 4 then dec CameraRadius#,.05
if CameraRadius# < 4 then inc CameraRadius#,.05
Rem makes the camera focus on the character
point camera 0,object position x(1),object position y(1),object position z(1)
CAY# = Camera Angle Y(0) `Gets the cameras new Y angle
Rem rotate the camera using the mouse
inc CAY#,MMX
inc CAX#,MMY
Rem put a limit on the cameras X angle
if CAX# <5 then CAX# =5
if CAX# > 80 then CAX# = 80
Rem Positions and rotates the camera
position camera 0,object position x(1),object position y(1)+.9,object position z(1)
rotate camera 0,CAX#,CAY#,0
move camera 0,-CameraRadius#
rem add gravity
dec speedY#,.02
inc y#,speedY#
rem check for collision
collide1 = sc_sphereslide(0,oldx#,oldy#,oldz#,X#,Y#,Z#,0.4,0)
if collide1>0
rem get new positions of player
X# = sc_getcollisionslideX()
Y# = sc_getcollisionslideY()
Z# = sc_getcollisionslideZ()
nY# = sc_getcollisionnormalY()
if nY#>.9
speedY# = 0
//if spacekey() then speedY# = .33
endif
endif
// check for collision
if object collision (1,2) and collided = 0
collided = 1 // stop this from being executed more than once while colliding
number_of_jumps = 0
speedy# = 0
endif
if object collision (1,2) = 0 // so if not colliding
// reset our flag
collided = 0
endif
if SpeedY# > fall_speed_jump_limit# and SpeedY# =< 0
if spacekey_pressed = 0
if number_of_jumps < max_number_of_jumps
if spacekey() = 1
spacekey_pressed = 1
inc number_of_jumps
SpeedY# = jspd#
endif
endif
endif
if spacekey() = 0 then spacekey_pressed = 0
endif
rem update player positions
position object 1,x#,y#-0.4,z#
sync
loop
delete memblock 1
sazex