Author Topic: My roguelike in BASIC  (Read 5008 times)

0 Members and 1 Guest are viewing this topic.

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #50 on: 21:57, 20 October 19 »
Have you considered the A* pathfinding algorithm?
I had a look at that algorithm amongst many others. Problem is, the A* uses a much complicated math from what I can handle. The other methods are great, but they all imply that you´re in an actual labyrinth, meaning corridors 1 square width, so it´s very easy to find paths. My gameboard is different since it´s mainly an empty area with some obstacles scattered, so there are no real corridors.

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 562
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 547
  • Likes Given: 289
Re: My roguelike in BASIC
« Reply #51 on: 23:20, 20 October 19 »
Watching your progress with joy.
What I see is you are using very long variable names. Those "waste" a lot of space (and time for interpreter) on a CPC

-> see RAM excerpt


I recommend to shorten them for more free RAM and speed :)


Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #52 on: 23:43, 20 October 19 »
Watching your progress with joy.
What I see is you are using very long variable names. Those "waste" a lot of space (and time for interpreter) on a CPC

-> see RAM excerpt


I recommend to shorten them for more free RAM and speed :)
Well, it´s a balance between length and readability. Obviously, for the player strength an optimal variable name would be something like "ps", but that would have me reading a list of references to understand what I´m seeing, so I tend to name it something more like "player_str" or something similar. But yes, I know you´re right.
EDIT: Maybe a solution would be keep coding with long variables and shorten them once the game is finished (I´m using sublime, so it wouldn´t be difficult to do)
« Last Edit: 00:09, 21 October 19 by PAQUITO »

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 562
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 547
  • Likes Given: 289
Re: My roguelike in BASIC
« Reply #53 on: 22:03, 21 October 19 »
Source from 17.10.2019 - 3650 Bytes less :)
Code: [Select]
10 ' 8 BIT DUNGEONS
20 ' BY JNL
30 ' SEPT 2019
40 '
50 ' INICIALIZA VARIABLES NUMERICAS
51 INK 0,0:INK 1,25:MODE 1:BORDER 0:PAPER 0:PEN 1
61 INPUT"NAME:",N$:N$=UPPER$(N$):IF LEN(N$)>7 THEN PRINT"7 characters maximum":GOTO 61 ELSE 70
63 IF N$=""THEN 61
70 CLS:WINDOW#2,1,26,1,25:WINDOW#3,28,40,7,11:P2=1:D5=0:F=100:D2=100:H0=100:H=100:M2=1:'
120 ' DEFINE GRAFICOS
130 SYMBOL AFTER 48:' TIPOGRAFIA
150 SYMBOL 48,28,38,102,102,102,100,56,0:SYMBOL 49,16,56,24,24,24,24,16,0:SYMBOL 50,56,92,8,16,32,68,124,0:SYMBOL 51,124,72,16,60,12,8,16,32:SYMBOL 52,12,28,44,76,126,12,12,8:SYMBOL 53,30,36,112,56,28,12,68,56:SYMBOL 54,56,96,104,124,108,108,56,0
220 SYMBOL 55,124,100,8,8,16,16,48,24:SYMBOL 56,60,102,100,24,38,102,60,0:SYMBOL 57,60,102,102,110,118,38,4,24:SYMBOL 65,2,54,78,86,38,86,142,0:SYMBOL 67,58,86,208,208,208,82,60,0:SYMBOL 69,222,100,104,124,100,64,254,0
280 SYMBOL 72,64,228,110,118,102,103,102,4:SYMBOL 76,12,54,112,176,48,34,126,0:SYMBOL 77,74,254,106,106,106,107,74,0:SYMBOL 79,60,70,214,238,198,196,120,0:SYMBOL 80,44,246,102,102,118,236,96,240:SYMBOL 82,54,91,49,50,60,54,243,0
340 SYMBOL 83,58,68,200,124,38,98,188,0:SYMBOL 84,122,174,104,104,104,106,60,0:SYMBOL 85,68,238,102,102,102,111,50,0:SYMBOL 86,68,238,118,102,102,54,28,0:' GRAFICOS
390 SYMBOL 221,60,126,175,211,165,243,118,60:SYMBOL 222,126,126,126,126,126,126,60,24:SYMBOL 223,0,108,254,254,124,56,16,0:SYMBOL 224,0,6,14,220,120,48,88,136:SYMBOL 225,16,4,0,8,77,3,231,255:SYMBOL 226,0,140,204,208,224,232,252,224
450 SYMBOL 227,63,15,103,111,13,24,0,4:SYMBOL 228,242,254,252,224,224,244,224,0:SYMBOL 229,0,0,28,29,15,151,127,4:SYMBOL 230,1,1,226,244,248,248,248,40:SYMBOL 231,0,0,0,0,0,0,195,239:SYMBOL 232,0,0,0,0,48,240,224,192
510 SYMBOL 233,223,239,223,239,223,227,192,0:SYMBOL 234,255,255,232,232,208,160,0,0:SYMBOL 235,1,7,14,28,58,60,62,28:SYMBOL 236,224,216,220,108,240,120,184,112:SYMBOL 237,0,254,252,248,240,248,252,254:SYMBOL 238,0,127,63,31,15,31,63,127
570 SYMBOL 239,0,255,255,255,255,255,255,255:SYMBOL 240,1,35,119,119,113,116,115,114:SYMBOL 241,0,128,192,192,192,128,63,187:SYMBOL 242,249,6,119,15,15,15,60,30:SYMBOL 243,49,187,59,187,191,222,236,112:SYMBOL 244,85,254,255,254,255,254,255,254
630 SYMBOL 245,85,255,255,255,255,255,255,255:SYMBOL 246,253,170,127,255,255,255,255,127:SYMBOL 247,127,170,255,255,255,255,255,254:SYMBOL 248,83,238,217,181,181,109,125,109:SYMBOL 249,193,113,153,172,172,182,190,182
680 SYMBOL 250,121,102,118,105,125,109,125,109:SYMBOL 251,190,182,190,182,190,182,190,182:SYMBOL 252,31,55,59,0,59,59,59,59:SYMBOL 253,248,252,204,0,204,252,252,252:SYMBOL 254,0,0,6,73,249,6,0,0:'
740 ' DEFINE VARIABLES DE LOS SPRITES
750 R0$=STRING$(2,8)+CHR$(10):B0$="  "+R0$+"  ":G0$=CHR$(15)+CHR$(1)+CHR$(240)+CHR$(241)+STRING$(2,8)+CHR$(10)+CHR$(242)+CHR$(243):M3$=CHR$(15)+CHR$(1)+CHR$(244)+CHR$(245)+STRING$(2,8)+CHR$(10)+CHR$(246)+CHR$(247)
790 P5$=CHR$(15)+CHR$(2)+CHR$(248)+CHR$(249)+R0$+CHR$(250)+CHR$(251):C7$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(252)+CHR$(253):L1$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(254):C4$=CHR$(15)+CHR$(3)+CHR$(238)+CHR$(239):C3$=CHR$(15)+CHR$(3)+CHR$(239)+CHR$(237)
840 B1$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(235)+CHR$(236):M$=CHR$(15)+CHR$(2)+CHR$(231)+CHR$(232)+R0$+CHR$(233)+CHR$(234):R$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(229)+CHR$(230):G$=CHR$(15)+CHR$(3)+CHR$(225)+CHR$(226)+R0$+CHR$(227)+CHR$(228)
880 xp$=CHR$(15)+CHR$(3)+"  "+R0$+" "+CHR$(221):E1$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(222):C8$=CHR$(15)+CHR$(3)+"  "+R0$+" "+CHR$(223):E2$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(224):'
930 ' DIBUJA PANTALLA DE JUEGO
940 GOSUB 1660:FOR y=1 TO 12:FOR x=1 TO 13:IF C$(x,y)="*"THEN PAPER 0:LOCATE(x*2)-1,(y*2)-1:PRINT M3$
980 IF C$(x,y)="F"THEN PAPER 0:LOCATE(x*2)-1,(y*2)-1:PRINT P5$
990 NEXT x:NEXT y:LOCATE 30,1:PAPER 3:PEN 0:PRINT"         ":LOCATE 29,2:PAPER 0:PEN 3:PRINT C4$+"       "+C3$:LOCATE 31,1:PAPER 3:PEN 0:PRINT N$:LOCATE 28,4:PAPER 0:PRINT G0$:LOCATE 31,4:PRINT"LV 06":H0$=STR$(H0):H0$=RIGHT$(H0$,LEN(H0$)-1):H$=STR$(H)
1052 H$=RIGHT$(H$,LEN(H$)-1):LOCATE 31,5:PRINT"HP ";H0$;"/";H$:LOCATE 28,23:PRINT B1$;D5:LOCATE 32,14:PRINT CHR$(224);F:LOCATE 32,15:PRINT CHR$(222);D2:LOCATE 32,16:PRINT CHR$(221);X0:LOCATE 13,25:PAPER 3:PEN 0:PRINT P2:'
1130 PAPER 0:' DECIDE POSICION ALEATORIA DE JUGADOR Y LLAVE. LOS DIBUJA
1150 x=INT(RND*11)+2:y=INT(RND*10)+2:C$(x,y)="J":LOCATE(x*2)-1,(y*2)-1:PEN 1:PRINT G0$
1180 L=INT(RND*11)+2:L0=INT(RND*10)+2:IF C$(L,L0)<>"."THEN 1180
1200 C$(L,L0)="K":LOCATE(L*2)-1,(L0*2)-1:PRINT L1$:'
1230 ' DECIDE POSICION ALEATORIA DE COFRE Y LO DIBUJA
1240 C5=INT(RND*11)+2:C6=INT(RND*10)+2:IF C$(C5,C6)<>"."THEN 1240
1260 C$(C5,C6)="C":LOCATE(C5*2)-1,(C6*2)-1:PAPER 0:PRINT C7$:'
1263 ' COLOCA RATAS AL AZAR
1264 ' cuantas ratas? (entre 3 y 6)
1265 E=INT((RND*5)+2):M1=E:FOR E0=1 TO E
1300 E(E0)=INT(RND*9)+2:E0(E0)=INT(RND*9)+2:IF C$(E(E0),E0(E0))<>"."THEN 1300
1311 F(E0)=100:D(E0)=100:H(E0)=100:X(E0)=50:C$(E(E0),E0(E0))="1":LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PAPER 0:PRINT R$:I$(E0)="RAT":NEXT E0:'
1340 ' CALCULA OBSTACULOS AL AZAR Y LOS DIBUJA
1350 FOR C1=3 TO 10:FOR C0=3 TO 11:IF C$(C0,C1)<>"."THEN 1400
1380 RANDOMIZE RND:=INT(RND*4):IF<>1 THEN 1400
1390 LOCATE(C0*2)-1,(C1*2)-1:PAPER 0:PRINT M3$:C$(C0,C1)="*"
1400 NEXT C0:NEXT C1:'
1421 ' ESPERA TECLAS DEL JUGADOR
1430 GOSUB 2260
1440 C$(x,y)="J":CLEAR INPUT
1450 LOCATE 31,8:PRINT"STEPS:":LOCATE 28,9:PRINT"<SPACE> END":IF M1<>0 THEN PAPER 0:PEN 1:LOCATE 37,8:PRINT P1 ELSE 1453
1453 a$=INKEY$:IF a$=""THEN 1450
1460 IF a$=CHR$(240)THEN D3=x:D4=y-1:GOTO 1520
1470 IF a$=CHR$(241)THEN D3=x:D4=y+1:GOTO 1520
1480 IF a$=CHR$(242)THEN D3=x-1:D4=y:GOTO 1520
1490 IF a$=CHR$(243)THEN D3=x+1:D4=y:GOTO 1520
1491 IF a$=" "THEN M2=0:CLS#3:GOTO 2270 ELSE 1500
1500 GOTO 1453:'
1520 ' movim JUGADOR
1530 IF C$(D3,D4)="*"THEN 1450
1540 IF C$(D3,D4)="1"THEN 2680
1550 IF C$(D3,D4)="F"AND L1=1 THEN 1960
1560 IF C$(D3,D4)="F"AND L1=0 THEN 1450
1570 IF C$(D3,D4)="K"THEN L1=1:C$(D3,D4)=".":SOUND 1,150,10:SOUND 1,50,10
1580 IF C$(D3,D4)="C"THEN 2060
1590 IF C$(D3,D4)="$"THEN 2130
1600 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:C$(x,y)=".":x=D3:y=D4:C$(x,y)="J":LOCATE(x*2)-1,(y*2)-1:PRINT G0$:SOUND 1,4000,1:SOUND 1,4000,1
1630 P1=P1-1:IF P1=0 AND M1<>0 THEN 2520
1640 GOTO 1440:'
1660 ' DEFINE CUADRICULA DEL MAPA
1670 DIM C$(14,13):DIM M$(12):M$(1)="*************":M$(2)="*...........*":M$(3)="*...........*":M$(4)="*...........*":M$(5)="*...........*":M$(6)="*...........*":M$(7)="*...........*":M$(="*...........*":M$(9)="*...........*"
1770 M$(10)="*...........*":M$(11)="*...........*":M$(12)="*************":FOR C1=1 TO 12:FOR C0=1 TO 13:C$(C0,C1)=MID$(M$(C1),C0,1):NEXT C0:NEXT C1:'
1860 ' DECIDE POSICION ALEATORIA DE LA PUERTA Y LA ESTABLECE COMO PUNTO DE ESCAPE
1870 RANDOMIZE TIME:RANDOMIZE RND:P=INT(RND*4):IF P=0 THEN P4=1:P3=(INT(RND*11))+2
1900 IF P=1 THEN P3=13:P4=(INT(RND*10))+2
1910 IF P=2 THEN P4=12:P3=(INT(RND*11))+2
1920 IF P=3 THEN P3=1:P4=(INT(RND*10))+2
1930 C$(P3,P4)="F":RETURN:'
1960 ' AVANZAR UNA FASE
1970 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:LOCATE(P3*2)-1,(P4*2)-1:PRINT G0$:ENV 1,5,3,20:SOUND 1,478,0,0,1:FOR E3=1 TO 500:NEXT E3:ERASE C2$,M0$:L1=0:P2=P2+1:WINDOW SWAP 0,2:FOR S=1 TO 25:LOCATE 1,25:PRINT CHR$(10):NEXT:WINDOW SWAP 0,2:CLS#3:GOTO 930
2060 '
2070 ' ABRE COFRE Y GENERA DINERO AL AZAR
2080 B1=INT(RND*99)+1:LOCATE(D3*2)-1,(D4*2)-1:PRINT B1$:C$(D3,D4)="$":GOTO 1450:'
2130 ' COGE EL DINERO
2140 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:LOCATE(D3*2)-1,(D4*2)-1:PRINT G0$:C$(x,y)=".":x=D3:y=D4:FOR E3=1 TO 50:NEXT E3:LOCATE 30,24:PRINT CHR$(15)+CHR$(1);D5;CHR$(15)+CHR$(3);"+";B1:FOR E3=1 TO 1000:NEXT E3:FOR C9=D5 TO(D5+B1)STEP 2:LOCATE 30,24
2210 PRINT CHR$(15)+CHR$(1);C9;CHR$(15)+CHR$(3);"+";B1:SOUND 1,150,1:NEXT C9:D5=D5+B1:LOCATE 30,24:PRINT CHR$(15)+CHR$(1);D5;"    ";:GOTO 1630
2260 '
2270 ' MENU
2271 E0=0:O$(1)="PASS TURN":O$(2)="MOVE":O$(3)="ATTACK":O$(4)="USE":FOR O1=1 TO 4:PAPER 0:PEN 1:LOCATE 32,O1+7:PRINT O$(O1):NEXT O1:LOCATE 30,7:PRINT M$:O1=1
2350 LOCATE 30,O1+6:PRINT M$:LOCATE 32,O1+7:PAPER 2:PEN 0:PRINT O$(O1)
2370 a$=INKEY$:IF a$=""THEN 2370
2380 IF a$=CHR$(240)THEN 2420
2390 IF a$=CHR$(241)THEN 2460
2400 IF a$=" "AND O1=1 THEN 2530
2401 IF a$=" "AND O1=2 THEN 2500
2410 GOTO 2370
2420 IF O1=1 THEN 2370
2430 PAPER 0:LOCATE 30,O1+6:PRINT B0$:PEN 1:PAPER 0:LOCATE 32,O1+7:PRINT O$(O1):O1=O1-1:GOTO 2350
2460 IF O1=4 THEN 2370
2470 PAPER 0:LOCATE 30,O1+6:PRINT B0$:PEN 1:PAPER 0:LOCATE 32,O1+7:PRINT O$(O1):O1=O1+1:GOTO 2350
2500 IF M2=0 THEN 2370 ELSE M2=1
2501 PAPER 1:CLS#3:P1=5:PAPER 0:GOTO 1450
2520 '
2530 ' MOVIMIENTO ENEMIGOS
2531 IF M1=0 THEN 1440
2532 PAPER 0:CLS#3:FOR E0=1 TO E:IF H(E0)<1 THEN 2661
2542 B=0:IF C$(E(E0),E0(E0)-1)<>"."THEN B=B+1
2544 IF C$(E(E0)+1,E0(E0))<>"."THEN B=B+1
2545 IF C$(E(E0),E0(E0)+1)<>"."THEN B=B+1
2546 IF C$(E(E0)-1,E0(E0))<>"."THEN B=B+1
2547 IF B=4 THEN 2661
2548 FOR P0=1 TO 4
2550 RANDOMIZE TIME:C=INT(RND*4)+1:IF C=1 AND C$(E(E0),E0(E0)-1)<>"."THEN 2550
2570 IF C=2 AND C$(E(E0)+1,E0(E0))<>"."THEN 2550
2580 IF C=3 AND C$(E(E0),E0(E0)+1)<>"."THEN 2550
2590 IF C=4 AND C$(E(E0)-1,E0(E0))<>"."THEN 2550
2600 LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PRINT B0$:C$(E(E0),E0(E0))=".":IF C=1 THEN E0(E0)=E0(E0)-1
2620 IF C=2 THEN E(E0)=E(E0)+1
2630 IF C=3 THEN E0(E0)=E0(E0)+1
2640 IF C=4 THEN E(E0)=E(E0)-1
2650 C$(E(E0),E0(E0))="1":LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PRINT R$:NEXT P0
2661 NEXT E0:M2=1:GOTO 2270
2680 '
2681 ' ATAQUE JUGADOR
2682 ' CALCULA DAO:
2683 ' 1. a quien estamos atacando?
2684 '
2685 FOR E0=1 TO E:IF D3=E(E0)AND D4=E0(E0)THEN O=E0
2687 NEXT E0:'
2699 ' 2. cuanto dao le hacemos?
2700 '
2750 D=INT(RND*(F/2)):A0=F+D:D=INT(RND*(D(O)/2)):D0=D(O)+D:G=A0-D0:IF A0>D0 THEN GOSUB 4000 ELSE GOSUB 4170
2791 IF H(O)<1 THEN 6000
2830 '
2840 ' CONTRAATAQUE DEL ENEMIGO
2860 D=INT(RND*(F(O)/2)):A0=F(O)+D:D=INT(RND*(D2/2)):D0=D1+D:G=A0-D0:IF A0>D0 THEN GOSUB 4100 ELSE GOSUB 5000
2910 IF H(O)<1 THEN GOSUB 6000 ELSE 2530
4000 ' ANIMACION ATAQUE EXITOSO DEL JUGADOR
4010 LOCATE(D3*2)-1,(D4*2)-1:PRINT G$:ENV 1,11,-1,5:ENT 1,9,49,5,9,-10,15:SOUND 3,145,100,12,1,1,12:FOR E3=1 TO 1000:NEXT E3:LOCATE(D3*2)-1,(D4*2)-1:PRINT R$:H(O)=H(O)-G:RETURN
4100 ' ANIMACION ATAQUE EXITOSO DEL ENEMIGO
4110 LOCATE(x*2)-1,(y*2)-1:PRINT G$:ENV 1,11,-1,5:ENT 1,9,49,5,9,-10,15:SOUND 3,145,100,12,1,1,12:FOR E3=1 TO 1000:NEXT E3:LOCATE(x*2)-1,(y*2)-1:PRINT G0$:LOCATE 33,6:PAPER 0:PEN 3:PRINT G*(-1):H0=H0-G
4151 IF H0<1 THEN LOCATE 33,5:PAPER 0:PEN 1:PRINT" 0  ":GOTO 7000 ELSE 4152
4152 H0$=STR$(H0):H0$=RIGHT$(H0$,LEN(H0$)-1):H$=STR$(H):H$=RIGHT$(H$,LEN(H$)-1):PAPER 0:PEN 1:LOCATE 34,5:PRINT H0$;"/";H$;" ":CLS#3:RETURN
4170 ' ANIMACION ATAQUE FALLIDO DEL JUGADOR
4180 PRINT CHR$(7):RETURN
5000 ' ANIMACION ATAQUE FALLIDO DEL ENEMIGO
5010 PRINT CHR$(7):RETURN
6000 '
6010 ' BORRA ENEMIGO MUERTO Y LIBERA SU CASILLA
6020 LOCATE(D3*2)-1,(D4*2)-1:PRINT B0$:C$(D3,D4)=".":M1=M1-1:'
6060 ' suma experiencia al jugador
6070 FOR C9=1 TO X(O)STEP 2:LOCATE 33,16:PRINT X0+C9:SOUND 1,150,1:NEXT C9:X0=X0+X(O):LOCATE 33,16:PRINT X0:GOTO 2530
7000 '
7010 ' GAME OVER
7020 PAPER 0:CLS:PRINT N$;" HAS BEEN SLAINED BY A ";I$(O):PRINT"IN FLOOR ";P2:PRINT"YOUR MANAGED TO LOOT ";D5;"COINS":PRINT:PRINT"PRESS ANY KEY TO RESTART...":CALL &BB18:RUN
using AMSTRAD TOOLKIT from BEEBUGSOFT

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 2.921
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 1091
  • Likes Given: 2304
Re: My roguelike in BASIC
« Reply #54 on: 22:13, 21 October 19 »
What I see is you are using very long variable names. Those "waste" a lot of space (and time for interpreter) on a CPC
I recommend to shorten them for more free RAM and speed :)

JavaME has obfuscators for this.
Could be fun to have something like that for CPC BASIC stuff to; a tool that runs through the source to shorten variable names and such.  :)

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #55 on: 03:28, 22 October 19 »
Source from 17.10.2019 - 3650 Bytes less :)
Code: [Select]
10 ' 8 BIT DUNGEONS
20 ' BY JNL
30 ' SEPT 2019
40 '
50 ' INICIALIZA VARIABLES NUMERICAS
51 INK 0,0:INK 1,25:MODE 1:BORDER 0:PAPER 0:PEN 1
61 INPUT"NAME:",N$:N$=UPPER$(N$):IF LEN(N$)>7 THEN PRINT"7 characters maximum":GOTO 61 ELSE 70
63 IF N$=""THEN 61
70 CLS:WINDOW#2,1,26,1,25:WINDOW#3,28,40,7,11:P2=1:D5=0:F=100:D2=100:H0=100:H=100:M2=1:'
120 ' DEFINE GRAFICOS
130 SYMBOL AFTER 48:' TIPOGRAFIA
150 SYMBOL 48,28,38,102,102,102,100,56,0:SYMBOL 49,16,56,24,24,24,24,16,0:SYMBOL 50,56,92,8,16,32,68,124,0:SYMBOL 51,124,72,16,60,12,8,16,32:SYMBOL 52,12,28,44,76,126,12,12,8:SYMBOL 53,30,36,112,56,28,12,68,56:SYMBOL 54,56,96,104,124,108,108,56,0
220 SYMBOL 55,124,100,8,8,16,16,48,24:SYMBOL 56,60,102,100,24,38,102,60,0:SYMBOL 57,60,102,102,110,118,38,4,24:SYMBOL 65,2,54,78,86,38,86,142,0:SYMBOL 67,58,86,208,208,208,82,60,0:SYMBOL 69,222,100,104,124,100,64,254,0
280 SYMBOL 72,64,228,110,118,102,103,102,4:SYMBOL 76,12,54,112,176,48,34,126,0:SYMBOL 77,74,254,106,106,106,107,74,0:SYMBOL 79,60,70,214,238,198,196,120,0:SYMBOL 80,44,246,102,102,118,236,96,240:SYMBOL 82,54,91,49,50,60,54,243,0
340 SYMBOL 83,58,68,200,124,38,98,188,0:SYMBOL 84,122,174,104,104,104,106,60,0:SYMBOL 85,68,238,102,102,102,111,50,0:SYMBOL 86,68,238,118,102,102,54,28,0:' GRAFICOS
390 SYMBOL 221,60,126,175,211,165,243,118,60:SYMBOL 222,126,126,126,126,126,126,60,24:SYMBOL 223,0,108,254,254,124,56,16,0:SYMBOL 224,0,6,14,220,120,48,88,136:SYMBOL 225,16,4,0,8,77,3,231,255:SYMBOL 226,0,140,204,208,224,232,252,224
450 SYMBOL 227,63,15,103,111,13,24,0,4:SYMBOL 228,242,254,252,224,224,244,224,0:SYMBOL 229,0,0,28,29,15,151,127,4:SYMBOL 230,1,1,226,244,248,248,248,40:SYMBOL 231,0,0,0,0,0,0,195,239:SYMBOL 232,0,0,0,0,48,240,224,192
510 SYMBOL 233,223,239,223,239,223,227,192,0:SYMBOL 234,255,255,232,232,208,160,0,0:SYMBOL 235,1,7,14,28,58,60,62,28:SYMBOL 236,224,216,220,108,240,120,184,112:SYMBOL 237,0,254,252,248,240,248,252,254:SYMBOL 238,0,127,63,31,15,31,63,127
570 SYMBOL 239,0,255,255,255,255,255,255,255:SYMBOL 240,1,35,119,119,113,116,115,114:SYMBOL 241,0,128,192,192,192,128,63,187:SYMBOL 242,249,6,119,15,15,15,60,30:SYMBOL 243,49,187,59,187,191,222,236,112:SYMBOL 244,85,254,255,254,255,254,255,254
630 SYMBOL 245,85,255,255,255,255,255,255,255:SYMBOL 246,253,170,127,255,255,255,255,127:SYMBOL 247,127,170,255,255,255,255,255,254:SYMBOL 248,83,238,217,181,181,109,125,109:SYMBOL 249,193,113,153,172,172,182,190,182
680 SYMBOL 250,121,102,118,105,125,109,125,109:SYMBOL 251,190,182,190,182,190,182,190,182:SYMBOL 252,31,55,59,0,59,59,59,59:SYMBOL 253,248,252,204,0,204,252,252,252:SYMBOL 254,0,0,6,73,249,6,0,0:'
740 ' DEFINE VARIABLES DE LOS SPRITES
750 R0$=STRING$(2,8)+CHR$(10):B0$="  "+R0$+"  ":G0$=CHR$(15)+CHR$(1)+CHR$(240)+CHR$(241)+STRING$(2,8)+CHR$(10)+CHR$(242)+CHR$(243):M3$=CHR$(15)+CHR$(1)+CHR$(244)+CHR$(245)+STRING$(2,8)+CHR$(10)+CHR$(246)+CHR$(247)
790 P5$=CHR$(15)+CHR$(2)+CHR$(248)+CHR$(249)+R0$+CHR$(250)+CHR$(251):C7$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(252)+CHR$(253):L1$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(254):C4$=CHR$(15)+CHR$(3)+CHR$(238)+CHR$(239):C3$=CHR$(15)+CHR$(3)+CHR$(239)+CHR$(237)
840 B1$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(235)+CHR$(236):M$=CHR$(15)+CHR$(2)+CHR$(231)+CHR$(232)+R0$+CHR$(233)+CHR$(234):R$=CHR$(15)+CHR$(1)+"  "+R0$+CHR$(229)+CHR$(230):G$=CHR$(15)+CHR$(3)+CHR$(225)+CHR$(226)+R0$+CHR$(227)+CHR$(228)
880 xp$=CHR$(15)+CHR$(3)+"  "+R0$+" "+CHR$(221):E1$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(222):C8$=CHR$(15)+CHR$(3)+"  "+R0$+" "+CHR$(223):E2$=CHR$(15)+CHR$(2)+"  "+R0$+" "+CHR$(224):'
930 ' DIBUJA PANTALLA DE JUEGO
940 GOSUB 1660:FOR y=1 TO 12:FOR x=1 TO 13:IF C$(x,y)="*"THEN PAPER 0:LOCATE(x*2)-1,(y*2)-1:PRINT M3$
980 IF C$(x,y)="F"THEN PAPER 0:LOCATE(x*2)-1,(y*2)-1:PRINT P5$
990 NEXT x:NEXT y:LOCATE 30,1:PAPER 3:PEN 0:PRINT"         ":LOCATE 29,2:PAPER 0:PEN 3:PRINT C4$+"       "+C3$:LOCATE 31,1:PAPER 3:PEN 0:PRINT N$:LOCATE 28,4:PAPER 0:PRINT G0$:LOCATE 31,4:PRINT"LV 06":H0$=STR$(H0):H0$=RIGHT$(H0$,LEN(H0$)-1):H$=STR$(H)
1052 H$=RIGHT$(H$,LEN(H$)-1):LOCATE 31,5:PRINT"HP ";H0$;"/";H$:LOCATE 28,23:PRINT B1$;D5:LOCATE 32,14:PRINT CHR$(224);F:LOCATE 32,15:PRINT CHR$(222);D2:LOCATE 32,16:PRINT CHR$(221);X0:LOCATE 13,25:PAPER 3:PEN 0:PRINT P2:'
1130 PAPER 0:' DECIDE POSICION ALEATORIA DE JUGADOR Y LLAVE. LOS DIBUJA
1150 x=INT(RND*11)+2:y=INT(RND*10)+2:C$(x,y)="J":LOCATE(x*2)-1,(y*2)-1:PEN 1:PRINT G0$
1180 L=INT(RND*11)+2:L0=INT(RND*10)+2:IF C$(L,L0)<>"."THEN 1180
1200 C$(L,L0)="K":LOCATE(L*2)-1,(L0*2)-1:PRINT L1$:'
1230 ' DECIDE POSICION ALEATORIA DE COFRE Y LO DIBUJA
1240 C5=INT(RND*11)+2:C6=INT(RND*10)+2:IF C$(C5,C6)<>"."THEN 1240
1260 C$(C5,C6)="C":LOCATE(C5*2)-1,(C6*2)-1:PAPER 0:PRINT C7$:'
1263 ' COLOCA RATAS AL AZAR
1264 ' cuantas ratas? (entre 3 y 6)
1265 E=INT((RND*5)+2):M1=E:FOR E0=1 TO E
1300 E(E0)=INT(RND*9)+2:E0(E0)=INT(RND*9)+2:IF C$(E(E0),E0(E0))<>"."THEN 1300
1311 F(E0)=100:D(E0)=100:H(E0)=100:X(E0)=50:C$(E(E0),E0(E0))="1":LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PAPER 0:PRINT R$:I$(E0)="RAT":NEXT E0:'
1340 ' CALCULA OBSTACULOS AL AZAR Y LOS DIBUJA
1350 FOR C1=3 TO 10:FOR C0=3 TO 11:IF C$(C0,C1)<>"."THEN 1400
1380 RANDOMIZE RND:=INT(RND*4):IF<>1 THEN 1400
1390 LOCATE(C0*2)-1,(C1*2)-1:PAPER 0:PRINT M3$:C$(C0,C1)="*"
1400 NEXT C0:NEXT C1:'
1421 ' ESPERA TECLAS DEL JUGADOR
1430 GOSUB 2260
1440 C$(x,y)="J":CLEAR INPUT
1450 LOCATE 31,8:PRINT"STEPS:":LOCATE 28,9:PRINT"<SPACE> END":IF M1<>0 THEN PAPER 0:PEN 1:LOCATE 37,8:PRINT P1 ELSE 1453
1453 a$=INKEY$:IF a$=""THEN 1450
1460 IF a$=CHR$(240)THEN D3=x:D4=y-1:GOTO 1520
1470 IF a$=CHR$(241)THEN D3=x:D4=y+1:GOTO 1520
1480 IF a$=CHR$(242)THEN D3=x-1:D4=y:GOTO 1520
1490 IF a$=CHR$(243)THEN D3=x+1:D4=y:GOTO 1520
1491 IF a$=" "THEN M2=0:CLS#3:GOTO 2270 ELSE 1500
1500 GOTO 1453:'
1520 ' movim JUGADOR
1530 IF C$(D3,D4)="*"THEN 1450
1540 IF C$(D3,D4)="1"THEN 2680
1550 IF C$(D3,D4)="F"AND L1=1 THEN 1960
1560 IF C$(D3,D4)="F"AND L1=0 THEN 1450
1570 IF C$(D3,D4)="K"THEN L1=1:C$(D3,D4)=".":SOUND 1,150,10:SOUND 1,50,10
1580 IF C$(D3,D4)="C"THEN 2060
1590 IF C$(D3,D4)="$"THEN 2130
1600 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:C$(x,y)=".":x=D3:y=D4:C$(x,y)="J":LOCATE(x*2)-1,(y*2)-1:PRINT G0$:SOUND 1,4000,1:SOUND 1,4000,1
1630 P1=P1-1:IF P1=0 AND M1<>0 THEN 2520
1640 GOTO 1440:'
1660 ' DEFINE CUADRICULA DEL MAPA
1670 DIM C$(14,13):DIM M$(12):M$(1)="*************":M$(2)="*...........*":M$(3)="*...........*":M$(4)="*...........*":M$(5)="*...........*":M$(6)="*...........*":M$(7)="*...........*":M$(="*...........*":M$(9)="*...........*"
1770 M$(10)="*...........*":M$(11)="*...........*":M$(12)="*************":FOR C1=1 TO 12:FOR C0=1 TO 13:C$(C0,C1)=MID$(M$(C1),C0,1):NEXT C0:NEXT C1:'
1860 ' DECIDE POSICION ALEATORIA DE LA PUERTA Y LA ESTABLECE COMO PUNTO DE ESCAPE
1870 RANDOMIZE TIME:RANDOMIZE RND:P=INT(RND*4):IF P=0 THEN P4=1:P3=(INT(RND*11))+2
1900 IF P=1 THEN P3=13:P4=(INT(RND*10))+2
1910 IF P=2 THEN P4=12:P3=(INT(RND*11))+2
1920 IF P=3 THEN P3=1:P4=(INT(RND*10))+2
1930 C$(P3,P4)="F":RETURN:'
1960 ' AVANZAR UNA FASE
1970 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:LOCATE(P3*2)-1,(P4*2)-1:PRINT G0$:ENV 1,5,3,20:SOUND 1,478,0,0,1:FOR E3=1 TO 500:NEXT E3:ERASE C2$,M0$:L1=0:P2=P2+1:WINDOW SWAP 0,2:FOR S=1 TO 25:LOCATE 1,25:PRINT CHR$(10):NEXT:WINDOW SWAP 0,2:CLS#3:GOTO 930
2060 '
2070 ' ABRE COFRE Y GENERA DINERO AL AZAR
2080 B1=INT(RND*99)+1:LOCATE(D3*2)-1,(D4*2)-1:PRINT B1$:C$(D3,D4)="$":GOTO 1450:'
2130 ' COGE EL DINERO
2140 LOCATE(x*2)-1,(y*2)-1:PRINT B0$:LOCATE(D3*2)-1,(D4*2)-1:PRINT G0$:C$(x,y)=".":x=D3:y=D4:FOR E3=1 TO 50:NEXT E3:LOCATE 30,24:PRINT CHR$(15)+CHR$(1);D5;CHR$(15)+CHR$(3);"+";B1:FOR E3=1 TO 1000:NEXT E3:FOR C9=D5 TO(D5+B1)STEP 2:LOCATE 30,24
2210 PRINT CHR$(15)+CHR$(1);C9;CHR$(15)+CHR$(3);"+";B1:SOUND 1,150,1:NEXT C9:D5=D5+B1:LOCATE 30,24:PRINT CHR$(15)+CHR$(1);D5;"    ";:GOTO 1630
2260 '
2270 ' MENU
2271 E0=0:O$(1)="PASS TURN":O$(2)="MOVE":O$(3)="ATTACK":O$(4)="USE":FOR O1=1 TO 4:PAPER 0:PEN 1:LOCATE 32,O1+7:PRINT O$(O1):NEXT O1:LOCATE 30,7:PRINT M$:O1=1
2350 LOCATE 30,O1+6:PRINT M$:LOCATE 32,O1+7:PAPER 2:PEN 0:PRINT O$(O1)
2370 a$=INKEY$:IF a$=""THEN 2370
2380 IF a$=CHR$(240)THEN 2420
2390 IF a$=CHR$(241)THEN 2460
2400 IF a$=" "AND O1=1 THEN 2530
2401 IF a$=" "AND O1=2 THEN 2500
2410 GOTO 2370
2420 IF O1=1 THEN 2370
2430 PAPER 0:LOCATE 30,O1+6:PRINT B0$:PEN 1:PAPER 0:LOCATE 32,O1+7:PRINT O$(O1):O1=O1-1:GOTO 2350
2460 IF O1=4 THEN 2370
2470 PAPER 0:LOCATE 30,O1+6:PRINT B0$:PEN 1:PAPER 0:LOCATE 32,O1+7:PRINT O$(O1):O1=O1+1:GOTO 2350
2500 IF M2=0 THEN 2370 ELSE M2=1
2501 PAPER 1:CLS#3:P1=5:PAPER 0:GOTO 1450
2520 '
2530 ' MOVIMIENTO ENEMIGOS
2531 IF M1=0 THEN 1440
2532 PAPER 0:CLS#3:FOR E0=1 TO E:IF H(E0)<1 THEN 2661
2542 B=0:IF C$(E(E0),E0(E0)-1)<>"."THEN B=B+1
2544 IF C$(E(E0)+1,E0(E0))<>"."THEN B=B+1
2545 IF C$(E(E0),E0(E0)+1)<>"."THEN B=B+1
2546 IF C$(E(E0)-1,E0(E0))<>"."THEN B=B+1
2547 IF B=4 THEN 2661
2548 FOR P0=1 TO 4
2550 RANDOMIZE TIME:C=INT(RND*4)+1:IF C=1 AND C$(E(E0),E0(E0)-1)<>"."THEN 2550
2570 IF C=2 AND C$(E(E0)+1,E0(E0))<>"."THEN 2550
2580 IF C=3 AND C$(E(E0),E0(E0)+1)<>"."THEN 2550
2590 IF C=4 AND C$(E(E0)-1,E0(E0))<>"."THEN 2550
2600 LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PRINT B0$:C$(E(E0),E0(E0))=".":IF C=1 THEN E0(E0)=E0(E0)-1
2620 IF C=2 THEN E(E0)=E(E0)+1
2630 IF C=3 THEN E0(E0)=E0(E0)+1
2640 IF C=4 THEN E(E0)=E(E0)-1
2650 C$(E(E0),E0(E0))="1":LOCATE(E(E0)*2)-1,(E0(E0)*2)-1:PRINT R$:NEXT P0
2661 NEXT E0:M2=1:GOTO 2270
2680 '
2681 ' ATAQUE JUGADOR
2682 ' CALCULA DAO:
2683 ' 1. a quien estamos atacando?
2684 '
2685 FOR E0=1 TO E:IF D3=E(E0)AND D4=E0(E0)THEN O=E0
2687 NEXT E0:'
2699 ' 2. cuanto dao le hacemos?
2700 '
2750 D=INT(RND*(F/2)):A0=F+D:D=INT(RND*(D(O)/2)):D0=D(O)+D:G=A0-D0:IF A0>D0 THEN GOSUB 4000 ELSE GOSUB 4170
2791 IF H(O)<1 THEN 6000
2830 '
2840 ' CONTRAATAQUE DEL ENEMIGO
2860 D=INT(RND*(F(O)/2)):A0=F(O)+D:D=INT(RND*(D2/2)):D0=D1+D:G=A0-D0:IF A0>D0 THEN GOSUB 4100 ELSE GOSUB 5000
2910 IF H(O)<1 THEN GOSUB 6000 ELSE 2530
4000 ' ANIMACION ATAQUE EXITOSO DEL JUGADOR
4010 LOCATE(D3*2)-1,(D4*2)-1:PRINT G$:ENV 1,11,-1,5:ENT 1,9,49,5,9,-10,15:SOUND 3,145,100,12,1,1,12:FOR E3=1 TO 1000:NEXT E3:LOCATE(D3*2)-1,(D4*2)-1:PRINT R$:H(O)=H(O)-G:RETURN
4100 ' ANIMACION ATAQUE EXITOSO DEL ENEMIGO
4110 LOCATE(x*2)-1,(y*2)-1:PRINT G$:ENV 1,11,-1,5:ENT 1,9,49,5,9,-10,15:SOUND 3,145,100,12,1,1,12:FOR E3=1 TO 1000:NEXT E3:LOCATE(x*2)-1,(y*2)-1:PRINT G0$:LOCATE 33,6:PAPER 0:PEN 3:PRINT G*(-1):H0=H0-G
4151 IF H0<1 THEN LOCATE 33,5:PAPER 0:PEN 1:PRINT" 0  ":GOTO 7000 ELSE 4152
4152 H0$=STR$(H0):H0$=RIGHT$(H0$,LEN(H0$)-1):H$=STR$(H):H$=RIGHT$(H$,LEN(H$)-1):PAPER 0:PEN 1:LOCATE 34,5:PRINT H0$;"/";H$;" ":CLS#3:RETURN
4170 ' ANIMACION ATAQUE FALLIDO DEL JUGADOR
4180 PRINT CHR$(7):RETURN
5000 ' ANIMACION ATAQUE FALLIDO DEL ENEMIGO
5010 PRINT CHR$(7):RETURN
6000 '
6010 ' BORRA ENEMIGO MUERTO Y LIBERA SU CASILLA
6020 LOCATE(D3*2)-1,(D4*2)-1:PRINT B0$:C$(D3,D4)=".":M1=M1-1:'
6060 ' suma experiencia al jugador
6070 FOR C9=1 TO X(O)STEP 2:LOCATE 33,16:PRINT X0+C9:SOUND 1,150,1:NEXT C9:X0=X0+X(O):LOCATE 33,16:PRINT X0:GOTO 2530
7000 '
7010 ' GAME OVER
7020 PAPER 0:CLS:PRINT N$;" HAS BEEN SLAINED BY A ";I$(O):PRINT"IN FLOOR ";P2:PRINT"YOUR MANAGED TO LOOT ";D5;"COINS":PRINT:PRINT"PRESS ANY KEY TO RESTART...":CALL &BB18:RUN
using AMSTRAD TOOLKIT from BEEBUGSOFT
Well, that looks interesting. I assume you can do it with that toolkit thingy. I think I could have the original source for editing it in future updates and release the shortened version. That way it will still be readable to me while you get a lighter and faster version of the game. Am I right?By the way... Do you see a noticeable gain in performance too by shortening the variables?

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #56 on: 23:49, 26 October 19 »
Ok, it´s been a couple of days, but that doesn´t mean I´ve been inactive. There was a semi-heavy revamp on the project:
I felt like I was going in a different direction I wanted at the beginning, which is making a roguelike. All that maze-solving algorithms and movement points was driving me crazy, and I realized I was trying to make a tactical game, not a roguelike, so...

I decided to reorganize the code. At that point it was all getting really messy, with an unreadable codeflow, so I packed all the main sub-routines individually so they could be invoked in an organized and controlled way, just leaving a control group of GOSUBs at the beginning callign all the functions. Incredibly good decision! Just by doing this, the code looks now like something closer to a game engine than a straight program, which makes my life way easier. It´s now very modular and editable. Really sweet to work with it.
In the other hand, I changed to a pure roguelike turn system (one step each monster and player). Also added a dotted floor, like it should be (classic roguelike stuff)Right now I´m starting to documentate the combat system (that will be more deep and complex than before) based in the Warhammer Fantasy Rule Book... lots of awesome premade creatures to choose from!
So, I think there will be no updates this weekend, but the projects is alive and kicking. Expect to have cool updates in the near future with more creatures, enhanced combat system, roguelike system and much more... btw, do you guys like my skeleton design? :P


Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #57 on: 00:09, 28 October 19 »
New update! I´m so thrilled about the new direction that I pushed hard this evening to have something workable.I´m grabbing monsters, weapons, etc... from Warhammer Fantasy RPG, so now you have the rat and a new monster, which is the skeleton.The rat is really weak, too weak to harm you, so feel free to stab them at will.Beware the skeletons! They can hurt you badly, but don´t worry about that because by now, the character is using only a hand weapon and no armor or shield.The enemies are static. I will code their movement during the week. Time to sleep now.
Updated SDK and changelog in the first post.

Offline OBsd74

  • Speccy
  • *
  • Posts: 2
  • Country: fr
  • Liked: 0
  • Likes Given: 0
Re: My roguelike in BASIC
« Reply #58 on: 21:10, 28 October 19 »
Hello.
I wanted to test your roguelike, but since october 17th update or so, every single I try to run it whatever emulator I use, I got a "Direct command found" error.
I tried: javacpc, caprice32, Arnold and CPCBox (https://www.retrovm.com/) without any luck :(
Any idea about what is going on? Thanks!

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #59 on: 21:51, 28 October 19 »
Hello.
I wanted to test your roguelike, but since october 17th update or so, every single I try to run it whatever emulator I use, I got a "Direct command found" error.
I tried: javacpc, caprice32, Arnold and CPCBox (https://www.retrovm.com/) without any luck :(
Any idea about what is going on? Thanks!
It happens to me too. I guess it's related to the interpretation of the machine. If you get that error, just type RUN again and it will work.

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.235
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 992
  • Likes Given: 2275
Re: My roguelike in BASIC
« Reply #60 on: 22:20, 28 October 19 »
Please try something.


Just remove any 'ñ' character from your code, as I suspect it´s not properly translated and may cause the error when loading.

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #61 on: 22:32, 28 October 19 »
Mmm... That will be weird, since my emulator is in Spanish and it contains that letter. But I'll try anyways.

Offline robcfg

  • Supporter
  • 6128 Plus
  • *
  • Posts: 2.235
  • Country: se
  • 8-Bit Technomancer
    • index.php?action=treasury
  • Liked: 992
  • Likes Given: 2275
Re: My roguelike in BASIC
« Reply #62 on: 22:55, 28 October 19 »
Yes, but that doesn't mean that the ñ character is coded with the same value or that the value has the same meaning on the CPC.


I deleted rem lines 7123 and 7255 and saved it to disk, and now runs without problem.


If you list those lines you'll see two weird characters instead of the single ñ character.


Edit: On the ASCII table ñ and Ñ are characters 164 and 165 while on the CPC they are 171 and 161. Thus, if you save a 164, the CPC will show the copyright symbol instead of ñ.
« Last Edit: 23:03, 28 October 19 by robcfg »

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #63 on: 23:33, 28 October 19 »
Yes, but that doesn't mean that the ñ character is coded with the same value or that the value has the same meaning on the CPC.


I deleted rem lines 7123 and 7255 and saved it to disk, and now runs without problem.


If you list those lines you'll see two weird characters instead of the single ñ character.


Edit: On the ASCII table ñ and Ñ are characters 164 and 165 while on the CPC they are 171 and 161. Thus, if you save a 164, the CPC will show the copyright symbol instead of ñ.
I just tried editing then code replacing "ñ" with "n" from outside of the emulator (in sublime) then saving it, loading in the emulator and it still throws the "direct command found" error. So, the "ñ" theory doesn´t seem to be the problem.
The "direct command found" error indicates a non-numbered line in the ascii before converting it into a workable program by the CPC. Which is weird since I don´t have any non-numbered lines in my code.
Try this:
1. run the program from the disk
2. You´ll get the error
3. Do nothing and from then emulator itself, save the program again
4. Run the program again from the disk, you´ll get no error

There´s something with the emulator. I get a "Direct command found" most of the times (not everytime). Other times I get an "overflow" error, that gets fixed by deleting the first line of the program. Other times, the emulator replaces some random line with a random piece of other part of the code,etc... something happens in the import or the export of the ascii file.

Offline Fessor

  • CPC6128
  • ****
  • Posts: 199
  • Country: de
  • Liked: 164
  • Likes Given: 40
Re: My roguelike in BASIC
« Reply #64 on: 00:46, 29 October 19 »
There are a bunch of empty lines in your Code...
You can see them with this little program (it simply reads the ascii-file line for line and prints it)
Code: [Select]
10 openin "<FILENAME>"
20 while not eof
30 line input #9,a$:print a$
40 wend

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #65 on: 01:11, 29 October 19 »
There are a bunch of empty lines in your Code...
You can see them with this little program (it simply reads the ascii-file line for line and prints it)
Code: [Select]
10 openin "<FILENAME>"
20 while not eof
30 line input #9,a$:print a$
40 wend
Empty lines are empty strings. "Direct command found" means a BASIC command without a line number assigned. Anyways, I could check if removing the empty lines solves the problem. But for the code to be readable by the CPC it needs to have an empty line at the very end, so... XD

Anyways, don´t worry about that. If you get the error, just type RUN again and it will work. By the time of releasing the first full version I will make sure to re-save the program from the emulator, so it doesn´t give that problem.

Offline OBsd74

  • Speccy
  • *
  • Posts: 2
  • Country: fr
  • Liked: 0
  • Likes Given: 0
Re: My roguelike in BASIC
« Reply #66 on: 09:49, 29 October 19 »
It happens to me too. I guess it's related to the interpretation of the machine. If you get that error, just type RUN again and it will work.
Will try it and hope it will run this time. But seeing this bug in 4 emulators make me angry :(

Tried with prueba4.bas. File lost 1 kb. Instead of being 14Kb long, it is only 13kb long now. For prueba3, it went from 17 to 16 Kb.

Something is wrong with your export :(

Using this trick and your roguelike is running. At least :)
« Last Edit: 09:56, 29 October 19 by OBsd74 »

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #67 on: 13:56, 29 October 19 »
Actually, when it is done I'd try to embed 8bp library. You'd get an amazing game with it.
I had a look at some 8bp stuff. I was wondering if I could be implementing it in my game gradually. For example: Printing the dungeon is now quite slow. Could I have a call in your library that speeds up  that proccess?

Offline asertus

  • CPC664
  • ***
  • Posts: 71
  • Country: es
  • Liked: 58
  • Likes Given: 205
Re: My roguelike in BASIC
« Reply #68 on: 14:13, 29 October 19 »
I had a look at some 8bp stuff. I was wondering if I could be implementing it in my game gradually. For example: Printing the dungeon is now quite slow. Could I have a call in your library that speeds up  that proccess?

As you speak Spanish, in latest 8BP documentation, 

https://github.com/jjaranda13/8BP/tree/master/Documentacion

you can use 8BP:  |LAYOUT, y, x, @string$
command for that. Take a look at the documentation. Chapter 8: 8 Juegos de pantallas: layout o “tile map”

It draws the layout, lets you detect collissions, etc... Moreover in the frogger tutorial there is a good example about how to use it.

Offline SRS

  • Supporter
  • 6128 Plus
  • *
  • Posts: 562
  • Country: de
  • Schneider CPC464 - what else ?
  • Liked: 547
  • Likes Given: 289
Re: My roguelike in BASIC
« Reply #69 on: 17:43, 29 October 19 »
As you speak Spanish, in latest 8BP documentation, 

https://github.com/jjaranda13/8BP/tree/master/Documentacion

you can use 8BP:  |LAYOUT, y, x, @string$
command for that. Take a look at the documentation. Chapter 8: 8 Juegos de pantallas: layout o “tile map”

It draws the layout, lets you detect collissions, etc... Moreover in the frogger tutorial there is a good example about how to use it.


Isn't 8BP MODE 0 and the game is MODE 1 ? Just to consider ...
Maybe you can transform your chars to sprites with ESD2 and use them .. playing around a bit ... a loader to build and grab sprites, save them binary, and load the data and so on
Code: [Select]
10 ' ESD ADVANCED from THE BASIC IDEA
20 ' By Sean McManus - www.sean.co.uk
30 '
40 MODE 1:PRINT"Installing Machine Code...."
50 'Fine Force routine - September 1993 Sean McManus
60 RESTORE 60:FOR mem=40000 TO 40052
70 READ a$:a=VAL(("&")+a$)
80 POKE mem,a:NEXT
90 DATA DD,6E,0,DD,66,1,DD,5E,2,DD,56,3,CD,1D,BC,E5,DD,5E,4,DD,56,5,EB,4E,23,46,23,EB,E1,C5,E5,1A,77,23,13,10,FA,E1,1,0
100 DATA 8,9,30,4,1,50,C0,9,C1,D,20,E9,C9
110 '****** ENDS ******
260 'Fine Grab routine - September 1993
270 RESTORE 270:FOR mem=40164 TO 40221
280 READ a$:a=VAL(("&")+a$)
290 POKE mem,a:NEXT
300 DATA DD,6E,4,DD,66,5,DD,5E,6,DD,56,7,CD,1D,BC,EB,DD,6E,8,DD,66,9,DD,4E,0,DD,46,2,71,23,70,23,C5,D5,1A,77,23,13,10,FA
310 DATA D1,EB,1,0,8,9,30,4,1,50,C0,9,EB,C1,D,20,E7,C9
400 GOSUB 8150
410 MODE 1
415 CLS:PRINT borr$:CALL 40164,30000,0,199,4,16
420 CLS:PRINT muro$:CALL 40164,30000+(4*16+2),0,199,4,16
430 FOR x=0 TO 319 step 16:for y=15 to 199 step 16
435 CALL 40000,30000,x,y:NEXT y,x
440 FOR x=0 TO 319 step 16:for y=15 to 199 step 16
450 CALL 40000,30066,x,y:NEXT y,x:goto 430
499 END
8140 '
8150 ' DEFINE GRAFICOS
8151 '
8160 SYMBOL AFTER 216
8401 ' GRAFICOS
8410 SYMBOL 216,6,54,72,21,50,72,144,0
8411 SYMBOL 217,32,103,111,107,105,103,101,104
8412 SYMBOL 218,0,192,224,160,32,192,64,28
8413 SYMBOL 219,247,9,103,1,7,12,8,56
8414 SYMBOL 220,190,127,127,127,190,220,64,224
8420 SYMBOL 221,60,126,175,211,165,243,118,60
8430 SYMBOL 222,126,118,98,118,118,60,24,0
8440 SYMBOL 223,24,44,70,255,70,44,24,0
8450 SYMBOL 224,0,6,14,220,120,48,88,136
8460 SYMBOL 225,16,4,0,8,77,3,231,255
8470 SYMBOL 226,0,140,204,208,224,232,252,224
8480 SYMBOL 227,63,15,103,111,13,24,0,4
8490 SYMBOL 228,242,254,252,224,224,244,224,0
8500 SYMBOL 229,0,0,28,29,15,151,127,4
8510 SYMBOL 230,1,1,226,244,248,248,248,40
8520 SYMBOL 231,0,0,0,0,0,0,195,239
8530 SYMBOL 232,0,0,0,0,48,240,224,192
8540 SYMBOL 233,223,239,223,239,223,227,192,0
8550 SYMBOL 234,255,255,232,232,208,160,0,0
8560 SYMBOL 235,1,7,14,28,58,60,62,28
8570 SYMBOL 236,224,216,220,108,240,120,184,112
8580 SYMBOL 237,0,254,252,248,240,248,252,254
8590 SYMBOL 238,0,127,63,31,15,31,63,127
8600 SYMBOL 239,0,255,255,255,255,255,255,255
8610 SYMBOL 240,1,35,119,119,113,116,115,114
8620 SYMBOL 241,0,128,192,192,192,128,63,187
8630 SYMBOL 242,249,6,119,15,15,15,60,30
8640 SYMBOL 243,49,187,59,187,191,222,236,112
8650 SYMBOL 244,85,254,255,254,255,254,255,254
8660 SYMBOL 245,85,255,255,255,255,255,255,255
8670 SYMBOL 246,253,170,127,255,255,255,255,127
8680 SYMBOL 247,127,170,255,255,255,255,255,254
8690 SYMBOL 248,83,238,217,181,181,109,125,109
8700 SYMBOL 249,193,113,153,172,172,182,190,182
8710 SYMBOL 250,121,102,118,105,125,109,125,109
8720 SYMBOL 251,190,182,190,182,190,182,190,182
8730 SYMBOL 252,31,55,59,0,59,59,59,59
8740 SYMBOL 253,248,252,204,0,204,252,252,252
8750 SYMBOL 254,0,0,6,73,249,6,0,0
8760 SYMBOL 255,&X1
8770 '
8780 ' DEFINE VARIABLES DE LOS SPRITES
8790 ret$=STRING$(2,8)+CHR$(10)
8800 borr$=CHR$(15)+CHR$(1)+"  "+ret$+" "+CHR$(255)
8810 guerr$=CHR$(15)+CHR$(1)+CHR$(240)+CHR$(241)+STRING$(2,8)+CHR$(10)+CHR$(242)+CHR$(243)
8820 muro$=CHR$(15)+CHR$(1)+CHR$(244)+CHR$(245)+STRING$(2,8)+CHR$(10)+CHR$(246)+CHR$(247)
8830 puerta$=CHR$(15)+CHR$(2)+CHR$(248)+CHR$(249)+ret$+CHR$(250)+CHR$(251)
8840 cofre$=CHR$(15)+CHR$(1)+"  "+ret$+CHR$(252)+CHR$(253)
8850 llave$=CHR$(15)+CHR$(2)+"  "+ret$+" "+CHR$(254)
8860 cintai$=CHR$(15)+CHR$(3)+CHR$(238)+CHR$(239)
8870 cintad$=CHR$(15)+CHR$(3)+CHR$(239)+CHR$(237)
8880 botin$=CHR$(15)+CHR$(1)+"  "+ret$+CHR$(235)+CHR$(236)
8890 mano$=CHR$(15)+CHR$(2)+CHR$(231)+CHR$(232)+ret$+CHR$(233)+CHR$(234)
9000 golpe$=CHR$(15)+CHR$(3)+CHR$(225)+CHR$(226)+ret$+CHR$(227)+CHR$(228)
9010 xp$=CHR$(15)+CHR$(3)+"  "+ret$+" "+CHR$(221)
9020 escudo$=CHR$(15)+CHR$(2)+"  "+ret$+" "+CHR$(222)
9030 arco$=CHR$(15)+CHR$(3)+"  "+ret$+" "+CHR$(223)
9040 espada$=CHR$(15)+CHR$(2)+"  "+ret$+" "+CHR$(224)
9041 agilidad$=CHR$(15)+CHR$(2)+"  "+ret$+" "+CHR$(216)
9050 RETURN
« Last Edit: 20:41, 29 October 19 by SRS »

Offline asertus

  • CPC664
  • ***
  • Posts: 71
  • Country: es
  • Liked: 58
  • Likes Given: 205
Re: My roguelike in BASIC
« Reply #70 on: 16:18, 30 October 19 »
Isn't 8BP MODE 0 and the game is MODE 1 ? Just to consider ...


Since version 34 it has some support for Mode 1 too, 40x25, with some limitations.




Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #71 on: 20:41, 31 October 19 »
Let´s keep pushing! :)

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #72 on: 02:58, 01 November 19 »
Ok, another update:
We can now finally move in turns and the combat system and attributes has been refined a lot. Sadly, I saw no rats in the Warhammer bestiary, but I assigned it the values of a Snotling. The skeleton remains a skeleton. This way we have two levels of enemies to make some test gameplays. The snotling (which you see as a rat) is labeled in the rulebook as "easy". The skeleton is labeled as "routine".
Please grab the updated SDK in the first post and throw some feedback.Have a nice halloween everyone! :)

Offline PAQUITO

  • CPC464
  • **
  • Posts: 43
  • Country: es
  • Liked: 57
  • Likes Given: 7
Re: My roguelike in BASIC
« Reply #73 on: 23:50, 01 November 19 »
I´m particullary interested in your opinion about moving in diagonals.
Do you like it or do you prefer moving just in 4 directions?

Offline genesis8

  • CPC6128
  • ****
  • Posts: 186
  • Country: fr
    • Genesis8 Amstrad Page
  • Liked: 51
  • Likes Given: 20
Re: My roguelike in BASIC
« Reply #74 on: 16:04, 03 November 19 »
I´m particullary interested in your opinion about moving in diagonals.
Do you like it or do you prefer moving just in 4 directions?


It would be better and feel more roguelike with diagonals.
____________
Amstrad news site at Genesis8 Amstrad Page