Jump to content
IGNORED

Subpixel movement and friction


johnnywc

Recommended Posts

Hello all,

 

I know both of these topics have been discussed at length before, yet I still can't seem to grasp an easy way to apply friction to a moving object.

 

I'm trying to simulate the tank movement in Rip Off. I have 16 directions, each with a predefined horizontal and vertical component.

 

For the tank, I have the following variables:

 

TankXf ; fractional part of tank X coord

TankX ; integral part of tank X coord

 

TankYf

TankY

 

TankHf ; fractional part of horizontal speed

TankH ; integral part of horizontal speed

 

TankVf ; fract. part, vertical speed

TankV ; int. part, vert speed

 

The speeds are defined in a table.

 

So, assuming X holds the current direction (0-15), motionHf, motionH holds the 16 possible horizontal speeds and motionVf, motionV holds the 16 possible vertical speeds:

 

lda  TankHf
clc
adc motionHf,x
sta  TankHf
lda  TankH
adc  motionH
sta  TankH

lda  TankVf
clc
adc motionVf,x
sta  TankVf
lda  TankV
adc  motionV
sta  TankV

 

NOTE: motionH and motionV are 0 for positive directions and -1 for negative directions. motionHf and Vf are either +/- a value based on whether the direciton is negative or positive.

 

I then add TankHf, TankH to TankXf, TankX and add TankVf, TankV to TankYf, TankY. This produces good Asteroids type subpixel movement (albeit with no maximum speeds).

 

So, I'm looking for a way to:

 

1) add friction (have the values go to 0 when thrust is not applied)

2) have a maximum H and V speed (this may be solved with (1)

 

Of course, I'm looking to have this simulate the movement in Rip Off as close as possible.

 

Any ideas?

 

Thanks!

Edited by johnnywc
Link to comment
Share on other sites

 

Thanks - I did read that thread but I can't seem to find an elegant way to implement it. Any examples using the data structures I have above? Is it as simple as getting TankHf, TankH, doing an lsr a couple times (how many)? and then subtracting that from the original TankHf/TankH? (and the same for the TankV/Vf?) I tried something similar and the acceleration was very slow; also, it didn't work in the reverse direction.

 

Any help is appreciated!

 

Thanks again,

Link to comment
Share on other sites

I wonder why it didn't work for you. Probably you didn't shift often enough. And you have to make sure, that you shift arithmetically (shifting 1s into bit 7) when the speed is negative.

 

For will limit the maximum speed, but won't reduce the speed down to exactly zero. Just subtracting 1 more, should solve that problem.

 

Check my Cave1K code (ySpeed).

Edited by Thomas Jentzsch
Link to comment
Share on other sites

Here is some stripped code and binary, showing friction only.

 

Notice the difference acceleration and friction values for x and y. The combination of acceleration and friction values gives the maximum speed.

 

EDIT: Fixed version.

Friction02.bin

Friction02.zip

Edited by Thomas Jentzsch
Link to comment
Share on other sites

  • 2 weeks later...

Here is some stripped code and binary, showing friction only.

 

Notice the difference acceleration and friction values for x and y. The combination of acceleration and friction values gives the maximum speed.

 

EDIT: Fixed version.

Hallo Thomas

Wäre toll,wenn du mal was wirklich Gutes mit Batari Basic machen könntest.Dieser Sprite sieht doch schon recht gut aus(besser als andere).Wäre schön mal was vom Profi zu sehen.Ich bin überzeugt,dass du einiges aus Batari Basic rausholen könntest.

Gruss Walter

Link to comment
Share on other sites

Wäre toll,wenn du mal was wirklich Gutes mit Batari Basic machen könntest.Dieser Sprite sieht doch schon recht gut aus(besser als andere).Wäre schön mal was vom Profi zu sehen.Ich bin überzeugt,dass du einiges aus Batari Basic rausholen könntest.

Warum sollte ich?

1. Ist BASIC keine Herausforderung

2. Kann ich mit Assembler alles machen was geht und nicht nur was BASIC kann

3. Der Sprite ist wirklich nicht besonderes

 

Nee, BASIC ist nichts für mich. :)

Link to comment
Share on other sites

Wäre toll,wenn du mal was wirklich Gutes mit Batari Basic machen könntest.Dieser Sprite sieht doch schon recht gut aus(besser als andere).Wäre schön mal was vom Profi zu sehen.Ich bin überzeugt,dass du einiges aus Batari Basic rausholen könntest.

Warum sollte ich?

1. Ist BASIC keine Herausforderung

2. Kann ich mit Assembler alles machen was geht und nicht nur was BASIC kann

3. Der Sprite ist wirklich nicht besonderes

 

Nee, BASIC ist nichts für mich. :)

Hallo Thomas

Logisch,dass Basic für dich keine Herausforderung ist.Ich jedoch wäre froh,wenn ich es könnte.Ich warte immer noch auf den Kurs von Michael.

Klar kannst du in Assembler alles machen.aber du(als Top-Programmierer)könntest wahrscheinlich mehr herausholen,als viele Andere.

Ja,für Assembler Verhältnisse ist der Sprite nix Besonderes,aber wenn man mal sie anderen Sprites so sieht,dann ist dein Smilie richtig gut.

 

Gruss Walter

Link to comment
Share on other sites

Klar kannst du in Assembler alles machen.aber du(als Top-Programmierer)könntest wahrscheinlich mehr herausholen,als viele Andere.

Kaum, BASIC ist das Limit, nicht meine Fähigkeiten.

 

Ja,für Assembler Verhältnisse ist der Sprite nix Besonderes,aber wenn man mal sie anderen Sprites so sieht,dann ist dein Smilie richtig gut.

Das hat nun wirklich überhaupt nichts mit Basic zu tun. So'n Sprite kannst du in BASIC problemlos auch erstellen. Es ist ja nichtmal mehrfarbig.

 

Ich bin was Grafik angeht nun wirklich kein Experte. Wenn andere BASIC Sprites deiner Meinung nach noch schlechter aussehen als meine, dann hat das andere Gründe.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...