Jump to content



0

Making an ice patch..


4 replies to this topic

#1 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Fri Sep 19, 2008 11:48 AM

How would you simulate an ice patch in bB?

.. or maybe an effect like Lunar Lander? In which you press right, release the joystick, and your guy still slides a bit.

#2 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Fri Sep 19, 2008 12:31 PM

By adding deltas to the sprite X/Y instead of an absolute. The absolute in this case is the current direction the stick is held in. The first frame that the stick has been moved, the delta for that axis is given the minimal value. Each successive frame that the stick is held, the delta variable is increased. Doubling the delta on each successive frame causes it to rise too quickly...so you'd probably want delta = delta * 1.25 or something similar. If the stick is not moved, allow the delta to "decay".

#3 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Tue Sep 23, 2008 7:01 AM

What I really want to simulate is a fish swimming in water. When you stop moving right he slides a little to the right. Same with every other direction. I understand what you are saying I think, just don't know how to implement.

Edited by yuppicide, Tue Sep 23, 2008 7:05 AM.


#4 Nukey Shay OFFLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Tue Sep 23, 2008 9:01 AM

You need to use multiple variables. One should be the status of the stick on the last frame (updated after the current stick's reading has been dealt with), another should be the duration that it's been identical to the current stick value (topping out at, say, 8 frames or so)...maybe resetting to zero when a stick direction change occurs. By using the latter, you can read a delta value from a table if you wish...but this does not solve the problem of handling decay. One way to approach this is rather than resetting the duration value to zero, reduce it instead.

Another approach is to use 2 variables instead of a duration...DX and DY. IIRC bBasic allows the use of signed floating-point variables, so you can use multiplication to increase the speed in any direction - as described before. The stick alters DX/DY, DX/DY alter X/Y. It's not much different than you already know how to change the sprite position...it's just done as a 2-step process. When the stick is not moved, use division to reduce both DX and DY.

#5 yuppicide OFFLINE  

yuppicide

    I am the Black Knight. Give me your money!

  • 6,933 posts
  • Location:New Jersey

Posted Tue Sep 23, 2008 10:07 AM

I understand what you are saying completely. I'll try and implement it later on when I get home and continue my work.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users