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.

DarkBASIC Professional Discussion / Turn Based Stratagy Help

Author
Message
Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 3rd Nov 2010 17:23
I am trying out different methods for darkbasic like tbs, rts, fps, etc... anyways, i cant seem to figure out how to make it to where you click in an area and the object moves to it. i can only make it to where if you click in an area, the object repositions itself to it.

onhcet d(-_-)b techno
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 3rd Nov 2010 17:46 Edited at: 3rd Nov 2010 17:47
The best way to solve this is to use the newxvalue() and newzvalue() commands to interpolate between the two points.



Is this 2D or 3D? The solution above is for 3D, but if you have a 2D game, delete all of the lines with "y#", and after that rename all "z#" variables to "y#".

TheComet

Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 3rd Nov 2010 20:59
it is 3d. i will try this, but if i cant get it to work you may have to make it simpler or explain it more detailed.

onhcet d(-_-)b techno
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 3rd Nov 2010 23:36 Edited at: 3rd Nov 2010 23:37
I usually do this:



Cheers!
Sven B

Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 4th Nov 2010 18:17
i couldn't get it work. it shows that the array is missing a variable or something like that, sorry im at school so i cant check it. can someone make a full script without textures and images so i can just load it to dark basic pro. then if it works, ill study the code. thanks

onhcet d(-_-)b techno
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 4th Nov 2010 20:34 Edited at: 4th Nov 2010 20:45
Quote: "i couldn't get it work."

probably because the command "SC_raycast" is a function from an external plugin, and DBPro recognizes the command as a reference to an array if you don't have the plugin installed.



Generally, there are two methods of selecting units. If you have a bumpy terrain, going up and down and every which way, then you really should use that SC_raycast command (SC stands for Sparky's Collision). However, if you just have a plane, then you can use simpler math to figure out where your mouse is clicking. Here's some code that does just that:




raycasting is easier, and allows for odd shaped terrain, but math stuff works just as well for flat planes. If you want to know exactly what all that math is doing, i strongly suggest you take a look at this tutorial:
http://www.neurofuzzydev.com/V/D/index.htm
called "Vectors Don't Bite!"

[edit]
wait wait wait I think i totally misunderstood the problem...
Is something like this more what you're looking for?


Beyond the Humans Knowledge
15
Years of Service
User Offline
Joined: 27th Oct 2010
Location:
Posted: 4th Nov 2010 20:58
cool it worked, but now i just need to make it to where a selected object moves towards it.

onhcet d(-_-)b techno

Login to post a reply

Server time is: 2026-07-26 05:02:30
Your offset time is: 2026-07-26 05:02:30