BBC BASIC
« BBCSDL for Android »

Welcome Guest. Please Login or Register.
Feb 20th, 2017, 12:40am


Cross-platform BBC BASIC (Win32, Linux x86, Android, Mac OS-X, Raspberry Pi)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: BBCSDL for Android  (Read 88 times)
jorgerhv
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 5
xx BBCSDL for Android
« Thread started on: Feb 2nd, 2017, 5:56pm »

I am glad to play this puzzle in Android now.
I know the code is poor and bad style.
But it works !
I would like improve it.

This is the old puzzle NO-LEFT. You must arrive to the exit
without use the left key.
The QUIT command get me out of IDE.
It has some flickering.
The SYS call is not working.

Thanks

Code:
ON ERROR OSCLI "REFRESH ON" : IF ERR=17 CHAIN @dir$+"../tools/touchide" ELSE MODE 3 : PRINT REPORT$ : END

      REM SW_MAXIMIZE = 3:                             REM    Maximize the window
      REM SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
      REM VDU 26:                                  REM    Resetting origen to fill the area

      ORIGIN 0, -80

      REM SYS "CreateMenu" TO hmenu%
      REM SYS "SetMenu", @hwnd%, hmenu%
      REM SYS "AppendMenu", hmenu%, 0, 0, "RESET"
      REM SYS "AppendMenu", hmenu%, 0, 1, "HELP"
      REM SYS "DrawMenuBar", @hwnd%

      REM Click% = -1
      REM ON SYS Click% = @wparam% :RETURN

      DIM A(22,22)

      REM                                          RESTART
      (REINICIAR)

      Izquierda = 1
      Arriba = 1
      Derecha = 1
      Abajo = 1

      CLS
      Click% = -1
      CAJAS = 6
      RESTORE
      REM                                          Maze was made with origin on top left.
      FOR J=17 TO 1 STEP -1:FOR I=1 TO 17
          READ A(I,J)
          IF A(I,J) = 1 THEN PX = I:PY = J
        NEXT I:NEXT J

      GOSUB (DIBUJAR):                             REM TO DRAW

      REM                                          Wait for key input or mouse click.
      (ESPERA)

      REM IF Click% = 0 THEN GOTO (REINICIAR)
      REM IF Click% = 1 THEN PROChelp


      MOUSE x, y, b
      REM gcol 4                                   rem colour Y GRUESO DE UN PIXEL
      IF b AND (x>1130) AND (x<1230) AND (y>150) AND (y<250) THEN QUIT
      IF b AND (x>1130) AND (x<1230) AND (y>280) AND (y<380) THEN GOTO (REINICIAR)
      IF b AND (x>1090) AND (x<1170) AND (y>600) AND (y<700) THEN LET ch = 136 : GOTO (KEYDETECTED): REM LEFT
      IF b AND (x>1140) AND (x<1220) AND (y>720) AND (y<820) THEN LET ch = 139 : GOTO (KEYDETECTED): REM UP
      IF b AND (x>1190) AND (x<1270) AND (y>600) AND (y<700) THEN LET ch = 137 : GOTO (KEYDETECTED)
      IF b AND (x>1140) AND (x<1220) AND (y>480) AND (y<580) THEN LET ch = 138 : GOTO (KEYDETECTED)

      k$ = INKEY$(1):IF k$ = "" THEN GOTO (ESPERA)
      IF ((k$ = "r") OR (k$ = "R")) THEN GOTO (REINICIAR)
      ch = ASC(k$)

      (KEYDETECTED)

      IF (ch = 138 AND PY > 1 AND  A(PX,PY-1) <> 9 AND  A(PX,PY-1) <> 8) THEN GOSUB (ARRIBA):GOSUB (DIBUJAR)
      IF (ch = 139 AND PY < 20 AND  A(PX,PY+1) <> 9 AND A(PX,PY+1) <> 8) THEN GOSUB (ABAJO):GOSUB (DIBUJAR)
      IF (ch = 137 AND PX < 20 AND  A(PX+1,PY) <> 9 AND  A(PX+1,PY) <> 8) THEN GOSUB (DERECHA):GOSUB (DIBUJAR)
      IF (ch = 136 AND PX > 1 AND  A(PX-1,PY) <> 9 AND  A(PX-1,PY) <> 8) THEN GOSUB (IZQUIERDA):GOSUB (DIBUJAR)

      GOTO (ESPERA)

      REM LABEL ARRIBA ( UP )
      (ARRIBA)
      IF Arriba = 0 THEN RETURN
      Izquierda = 1
      Arriba = 1
      Derecha = 0
      Abajo = 0
      A(PX,PY) = 0
      PY=PY-1
      A(PX,PY) = 1
      RETURN

      REM LABEL ABAJO ( DOWN )
      (ABAJO)
      IF Abajo = 0 THEN RETURN
      Izquierda = 0
      Arriba = 0
      Derecha = 1
      Abajo = 1
      A(PX,PY) = 0
      PY=PY+1
      A(PX,PY) = 1
      RETURN

      REM LABEL DERECHA ( RIGHT )
      (DERECHA)
      IF Derecha =0 THEN RETURN
      Izquierda = 0
      Arriba = 1
      Derecha = 1
      Abajo = 0
      A(PX,PY) = 0
      PX=PX+1
      A(PX,PY) = 1
      RETURN

      REM LABEL IZQUIERDA ( LEFT )
      (IZQUIERDA)
      IF Izquierda = 0 THEN RETURN
      Izquierda = 1
      Arriba = 0
      Derecha = 0
      Abajo = 1
      A(PX,PY) = 0
      PX=PX-1
      A(PX,PY) = 1
      RETURN

      (DIBUJAR)

      FOR I=1 TO 20:FOR J=1 TO 20
          X = I*60:Y = J*60

          IF (A(I,J) = 1) THEN
            GCOL 1:CIRCLE FILL X+30,Y+30,24:GOTO (SIGUIENTE)
          ENDIF

          IF (A(I,J) = 9) THEN GCOL 2:RECTANGLE FILL X,Y,60,60:GOTO (SIGUIENTE)
          IF (A(I,J) = 5) THEN GCOL 4:CIRCLE FILL X+30,Y+30,24:GOTO (SIGUIENTE)
          IF (A(I,J) = 3) THEN GCOL 0:RECTANGLE FILL X,Y,60,60:GOTO (SIGUIENTE)
          IF (A(I,J) = 0) THEN GCOL 15:RECTANGLE FILL X,Y,60,60:GOTO (SIGUIENTE)
          GCOL 14:RECTANGLE X,Y,60,60

          (SIGUIENTE)
        NEXT J:NEXT I
      GCOL 0:RECTANGLE 1130,150,100,100
      VDU 5:MOVE 1150, 210:PRINT "QUIT"
      GCOL 0:RECTANGLE 1130,280,100,100
      MOVE 1140, 340:PRINT "RESET"
      GCOL 0:RECTANGLE 1140,480,80,100
      MOVE 1170, 540:PRINT "Dn"
      GCOL 0:RECTANGLE 1090,600,80,100
      MOVE 1120, 660:PRINT "Lt"
      GCOL 0:RECTANGLE 1190,600,80,100
      MOVE 1220, 660:PRINT "Rt"
      GCOL 0:RECTANGLE 1140,720,80,100
      MOVE 1170, 780:PRINT "Up"


      RETURN

      DEF PROChelp:LOCAL H$
      H$  = "The objective is arrive to the Exit"+CHR$13
      H$ += "without turn to the left"+CHR$13
      H$ += "and not to go back."+CHR$13
      SYS "MessageBox", @hwnd%, H$, "Help", 0
      Click% = -1
      ENDPROC

      DATA 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9
      DATA 9,0,0,0,0,0,0,0,0,0,0,0,9,0,0,0,9
      DATA 9,0,9,0,9,9,9,0,9,9,9,0,9,0,9,0,9
      DATA 9,0,0,0,9,0,0,0,9,0,0,0,0,0,0,0,9
      DATA 9,9,9,0,9,0,9,0,9,0,9,0,9,0,9,0,9
      DATA 9,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,9
      DATA 9,0,9,9,9,0,9,9,9,0,9,0,9,0,9,9,9
      DATA 9,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,9
      DATA 9,0,9,0,9,9,9,0,9,0,9,0,9,0,9,0,9
      DATA 9,0,9,0,0,0,0,0,0,0,0,0,9,0,0,0,9
      DATA 9,0,9,0,9,0,9,0,9,9,9,0,9,0,9,0,9
      DATA 9,0,9,0,0,0,0,0,0,0,9,0,0,0,0,0,9
      DATA 9,0,9,0,9,0,9,0,9,0,9,0,9,9,9,0,9
      DATA 9,0,0,0,0,0,9,0,0,0,0,0,0,0,9,3,0
      DATA 9,0,9,0,9,0,9,9,9,0,9,9,9,0,9,9,9
      DATA 9,0,0,0,9,0,0,0,0,0,0,0,0,0,0,1,9
      DATA 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9 

« Last Edit: Feb 4th, 2017, 3:51pm by Richard Russell » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 358
xx Re: BBCSDL for Android
« Reply #1 on: Feb 2nd, 2017, 9:31pm »

on Feb 2nd, 2017, 5:56pm, jorgerhv wrote:
The QUIT command get me out of IDE.

Don't use QUIT in Android, it doesn't really have a meaning on that OS. Until I (or somebody else) can figure out how to call one Android app from another, you will have to copy the approach that all the example programs use for returning to 'touchide' (i.e. a CHAIN statement in an ON ERROR handler).

Quote:
The SYS call is not working.

Are you asking for help in conversion, or are you happy to use the resources available to you on the web?

It would be nice if somebody could write a guide to translating Windows APIs to SDL APIs (those that aren't trivial, anyway) but that's not something I am going to do.

Richard.
User IP Logged

jorgerhv
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 5
xx Re: BBCSDL for Android
« Reply #2 on: Feb 3rd, 2017, 01:04am »

Thank you Richard.

It is ok for now.

I have converted more apps and they are working.

Jorge
User IP Logged

Edja
New Member
Image


member is offline

Avatar




PM


Posts: 11
xx Re: BBCSDL for Android
« Reply #3 on: Feb 4th, 2017, 2:12pm »

I tried this game with BB4W 6.02a.
It just displays the maze, then stops.
Edja
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 358
xx Re: BBCSDL for Android
« Reply #4 on: Feb 4th, 2017, 3:53pm »

on Feb 4th, 2017, 2:12pm, Edja wrote:
I tried this game with BB4W 6.02a. It just displays the maze, then stops.

If you are talking about Jorge's game it runs absolutely fine for me in BB4W. Are you sure you correctly edited the errors resulting from his omission of [code] tags? There are several places where Conforums has misconstrued code as emoticons as a result.

I've now added those tags to his post to make life easier for others.

Richard.
User IP Logged

Edja
New Member
Image


member is offline

Avatar




PM


Posts: 11
xx Re: BBCSDL for Android
« Reply #5 on: Feb 5th, 2017, 1:44pm »

Quote:
Are you sure you correctly edited the errors
Yes, I did. And, contrary to what I've posted earlier, the game ran flawlessly. I'm ashamed to have to admit that I've had misunderstood the game rules. So false alarm, very sorry!
Edja
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Donate $6.99 for 50,000 Ad-Free Pageviews!


This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls