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 / variables to move objects

Author
Message
Asternus
20
Years of Service
User Offline
Joined: 11th Aug 2004
Location: N.C. U.S.A
Posted: 25th Mar 2007 10:30 Edited at: 25th Mar 2007 10:32
I'm trying to make a sliding puzzle type program.I can pick a tile(object) and make it slide around.Can I take a variable and replace it with the object number (move object left variable,33)?
If so,the I should also be able to take that variable and randomize the tiles. Problem is. I can't figure out the right syntax.
Thanks,Please.

This a striped code of the original.

Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 25th Mar 2007 13:17
yes you can use a variable ( for integers ) to store object numbers:

object1=1
object2=2
object3=3
spaceship=100
redcar=10

and use the variable name instead of the object number:

move object1,1.0

or, you can use a general purpose variable to store object numbers of temporary usage:ex:

if activeobject=100 then gosub spaceship_fly
if activeobject=10 then gosub drive_car

----
spaceship_fly:
move object activeobject,1.0
return
---
drive_car:
move activeobject,1.0
return
----
wildbill
18
Years of Service
User Offline
Joined: 14th Apr 2006
Location:
Posted: 25th Mar 2007 17:00
You could alternatively use an array of objects this will make randomization easy. Just randomize the array number.
Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 25th Mar 2007 21:49
or alternatively you can use a function to use easily



so now with that function all you need is

player=makeObject("model.x",1)
monster=makeObject("monster.x",2)

etc...

hope it helps

Asternus
20
Years of Service
User Offline
Joined: 11th Aug 2004
Location: N.C. U.S.A
Posted: 26th Mar 2007 23:51
Thanks for the info all.I'll see what I can come up with.
Asternus
20
Years of Service
User Offline
Joined: 11th Aug 2004
Location: N.C. U.S.A
Posted: 30th Mar 2007 07:01
Wonderful! Now to figure out how to load and split up a picture on each tile,and I'll upload it to the Code Base.

Thanks
Asternus
20
Years of Service
User Offline
Joined: 11th Aug 2004
Location: N.C. U.S.A
Posted: 1st Apr 2007 04:31
well damn.how do you randomize a number without getting the same number twice or more?

Login to post a reply

Server time is: 2024-09-25 19:14:49
Your offset time is: 2024-09-25 19:14:49