TGC Codebase Backup



Move Arrow's Mouse With Arrows Keys (ITA / ING) by DarkTy

13th Feb 2007 7:06
Summary

DB1 - DBPRO To Move Arrow's Mouse On The Screen With Arrows Key On The Keyboard.



Description

Arrows Key :
------------
[Up] = arrow's mouse go Up
[Down] = arrow's mouse go Down (important increment + 2)
[Left] = arrow's mouse go Left
[Right] = arrow's mouse go Right (important increment + 2)

When mouse move , arrow of the mouse is moving
When mouse don't move , then a "ghost" move the arrows
When a arrow key is pressed then move arrow on the direction associated to the arrow
Always print a point on the position of mouse with current color selected

Space Key:
----------
[Space] Clear screen

Number key:
-----------
[1] Change Color's Cactor R (RED)
[2] Change Color's Cactor G (GREEN)
[3] Change Color's Cactor B (BLUE)

ESC :
-----
[ESC] EXIT



Code
                                    ` This code was downloaded from The Game Creators
                                    ` It is reproduced here with full permission
                                    ` http://www.thegamecreators.com
                                    
                                    REM ******************************
REM Program by Tonino 2007(DarkTy)  
Rem From Italy :-)
REM ******************************
Rem ING: 1) This program view how move arrow's mouse with arrows keys on the keyboard
Rem ING: 2) Be ware that if you increase position of the mouse to down or to the right
Rem         ...the value must to be >1 also don't move
Rem ITA: 1) Questo programma visualizza il movimento del mouse che puo' essere controllato dalla tastiera
Rem ITA: 2) Per spostare il puntatore del mouse a destra o in basso occorre incrementare le variabili
Rem         ...con un valore di passo maggiore di 1 altrimenti resta fermo.

REM ==================================================
REM 3 Blocchi Configurazione / 3 Block Configuration :
REM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
REM C 0001 * IMPOSTAZIONI INIZIALI
REM C 0002 * ASSEGNAZIONE DEI VALORI
REM C 0003 * [[ CICLO PRINCIPALE ]]

REM ==================================================
REM 8 Blocchi Ciclati        / 8 Cicled Block        :
REM ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
REM DO 0001 * INTERROGAZIONE DATI
REM DO 0002 * CONFRONTO NUOVO PRELIEVO CON VECCHO PRELIEVO
REM DO 0003 * ARCHIVIAZIONE DATI
REM DO 0004 * INTERAZIONE UTENTE
REM DO 0005 * GESTIONE DATI E [[ EVENTI ]]
REM DO 0006 * AZIONE GRAFICA
REM DO 0007 * VISUALIZZAZIONE INFORMAZIONI
REM DO 0008 * AGGIORNAMENTO DELLO SCHERMO

REM ********
REM C 0001 *
REM =====================
REM IMPOSTAZIONI INIZIALI
REM =====================
SET DISPLAY MODE 1024,768,32
SYNC ON
SYNC RATE 1000

REM ********
REM C 0002 *
REM =======================
REM ASSEGNAZIONE DEI VALORI
REM =======================
Rem [Posizione e movimento]
IncrementoX=1
IncrementoY=1
LimiteMax_X=1024
LimiteMax_Y=768
OkLimitare = 1 :Rem  0=No limite  , 1=OK Limita
Rem [Colore]
ColoreR=255
ColoreG=255
ColoreB=255

REM ********
REM C 0003 *
REM ================
REM CICLO PRINCIPALE
REM ================
DO
   REM *********
   REM DO 0001 *
   REM ===================
   REM INTERROGAZIONE DATI
   REM ===================
   MX=MouseX()
   MY=MouseY()

   REM *********
   REM DO 0002 *
   REM ============================================
   REM CONFRONTO NUOVO PRELIEVO CON VECCHO PRELIEVO
   REM ============================================
   If (MX<>MemoriaMX or MY<>MemoriaMY) THEN OkEvento=-1
   If (MX=MemoriaMX AND MY=MemoriaMY) THEN OkEvento=0
   REM *********
   REM DO 0003 *
   REM ==================
   REM ARCHIVIAZIONE DATI
   REM ==================
   MemoriaMX = MX
   MemoriaMY = MY

   REM *********
   REM DO 0004 *
   REM ==================
   REM INTERAZIONE UTENTE
   REM ==================
   REM [Freccie / Arrows]  X   Movimento/ To Move
   IF UpKey()=1           THEN MY=MY-IncrementoY   :OkEvento=1
   IF DownKey()=1         THEN MY=MY+IncrementoY+1 :OkEvento=2
   IF LeftKey()=1         THEN MX=MX-IncrementoX   :OkEvento=4
   IF RightKey()=1        THEN MX=MX+IncrementoX+1 :OkEvento=8

   REM [Numeri]            X   Cambiare Colore / To Change Color
   A$=Inkey$()
   If A$="1"              Then ColoreR=ColoreR+1:IF ColoreR>255 Then ColoreR=0
   If A$="2"              Then ColoreG=ColoreG+1:IF ColoreG>255 Then ColoreG=0
   If A$="3"              Then ColoreB=ColoreB+1:IF ColoreB>255 Then ColoreB=0

   REM [Spazio]
   If A$=" " THEN CLS

   REM *********
   REM DO 0005 *
   REM ======================
   REM GESTIONE DATI E EVENTI
   REM ======================
   If OkLimitare=1 and MX>LimiteMax_X Then MX=LimiteMax_X
   If OkLimitare=1 and MY>LimiteMax_Y Then MY=LimiteMax_Y

   If OkEvento=-1 Then OrigineDati$ = "Mouse " :
   If OkEvento=0  Then OrigineDati$ = "Fantasma! / Ghost!" : POSITION MOUSE MX+RND(3)-RND(1),MY+RND(3)-RND(1) :REM DISEGNO DA FANTASMA
   If OkEvento>0
      REM *********************************
      REM =================================
      REM MOVIMENTO DEL PUNTATORE DEL MOUSE
      REM =================================
      REM *********************************
      POSITION MOUSE MX,MY                 :REM <<< MOVIMENTO DEL MOUSE IN MANUALE!!!
      OrigineDati$ = "Tastiera / KeyBoards"
   ENDIF

   REM *********
   REM DO 0006 *
   REM ==============
   REM AZIONE GRAFICA
   REM ==============
   Ink Rgb(ColoreR,ColoreG,ColoreB),0
   Dot MX,MY

   REM *********
   REM DO 0007 *
   REM ============================
   REM VISUALIZZAZIONE INFORMAZIONI
   REM ============================
   Rem [Titolo]
   Ink Rgb(0,128,0),0:BOX 0,0,1024,100
   Ink Rgb(0,64,32),0:BOX 0+5,0+5,1024-5,100-5
   SET TEXT SIZE 40 : INK RGB(0,255,0),0
   CENTER TEXT 1024/2,20,"Premere le Freccie Per Muovere Il puntatore del Mouse"
   CENTER TEXT 1024/2,60,"Use Arrows Key To Move Arrow's Mouse"
   INK RGB(255,255,255),0:Text 20,20,"ITA:" : Text 20,60,"ING:"

   Rem [Posizione del Mouse]
   SET TEXT OPAQUE
       SET TEXT SIZE 20
       INK RGB(255,255,255),0
       TEXT 20,700,"| Mouse | X: " + STR$(MX) + " | Y: " + STR$(MY) + " | " + SPACE$(40) + "Evento: " + SPACE$(40)
       INK RGB(255-(OkEvento*16),255-(OkEvento*32),100-(OkEvento*32)),0
       TEXT 650,700,OrigineDati$ + SPACE$(20)
   SET TEXT TRANSPARENT

   Rem [Info Colore]
   Ink Rgb(0,0,128),0:BOX 0,190,220,290
   Ink Rgb(0,32,64),0:BOX 0+5,190+5,220-5,290-5

   Ink Rgb(255,255,255),0
   Text 20,200,"RGB: ( " + STR$(ColoreR) + " , " + STR$(ColoreG) + " , " + STR$(ColoreB) + " ) "
   Text 20,120,"Premere [1] , [2] , [3] per cambiare colore , [Spazio] per pulire il foglio"
   Text 20,140,"Press   [1] , [2] , [3] for to change color , [Space]  for to clean up the paper"

   Ink Rgb(ColoreR,ColoreG,ColoreB),0
   Text 20,220,"[1] Rosso / Red   : " + Str$(ColoreR) + Space$(20)
   Text 20,240,"[2] Verde / Green : " + Str$(ColoreG) + Space$(20)
   Text 20,260,"[3] Blue  / Blue  : " + Str$(ColoreB) + Space$(20)


   REM *********
   REM DO 0008 *
   REM ===========================
   REM AGGIORNAMENTO DELLO SCHERMO
   REM ===========================
   SYNC
LOOP