It is currently Sun Jun 25, 2017 8:47 pm



Welcome
Welcome to rfobasic

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. In addition, registered members also see less advertisements. Registration is fast, simple, and absolutely free, so please, join our community today. **You are not required to provide truthful information to any registration questions. Be whomever you wish to be.!


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Touch and Touch2
Unread postPosted: Sat Oct 22, 2016 12:57 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1337
Hi All

When using the below demo to control a car. For example if you are turning left and

accelerating and you stop accelerating, the turning left stops also even though you finger is

still on turning left. if you move your finger a bit or re-tap the turning left then turning

left starts to work again. I want it to keep turning without having to move finger a bit or

re-tap the turning left.

I'm using 'gr_collision' and have tried gr.'bounded.touch' and bounded.touch2 but get the same

thing.

Any one think of a better way.


Regards Roy

Code:
Rem touch and touch2

di_height = 672 % set to my Device
di_width = 1152

FALSE = 0 : TRUE = 1

gr.open 255,86,80,82
gr.orientation 0 % landscape

WakeLock 3

gr.screen screenWidth, screenHeight
scale_x = screenWidth / di_width
scale_y = screenHeight / di_height
gr.scale scale_x, scale_y

gr.color 255,255,255,255

gr.text.size 40 : gr.text.align 3

gr.text.draw txtAccelerate,di_width - 50,400, "Accelerate"

gr.text.draw txtBrake, di_width - 50,500, "Brake"

gr.text.align 1

gr.text.draw txtTurnLeft, 50, 400, "Turn Left"

gr.text.draw txtTurnRight, 50, 500, "Turn Right"

gr.point collision, -1, -1

gr.render

do
    gosub Accelerate
    gosub Brake
    gosub TurnLeft
    gosub TurnRight
    gr.render
until 0

onbackKey:
    end
back.resume

!------------------------------------------------
! Accelerate car
!------------------------------------------------
Accelerate:
    AccelerateFlag = FALSE
    gr.touch t, tx, ty
    if t then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtAccelerate) then
            gr.modify txtAccelerate, "text", "Accelerating using touch1"
            AccelerateFlag = TRUE
        endif
    endif
   
    gr.touch2 t2, tx, ty
    if t2 then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtAccelerate) then
            gr.modify txtAccelerate, "text", "Accelerating using touch2"
            AccelerateFlag = TRUE
        endif
    endif
   
    if ! AccelerateFlag then gr.modify txtAccelerate, "text", "Not Accelerating"
   
return

!------------------------------------------------
! Apply brake
!------------------------------------------------
Brake:
    brakeFlag = FALSE
    gr.touch t, tx, ty
    if t then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtBrake) then
            gr.modify txtBrake, "text", "Braking using touch1"
            brakeFlag = TRUE
        endif
    endif
   
    gr.touch2 t2, tx, ty
    if t2 then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtBrake) then
            gr.modify txtBrake, "text", "Braking using touch2"
            brakeFlag = TRUE
        endif
    endif
   
    if ! brakeFlag then gr.modify txtBrake, "text", "Not Braking"
return

!------------------------------------------------
! Turn car right
!------------------------------------------------
TurnLeft:
    turnLeftFlag = FALSE
    gr.touch t, tx, ty
    if t then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtTurnLeft) then
            gr.modify txtTurnLeft, "text", "Turning left using touch1"
            turnLeftFlag = TRUE
        endif
    endif
   
    gr.touch2 t2, tx, ty
    if t2 then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtTurnLeft) then
            gr.modify txtTurnLeft, "text", "Turning left using touch2"
            turnLeftFlag = TRUE
        endif
    endif
   
    if ! turnLeftFlag then gr.modify txtTurnLeft, "text", "Not turning left"
return

!------------------------------------------------
! Turn car right
!------------------------------------------------
TurnRight:
    turnRightFlag = FALSE
    gr.touch t, tx, ty
    if t then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtTurnRight) then
            gr.modify txtTurnRight, "text", "Turning right using touch1"
            turnRightFlag = TRUE
        endif
    endif
   
    gr.touch2 t2, tx, ty
    if t2 then
        tx /= scale_x : ty /= scale_y
        gr.modify collision, "x", tx, "y", ty
        if gr_collision(collision, txtTurnRight) then
            gr.modify txtTurnRight, "text", "Turning right using touch2"
            turnRightFlag = TRUE
        endif
    endif
   
    if ! turnRightFlag then gr.modify txtTurnRight, "text", "Not turning right"
return



Attachment:
TouchTouch2.zip [882 Bytes]
Downloaded 9 times


Report this post
Top
 Profile  
 
 Post subject: Re: Touch and Touch2
Unread postPosted: Sat Oct 22, 2016 5:50 am 
Offline

Joined: Sat May 14, 2011 7:43 am
Posts: 359
Location: South Africa, UK & US (Florida)
Hello Roy

I fear that you are encountering the "multi-touch" problem that I was battling with back in April and before.
Have a look at
viewtopic.php?f=7&t=4217
There were a lot of suggestions and ideas, but I remain demonstrably certain that BASIC! doesn't correctly handle the first release after two touches are concurrently active.
Marc did confirm that something was not quite right, and indicated that he would put it "on the list", but nothing further has arisen. I have had a few more "inspired?" attempts, but no tricks that I have tried will give me independent "flippers".
Peter


Report this post
Top
 Profile  
 
 Post subject: Re: Touch and Touch2
Unread postPosted: Sat Oct 22, 2016 8:44 am 
Offline
User avatar

Joined: Mon Aug 18, 2014 1:16 pm
Posts: 1337
Thanks Peter

From reading the link you provided, I can see there is little point in going on with my project.

Lets hope it is fixed in the next BASIC! release.

Regards Roy


Report this post
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
suspicion-preferred