Sign In

Using the Stylus??

#1✎ 53JINC_DEVVideo GamesI like to play video games!HobbiesPokemon Is Awesome!I love Pokemon!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthHow can I make something(anything) happen when I touch the touch screen with the stylus????
Posted 2 months ago

#2✎ 124WarriorExpert ProgrammerProgramming no longer gives me any trouble. Come to me for help, if you like!Programming StrengthNight PersonI like the quiet night and sleep late.Express YourselfDrawingI 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 2 months ago

#3✎ 53JINC_DEVVideo GamesI like to play video games!HobbiesPokemon Is Awesome!I love Pokemon!Express YourselfIntermediate ProgrammerI 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????

#4✎ 121MZ952Intermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthDrawingI like to draw!HobbiesReadingI like to read books!HobbiesWHILE 1
TOUCH OUT T,X,Y
IF(T!=0)THEN GCIRCLE X,Y,3,#WHITE
WEND
Posted 2 months ago

#5✎ 53JINC_DEVVideo GamesI like to play video games!HobbiesPokemon Is Awesome!I love Pokemon!Express YourselfIntermediate ProgrammerI 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 2 months ago

#6✎ 134TheV360April Fool's 2017 Contest WinnerI won the SmileBASICSource April Fool's 2017 Contest!Programming ContestFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfHow would you check if a point is within a box normally?
IF X>=BX1 && Y>=BY1 && X<=BX2 && Y<=BY2 THEN...
Posted 2 months ago

#7✎ 53JINC_DEVVideo GamesI like to play video games!HobbiesPokemon Is Awesome!I love Pokemon!Express YourselfIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming Strength

He wasn’t asking if you know, he was giving an example in code of that situation.
Posted 2 months ago

#9✎ 134TheV360April Fool's 2017 Contest WinnerI won the SmileBASICSource April Fool's 2017 Contest!Programming ContestFirst DayJoined on the very first day of SmileBASIC SourceWebsiteNight PersonI like the quiet night and sleep late.Express YourselfACLS '@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

We are currently touching

Our touched point is to the right of the left side of the box

Our touched point is to the left of the right side of the box

Our touched point is below the top of the box

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 2 months ago
Edited 2 months ago
by TheV360

#10✎ 41kantackistanA 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 2 months ago

#11✎ 23CosmicTacoCatIntermediate ProgrammerI can make programs, but I still have trouble here and there. Programming StrengthVideo GamesI like to play video games!HobbiesNight PersonI 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.

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 2 months ago
Edited 2 months ago
by ProKuku