Ah, I see 29 games hath beaten me to it...
Well, here's my fixes anyway. I dunno if it will run coz
your media references don't match the file structure of your media archive and I can't mess around with that (I have mountains of work of my own. You'll find an error log at the top mentioning errors and changes.
remstart
ERROR LOG (Note that line numbers aren't accurate as this list grows - they are thereabouts):
-Use of elipsis "..." in comments causes errors with SOME DB editor/compilers
because it is used to merge the proceeding line
-Not commented
-at line 1107
-at line 1300
-Should be "EXITFUNCTION" not "EXIT FUNCTION"
-at line 507ish
-at line 1102ish
-Missing "IF" in conditional statement at line 1286ish
-Not declared
-"carinfoObjectNumber(n)"
-"freezertimer(n)"
-"myname$(n)"
-"connectiontype(n)"
-"thierplayernumber(n)"
-"carinforCarWeaponPower(n)"
-"specialobject(n)"
-"carinfomaxspeed(n)"
-"carinfoWeaponPower(n)"
-"specialobjectObjectNumber(n)"
-"projectileobjectnumber(30)"
-"projectileobjectspeed(30)"
-"projectileobjectTimer(30)"
-"projectileobjectdonedamge(30)"
-"projectileobjectdamage(30)"
-Typos ?
-projectileobjecttimer as "projectiletobjecttimer"
-projectileobjectspeed as "projectileobectspeed"
-projectileobjectnumber as "projectileobjectnum"
-projectileobjectdamage as "projectileobjectdamgae"
-specialobjectsObjectType as "specialobjetsObjectType"
-carinfoObjectNumber as "carinfoObjectNumbe"
-processSpecialobject as "processSpeicalobject"
-Variable and Array share a name - baaaad coding practice even if some languages allow it
-"myname$"
-"carinfomaxspeed"
remend
SYNC RATE 30
SYNC ON
DISABLE ESCAPEKEY `NEVER disble system keys on a learning project! Rather substitute in the future
AUTOCAM OFF
`CUSTOMS: Things to Declare
DIM carinfoObjectNumber(10)
DIM freezertimer(10)
DIM myname$(10)
DIM connectiontype(10)
DIM thierplayernumber(10)
DIM carinforCarWeaponPower(10)
DIM specialobject(10)
DIM carinfomaxspeed(10)
DIM carinfoWeaponPower(10)
DIM specialobjectObjectNumber(10)
DIM projectileobjectnumber(30)
DIM projectileobjectspeed(30)
DIM projectileobjectTimer(30)
DIM projectileobjectdonedamge(30)
DIM projectileobjectdamage(30)
`Special Types Defined
` This type contains the players information
` Their Name (name$)
` And if they are that player (Iam)
DIM playerinfoname$(2)
DIM playerinfoIam(2)
`This type references all the objects
` Laid through the level
` Objectnumber is the DarkBASIC object
` Objecttype is the type of object
` 3 = Health
` 4 = Speed
` 5 = Weapon
` 6 = Freeze
DIM specialobjectsObjectNumber(256)
DIM specialobjectsObjectType(256)
` This contains all the information about a
` project (what the car files)
` Objectnumber is the DarkBASIC object number.
` Objectspeed is how fast the projectile is going.
` Objecttimer is the time the projectile has to live
` Objectowner identifies who fired the projectile
` Objectdonedamage indicates if the object hit anything
` Objectdamage is how much damage the object can/will do
` Objecttype is the type of projectile being shot
DIM projectileObjectNumber(30)
DIM projectileObjecsSpeed(30)
DIM projectileObjectTimer(30)
DIM projectileObjectLive(30)
DIM projectileObjectOwner(30)
DIM projectileObjectDoneDamage(30)
DIM projectileObjectDamage(30)
DIM projectileObjectType(30)
` This type contains all the variables about the car
` ObjectStartX is the starting X position of the car
` ObjectStartZ is the starting Z position of the car
` There is no ObjectStartY because the car starts on
` the ground
` CarWeaponPower is how much Damage a shot from the
` car does
` CarAngle is the Angle the car is facing
` CarSpeed is the speed the car is going
` CarMaxSpeed is how fast the car can go
` CarHealth is how much health the car has left
` ObjectNumber is the DarkBASIC object number
DIM carinfoObjectStartX(2)
DIM carinfoObjectStartZ(2)
DIM carinfoCarWeaponPower(2)
DIM carinfoCarAngle(2)
DIM carinfoCarSpeed(2)
DIM carinfoCarMaxSpeed(2)
DIM carinfoCarHealth(2)
DIM carinfoCarObjectNumber(2)
` Global DIMS
` This contains your name
DIM yourname$(1)
` This contains connection TCPIP
` number
DIM connectType(1)
` This contains if a network connections
` was established
DIM nonetwork(1)
DIM myplayernumber(1)
` Contains what player number (They am)
` either 1 or 2 and is the opposite of
` myplayernumber
DIM theirplayernumber(1)
` Fire Counter to delay firing
DIM firecounter(1)
` How many special objects are out there
DIM specialobjcount(1)
` Stores whether other player quit or not
DIM hequit(1)
` Determines if the radar needs to be displayed
DIM showtheradar(1)
` Timer to freeze my car if need be
DIM freezetimer(1)
` If I'm host, this is 1
DIM Iamhost(1)
`Initialize the global DIMS
showtheradar(1) = 0
freezetimer(1) = 0
specialobjcount(1) = 0
myplayernumber(1) = 1
theirplayernumber(1) = 2
nonetwork(1) = 1
Iamhost(1) = 1
` Determine which connection is TCP/IP
ctype = STANDARDNETWORKSTUFF()
connectType(1) = ctype
` Process Menus and Play the game
WHILE PROCESSMENUS()=1
PLAYGAME()
ENDWHILE
END
`Process all the game menus
FUNCTION PROCESSMENUS()
flag = 0
retvalue = 1
` We need to loop until we have a game established..
` Once a game is established (or the player quits)
` Flag is set to 1
` Retvalue is used to determine if we need to play
` a game or not
WHILE flag = 0
` Display the Main Menu
command = MAINMENU()
` If they quit the main menu..
` Don't play the game
IF command = 3
flag = 1
retvalue = 0
ENDIF
IF command = 1
nonetwork(1) = 1
flag = 1
retvalue = 1
ENDIF
` Load up the multiplayer menus
IF command = 2
nonetwork(1) = 0
` Get their name
returnback = GETNAMESCREEN()
IF returnback <> -1
menucommand = -1
` Find out whose hosting and whose a client 3.
hostcommand = HOSTMENU()
IF hostcommand = 1
` If we are hosting wait for clients
menucommand = WAITFORHOSTMENU()
ENDIF
IF hostcommand = 2
` If we are client, look for the host
menucommand = CONNECTTOHOSTMENU()
ENDIF
IF hostcommand = 3
flag = 1
retvalue = 0
ENDIF
IF menucommand = -1
flag = 0
ELSE
flag = 1
ENDIF
ELSE
flag = 0
ENDIF
ENDIF
ENDWHILE
ENDFUNCTION retvalue
` PLAY THE MAIN GAME
FUNCTION PLAYGAME()
carinfoCarWeaponPower(1) = 1
carinfoCarWeaponPower(2) = 1
carinfoCarMaxSpeed(1) = 1
carinfoCarMaxSpeed(2) = 1
` Generates the Terrain for the level
GENERATELEVEL()
` Loads all the images for teh Heads Up Display (HUD)
LOAD IMAGE "Hud\Hud_all.bmp",20
LOAD IMAGE "Hud\Radar.bmp",21
LOAD IMAGE "Hud\RedBar.bmp",2
LOAD IMAGE "Hud\GreenBar.bmp",3
CREATE BITMAP 4,170,170
SET CURRENT BITMAP 0
` Intialized all the variables, models and sounds
INTIALLPROJECTILES()
LOADSOUNDS()
LOADCARMODELS()
INITIALSPECIALOBJECT()
SETCARLOCATION()
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
carinfoCarAngle(mynumber) = 0
carinfoCarSpeed(mynumber) = 0
sendlocationpacket_var = 0
firecounter(1) = 0
done = 0
hequit(1) = 0
myobjectnumber = carinfoCarObjectNumber(mynumber)
theirobjectnumber = carinfoCarObjectNumber(theirnumber)
` main game Loop-Exited when Done != 1
WHILE done = 0
` Check to see if radar should be displayed
IF SHIFTKEY()=1
showtheradar(1) = 1
ELSE
showtheradar(1) = 0
ENDIF
` Check to see if they quit
IF ESCAPEKEY()=1
SENDIQUITPACKET()
done = -1
ENDIF
` If they quit, I should quit too..
IF hequit(1) = 1
done = -1
ENDIF
` Process all the projectiles
PROCESSPROJECTILES()
` Process all the network packets
IF nonetwork(1) = 0
GET NET MESSAGE
IF NET MESSAGE EXISTS()<>0
PROCESSNETMESSAGES()
ENDIF
IF NET GAME LOST() = 1
done = -1
ENDIF
ENDIF
` Save the COORDS of my car
XLOC# = OBJECT POSITION X(myobjectnumber)
YLOC# = OBJECT POSITION Y(myobjectnumber)
ZLOC# = OBJECT POSITION Z(myobjectnumber)
YROT# = OBJECT ANGLE Y(myobjectnumber)
` Set the camera to follow my car
SET CAMERA TO FOLLOW XLOC#, YLOC#,ZLOC#, YROT#, -12, 5, 1, 1
`Reset my cars speed
carinfoCarSpeed(mynumber) = 0
carinfoCarSpeed(thiernumber) = 0
` Check to see if I'm frozen
IF freezetimer(1) > 0
secondsleft = freezertimer(1) - TIMER()
secondsleft = secondsleft / 1000
IF secondsleft < 0 THEN secondsleft = 0
newstring$ = "Frozen: "+STR$(secondsleft)+" seconds."
TEXT 0, 300,newstring$
IF TIMER() > freezetimer(1)
freezetimer(1) = 0
ENDIF
IF TIMER() < 10000
freezetimer(1) = 0
ENDIF
ENDIF
` Check to see if my car is moving or turning
sendlocationpacket_var = 0
sendlocationpacket_var = drivecar(mynumber)
lookforspacebarfire(mynumber)
carinfoCarAngle(mynumber) = WRAPVALUE(carinfoCarAngle(mynumber))
` Move and turn my car based on the value determined above
YROTATE OBJECT myobjectnumber, carinfoCarAngle(mynumber)
MOVE OBJECT myobjectnumber, carinfoCarSpeed(mynumber)
` If my var is colliding, move it back.
IF OBJECT COLLISION (myobjectnumber,theirobjectnumber) = 1
MOVE OBJECT myobjectnumber, carinfoCarSpeed(mynumber)*-1
ENDIF
` If my car collides with the edge of the world
XLOC# = OBJECT POSITION X(myobjectnumber)
ZLOC# = OBJECT POSITION Z(myobjectnumber)
IF XLOC# <= 0 OR XLOC# >= 320
MOVE OBJECT myobjectnumber, carinfoCarSpeed(mynumber)*-1
ENDIF
IF ZLOC# <= 0 OR ZLOC# >= 320
MOVE OBJECT myobjectnumber, carinfoCarSpeed(mynumber)*-1
ENDIF
` Tell the other player I've moved..
IF sendlocationpacket_var = 1 THEN SENDLOCATIONPACKET()
` Check for collisions to me..
checkforothercollisions(mynumber)
` Check for collisions to them
checkforothercollisions(theirnumber)
` Display the HUD
DISPLAYHUD()
` Display player's Name
DISPLAYPLAYERS()
` Determine the winner
` Set's Done to the Player's Number
` if there is a winner
IF done <> -1
done = GETWINNER()
ENDIF
` Display what we've processed
SYNC
ENDWHILE
`Send one final damage state so the other side knows who lost..
SENDDAMAGESTATE()
` Clean up everything allocated..
DELETE IMAGE 20
DELETE IMAGE 21
DELETE BITMAP 3
DELETE BITMAP 2
DELETE BITMAP 4
DELETE SOUND 1
DELETE SOUND 2
DELETE SOUND 3
KILLSPECIALOBJECT()
KILLLEVEL()
` Reset Camera
RESETCAMERA()
` If we have a winner display them
IF done <> -1
DISPLAYWINNER(done)
ENDIF
` Free the net game so we can start another
IF NET GAME EXISTS() = 1 THEN FREE NET GAME
` Delete the cars
DELETE OBJECT 2
DELETE OBJECT 1
ENDFUNCTION
` Loads the Terrain, Terrain texture, and
` Skybox Texture
FUNCTION GENERATELEVEL()
` Load the Terrain Texture
LOAD IMAGE "Terrain\texutre.bmp",10
`Make the terrain
MAKE MATRIX 1,320,320,10,10
PREPARE MATRIX TEXTURE 1, 10, 1, 1
` Load Skybox
LOAD OBJECT "Background\sky01.x",3
` Turn off collision with the skybox as
` the car is inside the sky box and will
` always collide with it otherwise
SET OBJECT COLLISION OFF 3
` Set the position, scale, and CULL of the
` Skybox
POSITION OBJECT 3,160,0,160
SCALE OBJECT 3,5000,5000,5000
ENDFUNCTION
FUNCTION KILLLEVEL()
` Free the Terrain
DELETE MATRIX 1
` Free the SkyBox Object
DELETE OBJECT 3
` Free the Terrain Texture
DELETE IMAGE 10
ENDFUNCTION
`Display the Main Menu
FUNCTION MAINMENU()
` Sets the ambient light
SET AMBIENT LIGHT 100
` Loads Resources for this Menu
LOAD OBJECT "Backgroundsky01.x",3
LOAD IMAGE "Menu\Menu.bmp",1
` Set Variables
flag = 0
backgroundangle = 0
black = rgb(0,0,0)
orange = rgb(255,102,0)
SET CURSOR 10, 10
` Loops until flag <> 0
WHILE flag = 0
IF ESCAPEKEY() = 1 THEN flag = 3
backgroundangle = backgroundangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3,backgroundangle
MX = MOUSEX()
MY = MOUSEY()
` Check to see if Multiplayer was selected
IF MX >230 AND MX <50 AND MY >180 AND MY<255
INK orange, black
BOX 230,180,500,225
IF MOUSECLICK() = 1 THEN flag = 2
ENDIF
` Paste the main menu image on the screen
PASTE IMAGE 1,0,0,1
SYNC
ENDWHILE
` Free rescources used in this menu
DELETE IMAGE 1
DELETE IMAGE 3
ENDFUNCTION flag
` Display the Host or Client Menu
FUNCTION HOSTMENU()
` Sets the ambient light
SET AMBIENT LIGHT 100
` Loads Rescources for this menu
LOAD OBJECT "Background\sky01.x",3
LOAD IMAGE "Menu\Multiplayer.bmp",1
` Set Variables
flag = 0
backgroundangle = 0
black = rgb(0,0,0)
orange = rgb(255,102,0)
SET CURSOR 10,10
`This loop ask the player to Host or
` Join a game.
` Loops until flag <> 0
WHILE flag = 0
backgroundangle = backgrounangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3,backgroundangle
MX = MOUSEX()
MY = MOUSEY()
` Check to see if host was selected
IF MX >320 AND MX <400 AND MY >110 AND MY<155
INK orange, black
BOX 230,110,400,155
IF MOUSECLICK() = 1 THEN flag = 1
ENDIF
` Check to see if join was selected
IF MX >230 AND MX <500 AND MY >180 AND MY < 225
INK orange, black
BOX 230,180,500,225
IF MOUSECLICK() = 1 THEN flag = 2
ENDIF
` Check to see if quit was selected
IF MX >230 AND MX <310 AND MY >390 AND MY <435
INK orange, black
BOX 230, 390, 310, 435
IF MOUSECLICK() = 1 THEN flag = 3
ENDIF
PASTE IMAGE 1,0,0,1
SYNC
ENDWHILE
` Free Rescources used in this menu
DELETE IMAGE 1
DELETE OBJECT 3
ENDFUNCTION flag
FUNCTION GETNAMESCREEN()
` Sets the ambient light
SET AMBIENT LIGHT 100
` loads rescources for this menu
LOAD OBJECT "Background\sky01.x",3
LOAD IMAGE "Menu\NameOnly.bmp",1
` Set Variables
flag = 0
backgroundangle= 0
black = rgb(0,0,0)
white = rgb(255,255,255)
INK white, black
SET CURSOR 10,10
B$ = ""
C$ = ""
CLEAR ENTRY BUFFER
` This loop collects the players name
` Loops until flag <> 0
WHILE flag = 0
IF ESCAPEKEY()=1 THEN flag = -1
backgroundangle = backgroundangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3, backgroundangle
IF RETURNKEY()=1 AND B$ <> ""
WHILE RETURNKEY()=1
ENDWHILE
flag = 1
ENDIF
CENTER TEXT 320, 260,"Enter Your Name"
A$ = INKEY$()
IF ASC(A$) = 8
C$ = C$ + ENTRY$()
C$ = LEFT$(C$,LEN(C$)-1)
CLEAR ENTRY BUFFER
ENDIF
B$ = C$ + ENTRY$()
CENTER TEXT 320,280,B$
PASTE IMAGE 1,0,0,1
SYNC
ENDWHILE
` Free Resources used in this menu
yourname$(1) = LEFT$(B$,LEN(B$)-1)
DELETE IMAGE 1
DELETE OBJECT 3
CLEAR ENTRY BUFFER
ENDFUNCTION flag
FUNCTION CONNECTTOHOSTMENU()
` Check for valid network connection
ctype = connectType(1)
retvar = 0 `When using EXITFUNCTION, no literals
IF ctype = 0: EXITFUNCTION retvar: ENDIF `ALSO NO SPACE, it's EXITFUNCTION, not "EXIT FUNCTION"
Iamhost(1) = 0
` Sets the ambient light
SET AMBIENT LIGHT 100
` Loads Resources for this menu
LOAD OBJECT "Background\sky01.x",3
LOAD IMAGE "Menu\NameOnly.bmp",1
` Set variables
myplayernumber(1) = 2
theirplayernumber(1) = 1
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
mynaam$ = myname$(1) `To quote Gordon Ramsey: "WHAT THE FU** IS THIS? "myname$ = myname$(1) - VARIABLE and ARRAY NEVER SHARE NAMES
flag = 0
backgroundangle = 0
black = rgb(0,0,0)
white = rgb(255,255,255)
INK white, black
SET CURSOR 10,10
B$ = ""
C$ = ""
CLEAR ENTRY BUFFER
` This loop get's the IP address
` of the host you are connecting to.
` It loops unitl flag <> 0
WHILE flag = 0
IF ESCAPEKEY() = 1 THEN flag = -1
backgroundangle = backgroundangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3, backgroundangle
IF RETURNKEY() = 1
WHILE RETURNKEY() = 1
ENDWHILE
flag = 1
ENDIF
CENTER TEXT 320,260,"Connecting to Client"
PASTE IMAGE 1,0,0,1
SYNC
ENDWHILE
` Free Resoures used int this menu
` if escape was pressed
IF flag = -1
DELETE IMAGE 1
DELETE OBJECT 3
EXITFUNCTION flag
ENDIF
GETPLAYERNAMES()
DELETE IMAGE 1
DELETE OBJECT 3
ENDFUNCTION flag
FUNCTION WAITFORHOSTMENU()
` Check for valid network connection
ctype = connectiontype(1)
IF ctype = 0 THEN EXITFUNCTION
Iamhost(1) = 1
SET NET CONNECTION ctype," "
mynaam$ = yourname$(1)
CREATE NET GAME "DUALRACER", mynaam$, 2
` Sets the ambient light
SET AMBIENT LIGHT 100
` Loads Resources for this menu
LOAD OBJECT "Background\sky01.x",3
LOAD IMAGE "Menu\NameOnly.bmp",1
` Set variables
myplayernumber(1) = 1
thierplayernumber(1) = 2
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
mynaam$ = myname$(1)
flag = 0
backgroundangle = 0
black = rgb(0,0,0)
white = rgb(255,255,255)
INK white, black
SET CURSOR 10, 10
` This waits until two players are joined in the
` game created on this computer
` It loops until flag <> 0
WHILE flag = 0
IF ESCAPEKEY() = 1 THEN flag = -1
backgroundangle = backgroundangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3,backgroundangle
PERFORM CHECKLIST FOR NET PLAYERS
numofplayers = CHECKLIST QUANTITY()
IF CHECKLIST QUANTITY() = 2
flag = 1
ENDIF
IF RETURNKEY() = 1
flag = 3
ENDIF
CENTER TEXT 320,260,"Waiting for Client"
newstring$ = "Players Waiting: "+STR$(numofplayers)
CENTER TEXT 320,280, newstring$
PASTE IMAGE 1,0,0,1
SYNC
ENDWHILE
` Free the resources if ESC was pressed
` Includes freeing the game.
IF flag = -1
FREE NET GAME
DELETE IMAGE 1
DELETE OBJECT 3
EXITFUNCTION flag
ENDIF
` Loads the players names into the correct
` variables
GETPLAYERNAMES()
` Free the resources if esc was pressed
DELETE IMAGE 1
DELETE OBJECT 3
ENDFUNCTION flag
` Records the players names into the
` PlayerInfo 3. globals
FUNCTION GETPLAYERNAMES()
PERFORM CHECKLIST FOR NET PLAYERS
NUMOFPLAYERS = CHECKLIST QUANTITY()
FOR x = 1 TO NUMOFPLAYERS
playerinfoname$(x) = CHECKLIST STRING$(x)
IF playerinfoname$(x) = yourname$(x)
playerinfoiam(x) = 1
ELSE
playerinfoiam(x) = 0
ENDIF
NEXT x
ENDFUNCTION
` Displays the players name on the screen
FUNCTION DISPLAYPLAYERS()
black = rgb(0,0,0)
white = rgb(255,255,255)
INK white, black
FOR x = 1 to 2
TEXT 10,(x*10)+20,playerinfoname$(x)
NEXT x
ENDFUNCTION
` Displays the heads up display on the screen
FUNCTION DISPLAYHUD()
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
PASTE IMAGE 1,0,0,1
COPY BITMAP 3,0,0,199,11,0,20,440,220,452
COPY BITMAP 3,0,0,199,11,0,20,460,220,472
` Displays the health of both cars
XSIZE = carinfoCarHealth(mynumber)*2
IF XSIZE <> 0
COPY BITMAP 2,0,0,XSIZE-1,11,0,20,440,20+XSIZE,452
ENDIF
XSIZE = carinfoCarHealth(theirnumber)*2
IF XSIZE <> 0
COPY BITMAP 2,0,0,XSIZE-1,11,0,20,460,20+XSIZE,472
ENDIF
IF SHOWTHERADAR(1)=1 THEN DISPLAYRADAR()
ENDFUNCTION
` Display the RADAR on the screen
FUNCTION DISPLAYRADAR()
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
myobjnumber = carinfoObjectNumber(mynumber)
myxpos = OBJECT POSITION X(myobjnumber)
myzpos = OBJECT POSITION Z(myobjnumber)
theirobjnumber = carinfoObjectNumber(theirnumber)
theirxpos = OBJECT POSITION X(theirobjnumber)
theirzpos = OBJECT POSITION Z(theirobjnumber)
myxpos = myxpos / 2
myypos = myypos / 2
theirxpos = thierxpos / 2
theirypos = theirypos / 2
myxpos = myxpos+5
myypos = myypos+5
theirxpos = thierxpos+5
theirypos = theirypos+5
` Display the players positions
green = rgb(0,255,0)
red = rgb(255,0,0)
white = rgb(255,255,255)
black = rgb(0,0,0)
SET CURRENT BITMAP 4
PASTE IMAGE 21,0,0,0
X1 = myxpos-2
X2 = myxpos+2
Y1 = myypos-2
Y2 = myypos+2
INK green, black
BOX X1,X2,Y1,Y2
X1 = theirxpos-2
X2 = theirxpos+2
Y1 = theirypos-2
Y2 = theirypos+2
INK red, black
BOX X1,X2,Y1,Y2
INK white, black
` Display all projectiles being fired.
FOR x = 1 TO 30
pobj = projectileobjectnumber(x)
IF OBJECT EXIST(pobj)
PROX = OBJECT POSITION X(pobj)
PROY = OBJECT POSITION Z(pobj)
PROX = PROX/2
PROY = PROY/2
PROX = PROX+5
PROY = PROY+5
X1 = PROX-2
X2 = PROX+2
Y1 = PROY-2
Y2 = PROY+2
BOX X1,Y1,X2,Y2
ENDIF
NEXT x
SET CURRENT BITMAP 0
COPY BITMAP 4,0,0,169,169,0,465,75,634,244
ENDFUNCTION
` Sets all the projectiles to a base state
FUNCTION INTIALLPROJECTILES()
FOR x = 1 TO 30
projectileobjectnumber(x) = 49 + x
projectileobjectspeed(x) = 0
projectileobjectlive(x) = 0
projectileobjectTimer(x) = 0
projectileobjectowner(x) = 0
projectileobjectdonedamge(x) = 0
projectileobjectdamage(x) = 0
projectileobjectType(x) = 0
NEXT x
ENDFUNCTION
` Process all the projectiles
FUNCTION PROCESSPROJECTILES()
FOR x = 1 TO 30
objnumber = projectileobjectnumber(x)
objspeed = projectileobjectspeed(x)
objtimer = projectileobjectTimer(x)
` Make sure the object exists
` if it does not, the projectile
` has not been fired yet
IF OBJECT EXIST (objnumber) = 1
` Move the projectile forward
MOVE OBJECT objnumber, objspeed
` Decrease the object timer
projectileobjectTimer(x) = objtimer - 1
` Check for the end of the projectile
IF projectileobjectTimer(x) <= 10
GHOST OBJECT ON objnumber
FADE OBJECT objnumber, 25
ENDIF
` Free the projectile if it's at the end 3.
IF projectileobjectTimer(x) <= 0
projectileobjectLive(x) = 0
projectileobjectowner(x) = 0
DELETE OBJECT objnumber
ENDIF
ENDIF
NEXT x
ENDFUNCTION
` This function is called when a projectile
` collides with another player
FUNCTION DAMAGEPLAYER(playernum , damagedone)
mynumber = myplayernumber(1)
` You can't get hit by your own projectile
IF playernum <> mynumber THEN EXITFUNCTION
` Reduce their health
carinfoCarHealth(playernum) = carinfoCarHealth(playernum) - damagedone
` If the health is less then 0 make it equal to 0
IF carinfoCarHealth(playernum) < 0
carinfoCarHealth(playernum) = 0
ENDIF
` Send the damage information to the other player
SENDDAMAGESTATE()
ENDFUNCTION
` This function is called when the projectile collides with a player
FUNCTION EXPLODEPROJECTILE(projectilenum)
projectileobjectTimer(projectilenum) = 10
projectileobjectspeed(projectilenumb) = 0
projectileobjectdonedamage(projectilenum) = 1
ENDFUNCTION
` This is called when a projectile needs to be fired.
FUNCTION FIREPROJECTILE(playernum, projectiletype)
flag = 0
` This set of IF and FOR statements determine the
` next particle availible to you
IF playernum = 1
FOR x = 1 to 15
IF projectileobjectlive(x) = 0
flag = x
x = 30
ENDIF
NEXT x
ELSE
FOR x = 16 to 30
IF projectileobjectlive(x) = 0
flag = x
x = 30
ENDIF
NEXT x
ENDIF
` If no particles are availible leave this function
` You don't want to fire blanks
IF flag = 0
EXITFUNCTION flag
ENDIF
` Setup the Data for the Particle
projectileobjectowner(flag) = playernum
proObjectnum = projectileobjectnumber(flag)
carobjectnumber = carinfoObjectNumber
Xpos# = OBJECT POSITION X(carobjectnumber)
Ypos# = OBJECT POSITION Y(carobjectnumber)
Zpos# = OBJECT POSITION Z(carobjectnumber)
Xrot# = OBJECT ANGLE X(carobjectnumber)
Yrot# = OBJECT ANGLE Y(carobjectnumber)
Zrot# = OBJECT ANGLE Z(carobjectnumber)
` Created the particle VIA the MAKE OBJECT SPHERE
` command
MAKE OBJECT SPHERE proObjectnum, 2
` SCALE POSITION and Size the particle
SCALE OBJECT proObjectnum, 25,25,25
POSITION OBJECT proObjectnum, Xpos#, Ypos#, Zpos#
ROTATE OBJECT proObjectnum, Xrot#, Yrot#, Zrot#
MOVE OBJECT proObjectnum, -2
` Turn on the collision for the particle
SET OBJECT COLLISION ON proObjectnum
SET OBJECT COLLISION TO BOXES proObjectnum
` Set the remaining values for the Particle
projectileObjectSpeed(flag) = carmaxspeed-1
projectileObjectTimer(flag) = 100
projectileObjectLive(flag) = 1
projectileObjectDamage(flag) = carinforCarWeaponPower(playernum)
ProjectileObjectDoneDamage(flag) = 0
ProjectileObjectType(flag) = projectiletype
` Play fire sound
PLAY SOUND 1
ENDFUNCTION FLAG
` Sends location packets
FUNCTION SENDLOCATIONPACKET()
`If there is no network 3. Don't send the packet
IF nonetwork(1) = 1 THEN EXITFUNCTION
MAKE MEMBLOCK 1,60
` Collectes the location infromation
mynumber = myplayernumber(1)
myspeed = carinfoCarSpeed(mynumber)
myobjectnumber = carinfoObjectNumber(mynumber)
Xpos# = OBJECT POSITION X(myobjectnumber)
Ypos# = OBJECT POSITION Y(myobjectnumber)
Zpos# = OBJECT POSITION Z(myobjectnumber)
Xrot# = OBJECT ANGLE X(myobjectnumber)
Yrot# = OBJECT ANGLE Y(myobjectnumber)
Zrot# = OBJECT ANGLE Z(myobjectnumber)
myhealth = carinfoCarHealth(mynumber)
` Writes all the location information into the memblock
WRITE MEMBLOCK DWORD 1,1,1
WRITE MEMBLOCK FLOAT 1,5,Xpos#
WRITE MEMBLOCK FLOAT 1,9,Ypos#
WRITE MEMBLOCK FLOAT 1,13,Zpos#
WRITE MEMBLOCK FLOAT 1,17,Xrot#
WRITE MEMBLOCK FLOAT 1,21,Yrot#
WRITE MEMBLOCK FLOAT 1,25,Zrot#
WRITE MEMBLOCK DWORD 1,29,myhealth
` Sends the packet
SEND NET MESSAGE MEMBLOCK 0,1,1
DELETE MEMBLOCK 1
ENDFUNCTION
`Sends projectile packets.
FUNCTION SENDPROJECTILEPACKET(objectnum,projectiletype)
` If there is no netowrk 3. don't send the packet!
IF nonetwork(1) = 1 THEN EXITFUNCTION
MAKE MEMBLOCK 1,50
` Collectes the location infromation
mynumber = myplayernumber(1)
newnumber = projectileobjectnumber(objectnum)
myobjectnumber = carinfoObjectNumber(mynumber)
Xpos# = OBJECT POSITION X(myobjectnumber)
Ypos# = OBJECT POSITION Y(myobjectnumber)
Zpos# = OBJECT POSITION Z(myobjectnumber)
Xrot# = OBJECT ANGLE X(myobjectnumber)
Yrot# = OBJECT ANGLE Y(myobjectnumber)
Zrot# = OBJECT ANGLE Z(myobjectnumber)
myhealth = carinfoCarHealth(mynumber)
` Writes all the location
` and firing information
` into memblock
WRITE MEMBLOCK DWORD 1,1,2
WRITE MEMBLOCK FLOAT 1,5,Xpos#
WRITE MEMBLOCK FLOAT 1,9,Ypos#
WRITE MEMBLOCK FLOAT 1,13,Zpos#
WRITE MEMBLOCK FLOAT 1,17,Xrot#
WRITE MEMBLOCK FLOAT 1,21,Yrot#
WRITE MEMBLOCK FLOAT 1,25,Zrot#
WRITE MEMBLOCK DWORD 1,29,projectiletype
WRITE MEMBLOCK DWORD 1,33,objectnum
WRITE MEMBLOCK DWORD 1,37,myhealth
` Sends the packet
SEND NET MESSAGE MEMBLOCK 0,1,1
DELETE MEMBLOCK 1
ENDFUNCTION
` Sends the Quitting packet... 3.
FUNCTION SENDIQUITPACKET()
IF nonetwork(1) = 1 THEN EXITFUNCTION
MAKE MEMBLOCK 1,50
WRITE MEMBLOCK DWORD 1,1,4
` Sends the packet... 3.
SEND NET MESSAGE MEMBLOCK 0,1,1
DELETE MEMBLOCK 1
ENDFUNCTION
` Sends Damages State packets
FUNCTION SENDDAMAGESTATE()
` If there is no network.. don't send the packet
IF nonetwork(1) = 1 THEN EXITFUNCTION
MAKE MEMBLOCK 1,50
` Collects damage information
mynumber = myplayernumber(1)
myhealth = carinfoCarHealth(mynumber)
` Writes the damage information to the MEMBLOCK
WRITE MEMBLOCK DWORD 1,1,5
WRITE MEMBLOCK DWORD 1,5,myhealth
` Sends the packet
SEND NET MESSAGE MEMBLOCK 0,1,1
DELETE MEMBLOCK 1
ENDFUNCTION
` Processes all the network messages (Packets).
FUNCTION PROCESSNETMESSAGES()
`If there is no network.. Don't send
IF nonetwork(1) = 1 THEN EXITFUNCTION
MAKE MEMBLOCK 2,50
theirnumber = theirplayernumber(1)
` Loops while we still have some network messages to read..
WHILE NET MESSAGE EXISTS()=1
` Get the message
NET MESSAGE MEMBLOCK 2
` The first DWORD in the message is the command
cmdnumber = MEMBLOCK DWORD(2,1)
` This was a location packet
IF cmdnumber = 1
theirobjnum = carinfoObjectNumber(theirnumber)
Xpos# = MEMBLOCK FLOAT (2,5)
Ypos# = MEMBLOCK FLOAT (2,9)
Zpos# = MEMBLOCK FLOAT (2,13)
Xrot# = MEMBLOCK FLOAT (2,17)
Yrot# = MEMBLOCK FLOAT (2,21)
Zrot# = MEMBLOCK FLOAT (2,25)
newhealth = MEMBLOCK DWORD(2,29)
carinfoCarHealth(theirnumber) = newhealth
POSITION OBJECT theirobjnum, Xpos#, Ypos#, Zpos#
ROTATE OBJECT theirobjnum, Xrot#, Yrot#, Zrot#
carinfoCarAngle(theirnumber) = Yrot
ENDIF
` This was a Projectile packet
IF cmdnumber = 2
theirobjnum = carinfoObjectNumber(theirnumber)
Xpos# = MEMBLOCK FLOAT (2,5)
Ypos# = MEMBLOCK FLOAT (2,9)
Zpos# = MEMBLOCK FLOAT (2,13)
Xrot# = MEMBLOCK FLOAT (2,17)
Yrot# = MEMBLOCK FLOAT (2,21)
Zrot# = MEMBLOCK FLOAT (2,25)
newhealth = MEMBLOCK DWORD (2,37)
carinfoCarHealth(theirnumber) = newhealth
POSITION OBJECT theirobjnum, Xpos#, Ypos#, Zpos#
ROTATE OBJECT theirobjnum, Xrot#, Yrot#, Zrot#
projectiletype = MEMBLOCK DWORD(2,29)
FIREPROJECTILE(theirnumber,projectiletype)
ENDIF
` This was a Quit Packet
IF cmdnumber = 4
HEQUIT(1) = 1
ENDIF
` This was a damage packet.
IF cmdnumber = 5
newhealth = MEMBLOCK DWORD(2,5)
carinfoCarHealth(theirnumber) = newhealth
ENDIF
` Get the next message
GET NET MESSAGE
ENDWHILE
DELETE MEMBLOCK 2
ENDFUNCTION
` Determine what connection number
` TCP/IP is
FUNCTION STANDARDNETWORKSTUFF()
flag = 0
CLS
PERFORM CHECKLIST FOR NET CONNECTIONS
FOR x = 1 TO CHECKLIST QUANTITY()
service$ = CHECKLIST STRING$(x)
IF LEFT$(service$,15)="Internet TCP/IP"
flag = x
ENDIF
NEXT x
ENDFUNCTION flag
` Data Format
` Object Number, Xpos, Zpos, ObjectType
` Health Powerups
DATA 55,250,3,31
DATA 25,150,3,31
DATA 178,192,3,31
DATA 299,170,3,31
DATA 49,21,3,31
DATA 62,130,2,31
DATA 71,49,3,31
DATA 99,112,3,31
DATA 57,38,3,31
DATA 22,245,3,31
` Speed Powerups
DATA 15,131,4,32
DATA 263,42,4,32
`Weapon PowerUp
DATA 10,310,5,33
DATA 310,10,5,33
DATA 10,10,5,33
DATA 310,310,5,33
DATA 130,18,5,33
DATA 301,22,5,33
DATA 41,108,5,33
DATA 163,23,5,33
` Freeze Powerup
DATA 47,180,6,34
DATA 220,20,6,34
DATA 77,111,6,34
DATA 125,132,6,34
`Initializes all the special objects and their placement
FUNCTION INITIALSPECIALOBJECT()
newobjectnum = 500
specialobjcount(1) = 0
objcount = 1
` Load all the textures
LOAD IMAGE "Pieces\Health.bmp",31
LOAD IMAGE "Pieces\Speed.bmp",32
LOAD IMAGE "Pieces\Weapon.bmp",33
LOAD IMAGE "Pieces\Freeze.bmp",34
FOR x = 1 to 24
READ Xloc
READ Zloc
READ objtype
READ textnum
MAKE OBJECT BOX newobjectnum,2,2,2
TEXTURE OBJECT newobjectnum,textnum
POSITION OBJECT newobjectnum, Xloc,1,Zloc
specialobjectsObjectNumber(objcount) = newobjectnum
specialobjectsObjectType(objcount) = objtype
SET OBJECT COLLISION ON newobjectnum
objcount = objcount + 1
newobjectnum = newobjectnum + 1
NEXT x
specialobject(1) = 24
ENDFUNCTION
` Process the effects of special objects on the car
FUNCTION PROCESSSPECIALOBJECT(objectindex,player)
theirnumber = theirplayernumber(1)
mynumber = myplayernumber(1)
phealth = carinfoCarHealth(player)
spobjnum = specialobjectsObjectNumber(objectindex)
SELECT specialobjectsObjectType(objectindex)
` Health objects
CASE 3
IF phealth = 100 THEN EXITFUNCTION 0 `EXITFUNCTION not "EXIT FUNCTION"
IF phealth > 75 `<-------------- Calls Syntax Error `Missing Comment
carinfoCarHealth(player) = 100
ELSE
carinfoCarHealth(player) = phealth + 75
ENDIF
IF OBJECT EXIST(spobjnum)
DELETE OBJECT spobjnum
ENDIF
ENDCASE
` Speed objects
CASE 4
IF carinfoCarMaxSpeed(player) = 2 THEN EXITFUNCTION 0
carinfomaxspeed(Player) = carinfo_maxspeed + 1 `NEIN
IF OBJECT EXIST(spobjnum)
DELETE OBJECT spobjnum
ENDIF
ENDCASE
` Weapons Powerup
CASE 5
weppow = carinfoCarWeaponPower(player)
IF weppow = 5 THEN EXITFUNCTION 0
carinfoWeaponPower(player) = weppow + 1
IF OBJECT EXIST(spobjnum)
DELETE OBJECT spobjnum
ENDIF
ENDCASE
` Speed Power Up
CASE 6
IF player = theirnumber
freezetimer(1) = TIMER()+1000
ENDIF
IF OBJECT EXIST(spobjnum)
DELETE OBJECT spobjnum
ENDIF
ENDCASE
ENDSELECT
ENDFUNCTION 1
` Frees all unused special objects
FUNCTION KILLSPECIALOBJECT()
specialcount = specialobjcount(1)
FOR x = 1 TO specialobjcount(1)
objnum = 499+x
IF OBJECT EXIST(objnum)
DELETE OBJECT objnum
ENDIF
NEXT x
` Frees the textures as well
DELETE IMAGE 31
DELETE IMAGE 32
DELETE IMAGE 33
DELETE IMAGE 34
ENDFUNCTION
` Loads all the car models
FUNCTION LOADCARMODELS()
` Loads the models
LOAD OBJECT "models\Beach Bug\H-Beach Bug-move.x",1
LOAD OBJECT "models\Beach Bug\L-Beach Bug-move.x",2
LOAD OBJECT "models\Beach Bug 2\H-Beach Bug 2-move.x",3
LOAD OBJECT "models\Beach Bug 2\L-Beach Bug 2-move.x",4
` Sets's their collision on
SET OBJECT COLLISION TO BOXES 1
SET OBJECT COLLISION TO BOXES 2
SET OBJECT COLLISION TO BOXES 3
SET OBJECT COLLISION TO BOXES 4
SET OBJECT COLLISION ON 1
SET OBJECT COLLISION ON 2
SET OBJECT COLLISION ON 3
SET OBJECT COLLISION ON 4
` Set theri objectnumber
carinfoObjectNumber(1) = 1 OR 2
carinfoObjectNumber(2) = 3 OR 4
` Set their car health
carinfoCarHealth(1) = 100
carinfoCarHealth(2) = 100
ENDFUNCTION
` Loads all the sounds Used
FUNCTION LOADSOUNDS()
LOAD SOUND "sounds\FIRE.WAV",1
LOAD SOUND "sounds\HIT.WAV",2
LOAD SOUND "sounds\PICKUP.WAV",3
ENDFUNCTION
` Positions the car in the world
FUNCTION SETCARLOCATION()
Xloc# = 25
Zloc# = 25
objnum = carinfoObjectNumber(1)
POSITION OBJECT objnum,Xloc#,0,Zloc#
Xloc# = 295
Zloc# = 295
objnum = carinfoObjectNumber(2)
POSITION OBJECT objnum,Xloc#,0,Zloc#
` Send an object packet so the other
` player knows where you are
SENDLOCATIONPACKET()
ENDFUNCTION
` This function drives the car around
` the world
FUNCTION DRIVECAR(carnumber)
` If your frozen, you can't drive
IF freezetimer(1) <> 0 THEN EXITFUNCTION 0
` Set the Variables
mynumber = carnumber
sendlocationpacket_var = 0
maxcarspeed = carinfoCarMaxSpeed(mynumber)
` Check for Forward motion
IF UPKEY()=1
carinfoCarSpeed(mynumber) = maxcarspeed*-1
sendlocationpacket_var = 1
ENDIF
` Check for Backward Motion
IF DOWNKEY()=1
carinfoCarspeed(mynumber) = maxcarspeed*1
sendlocationpacket_var = 1
ENDIF
curangle = carinfoCarAngle(mynumber)
` Check for Backwards motion and
` Turning Left
IF LEFTKEY()= 1 AND carinfoCarSpeed(mynumber)>0
carinfoCarAngle(mynumber) = curangle +5
IF carinfoCarAngle(mynumber) > 360
carinfoCarAngle(mynumber) = 5
ENDIF
sendlocationpacket_var = 1
ENDIF
` Check for foward motion and
` turning left
IF LEFTKEY()=1 AND carinfoCarSpeed(mynumber)<0
carinfoCarAngle(mynumber) = curangle -5
IF carinfoCarAngle(mynumber) < 0
carinfoCarAngle(mynumber) = 355
ENDIF
sendlocationpacket_var = 1
ENDIF
` Check for Backwards motion and
` Turning right
IF RIGHTKEY()= 1 AND carinfoCarSpeed(mynumber)>0
carinfoCarAngle(mynumber) = curangle -5
IF carinfoCarAngle(mynumber) < 0
carinfoCarAngle(mynumber) = 355
ENDIF
sendlocationpacket_var = 1
ENDIF
` Check for foward motion and
` turning right
IF RIGHTKEY()=1 AND carinfoCarSpeed(mynumber)<0
carinfoCarAngle(mynumber) = curangle +5
IF carinfoCarAngle(mynumber) > 360
carinfoCarAngle(mynumber) = 5
ENDIF
sendlocationpacket_var = 1
ENDIF
ENDFUNCTION sendlocationpacket_var
` Detects if the space bar was pressed
` and if it was, fires a projectile
FUNCTION LOOKFORSPACEBARFIRE(carnumber)
mynumber = carnumber
` Checks the fire counter to space out
` the projectiles
IF SPACEKEY()=1 AND firecounter(1) = 0
flag = fireprojectile(mynumber,1)
IF flag <> 0
SENDPROJECTILEPACKET(flag,1)
ENDIF
firecounter(1) = 5
ENDIF
IF firecounter(1)>0
firecounter(1) = firecounter(1) -1
ENDIF
ENDFUNCTION
`Checks for collision with other objects.
FUNCTION CHECKFOROTHERCOLLISIONS(playernumber)
theirnumber = theirplayernumber(1)
mynumber = myplayernumber(1)
carobjnum = carinfoObjectNumber(playernumber)
` If the player isn't colliding, Quit 3.
IF objectnumcolide = 0 THEN EXITFUNCTION `Missing "IF"
flag = 0
` Check if the player is colliding with 3.
` projectiles
FOR x = 1 TO 30
pobjnum = projectileObjectNumber(x)
pobjown = projectileObjectOwner(x)
pobjdmg = projectileObjectDamage(x)
IF objectnumcolide = pobjnum and pobjown <> playernumber
SET OBJECT COLLISION OFF pobjnum
DAMAGEPLAYER(playernumber , pobjdmg)
STOP SOUND 1
PLAY SOUND 2 `<---Syntax error again `Was not commented
EXPLODEPROJECTILE(x)
flag = 1
ENDIF
NEXT x
`If they collide with a projectile quit..
` No need to process further
IF flag = 1 THEN EXITFUNCTION
` Check if the player is colliding with
` Special objects
flag = 0
FOR x = 1 TO 25
IF objectnumcolide = specialobjectObjectNumber(x)
flag = x
x = 25
ENDIF
NEXT x
IF flag <> 0
newflag = processSpecialobject(flag,playernumber)
ENDIF
ENDFUNCTION
` Determines the winner
FUNCTION GETWINNER()
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
IF carinfoCarHealth(mynumber) <= 0
EXITFUNCTION theirnumber
ENDIF
IF carinfoCarHealth(theirnumber) <= 0
EXITFUNCTION mynumber
ENDIF
ENDFUNCTION 0
` Displays the Winning Screen
FUNCTION DISPLAYWINNER(winnernumber)
` Sets Ambient Light
SET AMBIENT LIGHT 100
` Loads the sky box
LOAD OBJECT "Background\skybox01.x",3
black = rgb(0,0,0)
white = rgb(255,255,255)
INK white,black
POSITION OBJECT carinfoObjectNumber(winnernumber), 0,0,5
mynumber = myplayernumber(1)
theirnumber = theirplayernumber(1)
IF winnernumber = mynumber
IF playerinfoIam(1) = 1
winnertext$ = playerinfoname$(1)
ELSE
winnertext$ = playerinfoname$(2)
ENDIF
ENDIF
IF winnernumber = theirnumber
IF playerinfoIam(1) = 0
winnertext$ = playerinfoname$(1)
ELSE
winnertext$ = playerinfoname$(2)
ENDIF
ENDIF
winnertext$ = winnertext$ +" is the winner!"
backgroundangle = 0
winobjnum = carinfoObjectNumber(winnernumber)
flag = 0
` Waits until the ESCAPEKEY is pressed
WHILE flag = 0
backgroundangle = backgroundangle + 1
backgroundangle = WRAPVALUE(backgroundangle)
YROTATE OBJECT 3,backgroundangle
YROTATE OBJECT winobjnum, backgroundangle
CENTER TEXT 320,40,winnertext$
IF RETURNKEY() =1 THEN flag = 1
SYNC
ENDWHILE
` Free the skybox
DELETE OBJECT 3
ENDFUNCTION
` Resets the camera
FUNCTION RESETCAMERA()
POSITION CAMERA 0,0,0
ROTATE CAMERA 0,0,0
ENDFUNCTION
I have made
many assumptions but got it working to the point where if
I press
F4 it works.In otherwords the code compiles. What it deoes is anybody's guess.
Quote: "to be quite honest it's all been a bit of a nightmare"
I think that's an
understatement - the 99th circle of hell perhaps.
But yeah, what 29 games said is right. VGHero11, you need to revise the entire way you code, especially if you intend to do large projects or any team work.
Here are some suggestions for future endeavors:
Firstly:
INDENT YOUR CODE CODE (DOUBLE INDENT IF YOU USE UPPERCASE).
2. Never ever ever ever share variable names, ie var, var$, var(10)
3. Don't use naming conventions that cause typos if you make many typos yourself. Using an underscore may help make variable legible.
4. The best way to name your variables is the Hungarian naming system. For DBPro, I use my own derivative:
`I only do this with global stuff
`Constants
#CONSTANT c_mycon 100
`Globals
GLOBAL flo_aspect# AS FLOAT: flo_aspect# = 1.777
GLOBAL str_name$ AS STRING: str_name$ = "Dark Basic"
`Arrays
DIM arr_myvar(10)
`Program
PRINT a()
END
Function a()
LOCAL shoesize AS INTEGER: shoesize = 9
EndFunction shoesize
This lets you know just by looking at it, exactly what it is and what it's for. Locals aren't that important because they're bound by the function/module's scope so they are easy to track
and you know they are local because they are without prefix. Ultimately how you name variables is up to you, but you should think about rule sets.
5. If an array has 1 dimension, make it a global. In general you shoud pick your type carefully which brings me to...
6. If you have an "object", rather than haveing objectABC, objectDEF, objectQWERTY, objectnumber, consider using UDTs, ie: object.abc, object.def, etc. It mey help tracking although it can require more management.
7. ECHO
Quote: "I appreciate that you did a lot of typing but you really need to pay attention to this sort of detail."
Be mindful. Check for spelling errors, etc. every 20 lines.
8. ECHO
Quote: "I generally compile and run my code when I complete each section (which is generally no more than a hundred lines at a time)"
Quote: "also an EDIT log to tell future readers whata changed is helpful this is also optional"
I don't bother unless it's a significant edit and if somebody has posted before my edit. I usually use "[EDIT]....[/EDIT]" to enclose my appends or edit logs.