Looks nice Roxas! But maybe a little too dark
Andrew and I, on MSN, we worked out a good structure for the game.
Here it goes...
Name : TGC Heroes
The code in the game has a strict structure. Every coder works on different parts of the game, but they follow the structure that we have. This way, you can easily just copy paste into the main code and it'll work smoothly.
If you want to add global variables, then just drop some in at the bottom of the code. Everything in the main loop MUST be a function or just a simple command.
Here it is so far folks. I get 230 fps and Andrew(TEH_CODERER) gets 250 fps. Please run this code and tell us what FPS you get with it.
REM Project: TGC Heroes
REM Created: 3/30/2007 4:35:18 PM
REM
REM ***** Main Source File *****
REM
Initialize()
CreatePlayer(1,"Box","Small")
CreatePlayer(2,"Cone","Large")
CreatePlayer(3,"Pole","Medium")
CreatePlayer(4,"Cube","Large")
CreatePlayer(5,"Sphere","Medium")
`This Has to ALWAYS Be right before the loop!
SetupTimerBasedSystem(180)
Do
HandleScreenText(20,20)
`The Actual Speed for all objects to move at is MFrame#
HandleTimerBasedSystem()
FastSync
Loop
Function Initialize()
Sync On
Sync Rate 0
AutoCam Off
Set Display Mode 1024,768,16
GoSub DeclareGlobalVariables
EndFunction
Function SetupTimerBasedSystem(PlayerMoveSpeed)
Movespeed#=PlayerMoveSpeed
MoveTimer=timer()
EndFunction
Function HandleTimerBasedSystem()
Mtime=timer()-MoveTimer
MFrame#=Mtime*(MoveSpeed#/1000)
MoveTimer=timer()
EndFunction
Function HandleScreenText(startx,starty)
Text Startx,Starty,"FPS : "+Str$(Screen FPS())
Text Startx,Starty+20,"Polies : "+Str$(Statistic(1))
EndFunction
Function CreatePlayer(ObjectNumber,ObjectType$,Size$)
If lower$(Size$)="small" then ObjSize=2
If lower$(Size$)="medium" then ObjSize=5
If lower$(Size$)="large" then ObjSize=8
If lower$(ObjectType$)="box" or lower$(ObjectType$)="cube"
Make Object Cube ObjectNumber,ObjSize
Endif
If lower$(ObjectType$)="circle" or lower$(ObjectType$)="sphere"
Make Object Sphere ObjectNumber,ObjSize
Endif
If lower$(ObjectType$)="triangle" or lower$(ObjectType$)="cone"
Make Object Cone ObjectNumber,ObjSize
Endif
If lower$(ObjectType$)="cylinder" or lower$(ObjectType$)="pole"
Make Object Cylinder ObjectNumber,ObjSize
Endif
If Object Exist(ObjectNumber)
Move Object Left ObjectNumber,30
Move Object Right ObjectNumber,ObjectNumber*10
Repeat
Move Camera -4
FastSync
Until Object In Screen(ObjectNumber)
Endif
EndFunction
DeclareGlobalVariables:
RemStart
If you are going to add some,
then you have to organize it.
At the top, put a rem statement
to seperate that portion of
variables. Keep that portion
aside from the other variables
so we don't get confused :)
RemEnd
`System Global Variables
`None
`Timer Global Variables
Global MFrame#
Global MoveSpeed#
Global MoveTimer
Global Mtime
`CreatePlayer() Global Variables
Global ObjSize
Return
-Mansoor
