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 / Two Tiny,Funny,Silly questions!

Author
Message
Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 18th Aug 2004 10:25
1, how can I delete a circle or change its color?
The object can be deleted easily, but how about a circle or line?

for example:
ink rgb(100,255,100),rgb(0,0,0)
Circle 22,21,1
This will represent the position of an object in the radar, but when I delete the object, I also want to delete the circle or just change its color, how can?

2, when I place a monster into the game and want it move to a postion, but he just stay there

the code like this:

PlaceAgents:

RANDOMIZE timer()
num=rnd(3)

if num=0
mX#=1
mY#=0
mZ#=9999
position object 3,mX#,mY#,mZ#
endif
...

Return

and in the main loop,

...

if mX#=1 and mZ#=9999
point object 3,4400,0,5750
Rem Move monster
Move Object 3,7
endif

I want to move the monster to the postion 4400,0,5750, but it just stay there..


Help Please!!!!!!!!!!!!!!!!!!!!!!
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 18th Aug 2004 11:18 Edited at: 18th Aug 2004 11:18
Okay,

First off, deleting the circle. the reason the circle doesn't go away is because you haven't told the drawing routine to make it go away, since I don't see enough code here to find a sync command. In that case, I'd suggest you delete it the easy way, by drawing it's reverse;

rem make it
ink rgb(100,255,100),rgb(0,0,0)
circle 22,21,1

rem remove it
ink rgb(0,0,0),rgb(0,0,0)
circle 22,21,1

Now, there is a problem that the color black is not drawn to the screen often, so you may need to use a "near black" to get the circle to go away;

rem away way...
ink rgb(8,8,8),rgb(0,0,0)
circle 22,21,1

That's what syncing is all about... updating the screen so objects will vanish if not drawn.

Second, monster moving. The code you have assumes 1 thing... that the values of mx# and mz# remain equal to your starting position. If your monster is moving, and you are changing mx# and mz# to follow him, then the code you have will only move him for 1 step of 7 units. What you probably want to do is;

point object 3,4400,0,5750

do ...

if mX#<>4400 and mZ#<>5750
Move Object 3,7
endif

sync
loop

good luck!
S.

Any truly great code should be indisguishable from magic.
Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 18th Aug 2004 20:44
Thanks a lot, mate!

but the problem still there, I give more code this time.

1,

when I do this, change the color, it will have a black dot in different place and disappear instantly, and the old green one didnot change at all.

Do
...
rem make it
ink rgb(100,255,100),rgb(0,0,0)
circle 22,21,1
...
if something happened
ink rgb(8,8,8),rgb(0,0,0)
circle 22,21,1
endif
sync
loop

2,

Do
...
mX#=object position X(3)
mZ#=object position Z(3)
mY#=0

rem I dim X(33), Z(33), two array to store 33 nodes
For i=29 to 33
rem this calculate the distance from the targets
if ABS(mX#-X(i))+ABS(mZ#-Z(i)) >10100
if ABS(mX#-X(i))+ABS(mZ#-Z(i)) <11350

point object 3,X(i),0,Z(i)
*****************************
while mX#<>X(i) and mZ#<>Z(i)
Move Object 3,7
endwhile
*****************************
endif
endif
Next i
...
Sync
Loop

when I use *while*, the screen fixed, i mean the game didnot run.
but if i change the *while* into:

if mX#<>X(i) and mZ#<>Z(i)
Move Object 3,7

it will move only 7 steps.

headache..
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 18th Aug 2004 21:17
olympic i think i have solved your problem. when you are coding you have to remember that for/next, while/endwhile and repeat/until are all loops and if you update objects within them then you have to put a sync command at the end of the loop. if you don't do this, then the objects will not be updated. Another thing you have to remember is that if you don't change the variable within while/endwhile or repeat/until loops then they will keep running forever. These points taken into account, i think your code should look more like this:



As for your disappearing circle, try implementing this into your code:

Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 19th Aug 2004 11:02
Dodo, for the first problem, after I add sync there, the game turn to be very slow and the monster still move only 7 steps.

the second one, I am not sure what you mean, so I just put the whole code here, they are all in the main loop.

Do
...
rem get monster position
mX#=object position X(3)
mZ#=object position Z(3)
mY#=0

rem calculate the distance from targets and choose one
rem I dim X(33), Z(33), two array to store 33 nodes
For i=29 to 33

if ABS(mX#-X(i))+ABS(mZ#-Z(i)) >10100
if ABS(mX#-X(i))+ABS(mZ#-Z(i)) <11350

point object 3,X(i),0,Z(i)
if mX#<>X(i) and mZ#<>Z(i)
Move Object 3,7
endif
endif
endif
sync
Next i
...

if mX#=X(i) and mZ#=Z(i)
ink rgb(0,0,0),rgb(0,0,0)
circle 22,21,1
endif
...

Rem make radar
Copy Bitmap 2,1
set current bitmap 1

rem one target in radar

ink rgb(100,255,100),rgb(0,0,0)
Circle 22,21,1

`player on map
ink rgb(0,0,255),rgb(0,0,0)
PRX#=X#/200
PRZ#=50-(Z#/200)
Circle PRX#,PRZ#,1

`monster on map
ink rgb(255,0,0),rgb(0,0,0)
MRX#=mX#/200
MRZ#=50-(mZ#/200)
Circle MRX#,MRZ#,1

Get image 200,0,0,50,50
set current bitmap 0
texture object 200,200
ink rgb(255,128,128),rgb(0,0,0)

Sync
Loop
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 19th Aug 2004 19:01
olympic, i am not sure because i dont know what you are trying to do, but i think that you have put the if mX#<>X(i) and mZ#<>Z(i)
Move Object 3,7 in the wrong place. This is because in order for this to be true, the two if state ments before it also have to be true. i think it should look more like this:



the reason that it runs so slowly is because every time your for/next loop runs, it can't run any faster than your syunc rate(because of the sync). to get around this set your sync rate a lot higher, say 120.

the second problem i have implemented into your code for you, because i can't be bothered to explain it properly (its very early..) maybe i will later.


hope this works.
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Aug 2004 02:38
I would also like to add a little more here... in that your "select target" code has a problem that it checks for EVERY target every time. This means that if one target is in front of you and you move towards it, while another one is behind you at the same distance, after stepping forward you turn back and step backward in the very same loop!

You need something like;


good luck!
S.


...

Any truly great code should be indisguishable from magic.
Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 20th Aug 2004 10:21
Thanks Dodo and SandraD, anyway, I solved the moving problem!
but for the circle one, I still cannot get it

Dodo,This code still doesnot work:
rem one target in radar
ink rgb(100,255,100),rgb(0,0,0)
Circle 22,21,1

`get rid of radar target
if mX#=X(i) and mZ#=Z(i)
ink rgb(0,0,0),rgb(0,0,0)
circle 22,21,1
endif

very confused..

Thanks again!
SandraD
20
Years of Service
User Offline
Joined: 30th May 2004
Location: Down on the corner, out in the street.
Posted: 20th Aug 2004 20:03
Well, assuming your make radar code is in the main loop, then the delete code will only run when the objects are on top of each other, so the circle will be back once the loop starts again. In my movement code sample I posted I used the value of "i" to indicate that a target had been selected or it was zero in the case when it was not. Assuming your code follows the same sort of thinking, you need to surround the make radar code with a IF like;

if i>0
rem one target in radar
ink rgb(100,255,100),rgb(0,0,0)
Circle 22,21,1
endif

which will only draw the radar when and if a target is selected. The other code, the delete radar thing, should handle the removal.

good luck,
S.

Any truly great code should be indisguishable from magic.
Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 20th Aug 2004 21:41
right, but I want the targets always appeared in the radar from the start of the game, and then I tell manster or player to find them
After found,change the color or delete it from the radar
Dodo
20
Years of Service
User Offline
Joined: 8th Aug 2004
Location: eating lunch
Posted: 20th Aug 2004 23:14
Here how about this, does this work? you will need to put a variable before the main loop defining TargetShow as 1

Olympic
20
Years of Service
User Offline
Joined: 18th Aug 2004
Location:
Posted: 21st Aug 2004 08:36
Brilliant Dodo!

It works!
I just put several variables=1 to represent the different targets in the radar before the main loop start, and after the monster find one of them just make the varibale=0, donot even color it, so it disappear from the radar.

Thanks a lot!
Thanks for all your help!

Login to post a reply

Server time is: 2024-11-27 07:45:58
Your offset time is: 2024-11-27 07:45:58