Monday 16 April 2012

Another Tidy Up

Time for another tidy up.

Some of the test code we used needs to be incorporated into the program, some of it need to go.

First to clear out the dead wood.

From the start of the program, we remove the following lines.
testObject1 = AddWorkObject( 1 , 0 )
CreateWorkObjectSprite( testObject1 , 100 , 100 )
testObject2 = AddWorkObject( 10 , 0 )
CreateWorkObjectSprite( testObject2 , 200 , 200 )
as well as
thisSrc$ = ""
for i=1 to 10
   thisValue = random( 0 , 9215 )
   thisSrc$ = thisSrc$ + Base96Encode( thisValue )
next i
thisSort$ = Base96Sort( thisSrc$ )
From the main loop we remove.
for i=0 to 9
   thisCode$ = Base96Encode( i )
   thisDecode = Base96Decode( thisCode$ )
   s$ = chr(34) + thisCode$ + chr(34)
   s$ = s$ + " = " + str( thisDecode )
   print( str(i) + " = " + s$ )
next i
for i=95 to 104
   thisCode$ = Base96Encode( i )
   thisDecode = Base96Decode( thisCode$ )
   s$ = chr(34) + thisCode$ + chr(34)
   s$ = s$ + " = " + str( thisDecode )
   print( str(i) + " = " + s$ )
next i
print("")
print(chr(34)+ thisSrc$ + chr(34))
print(chr(34)+ thisSort$ + chr(34))
print("")
for i=1 to 10
   thisCodeSrc = Base96Decode( mid( thisSrc$ , i*2 - 1 , 2 ) )
   thisCodeDst = Base96Decode( mid( thisSort$ , i*2 - 1 , 2 ) )
   printc( right( spaces(1) + str( i ), 2) + " : ")
   printc( right( spaces(3) + str( thisCodeSrc ), 4) + " : ")
   print( right( spaces(3) + str( thisCodeDst ), 4))
next i
Which leaves things a little better.

Next up - we tidy up our test output, by changing the lines
printc( "Physical: " )
print( str( PhysWidth() ) + " x " + str( PhysHeight() ) )
to
printc( "Phy: " + str( PhysWidth() , 0) + " x " + str( PhysHeight() , 0 ))
Which combines both these lines and reduces the output in two ways.
  • It uses Phy: instead of Physical,
  • It prevents display of decimal places
Using a second value with the str() command instructs it to use that many decimal paces when converting the first value to a string.  As the display is a whole number of pixels across and down, we don't need to show any more.

Now add this line immediately after.
printc( ", Vir: " + str( VirtWidth() , 1) + " x " + str( VirtHeight() , 1 ))
Which now displays the Virtual screen size, but this time uses two decimal places.

As the Virtual resolution is not tied to a physical screen dot, and can use scaled values, these may at some point have decimal places.  But one should be plenty to show the difference.

Both use printc(), which doesn't end the line, so there is more to come.

Now move the existing line.
print( "FPS: " + str ( lastFPS() ) )
to after these and change it to
print( ", @ " + str ( lastFPS() , 2 ) + " fps" + chr(10) )
Which displays the frame rate at the end, using 2 decimal places.
Now both screen resolutions and the frame rate have been condensed onto 1 display line to reduce on-screen clutter.
I did say REDUCE there.

No comments:

Post a Comment