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 / Point and click in 2D

Author
Message
Space Baybe IV
11
Years of Service
User Offline
Joined: 13th May 2012
Location:
Posted: 23rd Dec 2012 02:14
Hi, I'd like to know how to make a sprite move/glide to where you point and click. I know how to make it move/glide to a point but only in increments of 1 which is very slow, and you can't do anything until the sprite reaches its destination. I've searched the forums but couldn't find anything relevant to my problem. Thanks in advance.
Sorry if this is the wrong board.
Cybermind
Valued Member
21
Years of Service
User Offline
Joined: 28th Nov 2002
Location: Denmark
Posted: 23rd Dec 2012 14:50
Do you use the command "move sprite sprite number,sprite speed" or calculate the route yourself and then update sprite coordinates with "sprite sprite number,x,y,image number"?

The byte chrunchers are coming...
DIVIDING BY ZERO/BECAUSE WE SUCK...
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 23rd Dec 2012 21:06 Edited at: 23rd Dec 2012 21:08
DBP features a curve value command that translates values in a smooth curved fashion, thus it interpolates, no mater how fast the initial movement; thus reducing the delay:


So from these facts you can move a sprite to a mouse location smoothly using floating point variables and a loop, as shown here:


The floating point coordinates can be clamped near the target; and the state or event which depends on distance from target can be finalized.

The exact position of the entity is retained in the variable, however the visual uses the nearest pixel to the more precise floating point location, as is the case with DBP's 3D objects.

Space Baybe IV
11
Years of Service
User Offline
Joined: 13th May 2012
Location:
Posted: 23rd Dec 2012 22:27 Edited at: 23rd Dec 2012 22:28
Thanks Chris Tate, I didn't realize that that was what CURVEVALUE did. Now I can move on. Thanks a heap.

Login to post a reply

Server time is: 2024-03-29 11:58:35
Your offset time is: 2024-03-29 11:58:35