In my game, I want the character to move a ball in the direction they bump into it, but I can't quite figure out how to make it work. I looked up Bump() in the help, but I didn't understand all too well, and there weren't any demos to show how to move objects by running into them. It's like a soccer ball, and I want it to not move if there's a dense turf.
Thank you in advance for the help
-Drew
ID:272132
Apr 7 2008, 2:20 pm
|
|
In response to Darkmag1c1an11
|
|
Darkmag1c1an11 wrote:
I may have mixed up usr and src in the step proc, play around with that. Oh boy did you! There's a few small problems with your example. For starters, you are not going to get the ball moving the right direction like that. You have to get the direction from which it was kicked, by using get_dir(player,ball). The next problem, is the usr in proc. In most cases, usr in proc is not desirable. This is one of them. It WILL work, in this case, as usr is generally the last person to perform an action. Unfortunately, it's still just bad practice. It's better to pass the bumper along as an argument to the bumped object. atom/bumped(var/atom/movable/o) |
In response to Ter13
|
|
Thank you. I'll have to play around with it on Friday and see if I can get this thing working right. After hearing it explained a little from you two, it makes a bit more sense.
-Drew |
In response to Dragonn
|
|
This here wouldn't work too well. If you have walls listed as an object, then bumping into walls would move them. Use M.type if you need to get that specific.
|
In response to Darkmag1c1an11
|
|
Or just look at the better examples below...
|
In response to Aaiske Productions
|
|
Well, I got it working, but I'm having trouble with something else now. I want to have a small delay between hitting the ball (because if you press in a direction twice, it moves twice really fast). I've tried to make variables like AbletoBump=0, then after bumping it waits 0.5 seconds until it makes AbletoBump=1. It doesn't seem to work though... Is there something different about object vars? Or am I just missing something small?
Thanks -Drew |
In response to Aaiske Drew
|
|
did you try sleep?
|
In response to SadoSoldier
|
|
Yes, I used sleep. I figured out a different (and probably easier) way of doing it. I just made the var for mobs instead of the object itself, and it seems to work a-ok. It'd be better if it was a var for the object itself, but this'll work for now.
-Drew |
I may have mixed up usr and src in the step proc, play around with that.