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 / Really dumb question about making objects follow each other...

Author
Message
Beta1
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 9th Feb 2003 21:11
OK then in this game the objects are all on the same plane ie they all move only on the x and y axis. Each object has a position on the x and y axis, a speed on each and a rotation around the z axis top define the direction. the brake var slows theobject by multipling it by the speed on each axis Throttle is the straight acceleration for the object. Now object L should try to head towards the player (object 1). All positions etc are stored in o(object number) which has pos.x pos.y, speed.x speed.y etc..

rem work out angle between homer and player
xdiff#=o(L).pos.x-o(1).pos.x
ydiff#=o(L).pos.y-o(1).pos.y
ang#=WRAPvalue(ATANFULL(ydiff#,xdiff#))

o(L).rot=ang#

n(1).x=o(L).throttle*COS(o(L).rot)
n(1).y=o(L).throttle*SIN(o(L).rot)

INC o(L).speed.x, n(1).x
INC o(L).speed.y, n(1).y

o(L).speed.x=o(L).speed.x*o(L).brake
o(L).speed.y=o(L).speed.y*o(L).brake

IF o(L).speed.x
Beta1
23
Years of Service
User Offline
Joined: 28th Dec 2002
Location:
Posted: 9th Feb 2003 23:48
Oh Arse the code thingy screwed up. try again



Login to post a reply

Server time is: 2026-07-26 08:21:09
Your offset time is: 2026-07-26 08:21:09