Hi, I'm trying to make a simple engine that lets you create your own world (sort of garys modish) anyway, when i try creating a cube when the player clicks the mouse, instead of creating one, it creates two and moves the camera. I can't see any problems with my source, mind you I've only been using DBPro for about 4 hours
Here's my code:
rem | Set up the game window etc. =)
set display mode 1280, 1024, 16
sync on
sync rate 60
disable systemkeys
hide mouse
rem | Loads all textures =)
LoadTextures()
rem | Makes the floor =)
make object plane 1, 500, 500
rotate object 1, 90, 0, 0
position object 1, 0, -1, 0
texture object 1, 1
set object collision to polygons 1
rem | Makes the sun =)
make light 1
set directional light 1, 45, 15, 0
set global shadows on
rem | Global Variables =)
CameraAngleX = 0
CameraAngleY = 0
ObjectCount = 50
oldTime = timer()
rem | Creates the players view camera =)
make camera 1
set current camera 1
position camera 1, 0, 0, 0
rem | Game loop :I
repeat
rem | Update the camera angle
inc CameraAngley, (mousemovex()/2)
inc CameraAnglex, (mousemovey()/2)
rotate camera 1, CameraAngleX, CameraAngleY, 0
if upkey() = 1 then move camera 1, 3
if downkey() = 1 then move camera 1, -3
rem | Applies gravity to all objects apart from the floor =I
Phys()
rem | Create a Box
if mouseclick()>0
newTime = timer()
if (newTime-oldTime)>10000
rem | Increases the object count
inc ObjectCount
rem | sets boxes properties
make object cube ObjectCount, 50
set object collision to boxes ObjectCount
texture object ObjectCount, 2
position object ObjectCount, 0, 50, 0
rotate object ObjectCount, CameraAnglex, CameraAngley, 0
move object ObjectCount, 3
endif
endif
sync
until escapekey() = 1
rem | Load Textures :I
function LoadTextures()
rem | Floor texture
load image "WoodRough0021_S.bmp", 1
rem | Barrel texture
load image "Barrel.bmp", 2
endfunction
rem | Physics engine :I
function Phys()
for i=40 to 200
if object exist(i) = 1
orgRotX = object angle x(i)
orgRotY = object angle y(i)
orgRotZ = object angle x(i)
rotate object i, 0, 0, 0
move object down i, 5
if object collision(i, 0)>0 then move object up i, 5
rotate object i, orgRotx, orgRotY, orgRotZ
endif
next i
endfunction
(Note: I'm only using that rubbish little phys function until DarkPhysics decides to work -.-)
Any helps greatly appreciated =)