I'm making an overhead shooting game and I want my character to point in the direction of the aimer. I also want the aimer to follow the cursor wherever it goes. Here's the code I have:
FrameLimit 40
soldier=LoadObject("media\soldier.bmp", 72)
cross=LoadObject("media\crosshair.bmp", 72)
Repeat
PositionObject cross,Cos(MouseX()),Sin(MouseY())
PointObject soldier,cross
If UpKey() Then MoveObject soldier,2
If DownKey() Then MoveObject soldier,-2
DrawScreen
Until EscapeKey()
If you load that I'm sure you'll see my problem. I'm just starting out with CoolBasic and I know I must be doing something wrong. So any help is appreciated!
Last edited by shadow382 on Wed Oct 10, 2007 11:09 am, edited 1 time in total.
You cannot take cos or sin from coordinates or at least it does not make any sense. The parameter of sin and cos is angle, so you must put an angle to them. The only angle I can imagine is the angle from soldier to mouse's world coorindates. Here is code which seems to work correctly: