*BUMP* + info...
The problem with the original code is that the commands in the function body arent changing the variable values in the type being passed to it. As it stands, the function is creating a completely separate TYPE of object_info, and operating on that.
What I need is a way for my function to change the actual VALUES of the variables owned by the TYPE that I pass into the function. In C++ I can use pointers for this, but in Dark Basic PRO Im unsure of the proper syntax... I have tried using the '*' character in the prototype, but found that it then points to the ACTUAL type 'player' and NOT the type I am passing to the function:
Quote: "
movement(square)
FUNCTION movement(*player as object_info)
if player.right then turn object right player.object,player.turn
if player.left then turn object left player.object,player.turn
if player.go=1 then player.speed=player.speed+player.accel
if player.go=0 and player.speed>0 then player.speed=player.speed-player.coast
if player.go=0 and player.speed<0 then player.speed=player.speed+player.coast
if player.go=-1 then player.speed=player.speed-player.brake
if player.speed>player.topspeed then player.speed=player.topspeed
if player.speed<player.reverse then player.speed=player.reverse
move object player.object,player.speed
ENDFUNCTION
//THIS function code (even though Im calling it on 'square') operates //directly on 'player' -- not the intended result!
"
Again, I need pointers to make this function UNIVERSAL, so it could be effectively used as follows:
Quote: "
movement(square)
movement(triangle)
movement(cube)
movement(player)
movement(player2)
movement(enemy)
"
I hope that makes my problem more clear -- I have a hard time putting these things to words.
Any help would be greatly appreciated!
http://timmayj.cjb.net/