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