This is driving me mad

Blitz3D Forums/Blitz3D Programming/This is driving me mad

Ion(Posted 2007) [#1]
Why doesn't this simple code works? It's supposed to create a new cube and place it where the "mouse-cube" is when i press the left mouse button. But it doesn't :S

Graphics3D 640,480,16,2
SetBuffer BackBuffer()

Type cube
	Field x,y,z,rot#,entity
End Type

fixedy = 0
cube = CreateCube()
camera = CreateCamera()
light = CreateLight()

PositionEntity camera, 0, 5, -20
RotateEntity camera, 20,0,0
CameraClsColor camera, 0, 0, 255

MoveMouse 320,240
While Not KeyHit(1)
Cls
	If(posdone = False)
		MoveEntity cube, MouseXSpeed()/10, 0, -MouseYSpeed()/10
		MoveMouse 320,240
	EndIf
		
	If(MouseHit(1) And posdone = False And sizedone = False And rotdone = False)
		c.cube = New cube
		c\x = EntityX(cube)
		c\y = EntityY(cube)
		c\z = EntityZ(cube)
		c\entity = CreateCube()
		PositionEntity c\entity, c\x, 0, c\z
		lastcube = c\entity
		posdone = True
		HideEntity(cube)
	EndIf
	
	UpdateWorld()
	RenderWorld()
Flip
Wend



Ion(Posted 2007) [#2]
Ok, found the error....

c.cube = New cube

can't have a type and an entity with the same name... stupid me (or stupid compiler not warning for it?) :P


Ross C(Posted 2007) [#3]
Both :P


markcw(Posted 2007) [#4]
It's good practice to use a naming convention such as tcube or cubetype for type names and ecube or cubeentity for entities, etc.