Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Can anyone telling why this code won't work?

Author
Message
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 27th Oct 2002 16:13
I still cannot figure out why this code refuses to work properly. It's quite simple

set display mode 1024,768,32
sync on : sync rate 60 :backdrop off

x=0:y=0:z=0

make object box 1,100,100,100
make camera 1
position object 1,0,0,0
position camera 1,0,0,-500
point camera 1,0,0,0

do
text 1,1,str$(mousemovex())
text 1,21,str$(mousemovey())
text 1,41,str$(y)
if mousemovex()>0 then y=y+1
if mousemovex()0 then x=x+1
if mousemovey()
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 27th Oct 2002 16:22
It seems like the forum messed the code

set display mode 1024,768,32
sync on : sync rate 60 :backdrop off

x=0:y=0:z=0

make object box 1,100,100,100
make camera 1
position object 1,0,0,0
position camera 1,0,0,-500
point camera 1,0,0,0

do
text 1,1,str$(mousemovex())
text 1,21,str$(mousemovey())
text 1,41,str$(y)
if mousemovex()>0 then y=y+1
if mousemovex()<0 then y=y-1
if mousemovey()>0 then x=x+1
if mousemovey()<0 then x=x-1

rotate object 1,wrapvalue(x),wrapvalue(y),wrapvalue(z)
sync
loop

HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 27th Oct 2002 17:15
i think it was working, it's just you couldn't see it.
with the backdrop off it doesn't refresh the screen, plus the 'y=y+1' commands is only a same amount so it wasn't moving very much.
i hope this works for you, i don't use dbp very much.
try this:

`set display mode 1024,768,32
sync on : sync rate 60 :backdrop on

x=0:y=0:z=0

make object box 1,100,100,100
make camera 1
position object 1,0,0,0
position camera 1,0,0,-500
point camera 1,0,0,0
set text opaque
do
text 1,1,str$(mousemovex())
text 1,21,str$(mousemovey())
text 1,41,str$(y)
sync
if mousemovex()>0 then y=y+10
if mousemovex()<0 then y=y-10
if mousemovey()>0 then x=x+10
if mousemovey()<0 then x=x-10

rotate object 1,wrapvalue(x),wrapvalue(y),wrapvalue(z)
sync
loop
HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 27th Oct 2002 17:16
no edit?
same = small
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 27th Oct 2002 19:53
Thanx for replying but didn't work either
the problem seems to be with the
mousemove command.
Strange if you think that every fps out there is played
with the mouse.There is not even one example of it in the whole darkbasic pro
What if you want to rotate the point of view with the mouse?

When i substitute
if mousemovex()>0 then y=y+1
with
if rightkey()=1 then y=y+1
it works just fine.
But eventually I will need something like the camera view system in homeworld which I have already figured out how to do but can't get the mousemove command to work as it should.

HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 28th Oct 2002 01:33
what about changing:
rotate object 1,wrapvalue(x),wrapvalue(y),wrapvalue(z)
to:
rotate object 1,wrapvalue(mousex()),wrapvalue(mousey()),wrapvalue(z)
or is this not what you your trying to do?
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 28th Oct 2002 10:56
Nope
What I want to do is rotate an object in all 3 axis by 360 degrees with the mouse

John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 28th Oct 2002 13:43
Hmm Ill take a stab at it-
Well, I have used cameras many times, and you dont need the "make camera command"
to position and point the camera just put in
Position camera x,y,z
and
point camera x,y,z
Oh, and as far as I know, sync can only go up to 40
Well try some of these things- Im not sure if it will work, this is just what I have heard. I am always making matrices for my game, and I have never used the "make camera" command.
Later- hope I helped somewhat-
RPGgamer

BTW- I saw the sync thing somewhere so if I am wrong dont get mad at me! I think if you want your screen to refresh fast try
Sync on
Sync rate 0

Final Fantasy, best series ever made.
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 28th Oct 2002 17:51
Still the rotation of the object is too jerky with the mousemove command. I used to use it all the time with Db 1.xx but I can't make it work in pro. Hasn't anyone tried to control and rotate the point of view or an object with the mouse?

HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 28th Oct 2002 21:30
seems silly to me, as far as i'm concerned the mouse only moves in two directions.
this any good?:
Sync On
Sync Rate 30
make object cube 1,100.0
position object 1,0,0,135
Do
if mousemovex()<>0 then x=x+1
if mousemovey()<>0 then y=y+1
if mousemovez()<>0 then z=z+1
rotate object 1,wrapvalue(x),wrapvalue(y),wrapvalue(z)
sync
loop

ps.you didn't alter the z axis in your first code snippet.
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 28th Oct 2002 21:57
The mousemovez checks the roller of the mouse so I really don't need it for the rotation. I might need it for the zoom in - zoom out function.

I used the
text 1,1,str$(mousemovex())
text 1,21,str$(mousemovey())
so I can see the values that the mouse gives to these commands
When you move the mouse left the mousemovex() becomes negative
When you move the mouse right the mousemovex() becomes positive
When you don't move it at all it stays 0
So the idea is when you move the mouse to left the object rotates to the left and the opposite.
But even thought the mousemovex() is negative
and is easily checked by the number on the screen
when I state
if mousemovex()<0 the rotate blah
it doesn't work as it should.

HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 28th Oct 2002 23:32
sorry. i see what you mean now, somethings not right.
i think it has something to do with do/loop and mousemove() commands plus i think the mousemove() command might be a bit to fast, but i really am guessing.
try putting the sync command just after the `text1,41,str$(y~)` command. seems better but doesn't help your problem.
Krash
22
Years of Service
User Offline
Joined: 13th Oct 2002
Location:
Posted: 28th Oct 2002 23:34
seems as if the mousemove commands only check once per loop
so when you print the mouse move offsets to the screen, it seems fine. But the mouse hasn't moved again down the loop so it now equals zero. Set the mouse move to a variable at the top of the loop and check the variable... see code below.



It's all fun and games 'till someone loses an arm...
HAL
22
Years of Service
User Offline
Joined: 28th Aug 2002
Location:
Posted: 29th Oct 2002 00:49
is this just me? weird stuff!
i thought it might have had something to do with the do/loop, so i took it out and put in a for loop, the program runs as the normal(like the sync at the end of the do/loop) but when you hit escape the program runs like the sync after the text code. weird.. the escape doesn't exit the program but changes the programs behaviour. anyone else?


sync on : sync rate 60 :backdrop on

x=0:y=0:z=0

make object box 1,100,100,100
make camera 1
position object 1,0,0,0
position camera 1,0,0,-500
point camera 1,0,0,0
set text opaque

for i=0 to 10
`do
set cursor 100,100
print screen fps()
if mouseclick()=1 then i=10 else i=0
text 1,1,str$(mousemovex())
text 1,21,str$(mousemovey())
text 1,41,str$(y)
`sync
if mousemovex()>0 then x=x+1
if mousemovex()<0 then x=x-10
if mousemovey()>0 then y=y+1
if mousemovey()<0 then y=y-10
rotate object 1,wrapvalue(x),wrapvalue(y),wrapvalue(z)
sync
`loop
next i
RAG
22
Years of Service
User Offline
Joined: 27th Oct 2002
Location:
Posted: 29th Oct 2002 23:57
I finnaly found the solution to my problem
The only thing I had to do was to move the sync command right after the text commands and the whole program changed it's behaviour.
Oddly enough I never faced these problems in the original Dark basic

Login to post a reply

Server time is: 2024-11-23 17:34:28
Your offset time is: 2024-11-23 17:34:28