The Daily Click ::. Forums ::. Klik Coding Help ::. fixed movement allowance
 

Post Reply  Post Oekaki 
 

Posted By Message

Vaynes



Registered
  27/01/2005
Points
  15
2nd March, 2005 at 07:02:29 -

I'm trying to use pythagoras to calculate the distance travelled between my sprite and the active object i'm using to point where i want it to go, then take this value of the calculation from an alterable value.

i'm using an .ini file to save the calculation result then subtract the value of the .ini file from Alt val B. When alt val B = 0 the group should deactivate.

Can any one help me with this or suggest a better way to do it.

Its for time units (as in X-COM), turn based movement.

 
Ever bitten off more than you can chew?

clwe



Registered
  17/12/2002
Points
  702
2nd March, 2005 at 08:16:31 -

Well...if you're looking for the actual distance calculation, then it would be like this:

(X distance between objects, by the power of 2) plus (Y distance between objects, by the power of 2). Square root the result, and you have the distance.


I wouldn't recommend using an ini file, though. MMF allows for decimal numbers already, and if you're stuck with TGF, you can use the Advanced Math object to move the decimal offset (giving you a fairly accurate result as a large integer).

 
n/a

Vaynes



Registered
  27/01/2005
Points
  15
2nd March, 2005 at 08:30:31 -

thx

so I would just have to set the formula to subtract from the alterable value.

sounds too simple

 
Ever bitten off more than you can chew?

Vaynes



Registered
  27/01/2005
Points
  15
2nd March, 2005 at 13:06:22 -

this isn't working as it should. try a different way.

Does anyone know of a way to create a board game style movement, like in chess the pieces will only have a set amount they can move?



 
Ever bitten off more than you can chew?

RapidFlash

Savior of the Universe

Registered
  14/05/2002
Points
  2712
2nd March, 2005 at 22:55:40 -

Well, you could do something like:
Upon Pressing Left Arrow Key --> Set Alterable Value A to 32

Alterable Value A > 0 --> Set X Position to X Position("current object") + 1

Subtract 1 from Alterable Value A


 
http://www.klik-me.com

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1971

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
3rd March, 2005 at 20:21:33 -

if you actually make the movement grid based (like in xcom and virtually all other turn-based stratgey games), you could store all the map info in an array and use the grid or pathfinding extensions to do most of the hard work for you. this would make it much easier to load maps. the grid extension supports "weights" so you could make movement slower over a particular terrain.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click