All my UTD are at the top ALWAYS, It goes, #Constants, UDT, GLOBALS to ensure this does not become an issue.
Ortu the Line numbers seems pretty on point, just the reasoning for the errors is confusing me, like why its ignoring a command because the line before it was commented and strange things like that.
//_______
MAKE OBJECT sphere 1,10
MAKE OBJECT sphere 2,10
Was an error Chris only because of that comment on the line above making the Object never get created because the compiler was skipping over it which is NOT suppose to happen.
I sort of can't post the code at the moment Chris because I have temporarily gotten the errors fixed but I am sure more will appear out of no where like they have been.
Here is the code, I have another current issue if anyone knows a fix for it. The ball is falling ot the platform. I call Gravity if the player(ball) is falling , problem is two fold if it falls to fast it tunnels and gets stuck in the floor and another issue is its either falling or connecting. I'm a little stumped on how to have that in between because soon as I make him no longer being in connection with the floor he is essentially floating slightly above it and it again attempts to fall. Considering a Ray_cast to detect floor below the player but that seems total overkill and I am just missing something.
Anyway here is the code, I managed to get a little written out but I have been seriously slowed down by the strange Errors and now by my little game physics issue. I just want the stupid ball to jump when I hit space lol. It sort of does but there is many bugs to get it to work the way I want it to. Like when it hits the side of the platform it jumps up. That I really don't understand. Sorry its half Sparky Collision and half not. I was literally in the middle of removing Sparkys DLL from the project because of issues I was having and just going back to native commands.
Rem Project: Game
Rem Created: Monday, November 13, 2017
Rem ***** Main Source File *****
Sync On:CLS 0
SYNC RATE 60
type Vector2
X as float
y as float
endtype
type Vector3
X as float
y as float
z as float
endtype
type Vector4
X as float
y as float
z as float
w as float
endtype
type Platform
position as vector3
Height as integer
endtype
type player
HEALTH as integer
SCORE as integer
SPEED as float
POSITION as Vector3
VELOCITY as Vector3
FORCE AS float
JUMP_FLAG as boolean
FALLING_FLAG as boolean
TIME as float
endtype
Dim PLAYERS(2) as player
Dim World(10) as Platform
#constant Player_1 1
#constant Player_2 2
#constant TRUE 1
#constant FALSE 0
//-------------- Physics Defines -----------------------------------------
#constant GFORCE .5
GLOBAL X_ACCELERATION = 10
GLOBAL Y_ACCELERATION = 10
GLOBAL Z_ACCELERATION = 10
//-------------- Keyboard Defines -----------------------------------------
GLOBAL SPACEKEY_SWITCH
GLOBAL LEFTKEY_SWITCH
GLOBAL RIGHTKEY_SWITCH
GLOBAL UPKEY_SWITCH
GLOBAL DOWNKEY_SWITCH
GLOBAL GLOBAL_TIMER
//__________________LEVEL SETUP ______________________________________________________________________________________________//
//______________________________________________________________________________________________________________________________//
// Project Creation Date: 11/13/2017
// Dependencies: SPARKY COLLISION DLL
//
//
// MAIN GAME LOOP
//______________________________________________________________________________________________________________________________//
INITIALIZE()
MAKE OBJECT sphere 30,10
Do
PLAYER1_X# = OBJECT POSITION X(Player_1)
PLAYER1_Y# = OBJECT POSITION Y(Player_1)
PLAYER1_Z# = OBJECT POSITION Z(Player_1)
SC_updateObject PLAYER_1
//PLAYER1_collision = sc_OBJECT COLLISION(PLAYER_1,0)
INPUT_HANDLER()
COLLISION_HANDLER()
GRAVITY(PLAYER_1, PLAYERS(1).TIME)
SET CURSOR 0,0
print "Collision:";PLAYER1collision;" Frames:"; SCREEN FPS()
PRINT "Velocity Y:";PLAYERS(1).VELOCITY.Y
PRINT "Velocity X:";PLAYERS(1).VELOCITY.X
PRINT "Position X:";PLAYERS(1).POSITION.X;" Y:";PLAYERS(1).POSITION.Y ; " Z:";PLAYERS(1).POSITION.Z
print "JUMP_FLAG:"; PLAYERS(1).JUMP_FLAG
PRINT "HIT:"; SC_OBJECTCOLLISION(PLAYER_1,0)
print timer()
// POSITION OBJECT 30,OBJECT POSITION X(PLAYER_1),newyvalue(OBJECT POSITION Y(PLAYER_1),90,20) ,OBJECT POSITION Z(PLAYER_1)
PLAYERS(1).POSITION.X = OBJECT POSITION X(PLAYER_1)
PLAYERS(1).POSITION.Y = OBJECT POSITION Y(PLAYER_1)
PLAYERS(1).POSITION.Z = OBJECT POSITION Z(PLAYER_1)
sync
Loop
function INPUT_HANDLER()
If spacekey() = TRUE AND PLAYERS(1).JUMP_FLAG = FALSE
SPACEKEY_SWITCH = TRUE
endif
if SPACEKEY_SWITCH = TRUE and SPACEKEY() = FALSE AND PLAYERS(1).JUMP_FLAG = FALSE
PLAYERS(1).VELOCITY.Y = 10.0
PLAYERS(1).JUMP_FLAG = TRUE
PLAYERS(1).FALLING_FLAG = TRUE
SPACEKEY_SWITCH = FALSE
playerx# = object position x(PLAYER_1)
playery# = object position y(PLAYER_1)
playerz# = object position z(PLAYER_1)
inc playerx#, PLAYERS(1).VELOCITY.X * PLAYERS(1).TIME
inc playery#, PLAYERS(1).VELOCITY.Y * PLAYERS(1).TIME
POSITION OBJECT PLAYER_1,playerX#,playerY# + 1,playerZ#
sc_updateobject player_1
print "SPACE"
endif
IF leftkey() = true
INC PLAYERS(1).VELOCITY.X,2
IF PLAYERS(1).VELOCITY.X > 14 THEN PLAYERS(1).VELOCITY.X = 14
endif
IF rightkey() = true
INC PLAYERS(1).VELOCITY.X,-2
IF PLAYERS(1).VELOCITY.X < -14 THEN PLAYERS(1).VELOCITY.X = -14
endif
IF upkey() = true
INC PLAYERS(1).VELOCITY.Z,2
IF PLAYERS(1).VELOCITY.Z < -14 THEN PLAYERS(1).VELOCITY.Z = -14
endif
IF downkey() = true
INC PLAYERS(1).VELOCITY.Z,-1
IF PLAYERS(1).VELOCITY.Z < -14 THEN PLAYERS(1).VELOCITY.Z = -14
endif
endfunction
function GRAVITY(OBJ as integer,TIME as float)
inc PLAYERS(1).TIME,.01
DEC PLAYERS(1).VELOCITY.Y,1.1
playerx# = object position x(OBJ)
playery# = object position y(OBJ)
playerz# = object position z(OBJ)
inc playerx#, PLAYERS(1).VELOCITY.X * PLAYERS(1).TIME
HIT = SC_OBJECTCOLLISION(PLAYER_1,0)
if HIT = 0
inc playery#, PLAYERS(1).VELOCITY.Y * PLAYERS(1).TIME * 2
endif
POSITION OBJECT OBJ,playerX#,playerY#,playerZ#
SC_UPDATEOBJECT PLAYER_1
PLAYERS(1).VELOCITY.X = PLAYERS(1).VELOCITY.X / 1.1
if (PLAYERS(1).VELOCITY.Y) < -10 THEN (PLAYERS(1).VELOCITY.Y) = -10
if ABS(PLAYERS(1).VELOCITY.X) < 1 then PLAYERS(1).VELOCITY.X = 0
if ABS(PLAYERS(1).VELOCITY.Z) < 1 then PLAYERS(1).VELOCITY.Z = 0
if ABS(PLAYERS(1).VELOCITY.Y) < 1.4 then PLAYERS(1).VELOCITY.Y = 0
if SC_OBJECTCOLLISION(OBJ,0) <> 0 // AND PLAYERS(1).JUMP_FLAG = TRUE
PLAYERS(1).TIME = 0
PLAYERS(1).VELOCITY.Y = 0
endif
endfunction
function COLLISION_HANDLER()
XPOS# = OBJECT POSITION X(PLAYER_1)
YPOS# = OBJECT POSITION Y(PLAYER_1)
ZPOS# = OBJECT POSITION Z(PLAYER_1)
HIT = SC_OBJECTCOLLISION(PLAYER_1,0)
IF HIT <> 0
DEC XPOS#, GET OBJECT COLLISION X()
DEC YPOS#, GET OBJECT COLLISION Y()
DEC ZPOS#, GET OBJECT COLLISION Z()
POSITION OBJECT PLAYER_1,XPOS#,YPOS#,ZPOS#
SC_UPDATEOBJECT PLAYER_1
PLAYERS(1).JUMP_FLAG = FALSE
PLAYERS(1).VELOCITY.Y = 0
PLAYERS(1).FALLING_FLAG = FALSE
ENDIF
endfunction
function INITIALIZE()
AUTOCAM OFF
MAKE_LEVEL()
GLOBAL_TIMER = TIMER()
POSITION CAMERA 250,200,450
POINT CAMERA 250,0,0
MAKE OBJECT sphere PLAYER_1,30
COLOR OBJECT PLAYER_1,RGB(255,0,0)
POSITION OBJECT PLAYER_1,0,100,0
sc_setupobject PLAYER_1,0,2
SC_drawObjectBounds PLAYER_1
endfunction
function MAKE_LEVEL()
for count = 0 to 10
WORLD(count).position.x = COUNT * 50
WORLD(count).position.y = 0
WORLD(count).position.z = 0
WORLD(count).Height = 10
WORLD(10).Height = 50
WORLD(0).Height = 50
MAKE OBJECT box count + 3,50, WORLD(count).Height, 100
POSITION OBJECT count + 3,WORLD(count).position.x,WORLD(count).Height / 2,WORLD(count).position.z
COLOR OBJECT count+3,RGB(RND(255),RND(255),RND(255))
sc_setupobject count + 3,0,2
sc_drawobjectbounds count + 3
next
MAKE MATRIX 1,500,500,20,20
endfunction
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
REMSTART
// MMx = MouseMoveX()
// CamY# = WrapValue(Object Angle Y(p)+MMx): Yrotate Object p,Y#
// ObjX# = Object Position X(p): ObjZ# = Object Position Z(p)
// ObjHeight# = Get Ground Height(1,ObjX#,ObjZ#)
// Position Object p,ObjX#,ObjHeight#+1.0,ObjZ#
// Camheight# = ObjHeight#+ReqCamHeight# + 10
// Set Camera To Follow ObjX#,ObjHeight#,ObjZ#,WrapValue(Object Angle Y(p)+TrackAngle),Camdist#,Camheight#,Camsmooth,ColFlag
// Sync
// Camdist# = 15.0
// TrackAngle = 0: Rem 0 - Behind, 180 - Front, 90 & 270 - Sides
// ReqCamHeight# = 5.0
// Camsmooth = 20
// ColFlag = 0
//float positionX, positionY; // Position of the character
//float velocityX, velocityY; // Velocity of the character
//float gravity = 0.5f; // How strong is gravity
// void Update(float time)
// {
// positionX += velocityX * time; // Apply horizontal velocity to X position
// positionY += velocityY * time; // Apply vertical velocity to X position
// velocityY += gravity * time; // Apply gravity to vertical velocity
// }
//IF PLAYERS(1).JUMP_FLAG = FALSE THEN INC PLAYERS(1).VELOCITY.Y,.1
//IF PLAYERS(1).JUMP_FLAG = TRUE AND PLAYERS(1).VELOCITY.Y < -16.0 THEN PLAYERS(1).VELOCITY.Y = -16.0
// IF PLAYERS(1).JUMP_FLAG = TRUE AND ABS(PLAYERS(1).VELOCITY.Y) <1 THEN PLAYERS(1).JUMP_FLAG = FALSE
// IF PLAYERS(1).JUMP_FLAG = FALSE AND OBJECT COLLISION(OBJ,0) = FALSE THEN PLAYERS(1).VELOCITY.Y = PLAYERS(1).VELOCITY.Y * 2
// IF PLAYERS(1).JUMP_FLAG = TRUE THEN inc PLAYERS(1).VELOCITY.Y,1
// if PLAYERS(1).VELOCITY.Y = 14 then PLAYERS(1).JUMP_FLAG = FALSE
// IF PLAYERS(1).JUMP_FLAG = FALSE THEN dec PLAYERS(1).VELOCITY.Y,1
//
// if OBJECT COLLISION (obj,0) <> 0
// while OBJECT COLLISION (obj,0) <> 0
// POSITION OBJECT OBJ,playerx#,OBJECT POSITION y(obj) + 1,playerz#
// endwhile
// else
// POSITION OBJECT OBJ,playerx#,playery#,playerz#
// endif
//
// If sc_objectcollision(OBJ,0) <> 0 THEN EXITFUNCTION
// playerx# = object position x(OBJ)
// playery# = object position y(OBJ)
// playerz# = object position z(OBJ)
// dec playerY#
// POSITION OBJECT OBJ,playerx#,playery#,playerz#
//
I fixed the error I was getting by being extremely careful were I placed different things and if I had a // Comment before it because it was never ending the comment line for one causing the error I spoke of above in which Object 1 was not created because I just had a simple comment line above it,
ALSO It is not detecting the end of loops correctly on Do-For Etc, I have not tested a While loop yet.
Something is just really wrong with my IDE... My compiler.... or My computer just not 100% sure which is the source.