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.

2D All the way! / [DBPRO] 2.5d stacking game

Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 5th Nov 2010 04:01
Hey guys.
I was wondering if anyone could lend a hand with a small project im starting.
I want to be able to grab an object and stack it above other objects. Where i grabbed the object from will spawn another one, so you can just keep stacking.
All this would be with 3d assets, but on x and y only.
Can anyone help me?
I have no idea where to start.

Hey look at that!
Van B
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Nov 2010 15:44
You might need several different objects, so I would suggest having a band of parent objects - these would be placed, ready for picking up.

Let's say you have an object called teapot.x...

Load object "teapot.x",10
position object 10,-5,-5,-5
position camera 0,0,-25

So that 'might' position it on the screen for you. It's best to have your pickable objects in a set range, say objects 10 to 20 - because you have to specify a range when using PICK OBJECT().

Then you could have a main loop a bit like this:


if mouseclick()=1
if pickobj=0 then pickobj=p : inc obj,1 : clone object obj,pickobj : position object obj,object position x(pickobj),object position y(pickobj),0
xx#=object position x(obj)
yy#=object position y(obj)
inc xx#,mousemovex()/100.0
inc yy#,mousemovey()/100.0
position object obj,xx#,yy#,0
P=pick object(mousex(),mousey(),10,20)

Not tested any of this code, as it's just to give you an idea - but it will wait until you click and drag an object, then it will clone it, and position it depending on the mouse movement. I'd be happy to make a small example, if you need it.

Health, Ammo, and bacon and eggs!
Years of Service
User Offline
Joined: 20th Jun 2010
Location: Earth Prime
Posted: 8th Nov 2010 08:51
Hey van B,
An example would be great, I've been attempting your advice and example code with no luck.
Thanks for your help!

Hey look at that!

Login to post a reply

Server time is: 2024-02-22 04:51:48
Your offset time is: 2024-02-22 04:51:48