Code Help

Blitz3D Forums/Blitz3D Programming/Code Help

mintybreath(Posted 2007) [#1]
hey, i am just playing around, and trying to make a fake computer desktop game, where u can activate different things, like a real computer. Just playing around, not being really serious. But I seem to have hit a problem.
I am making the arrow keys move the arrow on the screen for the time being, the mouse will be the one to move the arrow later(figure out how to do that). but when i press the arrow keys, it does not move the arrow. Could someone please help, i am new at the coding business.

I only set the controlling arrows for the up and left arrows so far. Here is the code. I dont see anything wrong with it, but i figured people that know more than me might see a problem. Thanks for the help! :D

Code:
_________________

Graphics3D 640,480
SetBuffer BackBuffer()

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
tex3=LoadTexture("background image.jpg")
EntityTexture background,tex3

;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
EntityColor bar,50,50,200
tex2=LoadTexture("bar.jpg")
EntityTexture bar,tex2

;creating the arrow
arrow=CreateCone()
ScaleEntity arrow,.06,.06,.000001
EntityOrder arrow,-2
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

;controlls
If KeyDown(200)=True Then MoveEntity arrow,0,1,0
If KeyDown(203)=True Then MoveEntity arrow,1,0,0


While Not KeyDown(1)

RenderWorld
Flip

Wend

End


_33(Posted 2007) [#2]
use [ code ] code... [ /code ] to encapsulate your code when you post like this, it will make your message much more readable. That's my first recommendation.


Now, this code is outside your loop:
;controlls
If KeyDown(200)=True Then MoveEntity arrow,0,1,0
If KeyDown(203)=True Then MoveEntity arrow,1,0,0

That's your problem.

So, your loop should look like this:
While Not KeyDown(1)
   ;controlls
   If KeyDown(200)=True Then MoveEntity arrow,0,1,0
   If KeyDown(203)=True Then MoveEntity arrow,1,0,0

   UpdateWorld
   RenderWorld
   Flip
Wend

See I also added UpdateWorld.

Cheers.


mintybreath(Posted 2007) [#3]
Oh man, now i feel stupid, it was that obvious, lol. Thanks so much for the help. And for the forum posting tip