tschak909 Posted June 13, 2016 Share Posted June 13, 2016 I've been messing around trying to do my own fractional motion routine, so I can provide some inertia to my joystick controls... does anyone have a little snippet of code to jog my head? *embarrassed* (funny enough, one of my iterative attempts created a situation where you would hold the joystick in direction, and after half a second, it would scoot and then stop, like somebody lifting a REALLY heavy boulder, moving it, and then slamming it back down again.) What they say about coding truly is spot on... I either feel like a god...or I need my drool cup changed. -Thom Quote Link to comment Share on other sites More sharing options...
RevEng Posted June 14, 2016 Share Posted June 14, 2016 The fractional bit is easy enough. It's just 16-bit addition or subtraction, and you use the high byte as the coordinate. clc lda playerx+1 adc #32 ; or some other value, to give value/256 fractional addition sta playerx+1 lda playerx adc #0 sta playerx But you mention inertia, which is a bit more complex. For inertia, you need variables for velocity. When the player moves in a direction, the velocity value is subtly increased. Every frame, the velocity gets added to the player position. Something like... bit SWCHA bmi SkipJoyRight clc lda velocityx adc #5 ; just small arbitrary amount of thrust or impetus sta velocityx SkipJoyRight bit SWCHA bvs SkipJoyLeft sec lda velocityx sbc #5 sta velocityx SkipJoyLeft ; [misc game logic] ; add velocity to the player position every frame... clc lda playerx+1 adc velocityx sta playerx+1 lda playerx adc #0 sta playerx It's a bit more tricky if you want to add drag, or angular thrust, but those are just additional wrinkles on this basic system. Quote Link to comment Share on other sites More sharing options...
DanOliver Posted June 14, 2016 Share Posted June 14, 2016 (funny enough, one of my iterative attempts created a situation where you would hold the joystick in direction, and after half a second, it would scoot and then stop, like somebody lifting a REALLY heavy boulder, moving it, and then slamming it back down again.) I must be weird but I think a serendipitous result like that is difference between programming being art vs science. Movement like that could provide inspiration for a game idea. Got me thinking. Quote Link to comment Share on other sites More sharing options...
tschak909 Posted June 14, 2016 Author Share Posted June 14, 2016 I must be weird but I think a serendipitous result like that is difference between programming being art vs science. Movement like that could provide inspiration for a game idea. Got me thinking. Indeed. Nifty happy accidents.. -Thom Quote Link to comment Share on other sites More sharing options...
Thomas Jentzsch Posted June 14, 2016 Share Posted June 14, 2016 Also look here. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.