Quantcast

Jump to content

» «
Photo

Center between two moving objects

2 replies to this topic
thrndm
  • thrndm

    Player Hater

  • Members
  • Joined: 05 Mar 2010

#1

Posted 11 April 2012 - 12:21 PM Edited by thrndm, 11 April 2012 - 12:25 PM.

Hello there.

I'm trying to get center between two moving objects and save it's coordinates to variables.

Basic code is:
CODE
005A: 0@ += 4@ //0@ - 1 object X coordinate, 4@ - 2 object X coordinate
0014: 0@ /= 2
0084: 7@ = 0@
005A: 1@ += 5@ //1@ - 1 object Y coordinate, 5@ - 2 object Y coordinate
0014: 1@ /= 2
0084: 8@ = 1@


Game crashes when it meets 0014 opcode, I.. I don't get why. What could be wrong here?

Thanks.

fastman92
  • fastman92

    фастман92 | ف

  • Members
  • Joined: 28 Jul 2009
  • None

#2

Posted 11 April 2012 - 12:35 PM

CODE
0014: 0@ /= 2

Will crash.

See the example in opcode search, applies to math opcodes only:
CODE
0014: $HJ_TWOWHEELS_TIME /= 1000


R* Math opcodes require specified input - variable or value depending on command.
It doesn't apply to any other opcodes.

And also i think coordinates will be float values (floating points).
2 integer is saved differently in CLEO script than 2.0.
2 integer will compute floating point 2.802596929E-45

You must do:
CODE
0@ /= 2.0


Full code if XYZ coordinates 1 are in 0@, 1@, 2@ and coordinates 2 are in 3@, 4@, 5@:
CODE
0087: 6@ = 0@ // (float)
0087: 7@ = 1@ // (float)
0087: 8@ = 2@ // (float)
005A: 6@ += 3@  // (int)
005A: 7@ += 4@  // (int)
005A: 8@ += 5@  // (int)
6@ /= 2.0
7@ /= 2.0
8@ /= 2.0

Vincent Johnson
  • Vincent Johnson

    China

  • Members
  • Joined: 05 Apr 2012
  • China

#3

Posted 12 April 2012 - 11:52 AM

+1 to ^'comment




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users