Jump to content
IGNORED

Controlling sprites with the joystick on the C128


Frozone212

Recommended Posts

I'm not near a 128, but a combination of the JOY function and MOVSPR command should do what you want.

 

JOY(1) returns the position of joystick port 1 such that starting at Up/North as 1, the directions are numbered clockwise from 1-8 (so 8 is NW).  The fire button adds 128 to the value returned.

 

Take this value and feed it into MOVSPR - it expects degrees.

 

So, as a quick example:

10 A=JOY(1):IF A>128 THEN A=A-128

15 IF A=0 THEN MOVSPR 1,45*(A-1)#0:GOTO 10

20 MOVSPR 1,45*(A-1)#5

30 GOTO 10

 

This should move an already defined sprite in the direction the joystick is being pushed at speed 5.  It ignores the fire button, but you could put logic in there to check and do something different if the fire button is pressed.  If the joystick is released, the sprite stops moving.  

Edited by Casey
  • Like 1
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...