FANDOM


Hit detection, or collision detection is a technique used by TI-Basic programmers to prevent one or more pixels from moving through another pixel or set of pixels.

Hit detection is possible both on the Homescreen and Graph screen.

Home ScreenEdit

:ClrHome
:7→A
:2→B
:"::::::::::::::::
  :              :
  : :::::::::::: :
  : :          : :       // this is actually 1 entire line
  : : :::::::: : :       // its shown this way just to show how the screen would look
  : : :::::::::: :
  : :            :
  ::::::::::::::::→Str1
:Output(1,1,Ans
:Repeat A=5 and B=13  
:Repeat Ans
:getKey→K
:End
:Output(A,B," ​           //  one space after the "
:sum(Δlist(Ans={25,34
:A+Ans(" "=sub(Str1,16(A-1+Ans)+B,1→A
:sum(Δlist(K={24,26
:B+Ans(" "=sub(Str1,16A-16+B+Ans,1→B
:Output(A,Ans,"X
:End

This program draws a maze on the Homescreen and uses hit detection to stop you from moving through the walls.

Graph ScreenEdit

:AxesOff
:PlotsOff
:FnOff
:ClrDraw
:Horizontal Ymin
:Horizontal Ymax
:Vertical Xmin
:Vertical Xmax
:For(A,1,20
:Repeat not(pxl-Test(Y,X)) and not(pxl-Test(Y+1,X)) and not(pxl-Test(Y,X+1)) and not(pxl-Test(Y+1,X+1
:randInt(3,90→X
:randInt(3,58→Y
:End
:Pxl-On(Y,X
:Pxl-On(Y+1,X
:Pxl-On(Y,X+1
:Pxl-On(Y+1,X+1
:End
:Repeat not(pxl-Test(Y,X
:randInt(1,93→X
:randInt(1,61→Y
:End 
:0→K
:While K≠105
:getKey
:0stoZ
:Pxl-On(Y,X
:Repeat K
:getKey→K
:Z+1→Z
:If Z=5500
:105→K
:End
:Pxl-Off(Y,X
:Y-(Ans=25 and not(pxl-Test(Y-1,X)))+(Ans=34 and not(pxl-Test(Y+1,X→Y
:X-(K=24 and not(pxl-Test(Y,X-1)))+(K=26 and not(pxl-Test(Y,X+1→X
:End
:ClrDraw
:ClrHome

First the program draws a border around your screen.

Second it uses hit detection to draw 20 boxes that do not overlap.

Third it places a controllable dot on the screen that will not move through any of the boxes.

Thanks to hit detection you cannot move through any of the boxes or the outside border of the screen. You can end the program manually by simply pressing the Enter key.

Also, if you stop doing anything long enough the program will end on its own.

No need to worry if you leave it running =)

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.