I'm essentially trying to make a "pushing" system for my game, and I want the player to have the "push" icon_state while they're bumping into a pushable obj, and then go back to idle when they stop moving toward the obj. I initially tried flicking the icon state on each call of Bump() but that led to wonky animations. What simple and concise method am I overlooking?
ID:2105261
Jun 24 2016, 12:02 am
|
|
Jun 24 2016, 5:55 pm
|
|
could you not just change the icon state to push and hold your old icon state in a variable then switch your icon state to that variable when youre done pushing
|
In response to Zagros5000
|
|
Zagros5000 wrote:
could you not just change the icon state to push and hold your old icon state in a variable then switch your icon state to that variable when youre done pushing Not really sure what you mean. An example would be nice Also I managed to achieve the desired result with the following code, but I feel like it's in a very [inefficient?] way. A better way would be nice mob |
mob this might work the same edit: my bad u shudnt step again |
btw not really related but you shouldnt be creating procs like that then using the supercall, it's better to just have one long proc - if its for the same type. Not sure why but the more you have the longer it takes for the proc to run as i noticed in the profiler:
move() a ..() move() ..() b move() ..() c would takes three times as long run as: move a b c |
Zagros5000 said:
Not sure why but the more you have the longer it takes for the proc to run as i noticed in the profiler Proc call overhead is a factor. Bear with me as this is just a rough, untested thought. What I'm thinking involves something similar to this: atom/movable With this, the idea is that once you bump a pushable object, the icon_state of the mover is set along with the direction they are pushing via push_dir. Then, once the mover attempts a movement, their dir and push_dir are checked for consistency. If they are not consistent, we reset their icon_state and set push_dir to 0, indicating they are no longer pushing anything. There is no need to reset the icon_state every movement using this. This is in no way perfect, and again, it is untested; consider it an example of concept that you may or may not learn something from. Also, your Move() proc expects a number to be returned. If you do not fix this, you will have a broken game in the future. It wouldn't hurt if you checked out how movement works either. |
In response to FKI
|
|
FKI wrote:
Also, your Move() proc expects a number to be returned. If you do not fix this, you will have a broken game in the future. It wouldn't hurt if you checked out how movement works either. How does my Move() proc expect a number to be returned??? It's just a simple 2 line override. |
In response to SolarOblivion
|
|
In response to FKI
|
|