Post Reply 
Graphic cursor problem
01-09-2021, 09:20 PM
Post: #1
Graphic cursor problem
Hi all,

[/code]Currently I am making a graphics program (app) where a cursor in the shape of a black square is projected on one of the squares on the screen, such that the character in the square is visible in reverse video. With one touch on the screen, the cursor can be moved to another square of your choice. When the program starts, the cursor is placed on the first square. So the idea is that you can move the cursor to any other square on the screen, with a touch on the screen. Unfortunately it goes wrong there, if the screen is touched, the cursor is not moved, but you will see the screen of the app from which the program is derived.

Some explanation about the program is in order: All variables that appear in this program are all declared at the beginning of this program, but that declaration is not visible in the code presented here. The variables cx and cy contain the coordinates where the screen was touched. The content of variable 'cursor' determines whether the cursor is visible or not, and is initially 1. List L9 contains characters, and list L0 contains numbers and sometimes characters. G2 contains a .PNG file that is copied to G0, and on which some characters are projected on places predetermined by coordinates. The variable 'tcrd' contains coordinates for letters, and the variable 'mcrd' for numbers and sometimes letters. If possible, the touches on the screen are converted to an index, which then takes the correct coordinates from list 'mcrd' and has to place the cursor in the right place on the screen. Since the characters are placed in the center of a square as much as possible, the cursor needs some math to get it in the right place. Based on the code, what could possibly be wrong or what needs to be inserted in order for the program to work in the end? Sincerely, Karel.

Code:

    . . .
  tcrd:={{119,98},{81,137}};
  mcrd:={{102,118},{119,118},{102,135},{119,135}};
  RECT();
  BLIT_P(G0,0,0,320,240,G2,0,0,320,240,#FFFFFF,255);
    FOR I FROM 1 TO 2 DO
      TEXTOUT_P(LEFT(L9(I),1),G0,tcrd(I,1),tcrd(I,2),3,#0,13); 
    END;
    FOR I FROM 1 TO 4 DO
      TEXTOUT_P(L0(I),G0,mcrd(I,1),mcrd(I,2),4,#0);
    END;
    CASE
      IF (cx≥98) AND (cx≤113) THEN
        CASE
          IF (cy≥120) AND (cy≤135) THEN
          index:=1;
          END;
          IF (cy≥137) AND (cy≤152) THEN
          index:=3;
          END;
        END;
      END;
      IF (cx≥115) AND (cx≤130) THEN
        CASE
          IF (cy≥120) AND (cy≤135) THEN
          index:=2;
          END;
          IF (cy≥137) AND (cy≤152) THEN
          index:=4;
          END;
        END;
      END;
    END;
    IF cursor:=1 THEN
      dx:=mcrd(index,1); dy:=mcrd(index,2); 
      INVERT_P(G0,dx-4,dy+2,dx+11,dy+17);
    END;
    . . .

I use HP-16C, WP-34S emulator, HP-35s, HP-48GX, HP-50g, and HP Prime G2.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Graphic cursor problem - cahlucas - 01-09-2021 09:20 PM
RE: Graphic cursor problem - Han - 01-10-2021, 09:45 PM
RE: Graphic cursor problem - cahlucas - 01-12-2021, 05:39 AM
RE: Graphic cursor problem - Han - 01-13-2021, 02:27 AM
RE: Graphic cursor problem - C.Ret - 01-12-2021, 12:13 PM
RE: Graphic cursor problem - cahlucas - 01-13-2021, 05:52 AM



User(s) browsing this thread: 2 Guest(s)