Menu

Movement

2007-03-20
2013-04-04
  • Nobody/Anonymous

    I would like to post a tutorial on the website, but seeing as there are no uploading options the forum seems like a good place to start.  I have been toying around with BASIC ever since i first got my hands on a TI-83 calculator.  I don't have much time to upload tutorials, but i am looking for a hobby i can do while at home, so don't expect me to post too very often, especially as i am soon to be a father! anyway, here is a program i wrote using BASIC-256 that allows you to move a circle around the screen using the arrow keys on your keyboard, there are better methods for movement, but seeing as how im more used to the ti83 than i am to BASIC-256, i am using a very primitive method, but i hope i can spark some creative interest!

    x=50
    y=50
    k=0
    drawLoop:
    clg
    cls
    circle x,y,8
    print "x axis:"
    print x
    print "y axis:"
    print y
    label1:
    k = key
    if k = 0 then goto label1
    if k = 16777236 then x = x+10
    if k = 16777234 then x = x-10
    if k = 16777235 then y = y-10
    if k = 16777237 then y = y+10
    if x = 10 then x = 20
    if x = 290 then x = 280
    if y = 290 then y = 280
    if y = 10 then y = 20
    goto drawLoop

     
    • Nobody/Anonymous

      thanks, very nifty!

      Mike

       
    • SuperNatendo

      SuperNatendo - 2007-03-21

      All right, Im officially a member of this thread now! Yay!
      Anyway, here is an update to the progress I am making on the program I posted at the beginning of this thread:

      On the TI-83, if you want movement to take up less resources (since you need all you can get making games on the TI-83 LOL! I'm such a loser!)

      you can use a variant of the following commands on the TI-83's BASIC-like Program editor which doesn't seem to work in BASIC-256:

      x = x + (10 * (k = 16777236)) - (10 * (k = 16777234))

          This line of code, based on a similar algebraic function when used on the TI 83 anway, would reduce the lines of code needed for the program in the first post of this thread in half, since, given that the right arrow is pressed giving k the value of 16777236, the line (k = 16777236) would be reported as true (1) and (k = 16777234) would be reported as false (0).  Thus x = x + (10 * (k = 1677236)) - (10 * (k=16777234)) can be simplified as
      x = x + (10 * 1) - (10 * 0) which is further simplified as x = x + 10-0 or x = x + 10 resulting in the circle moving right.
         
      When the left arrow is pressed then (k = 16777234) would report as true (1) and (k = 16777236) as false (0) resulting in x = x + -10, which results in the circle moving left.

      The same function can be applied to the up and down arows changing the value of the y-axis:

      y = y + (10 * (k = 16777237)) - (10 * (k = 16777235))

      if anyone can show me how to make these equations work in BASIC-256 as i was able to do on the ti-83, then it would dramatically improve the program posted in the first post on this thread!

       
    • SuperNatendo

      SuperNatendo - 2007-03-21

      Oh, this might be a way to simplify the pong program i saw in the developers section as well...If only it worked!! grrrrrrrr....LOL

       
      • yhevhe

        yhevhe - 2007-05-10

        It would have to be something like this (I'm sure you already got it working anyway ;)

          if k=16777237 or k=16777235 then y = y + (10/2 * (k-16777237)) + (10/2 * (k-16777235))

         

Log in to post a comment.