I'm trying to make a first person Pacman game in DBC (I found it on sale for less than €10, so I chose to buy that).
The first thing I did was to lay out the pills, following the same layout they have in the original Pacman, but they gave a MAJOR slowdown to the program. I tried to follow every applicable suggestion in the "Make your game faster" topic, but they seem to have no effect.
This is the code: can anyone tell me what I'm doing wrong?
Backdrop On
` Activate manual syncronization and hide mouse
Sync Rate 60 : Sync On : Hide Mouse
`Check object visibility in the first loop
CHECKVISEVERY=0
Color Backdrop Rgb(63,204,239)
`Pac-Man (it's just a ball, but no-one's gonna see it anyway :-) )
Make Object Sphere 1,17.5
Color Object 1,Rgb(255,255,0)
Position Object 1,40,10,20
Hide Object 1
`Maze floor
Make Object Plain 4,290,320
Color Object 4,Rgb(50,50,250)
Position Object 4,144.7,0,160
Rotate Object 4,90,0,0
`Pills
For I=7 To 32
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-5)*10,10,20
Next I
For I=33 To 38
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-31)*10,10,50
Next I
For I=39 To 42
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-29)*10,10,50
Next I
For I=43 To 46
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-27)*10,10,50
Next I
For I=47 To 52
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-25)*10,10,50
Next I
For I=53 To 76
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,70,10,(I-47)*10
Next I
For I=77 To 100
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,220,10,(I-71)*10
Next I
For I=101 To 112
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-99)*10,10,300
Next I
For I=113 To 124
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-97)*10,10,300
Next I
For I=125 To 139
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-117)*10,10,260
Next I
For I=140 To 141
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,20,10,(I-137)*10
Next I
For I=142 To 143
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,130,10,(I-139)*10
Next I
For I=144 To 145
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,160,10,(I-141)*10
Next I
For I=146 To 147
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,270,10,(I-143)*10
Next I
For I=148 To 153
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-140)*10,10,80
Next I
For I=154 To 159
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-138)*10,10,80
Next I
For I=160 To 165
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-152)*10,10,110
Next I
For I=166 To 171
Make Object Sphere I,3
Set Object I,1,0,1
Position Object I,(I-150)*10,10,110
Next I
`Collision configuration
Set Global Collision On
Set Object Collision To Spheres 1
For I=7 To 112 : Set Object Collision To Boxes I : Next I
` Sets the mouse (and therefore the camera angle) to a position
` suitable for the game
Position Mouse 1,320
Position Camera 145,0,80
Set Camera Range 2,400
` Begin main loop
testscroll#=0
Do
XMOUSE=Mousex()
YMOUSE=Mousey()
` Wraps the screen around horizontally
If XMOUSE=639 Then Position Mouse 1,YMOUSE
If XMOUSE=0 Then Position Mouse 638,YMOUSE
` Rotates left/right
angle#=XMOUSE*360.0/640.0
` Rotates up/down
vert_angle#=(YMOUSE*180.0/480.0)-90
` Ensure angle stays within range
` angle#=wrapvalue(angle#)
vert_angle#=Wrapvalue(vert_angle#)
`Check if Pac-Man is colliding against something
PACBUMP=Object Collision(1,0)
Set Cursor 0,0
Print PACBUMP
` Moves forward/backward
If upkey()=1
TASTOSU=1 : TASTOGIU=0
move camera 2.1
Endif
If downkey()=1
TASTOSU=0 : TASTOGIU=1
move camera -2.1
Endif
fov_x#=CAMERA POSITION X()
fov_z#=CAMERA POSITION Z()
` Update camera (and Pac-Man)
Position Camera fov_x#,14,fov_z#
Position Object 1,fov_x#,14,fov_z#
Yrotate Camera angle#
Xrotate Camera vert_angle#
Inc CHECKVISEVERY
If CHECKVISEVERY=6
CHECKVISEVERY=0
For X=7 To 171
If Object Exist(X)
If Object In Screen(X) And Object Visible(X)=0 Then Hide Object X Else Show Object X
Endif
Next X
Endif
`Refresh screen
SYNC
` End loop
Loop