? Using the Stylus?? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password
[Help Wanted] SmileBASIC Documentation Project

Using the Stylus??

  • #1 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength How can I make something(anything) happen when I touch the touch screen with the stylus???? Posted
  • #2 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    How can I make something(anything) happen when I touch the touch screen with the stylus????
    TOUCH OUT T,TX,TY
    Posted
  • #3 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    How can I make something(anything) happen when I touch the touch screen with the stylus????
    TOUCH OUT T,TX,TY
    I've already tried that, i need more of a basic example.
    Posted
  • #4 ✎ 196 MZ952 Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Drawing I like to draw! Hobbies Reading I like to read books! Hobbies WHILE 1 TOUCH OUT T,X,Y IF(T!=0)THEN GCIRCLE X,Y,3,#WHITE WEND Posted
  • #5 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    WHILE 1 TOUCH OUT T,X,Y IF(T!=0)THEN GCIRCLE X,Y,3,#WHITE WEND
    That works great but is there a way for me to touch any where with in a box like area.
    Posted
  • #6 ✎ 192 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself How would you check if a point is within a box normally? IF X>=BX1 && Y>=BY1 && X<=BX2 && Y<=BY2 THEN... Posted
  • #7 ✎ 53 JINC_DEV Video Games I like to play video games! Hobbies Pokemon Is Awesome! I love Pokemon! Express Yourself Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength
    How would you check if a point is within a box normally?
    I don't know.
    Posted
  • #8 ✎ 219 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest First Year My account is over 1 year old Website
    How would you check if a point is within a box normally?
    I don't know.
    He wasn’t asking if you know, he was giving an example in code of that situation.
    Posted
  • #9 ✎ 192 TheV360 Third Year My account is over 3 years old Website First Day Joined on the very first day of SmileBASIC Source Website Night Person I like the quiet night and sleep late. Express Yourself ACLS '@1 XSCREEN 3 DISPLAY 1 X1=50:Y1=50 '@2 W1=32:H1=32 WHILE 1 '@3 VSYNC GCLS:CLS '@4 TOUCH OUT TT,TX,TY '@5 GCIRCLE TX,TY,3,#WHITE GBOX X1,Y1,X1+W1-1,Y1+H1-1,#LIME '@6 IF TT && TX>=X1 && TX<=X1+W1-1 && TY>=Y1 && TY<=Y1+H1-1 THEN:?"Touching square!" WEND Here's some sample code - but wait. It's not great to just Ctrl+C Ctrl+V the code (or in SmileBASIC's case, painstakingly type out each line), it's good to know what each line of code does. @1 This just resets the screen and lets us put stuff on the bottom screen. @2 This defines a few variables that represent a box with X and Y coordinates as well as a width and height. @3 This is just an infinite loop. @4 This sets a few variables to the touch screen coordinates. @5 This draws the box we defined in @2 and a circle around our current touch coordinates. @6 This checks to see if
    1. We are currently touching
    2. Our touched point is to the right of the left side of the box
    3. Our touched point is to the left of the right side of the box
    4. Our touched point is below the top of the box
    5. Our touched point is above the bottom of the box
    in that order. If all this is true, it shows the text "Touching square!" Note: When you stop touching the screen, the coordinates aren't reset. However, the time touched variable is reset to zero. This is why the circle sticks around even though we stopped touching the screen.
    Posted Edited by TheV360
  • #10 ✎ 42 kantackistan A trick I used in Super Bearland was to make an invisible Cursor sprite that moved to wherever you touched. Everything clickable was a sprite, so all I had to do was detect sprite collision to determine if you tapped something. Posted
  • #11 ✎ 23 CosmicTacoCat Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Video Games I like to play video games! Hobbies Night Person I like the quiet night and sleep late. Express Yourself
    A trick I used in Super Bearland was to make an invisible Cursor sprite that moved to wherever you touched. Everything clickable was a sprite, so all I had to do was detect sprite collision to determine if you tapped something.
    Yeah this. Makes things really easy.
    Posted
  • #12 ✎ 219 ProKuku Avatar Taboo I didn't change my avatar for 180 days Website Final(?) Contest Runner Up I placed 2nd in the (possibly) final SmileBASIC Source Contest! October 2018 Programming Contest First Year My account is over 1 year old Website
    ACLS '@1 XSCREEN 3 DISPLAY 1 X1=50:Y1=50 '@2 W1=32:H1=32 WHILE 1 '@3 VSYNC GCLS:CLS '@4 TOUCH OUT TT,TX,TY '@5 GCIRCLE TX,TY,3,#WHITE GBOX X1,Y1,X1+W1-1,Y1+H1-1,#LIME '@6 IF TT && TX>=X1 && TX<=X1+W1-1 && TY>=Y1 && TY<=Y1+H1-1 THEN:?"Touching square!" WEND
    I found this helpful with the touch screen, but is there a way to check if the circle is colliding with the square on the edges of the circle instead of just the middle, where the stylus is?
    Posted Edited by ProKuku
  • #13 ✎ 132 DFrost Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength measure distances(distance from one point to another in 360 degrees forms a circle) DEF DIST(X,Y,X2,Y2) RETURN SQR(POW(X2-X,2)+POW(Y2-Y,2))'use the Pythagorean Theorem END Posted Edited by DFrost