News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_Fabrizio Radica

Simple Engine Game in Basic

Started by Fabrizio Radica, 15:48, 29 July 16

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ervin

Quote from: SRS on 18:15, 01 August 16
and if you have no line between 610 and 640, you don't need a "GOTO 640" there :D

now this is "Haarspalterei" :D


Yes, you're absolutely right!
(I can't believe I didn't think of that!)


AMSDOS

With a few modifications, I was able to use "ON <expression> GOSUB", which can be compared to the IF..THEN..GOTO version.




10 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
100 MODE 0: 'PRINT CHR$(22)+CHR$(1) 'mode 0 ed attiva la trasparenza
110 CLS: BORDER 0: INK 0,0
150 maxAr%=20: SYMBOL AFTER 240
160 SYMBOL 245,&X1011010,&X10101,&X11000100,&X11011011,&X100110,&X1101000,&X1011011,&X11101001
165 SYMBOL 246,&X10000,&X1,&X1000,&X1010010,&X1000010,&X1000,&X10001,&X1000001
166 SYMBOL 247,&X111000,&X1111110,&X11111011,&X11111111,&X11111111,&X11111111,&X11111111,&X111100
200 DIM map%(20,20)
250 LOCATE 1,22 : PRINT "Loading..."
300 FOR y%=1 TO 20 'GENERO LA MAPPA DEL LIVELLO LEGGENDO I DATA
400 FOR x%=1 TO 20
500 READ map%(y%,x%)
510 ON map%(y%,x%) GOSUB 3010,3020,3000
640 NEXT x%
650 NEXT y%
660 x%=10:y%=8:v%=1:sc%=0:p%=0
670 SYMBOL 240,&X11000,&X111100,&X1111110,&X11011011,&X1111110,&X1100110,&X11011011,&X10000001
700 PRINT " " : PRINT "RetroAcademy." : LOCATE 1,22 : PRINT "Score     "
740 LOCATE x%,y%: PEN 3: PRINT CHR$(240)
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0 : sc%=sc%+1 : LOCATE 6,22 : PRINT " ";sc% :SOUND 2,100,8,10,1,1
780 IF NOT(INKEY(8)) AND NOT(map%(y%,x%-v%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):x%=x%-1:SOUND 1,200,1
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):x%=x%+1:SOUND 1,300,1
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):y%=y%-1:SOUND 1,50,1
880 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):y%=y%+1:SOUND 1,100,1
950 CALL &BD19
990 GOTO 740
1000 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1100 DATA 1,3,3,3,3,3,3,3,3,1,1,1,1,1,3,3,3,1,1,1
1200 DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
1300 DATA 1,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,3,3,1
1400 DATA 1,1,1,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1
1500 DATA 1,3,3,1,1,3,3,3,3,1,1,1,1,1,3,3,1,1,1,1
1600 DATA 1,3,3,3,3,3,3,3,3,1,1,1,1,1,3,3,1,1,1,1
1700 DATA 1,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1
1800 DATA 1,3,3,3,1,1,1,1,2,3,3,3,3,3,3,3,3,3,3,1
1900 DATA 1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1
2000 DATA 1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1
2100 DATA 1,3,3,3,3,2,1,1,1,1,3,1,1,1,3,3,3,1,1,1
2200 DATA 1,3,3,3,1,3,3,3,3,3,3,3,3,2,3,3,3,3,3,1
2300 DATA 1,3,1,1,1,1,3,3,3,1,1,1,1,3,3,3,3,3,3,1
2400 DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
2500 DATA 1,3,3,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1
2600 DATA 1,3,3,3,3,3,1,3,3,1,1,1,1,1,3,3,1,1,1,1
2700 DATA 1,1,1,3,3,3,1,3,3,1,3,3,3,3,3,3,3,3,3,1
2800 DATA 1,1,1,3,3,2,3,3,3,3,3,2,3,3,2,2,3,3,3,1
2900 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
3000 LOCATE x%,y%: PEN 8: PRINT CHR$(246):RETURN
3010 LOCATE x%,y%: PEN 6: PRINT CHR$(245):RETURN
3020 LOCATE x%,y%: PEN 1: PRINT CHR$(247):RETURN



To get that to work I had to change the DATA, so when ON <expression> GOSUB finds 1 - a wall is drawn, 2 - round yellow ball, 3 - background scenery. 0 isn't valid for this statement to work, so 0 becomes 3. 9 was too big, so I brought it down to 1. This also meant changing Lines 780-880, so as long as 1 was not found, it would continue with the rest of the statement.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Fabrizio Radica

Quote from: AMSDOS on 04:27, 02 August 16
With a few modifications, I was able to use "ON <expression> GOSUB", which can be compared to the IF..THEN..GOTO version.




10 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
100 MODE 0: 'PRINT CHR$(22)+CHR$(1) 'mode 0 ed attiva la trasparenza
110 CLS: BORDER 0: INK 0,0
150 maxAr%=20: SYMBOL AFTER 240
160 SYMBOL 245,&X1011010,&X10101,&X11000100,&X11011011,&X100110,&X1101000,&X1011011,&X11101001
165 SYMBOL 246,&X10000,&X1,&X1000,&X1010010,&X1000010,&X1000,&X10001,&X1000001
166 SYMBOL 247,&X111000,&X1111110,&X11111011,&X11111111,&X11111111,&X11111111,&X11111111,&X111100
200 DIM map%(20,20)
250 LOCATE 1,22 : PRINT "Loading..."
300 FOR y%=1 TO 20 'GENERO LA MAPPA DEL LIVELLO LEGGENDO I DATA
400 FOR x%=1 TO 20
500 READ map%(y%,x%)
510 ON map%(y%,x%) GOSUB 3010,3020,3000
640 NEXT x%
650 NEXT y%
660 x%=10:y%=8:v%=1:sc%=0:p%=0
670 SYMBOL 240,&X11000,&X111100,&X1111110,&X11011011,&X1111110,&X1100110,&X11011011,&X10000001
700 PRINT " " : PRINT "RetroAcademy." : LOCATE 1,22 : PRINT "Score     "
740 LOCATE x%,y%: PEN 3: PRINT CHR$(240)
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0 : sc%=sc%+1 : LOCATE 6,22 : PRINT " ";sc% :SOUND 2,100,8,10,1,1
780 IF NOT(INKEY() AND NOT(map%(y%,x%-v%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):x%=x%-1:SOUND 1,200,1
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):x%=x%+1:SOUND 1,300,1
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):y%=y%-1:SOUND 1,50,1
880 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%))=1 THEN LOCATE x%,y%:PEN 8:PRINT CHR$(246):y%=y%+1:SOUND 1,100,1
950 CALL &BD19
990 GOTO 740
1000 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
1100 DATA 1,3,3,3,3,3,3,3,3,1,1,1,1,1,3,3,3,1,1,1
1200 DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
1300 DATA 1,3,3,3,3,3,3,3,3,3,3,1,1,1,1,1,1,3,3,1
1400 DATA 1,1,1,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,2,1
1500 DATA 1,3,3,1,1,3,3,3,3,1,1,1,1,1,3,3,1,1,1,1
1600 DATA 1,3,3,3,3,3,3,3,3,1,1,1,1,1,3,3,1,1,1,1
1700 DATA 1,3,3,3,1,1,3,3,3,3,3,3,3,3,3,3,3,3,3,1
1800 DATA 1,3,3,3,1,1,1,1,2,3,3,3,3,3,3,3,3,3,3,1
1900 DATA 1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1
2000 DATA 1,1,1,1,1,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1
2100 DATA 1,3,3,3,3,2,1,1,1,1,3,1,1,1,3,3,3,1,1,1
2200 DATA 1,3,3,3,1,3,3,3,3,3,3,3,3,2,3,3,3,3,3,1
2300 DATA 1,3,1,1,1,1,3,3,3,1,1,1,1,3,3,3,3,3,3,1
2400 DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
2500 DATA 1,3,3,1,1,1,1,3,3,1,1,1,1,1,1,1,1,1,1,1
2600 DATA 1,3,3,3,3,3,1,3,3,1,1,1,1,1,3,3,1,1,1,1
2700 DATA 1,1,1,3,3,3,1,3,3,1,3,3,3,3,3,3,3,3,3,1
2800 DATA 1,1,1,3,3,2,3,3,3,3,3,2,3,3,2,2,3,3,3,1
2900 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
3000 LOCATE x%,y%: PEN 8: PRINT CHR$(246):RETURN
3010 LOCATE x%,y%: PEN 6: PRINT CHR$(245):RETURN
3020 LOCATE x%,y%: PEN 1: PRINT CHR$(247):RETURN



To get that to work I had to change the DATA, so when ON <expression> GOSUB finds 1 - a wall is drawn, 2 - round yellow ball, 3 - background scenery. 0 isn't valid for this statement to work, so 0 becomes 3. 9 was too big, so I brought it down to 1. This also meant changing Lines 780-880, so as long as 1 was not found, it would continue with the rest of the statement.



oh great!
I did not know how to assign a color to a tile.

I'm learning new things . it's only a week since I program here
very usefull, tnx :)

now i've a new question.
how to draw and move a sprite without symbol command?

I must put data at &4000 and move it with CALL?

i.e. call &4000,sprite,x,y?

tnx :)





Morri

Quote from: Fabrizio Radica on 09:35, 02 August 16now i've a new question. how to draw and move a sprite without symbol command? I must put data at &4000 and move it with CALL? i.e. call &4000,sprite,x,y? tnx :)
You've really reached the top end of graphics handling in Basic only, to get sprites into your game you will need to add a bit of ASM (machine code). There are topics around here which show off some sprite drivers. Perhaps you can find something that suits you.
Keeping it Kiwi since 1977

Morri

Had a quick look and found this thread. This 10 liner is a good example of what you can do.
Keeping it Kiwi since 1977

arnoldemu

@Fabrizio Radica :

Welcome.

I will describe the ram of the CPC.

Ram between 0-&40 is used by firmware.
Ram between &a600-&bf00 is used by firmware (and dos).
Screen is normally at &c000-&ffff.

if you use firmware (or basic) you can use ram &40-&a600, but basic uses some of this. So normally address like &4000 or more is used.

Basic starts at &170.

To make your code safe set HIMEM variable with BASIC MEMORY command. All above HIMEM is safe, BASIC doesn't touch it. HIMEM is max address for BASIC. (Under HIMEM is SYMBOL data, variables, basic program etc)

So if you do this:

MEMORY &3FFF
LOAD"driver",&4000

then basic will use &170-&3fff and your code can use &4000-&a600.

If your basic program is large &4000 is too low (basic will tell you "out of memory"), there will not be enough space for basic :(

So you can use higher value. e.g. &8000 or &9000.

Most sprite drivers are built to be in a fixed location in ram. i.e. They can't be relocated but most are higher up in memory.

So using basic and a sprite driver and the data for the sprites requires you to manage your ram a bit.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

AMSDOS

Quote from: Fabrizio Radica on 09:35, 02 August 16


oh great!
I did not know how to assign a color to a tile.

I'm learning new things . it's only a week since I program here
very usefull, tnx :)


It's not really a colour I'm using from the Data, more of a 1=Wall, 2=Treasure, 3=Background scenario.


ON map%(y%,x%) GOSUB can be used based on the DATA read in Line 500, if 1 is found routine Goes to Subroutine 3000, likewise if 2 or 3 is found it goes to Subroutine 3010 or 3020 and naturally all those Subroutines have RETURN to take you back to the Loop to read the next bit for the Array.


I think it works well and has eliminated a few IFs on the head
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

SRS

Quote from: Fabrizio Radica on 21:54, 01 August 16

HELP:
Anyone can send me a compiled version with BC for testing speed?
Tnx :)

There you go: after fixing the bug in line 780 -> retrofab is the "ESC"abable version, the other one is fast with switch /LE


Fabrizio Radica

Quote from: AMSDOS on 11:10, 02 August 16

It's not really a colour I'm using from the Data, more of a 1=Wall, 2=Treasure, 3=Background scenario.


ON map%(y%,x%) GOSUB can be used based on the DATA read in Line 500, if 1 is found routine Goes to Subroutine 3000, likewise if 2 or 3 is found it goes to Subroutine 3010 or 3020 and naturally all those Subroutines have RETURN to take you back to the Loop to read the next bit for the Array.


I think it works well and has eliminated a few IFs on the head


works very well,
i need to disasm to see the process.
btw, i think that gosub is more faster than if in any situations.

Fabrizio Radica

Quote from: SRS on 11:18, 02 August 16
There you go: after fixing the bug in line 780 -> retrofab is the "ESC"abable version, the other one is fast with switch /LE


oh, tnx mate :)
now, i need to make a DSK with FA.BA.COM.


Fabrizio Radica

New update and new video with new stuff :)


Fabrizio Radica

#36
aaargh... i've this problem with the 464 :(


how do i resolve it?
in basic 1.1 works fine (664 and 6128)

tnx.

here the code:




1 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
10 DEFINT A-Z:mode 0:transpOn$=CHR$(22)+CHR$(1):transpOff$=CHR$(22)+CHR$(0)
20 border 0:ink 0,0:maxx%=20:maxy%=20:lev%=0:isDown%=0:SYMBOL AFTER 240
160 SYMBOL 245,&X11111110,&X11111110,&X11111110,&X11111110,&X11111110,&X11111100,&X00000000,&X00000000 'wall
165 SYMBOL 246,&X01111110,&X10000000,&X10000000,&X10000000,&X10000000,&X10000000,&X00000000,&X00000000 'background
166 SYMBOL 247,&X00111100,&X01111110,&X11111011,&X11111111,&X11111111,&X11111111,&X01111110,&X00111100 'bonus
168 SYMBOL 248,&X11000000,&X00000000,&X00000000,&X00000000,&X00000000,&X00000000,&X00000000,&X00000000 'wall color
169 SYMBOL 249,&X00000000,&X00000000,&X00000100,&X00000000,&X00000000,&X00000000,&X00000000,&X00000000 'bonus light
170 SYMBOL 240,&X00111100,&X01111110,&X11101011,&X11111111,&X11111111,&X11000011,&X01100110,&X00111100 'player right
171 SYMBOL 250,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111 'ladders
172 SYMBOL 251,&X00111100,&X01111110,&X11010111,&X11111111,&X11111111,&X11000011,&X01100110,&X00111100 'player left


180 wa1$=chr$(245):bg$=chr$(246):bo1$=chr$(247):wa2$=chr$(248):bo2$=chr$(249):plyr$=chr$(240):plyl$=chr$(251):lad$=chr$(250)
200 DIM map%(maxy%,maxx%)
240 cls:PRINT transpOn$:LOCATE 1,24:ink 1,3:print "Loading"
250 for i%=2 to 15:ink i%,0:next i%
292 lev%=lev%+1
295 if (lev%>3) THEN cls: PRINT "YOU WIN!!" : end


300 curLeft$=CHR$(:curRight$=CHR$(9)
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(:bgr$=bgcolor$+bg$
340 wall$=fpen$+CHR$(9)+wa1$+curLeft$+white$+wa2$:bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$:playerr$=fpen$+CHR$(3)+plyr$:playerl$=fpen$+CHR$(3)+plyl$:ladders$=white$+lad$


345 DIM obj$(10),playerFrame$(10)
350 obj$(1)=wall$:obj$(2)=bonus$:obj$(3)=ladders$


354 frcount=1
355 pFrame$(1)=playerr$
356 pFrame$(2)=playerl$


400 FOR y%=1 TO maxy%
410 FOR x%=1 TO maxx%
420 READ a%:map%(y%,x%)=a%:locate x%,y%
430 ON map%(y%,x%) GOSUB 30010,30020,30030,30000
440 NEXT x%:NEXT y%


660 CALL &BC02:border 0:ink 0,0:INK 1,26:x%=2:y%=4:v%=1:sc%=0:p%=0:PRINT transpOff$
700 LOCATE 1,24:print "Score 0  - Lev ";lev%
720 'memory &7fff:load"music.bin",&8000:call &8000
740 LOCATE x%,y%:PRINT pFrame$(frcount):CALL &BD19
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0:locate 6,24:sc%=sc%+1:print sc%
780 IF NOT(INKEY() AND NOT(map%(y%,x%-v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=2: gosub 40000: x%=x%-v%
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=1: gosub 40000: x%=x%+v%
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%)=1) AND map%(y%-v%,x%)=3 THEN gosub 40000:y%=y%-v%
860 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%)=1) AND map%(y%+v%,x%)=3 THEN gosub 40000:y%=y%+v%
880 IF map%(y%+v%,x%)=0 or map%(y%+v%,x%)=2 THEN gosub 40000:y%=y%+v%
900 'if sc%>=9 then cls: goto 240
990 goto 740
1000 DATA 0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0
1100 DATA 0,1,4,4,0,0,0,0,4,1,1,1,1,1,0,0,0,1,1,0
1200 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,3,0,1
1300 DATA 1,0,0,0,0,0,4,4,0,0,0,1,1,1,1,1,1,3,0,1
1400 DATA 1,1,1,0,3,0,0,0,0,2,0,0,0,0,0,3,0,3,0,1
1500 DATA 1,0,0,1,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1600 DATA 1,0,0,0,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1700 DATA 1,0,0,0,3,1,2,0,0,0,0,4,4,0,0,3,0,4,4,1
1800 DATA 1,0,0,0,3,1,1,1,0,0,3,0,2,0,0,3,0,0,0,1
1900 DATA 1,2,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,1,0
2000 DATA 1,0,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,0,0
2100 DATA 1,0,0,0,3,3,1,1,1,1,3,1,1,1,0,4,4,1,1,0
2200 DATA 1,0,0,0,1,3,3,0,0,0,3,0,2,0,0,0,0,0,0,1
2300 DATA 1,0,1,1,1,1,3,0,0,1,1,1,1,1,0,0,2,0,0,1
2400 DATA 1,0,3,0,3,0,3,0,3,0,0,0,0,0,1,1,1,0,0,1
2500 DATA 1,0,3,1,3,1,1,0,3,1,1,1,1,1,1,1,1,1,0,1
2600 DATA 1,0,3,0,3,4,1,0,3,1,1,1,1,1,0,0,1,1,0,1
2700 DATA 0,1,1,0,3,0,1,0,3,1,0,4,4,0,0,0,0,0,0,1
2800 DATA 0,0,1,0,3,0,0,0,3,0,0,0,0,0,2,0,2,0,0,1
2900 DATA 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
30000 locate x%,y%:print bgr$:return
30010 locate x%,y%:print obj$(1):return
30020 locate x%,y%:print obj$(2):return
30030 locate x%,y%:print obj$(3):return
40000 LOCATE x%,y%:print" ":LOCATE x%,y%:print obj$(map%(y%,x%)):return



EDIT:
Ok, the BIG problem is here, with chr$(8 ) and chr$(15)



300 curLeft$=CHR$(8 ):curRight$=CHR$(9)
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(8 )bgr$=bgcolor$+bg$
340 wall$=fpen$+CHR$(9)+wa1$+curLeft$+white$+wa2$:bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$:playerr$=fpen$+CHR$(3)+plyr$:playerl$=fpen$+CHR$(3)+plyl$:ladders$=white$+lad$


if you replacing the lines 300,310,340 with:



300 curLeft$=CHR$(8 ):curRight$=CHR$(9)
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(:bgr$=bgcolor$+bg$
340 wall$=wa1$:bonus$=fpen$+CHR$(7)+bo1$:playerr$=plyr$:playerl$=plyl$:ladders$=white$+lad$


works fine on 464...
but i don't know how to resolve it...  :doh:

AMSDOS

#37
This is becoming a more problematic as the 464 handles Strings a little bit differently from the 664/6128. Morri started a thread a while ago and I posted a work around in it which worked, but when Coolbox came out, more complications arose and haven't got around to sorting them out  ???


Perhaps the easiest solution is to ditch the control code thing, Morri suggested using David Hall's Ariom Sprites, which would be more than adequate here for 8x8 Sprites, I maybe able to rummage through my Disks to find the program if you don't want to type it in.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Morri

Yes I have experienced this same nightmare.
Ronaldo tried to explain it to me here. Perhaps his explanation may help you.
Keeping it Kiwi since 1977

AMSDOS

Ok folks, this is what I knocked up to get it to work on a 464:




1 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
10 DEFINT A-Z:MODE 0:transpOn$=CHR$(22)+CHR$(1):transpOff$=CHR$(22)+CHR$(0)
11 ON BREAK GOSUB 50000
20 BORDER 0:INK 0,0:maxx%=20:maxy%=20:lev%=0:isDown%=0:SYMBOL AFTER 240
160 SYMBOL 245,&X11111110,&X11111110,&X11111110,&X11111110,&X11111110,&X11111100,&X0,&X0 'wall
165 SYMBOL 246,&X1111110,&X10000000,&X10000000,&X10000000,&X10000000,&X10000000,&X0,&X0 'background
166 SYMBOL 247,&X111100,&X1111110,&X11111011,&X11111111,&X11111111,&X11111111,&X1111110,&X111100 'bonus
168 SYMBOL 248,&X11000000,&X0,&X0,&X0,&X0,&X0,&X0,&X0 'wall color
169 SYMBOL 249,&X0,&X0,&X100,&X0,&X0,&X0,&X0,&X0 'bonus light
170 SYMBOL 240,&X111100,&X1111110,&X11101011,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player right
171 SYMBOL 250,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111 'ladders
172 SYMBOL 251,&X111100,&X1111110,&X11010111,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player left
180 wa1$=CHR$(245):bg$=CHR$(246):bo1$=CHR$(247):wa2$=CHR$(248):bo2$=CHR$(249):plyr$=CHR$(240):plyl$=CHR$(251):lad$=CHR$(250)
200 DIM map%(maxy%,maxx%)
240 CLS:PRINT transpOn$:LOCATE 1,24:INK 1,3:PRINT "Loading"
250 ' FOR i%=2 TO 15:INK i%,0:NEXT i%
292 lev%=lev%+1
295 IF (lev%>3) THEN CLS: PRINT "YOU WIN!!" : END
300 curLeft$=CHR$(8):curRight$=CHR$(9)
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(8):bgr$=bgcolor$+bg$
340 wall$=fpen$+CHR$(9)+wa1$+curLeft$+white$+wa2$:bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$:playerr$=fpen$+CHR$(3)+plyr$:playerl$=fpen$+CHR$(3)+plyl$:ladders$=white$+lad$
345 DIM obj$(10),playerFrame$(10)
350 obj$(1)=wall$:obj$(2)=bonus$:obj$(3)=ladders$
354 frcount=1
355 pframe$(1)=CHR$(240)
356 pframe$(2)=CHR$(251)
400 FOR y%=1 TO maxy%
410 FOR x%=1 TO maxx%
420 READ a%:map%(y%,x%)=a%:LOCATE x%,y%
430 ON map%(y%,x%) GOSUB 30010,30020,30030,30000
440 NEXT x%:NEXT y%
660 CALL &BC02:BORDER 0:INK 0,0:INK 1,26:x%=2:y%=4:v%=1:sc%=0:p%=0:PRINT transpOff$
700 LOCATE 1,24:PRINT "Score 0  - Lev ";lev%
720 'memory &7fff:load"music.bin",&8000:call &8000
740 LOCATE 1,1 : PRINT CHR$(15);CHR$(3); : LOCATE x%,y% : PRINT pframe$(frcount):CALL &BD19
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0:LOCATE 6,24:sc%=sc%+1:PRINT sc%
780 IF NOT(INKEY(8)) AND NOT(map%(y%,x%-v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=2: GOSUB 40000: x%=x%-v%
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=1: GOSUB 40000: x%=x%+v%
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%)=1) AND map%(y%-v%,x%)=3 THEN GOSUB 40000:y%=y%-v%
860 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%)=1) AND map%(y%+v%,x%)=3 THEN GOSUB 40000:y%=y%+v%
880 IF map%(y%+v%,x%)=0 OR map%(y%+v%,x%)=2 THEN GOSUB 40000:y%=y%+v%
900 'if sc%>=9 then cls: goto 240
990 GOTO 740
1000 DATA 0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0
1100 DATA 0,1,4,4,0,0,0,0,4,1,1,1,1,1,0,0,0,1,1,0
1200 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,3,0,1
1300 DATA 1,0,0,0,0,0,4,4,0,0,0,1,1,1,1,1,1,3,0,1
1400 DATA 1,1,1,0,3,0,0,0,0,2,0,0,0,0,0,3,0,3,0,1
1500 DATA 1,0,0,1,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1600 DATA 1,0,0,0,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1700 DATA 1,0,0,0,3,1,2,0,0,0,0,4,4,0,0,3,0,4,4,1
1800 DATA 1,0,0,0,3,1,1,1,0,0,3,0,2,0,0,3,0,0,0,1
1900 DATA 1,2,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,1,0
2000 DATA 1,0,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,0,0
2100 DATA 1,0,0,0,3,3,1,1,1,1,3,1,1,1,0,4,4,1,1,0
2200 DATA 1,0,0,0,1,3,3,0,0,0,3,0,2,0,0,0,0,0,0,1
2300 DATA 1,0,1,1,1,1,3,0,0,1,1,1,1,1,0,0,2,0,0,1
2400 DATA 1,0,3,0,3,0,3,0,3,0,0,0,0,0,1,1,1,0,0,1
2500 DATA 1,0,3,1,3,1,1,0,3,1,1,1,1,1,1,1,1,1,0,1
2600 DATA 1,0,3,0,3,4,1,0,3,1,1,1,1,1,0,0,1,1,0,1
2700 DATA 0,1,1,0,3,0,1,0,3,1,0,4,4,0,0,0,0,0,0,1
2800 DATA 0,0,1,0,3,0,0,0,3,0,0,0,0,0,2,0,2,0,0,1
2900 DATA 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
30000 LOCATE 1,1 : PRINT CHR$(15);CHR$(8); : LOCATE x%,y% : PRINT CHR$(246);:RETURN
30010 LOCATE 1,1 : PRINT CHR$(15);CHR$(9); : LOCATE x%,y% : PRINT CHR$(245);
30011 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(248);:RETURN
30020 LOCATE 1,1 : PRINT CHR$(15);CHR$(7); : LOCATE x%,y% : PRINT CHR$(247);
30021 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(249);:RETURN
30030 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(250);:RETURN
40000 LOCATE x%,y%:PRINT" ";:LOCATE x%,y%:PRINT obj$(map%(y%,x%));:RETURN
50000 CLEAR : CALL &BC02 : PEN 1 : MODE 2 : END
                                                                     



I've added Line 11 and 50000, which exits the program when break, and clear helps keep the 464 running smoothly.


curLeft & curRight are not used any more, and I'm deliberately positioning the control codes for the pen. My Face character is now a single Character, though still operates from the Array so Facing Left & Right works. Lines 300-350 remain, even though there's stuff there I'm not using, other things are being used, which change the outcome if they are removed.


I made notes which I'll post here in case it helps:




-- Control Codes --




fpen$=chr$(15)
curleft$=chr$(8)
curright$=chr$(9)
white$=fpen$+chr$(4)




-- Print Wall --


obj$(1)=wall$


wall$=fpen$+chr$(9)+wa1$+curleft$+white$+wa2$


wa1$=chr$(245)
wa2$=chr$(248)


chr$(15);chr$(9);chr$(245);chr$(8);chr$(15);chr$(4);chr$(248)


locate 1,1: print chr$(15);chr$(9) : locate x%,y% : print chr$(245);
locate 1,1: print chr$(15);chr$(4) : locate x%,y% : print chr$(248);


bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$


bo1$=chr$(247)
bo2$=chr$(249)




-- Print Bonus --


obj$(2)=bonus$


chr$(15);chr$(7);chr$(247);chr$(8);chr$(15);chr$(4);chr$(249)


locate 1,1 : print chr$(15);chr$(7) : locate x%,y% : print chr$(247);
locate 1,1 : print chr$(15);chr$(4) : locate x%,y% : print chr$(249);




-- Print Ladder --


obj$(3)=ladders$


chr$(15);chr$(4);chr$(250)


locate 1,1 : print chr$(15);chr$(4); : locate x%,y% : print chr$(250);


bgr$=chr$(15);chr$(8);chr$(246);


locate 1,1 : print chr$(15);chr$(8); : locate x%,y% : print chr$(246);




-- Print Player Left & Right --




playerr$=chr$(15);chr$(3);chr$(240)


playerl$=chr$(15);chr$(3);chr$(251)


locate 1,1 : print chr$(15);chr$(3); : locate x%,y% : print pframe$(frcount):call &bd19


pframe$(1)=chr$(240)
pframe$(2)=chr$(251)



Screenshot:


[attachimg=1]
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Fabrizio Radica

Quote from: AMSDOS on 07:48, 04 August 16
Ok folks, this is what I knocked up to get it to work on a 464:




1 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
10 DEFINT A-Z:MODE 0:transpOn$=CHR$(22)+CHR$(1):transpOff$=CHR$(22)+CHR$(0)
11 ON BREAK GOSUB 50000
20 BORDER 0:INK 0,0:maxx%=20:maxy%=20:lev%=0:isDown%=0:SYMBOL AFTER 240
160 SYMBOL 245,&X11111110,&X11111110,&X11111110,&X11111110,&X11111110,&X11111100,&X0,&X0 'wall
165 SYMBOL 246,&X1111110,&X10000000,&X10000000,&X10000000,&X10000000,&X10000000,&X0,&X0 'background
166 SYMBOL 247,&X111100,&X1111110,&X11111011,&X11111111,&X11111111,&X11111111,&X1111110,&X111100 'bonus
168 SYMBOL 248,&X11000000,&X0,&X0,&X0,&X0,&X0,&X0,&X0 'wall color
169 SYMBOL 249,&X0,&X0,&X100,&X0,&X0,&X0,&X0,&X0 'bonus light
170 SYMBOL 240,&X111100,&X1111110,&X11101011,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player right
171 SYMBOL 250,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111 'ladders
172 SYMBOL 251,&X111100,&X1111110,&X11010111,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player left
180 wa1$=CHR$(245):bg$=CHR$(246):bo1$=CHR$(247):wa2$=CHR$(248):bo2$=CHR$(249):plyr$=CHR$(240):plyl$=CHR$(251):lad$=CHR$(250)
200 DIM map%(maxy%,maxx%)
240 CLS:PRINT transpOn$:LOCATE 1,24:INK 1,3:PRINT "Loading"
250 ' FOR i%=2 TO 15:INK i%,0:NEXT i%
292 lev%=lev%+1
295 IF (lev%>3) THEN CLS: PRINT "YOU WIN!!" : END
300 curLeft$=CHR$(:curRight$=CHR$(9)
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(:bgr$=bgcolor$+bg$
340 wall$=fpen$+CHR$(9)+wa1$+curLeft$+white$+wa2$:bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$:playerr$=fpen$+CHR$(3)+plyr$:playerl$=fpen$+CHR$(3)+plyl$:ladders$=white$+lad$
345 DIM obj$(10),playerFrame$(10)
350 obj$(1)=wall$:obj$(2)=bonus$:obj$(3)=ladders$
354 frcount=1
355 pframe$(1)=CHR$(240)
356 pframe$(2)=CHR$(251)
400 FOR y%=1 TO maxy%
410 FOR x%=1 TO maxx%
420 READ a%:map%(y%,x%)=a%:LOCATE x%,y%
430 ON map%(y%,x%) GOSUB 30010,30020,30030,30000
440 NEXT x%:NEXT y%
660 CALL &BC02:BORDER 0:INK 0,0:INK 1,26:x%=2:y%=4:v%=1:sc%=0:p%=0:PRINT transpOff$
700 LOCATE 1,24:PRINT "Score 0  - Lev ";lev%
720 'memory &7fff:load"music.bin",&8000:call &8000
740 LOCATE 1,1 : PRINT CHR$(15);CHR$(3); : LOCATE x%,y% : PRINT pframe$(frcount):CALL &BD19
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0:LOCATE 6,24:sc%=sc%+1:PRINT sc%
780 IF NOT(INKEY() AND NOT(map%(y%,x%-v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=2: GOSUB 40000: x%=x%-v%
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=1: GOSUB 40000: x%=x%+v%
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%)=1) AND map%(y%-v%,x%)=3 THEN GOSUB 40000:y%=y%-v%
860 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%)=1) AND map%(y%+v%,x%)=3 THEN GOSUB 40000:y%=y%+v%
880 IF map%(y%+v%,x%)=0 OR map%(y%+v%,x%)=2 THEN GOSUB 40000:y%=y%+v%
900 'if sc%>=9 then cls: goto 240
990 GOTO 740
1000 DATA 0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0
1100 DATA 0,1,4,4,0,0,0,0,4,1,1,1,1,1,0,0,0,1,1,0
1200 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,3,0,1
1300 DATA 1,0,0,0,0,0,4,4,0,0,0,1,1,1,1,1,1,3,0,1
1400 DATA 1,1,1,0,3,0,0,0,0,2,0,0,0,0,0,3,0,3,0,1
1500 DATA 1,0,0,1,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1600 DATA 1,0,0,0,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1700 DATA 1,0,0,0,3,1,2,0,0,0,0,4,4,0,0,3,0,4,4,1
1800 DATA 1,0,0,0,3,1,1,1,0,0,3,0,2,0,0,3,0,0,0,1
1900 DATA 1,2,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,1,0
2000 DATA 1,0,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,0,0
2100 DATA 1,0,0,0,3,3,1,1,1,1,3,1,1,1,0,4,4,1,1,0
2200 DATA 1,0,0,0,1,3,3,0,0,0,3,0,2,0,0,0,0,0,0,1
2300 DATA 1,0,1,1,1,1,3,0,0,1,1,1,1,1,0,0,2,0,0,1
2400 DATA 1,0,3,0,3,0,3,0,3,0,0,0,0,0,1,1,1,0,0,1
2500 DATA 1,0,3,1,3,1,1,0,3,1,1,1,1,1,1,1,1,1,0,1
2600 DATA 1,0,3,0,3,4,1,0,3,1,1,1,1,1,0,0,1,1,0,1
2700 DATA 0,1,1,0,3,0,1,0,3,1,0,4,4,0,0,0,0,0,0,1
2800 DATA 0,0,1,0,3,0,0,0,3,0,0,0,0,0,2,0,2,0,0,1
2900 DATA 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
30000 LOCATE 1,1 : PRINT CHR$(15);CHR$(; : LOCATE x%,y% : PRINT CHR$(246);:RETURN
30010 LOCATE 1,1 : PRINT CHR$(15);CHR$(9); : LOCATE x%,y% : PRINT CHR$(245);
30011 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(248);:RETURN
30020 LOCATE 1,1 : PRINT CHR$(15);CHR$(7); : LOCATE x%,y% : PRINT CHR$(247);
30021 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(249);:RETURN
30030 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(250);:RETURN
40000 LOCATE x%,y%:PRINT" ";:LOCATE x%,y%:PRINT obj$(map%(y%,x%));:RETURN
50000 CLEAR : CALL &BC02 : PEN 1 : MODE 2 : END
                                                                     



I've added Line 11 and 50000, which exits the program when break, and clear helps keep the 464 running smoothly.


curLeft & curRight are not used any more, and I'm deliberately positioning the control codes for the pen. My Face character is now a single Character, though still operates from the Array so Facing Left & Right works. Lines 300-350 remain, even though there's stuff there I'm not using, other things are being used, which change the outcome if they are removed.


I made notes which I'll post here in case it helps:




-- Control Codes --




fpen$=chr$(15)
curleft$=chr$(
curright$=chr$(9)
white$=fpen$+chr$(4)




-- Print Wall --


obj$(1)=wall$


wall$=fpen$+chr$(9)+wa1$+curleft$+white$+wa2$


wa1$=chr$(245)
wa2$=chr$(248)


chr$(15);chr$(9);chr$(245);chr$(;chr$(15);chr$(4);chr$(248)


locate 1,1: print chr$(15);chr$(9) : locate x%,y% : print chr$(245);
locate 1,1: print chr$(15);chr$(4) : locate x%,y% : print chr$(248);


bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$


bo1$=chr$(247)
bo2$=chr$(249)




-- Print Bonus --


obj$(2)=bonus$


chr$(15);chr$(7);chr$(247);chr$(;chr$(15);chr$(4);chr$(249)


locate 1,1 : print chr$(15);chr$(7) : locate x%,y% : print chr$(247);
locate 1,1 : print chr$(15);chr$(4) : locate x%,y% : print chr$(249);




-- Print Ladder --


obj$(3)=ladders$


chr$(15);chr$(4);chr$(250)


locate 1,1 : print chr$(15);chr$(4); : locate x%,y% : print chr$(250);


bgr$=chr$(15);chr$(;chr$(246);


locate 1,1 : print chr$(15);chr$(; : locate x%,y% : print chr$(246);




-- Print Player Left & Right --




playerr$=chr$(15);chr$(3);chr$(240)


playerl$=chr$(15);chr$(3);chr$(251)


locate 1,1 : print chr$(15);chr$(3); : locate x%,y% : print pframe$(frcount):call &bd19


pframe$(1)=chr$(240)
pframe$(2)=chr$(251)



Screenshot:


[attachimg=1]


Many thanks' mate!!!

Now i try to correct it and comprehend your modify for optimize again :)


Really thanks for your support and for having helped me :)

AMSDOS

Quote from: Fabrizio Radica on 08:55, 04 August 16

Many thanks' mate!!!

Now i try to correct it and comprehend your modify for optimize again :)


Really thanks for your support and for having helped me :)


You might want to try this one out for size, it also works on a 464 a looks a little bit more like your code. The only difference I'm still not using curLeft$ or curRight control codes, but I'm using the Control code for Locate - chr(31)+chr(x%)+chr(y%) which lets me then incorporate it all in a single PRINT statement (even the PEN control code is in there).




1 'A (simple) GAME Routine BY FABRIZIO RADICA - 2016 Retroacademy.it
10 DEFINT A-Z:MODE 0:transpOn$=CHR$(22)+CHR$(1):transpOff$=CHR$(22)+CHR$(0)
11 ON BREAK GOSUB 50000
20 BORDER 0:INK 0,0:maxx%=20:maxy%=20:lev%=0:isDown%=0:SYMBOL AFTER 240
160 SYMBOL 245,&X11111110,&X11111110,&X11111110,&X11111110,&X11111110,&X11111100,&X0,&X0 'wall
165 SYMBOL 246,&X1111110,&X10000000,&X10000000,&X10000000,&X10000000,&X10000000,&X0,&X0 'background
166 SYMBOL 247,&X111100,&X1111110,&X11111011,&X11111111,&X11111111,&X11111111,&X1111110,&X111100 'bonus
168 SYMBOL 248,&X11000000,&X0,&X0,&X0,&X0,&X0,&X0,&X0 'wall color
169 SYMBOL 249,&X0,&X0,&X100,&X0,&X0,&X0,&X0,&X0 'bonus light
170 SYMBOL 240,&X111100,&X1111110,&X11101011,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player right
171 SYMBOL 250,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111,&X10000001,&X11111111 'ladders
172 SYMBOL 251,&X111100,&X1111110,&X11010111,&X11111111,&X11111111,&X11000011,&X1100110,&X111100 'player left
180 wa1$=CHR$(245):bg$=CHR$(246):bo1$=CHR$(247):wa2$=CHR$(248):bo2$=CHR$(249):plyr$=CHR$(240):plyl$=CHR$(251):lad$=CHR$(250)
200 DIM map%(maxy%,maxx%)
240 CLS:PRINT transpOn$:LOCATE 1,24:INK 1,3:PRINT "Loading"
250 ' FOR i%=2 TO 15:INK i%,0:NEXT i%
292 lev%=lev%+1
295 IF (lev%>3) THEN CLS: PRINT "YOU WIN!!" : END
310 fpen$=CHR$(15):green$=fpen$+CHR$(12):white$=fpen$+CHR$(4):bgcolor$=fpen$+CHR$(8):bgr$=bgcolor$+bg$
340 wall$=fpen$+CHR$(9)+wa1$+curLeft$+white$+wa2$:bonus$=fpen$+CHR$(7)+bo1$+curLeft$+white$+bo2$:playerr$=fpen$+CHR$(3)+plyr$:playerl$=fpen$+CHR$(3)+plyl$:ladders$=white$+lad$
345 DIM obj$(10),playerFrame$(10)
350 obj$(1)=wall$:obj$(2)=bonus$:obj$(3)=ladders$
354 frcount=1
355 pframe$(1)=CHR$(240)
356 pframe$(2)=CHR$(251)
400 FOR y%=1 TO maxy%
410 FOR x%=1 TO maxx%
420 READ a%:map%(y%,x%)=a%:LOCATE x%,y%
430 ON map%(y%,x%) GOSUB 30010,30020,30030,30000
440 NEXT x%:NEXT y%
660 CALL &BC02:BORDER 0:INK 0,0:INK 1,26:x%=2:y%=4:v%=1:sc%=0:p%=0:PRINT transpOff$
700 LOCATE 1,24:PRINT "Score 0  - Lev ";lev%
720 'memory &7fff:load"music.bin",&8000:call &8000
740 PRINT CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(3)+pframe$(frcount);:CALL &BD19
750 IF map%(y%,x%)=2 THEN map%(y%,x%)=0:LOCATE 6,24:sc%=sc%+1:PRINT sc%
780 IF NOT(INKEY(8)) AND NOT(map%(y%,x%-v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=2: GOSUB 40000: x%=x%-v%
800 IF NOT(INKEY(1)) AND NOT(map%(y%,x%+v%)=1) AND NOT(map%(y%+v%,x%)=0) THEN frcount=1: GOSUB 40000: x%=x%+v%
850 IF NOT(INKEY(0)) AND NOT(map%(y%-v%,x%)=1) AND map%(y%-v%,x%)=3 THEN GOSUB 40000:y%=y%-v%
860 IF NOT(INKEY(2)) AND NOT(map%(y%+v%,x%)=1) AND map%(y%+v%,x%)=3 THEN GOSUB 40000:y%=y%+v%
880 IF map%(y%+v%,x%)=0 OR map%(y%+v%,x%)=2 THEN GOSUB 40000:y%=y%+v%
900 'if sc%>=9 then cls: goto 240
990 GOTO 740
1000 DATA 0,0,1,1,1,1,1,1,1,0,0,0,0,0,1,1,1,1,0,0
1100 DATA 0,1,4,4,0,0,0,0,4,1,1,1,1,1,0,0,0,1,1,0
1200 DATA 1,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,3,0,1
1300 DATA 1,0,0,0,0,0,4,4,0,0,0,1,1,1,1,1,1,3,0,1
1400 DATA 1,1,1,0,3,0,0,0,0,2,0,0,0,0,0,3,0,3,0,1
1500 DATA 1,0,0,1,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1600 DATA 1,0,0,0,3,0,0,0,0,1,1,1,1,1,0,3,1,1,1,1
1700 DATA 1,0,0,0,3,1,2,0,0,0,0,4,4,0,0,3,0,4,4,1
1800 DATA 1,0,0,0,3,1,1,1,0,0,3,0,2,0,0,3,0,0,0,1
1900 DATA 1,2,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,1,0
2000 DATA 1,0,1,1,3,1,0,0,1,0,3,1,1,1,1,1,1,1,0,0
2100 DATA 1,0,0,0,3,3,1,1,1,1,3,1,1,1,0,4,4,1,1,0
2200 DATA 1,0,0,0,1,3,3,0,0,0,3,0,2,0,0,0,0,0,0,1
2300 DATA 1,0,1,1,1,1,3,0,0,1,1,1,1,1,0,0,2,0,0,1
2400 DATA 1,0,3,0,3,0,3,0,3,0,0,0,0,0,1,1,1,0,0,1
2500 DATA 1,0,3,1,3,1,1,0,3,1,1,1,1,1,1,1,1,1,0,1
2600 DATA 1,0,3,0,3,4,1,0,3,1,1,1,1,1,0,0,1,1,0,1
2700 DATA 0,1,1,0,3,0,1,0,3,1,0,4,4,0,0,0,0,0,0,1
2800 DATA 0,0,1,0,3,0,0,0,3,0,0,0,0,0,2,0,2,0,0,1
2900 DATA 0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0
30000 PRINT CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(8)+CHR$(246);:RETURN
30010 PRINT CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(9)+CHR$(245)+CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(4)+CHR$(248);:RETURN
30011 LOCATE 1,1: PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(248);:RETURN
30020 PRINT CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(7)+CHR$(247)+CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(4)+CHR$(249);:RETURN
30021 LOCATE 1,1 : PRINT CHR$(15);CHR$(4); : LOCATE x%,y% : PRINT CHR$(249);:RETURN
30030 PRINT CHR$(31)+CHR$(x%)+CHR$(y%)+CHR$(15)+CHR$(4)+CHR$(250);:RETURN
40000 LOCATE x%,y%:PRINT" ";:LOCATE x%,y%:PRINT obj$(map%(y%,x%));:RETURN
50000 CLEAR : CALL &BC02 : PEN 1 : MODE 2 : END
                                                   



It's all based around this Multicoloured Graphics article which was all done with a 464.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

AMSDOS

Oh and I forgot to mention Lines 30011 & 30021 can now be deleted (the program's not using them now anyway) & it appears there's some improvement in Speed.
* Using the old Amstrad Languages :D   * with the Firmware :P
* I also like to problem solve code in BASIC :)   * And type-in Type-Ins! :D

Home Computing Weekly Programs
Popular Computing Weekly Programs
Your Computer Programs
Updated Other Program Links on Profile Page (Update April 16/15 phew!)
Programs for Turbo Pascal 3

Fabrizio Radica

many thanks to all, really.


Now my tiny engine is near to be completed.
I have also implemented enemies and levels from disc (or tape)

Soon, i'll be ready to release the source code full commented, if you want :)




EgoTrip

Why don't you wait a couple of months, and enter it in the BASIC category in CPCretrodev 2016 contest? That'll give you loads of time to make a full game with it.

Fabrizio Radica

#45


Quote from: EgoTrip on 20:09, 04 August 16
Why don't you wait a couple of months, and enter it in the BASIC category in CPCretrodev 2016 contest? That'll give you loads of time to make a full game with it.




Ah why not! Thank's you!
I'm new here and did not know about this contest
Soon, you will see the new graphics.

Executioner

Quote from: EgoTrip on 20:09, 04 August 16
Why don't you wait a couple of months, and enter it in the BASIC category in CPCretrodev 2016 contest?

Does the BASIC category allow any machine code at all? You could do a simple routine to draw the multicolour tiles in about 20 bytes and it would be much much faster.

Morri

Quote from: Executioner on 23:07, 04 August 16Does the BASIC category allow any machine code at all? You could do a simple routine to draw the multicolour tiles in about 20 bytes and it would be much much faster.
No, the BASIC submissions must be one file (no multi-loading) and all interpreted BASIC 1.0 (no machine code pokes). My game CoolBox was going to be an entry but I couldn't get my code to work on Basic 1.0, the control code bug got me.
Keeping it Kiwi since 1977

ervin

Quote from: Fabrizio Radica on 20:20, 04 August 16
Ah why not! Thank's you!
I'm new here and did not know about this contest
Soon, you will see the new graphics.


Entering the competition is a great idea, but if you decide to enter, you may need to stop uploading code.
If you enter a game that is too similar to things you've already shown us, the game may get disqualified.
(The rules state that game cannot have been released before).


Executioner

Quote from: Morri on 23:38, 04 August 16
No, the BASIC submissions must be one file (no multi-loading) and all interpreted BASIC 1.0 (no machine code pokes).

By the looks of the graphics, you could simple POKE the overlay pixels into screen memory (that's not machine code). POKE &C000+X%*2+y%*80,255 for example should be much quicker than using transparent character overlay.

Powered by SMFPacks Menu Editor Mod