Help

Blitz3D Forums/Blitz3D Programming/Help

mintybreath(Posted 2007) [#1]
Hey everyone. I need help with a code i am making. I am sort of new, i only know basic code, and i am trying to make a game, with a fake, usable computer desktop. I was trying out what was in my mind for the desktop. When the start menu button is clicked the start menu below the desktop itself, would change its order to above the desktop. So i did the coding, and tried it out, and it did not work. If someone could please help me with this code i would really appreciate it. thank you very much.



Graphics3D 640,480
SetBuffer BackBuffer()
type_bracket=1
type_arrow=2

light=CreateLight()
camera=CreateCamera()
PositionEntity camera,0,0,-1.5


;creating the background
background=CreateCube()
ScaleEntity background,1,1,.5
EntityColor background,100,100,250
EntityOrder background,0
EntityColor background,13,1,161

;start button
start=CreateCube()
ScaleEntity start,.3,.09,.000001
PositionEntity start,-1.2,-1.04,0
EntityOrder start,-1
tex=LoadTexture("start button.jpg")
EntityTexture start,tex

;bar
bar=CreateCube()
PositionEntity bar,.3,-1.04,0
ScaleEntity bar,1.2,.09,.000001
EntityOrder bar,-1
tex2=LoadTexture("bar.jpg")
EntityTexture bar,tex2

;creating the recycle bin
recycle=CreateCube()
PositionEntity recycle,1.3,-.8,0
ScaleEntity recycle,.1,.15,.000001
EntityOrder recycle,-1
tex3=LoadTexture("recycle2.jpg")
EntityTexture recycle,tex3

;creating the arrow
arrow=CreateCone()
ScaleEntity arrow,.06,.06,.000001
EntityOrder arrow,-3
RotateEntity arrow,0,0,40

stick=CreateCube()
ScaleEntity stick,.01,.07,.000001
RotateEntity stick,0,0,40
PositionEntity stick,.03,-.04,0
EntityOrder stick,-2


;the notebook
notebook=CreateCube()
ScaleEntity notebook,.15,.15,.000001
EntityOrder notebook,-1
PositionEntity notebook,-1.3,.8,0
tex4=LoadTexture("notebook.jpg")
EntityTexture notebook,tex4

;test square thangy
test=CreateCube()
ScaleEntity test,1,1,1

While Not KeyDown(1)

If KeyHit(57) Then
	If EntityDistance(arrow,start)<2.0 Then
	EntityOrder test,-5
	EndIf
EndIf


;controlls
If KeyDown(200)=True Then MoveEntity arrow,.033,.04,0
If KeyDown(203)=True Then MoveEntity arrow,-.04,.033,0
If KeyDown(205)=True Then MoveEntity arrow,.04,-.033,0
If KeyDown(208)=True Then MoveEntity arrow,-.033,-.04,0

If KeyDown(200)=True Then MoveEntity stick,.033,.04,0
If KeyDown(203)=True Then MoveEntity stick,-.04,.033,0
If KeyDown(205)=True Then MoveEntity stick,.04,-.033,0
If KeyDown(208)=True Then MoveEntity stick,-.033,-.04,0
UpdateWorld

RenderWorld
Flip

Wend

End



puki(Posted 2007) [#2]
Ah, remember that EntityDistance works in 3 dimensions. You need to use a value much lower than 2.0 - try .15

Your route will probably be easier with EntityPick.

Blitz3D has something called 'Picking'.

You set an entity's pickmode with EntityPickMode - probably just as well to use CameraPick with your cursor.

If MouseHit(1) then whateverwaspicked=CameraPick(camera,MouseX(),MouseY())

EDIT:
Type CameraPick into your program, then press the F1 key twice to bring up the example program.


puki(Posted 2007) [#3]
If you replace your graphic mode setting to Graphics3D 640,480,16,2

The 2 on the end will force Blitz into Windowed mode - this will allow you to use your normal mouse cursor.

Where you create your 'Start Button' in your code, add in a line - EntityPickMode start,2

After While Not KeyDown(1) add:

If MouseHit(1)
	whatwaspicked=CameraPick(camera,MouseX(),MouseY())
EndIf 

If whatwaspicked=start
	End
EndIf 


You'll notice now that whenever you click your 'Start Bar' your program will end. Just replace END with whatever you want to do. I just chose End to demonstrate that it works.


_33(Posted 2007) [#4]
"Blitz3D Beginners Area" is where you want to post for stuff like this. A better title than "Help" is what I suggest, as "Help" doesn't explain anything and, when searching in the threads, you have to open the message to know what it's about. It's not helpful for the others IMHO.


mintybreath(Posted 2007) [#5]
ok ill remember that. i couldnt think of a name, so i just put help, but good point. and thanks for the help puki


puki(Posted 2007) [#6]
Actually, this doesn't address the question of the menu appearing.

Instead of entity order - you can use HideEntity and ShowEntity.

So you create an entity - then hide it, then when a condition is met, you show it.


mintybreath(Posted 2007) [#7]
ohhhh ya, why didnt i just think of doing that. that would be much more simpler. :) thanks again puki