Free your creativity - IOMBCC

Página 23/29
16 | 17 | 18 | 19 | 20 | 21 | 22 | | 24 | 25 | 26 | 27 | 28

Por dvik

Prophet (2200)

Imagen del dvik

22-04-2005, 08:29

It can actually be made a bit more efficient by only update the center line scroll
twice every loop (instead of everytime the grass is updated. It requires a bit
more code though. It actually looks a bit better too. The code below does this
but it does scrolls with a constant speed. It gives an idea though:

1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:V=14:SCREEN2,3,0:FORX=0TO2:FORY=0TO31:R=16-Y\2:
2 LINE(R-(X-1)*((SIN(Y^.8/6)-(Y<16))*6-R-2)+(X<2),X*32+Y)-STEP(Y+1,0):NEXTY,X
3 FORY=-1TO1:FORX=0TO14:PRESET(16+Y*X\4,64+32*Y-X):NEXTX,Y
4 N=14336:U=255:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*32+(IAND48)\2+(IAND448)*8):NEXT:SCREEN1:KEYOFF:FORO=0TO32:Y=0:FORR=RTOR+1:Y=Y*96+(ASC(MID$("3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&",R))-35)
5 NEXT:FORK=KTOK+Y\256:VPOKEK+N+I,YANDU:NEXTK,O:LOCATE8,1:PRINT"PLEASE WAIT!":R=N\2:FORI=256TO1023:VPOKE7952+I,85:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IAND32:VPOKE6432+(IAND63),228+8*(IAND3)-O
6 W=2^(IAND7):J=O*127\W\32:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:FORK=1TO13:FORH=0TO31:VPOKE6464+H+K*32,-(K<9ORH<13ORH>18)*(ASC(MID$("i=67'6&7/'6.&",K))+90):P(H\4)=50-15*(H\12AND1):NEXTH,K:VPOKE8192,V
13 SOUND3,V:FORW=8TO9:PUTSPRITEW,(80+64*W,159),V,W-2:SOUNDW,V:NEXT:VPOKE1209,U:TIME=0:FORT=7TOR:LOCATE1,1:D=96-(NAND127):Y=D>0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh    RANK:###";S;N\128-82:-:F=B:IFC<TTHENC=V+T+TMOD99:B=(R-T>99)*(1-CMOD3)
14 GOSUB20:S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*H,95),V,4*B+W+1:PUTSPRITE3+W,(W*H,127),V,4*F+3+W:NEXT:-:T=T+S-1:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T0)*(N\4-V):SOUND8,O:SOUND9,O:PUTSPRITE0,(116-(36-X)*D\126,68+D),-(D>0),S-D\24:LOCATE6,4:PRINTMID$(Z$+"Race Over   Time ="+STR$(Z/10)+"s"+Z$,NMOD42+1,S):-:NEXT:SCREEN0
7 FORJ=1TO3:FORI=0TO7:VPOKE64*J+I,254:VPOKE64*J+8+I,31:VPOKE64*J+16+I,0:VPOKE64*J+24+I,0:FORK=0TO1:VPOKE6671+32*I+K,ASC(MID$("KSKSIQQI",I+1))-65+K:NEXTK,I,J
20 A=A+1:VPOKE8193+0,238+(AAND1):VPOKE8193+1,238+(A+1AND1):RETURN

Por Alex Ganzeveld

Expert (89)

Imagen del Alex Ganzeveld

22-04-2005, 08:31

Dvik, NYYRIKKI: they should erect a statue for you guys! This is insane! And it's actually playable. This would have been a nice listing for the MSX Computer Magazine in 1986 Wink

Por dvik

Prophet (2200)

Imagen del dvik

22-04-2005, 08:34

Yeah we're about 20 years too late Wink On the other hand, the car games I did
20 years ago wouldn't make it into the Computer Magazine Smile

Por dvik

Prophet (2200)

Imagen del dvik

22-04-2005, 09:02

A small optimization of line 7 and 20:

7 FORI=0TOU:VPOKEI,(IAND16)*254\(8^(I\8AND1))\16:VPOKE6671+(IAND225),ASC(MID$("IQIQKSSK",I\32+1))-65+(IAND1):NEXT
20 A=A+(S+4)\6:FORW=0TO1:VPOKE8193+W,A\3+WAND1OR238:NEXT:RETURN

Now we're only about 120 characters short Wink

Por dvik

Prophet (2200)

Imagen del dvik

23-04-2005, 04:30

I've made a few optimizations. I was almost able to fit the center line into the size limits.
I found quite a few more characters (about 170) and I made two versions of
the code. One withthe center line and one without (that can be filled with nice features).

So here is the one with center line:

1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:SCREEN2,3,0:N=14336:V=32:FORX=-1TO1:FORY=0TO31:M=16-Y\2:W=V+X*V+Y:LINE(M-X*((SIN(Y^.8/6)-(Y<16))*6-M-2)+(X<1),W)-STEP(Y+1,0)
2 PRESET(16-X*(Y\5-6),-W*(Y>17)):NEXTY,X:U=255:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*V+(IAND48)\2+(IAND448)*8):NEXT:SCREEN1:KEYOFF:FORY=0TOU:VPOKEY,(YAND16)*(Y\VOR254)\(8^(Y\8AND1))\16:P(Y\V)=50-15*(Y\96AND1):NEXT:R=N\2:FORO=0TO73:Y=0
3 FORM=MTOM+1:Y=Y*96+(ASC(MID$("3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&wfw:w3w4w$Is%kIsIc%sIcIt%kItIl%sIlDD%q#-#.%qDDDS%q#5#6%qDSDK%q#5#6%qDKDC%q#-#.%qDC",M))-35):NEXT:FORK=KTOK+Y\256:VPOKEK+N+I+8335*(O>V),YANDU
4 NEXTK,O:FORI=256TO1023:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IANDV:VPOKE6432+(IAND63),228+8*(IAND3)-O:W=2^(IAND7):J=O*127\W\V:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:SOUND3,14:TIME=0
5 VPOKE1209,U:FORW=8TO9:PUTSPRITEW,(80+64*W,159),14,W-2:SOUNDW,14:NEXT:FORT=2TOR:SOUND1,83:G=G+F*S\2:LOCATE1,1:D=96-(NAND127):Y=D>0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh    RANK:###";S;N\128-82:-:F=B:IFC<TTHENC=9+T+TMOD99:B=(R-T>99)*(1-CMOD3)
6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*V,95),14,4*B+W+1:PUTSPRITE3+W,(W*V,127),14,4*F+3+W:NEXT:-:T=T+S-1:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T

And here is the one without:

1 J=S-J*(J<96-S):K=J\16:FORW=0TO2:VPOKE8208+W,P(W+K):NEXT:IFTTHENRESUMENEXTELSEONERRORGOTO1:DEFINTA-Y:COLOR15,5,1:KEYOFF:SCREEN2,3,0:U=255:V=32:FORX=-1TO1:FORY=0TO31:M=16-Y\2:LINE(M-X*((SIN(Y^.8/6)-(Y<16))*6-M-2)+(X<1),V+X*V+Y)-STEP(Y+1,0)
2 P(Y\4)=50-15*(Y\12AND1):NEXTY,X:N=14336:FORI=0TO383:VPOKEN+I,VPEEK((IAND7)+(IAND8)*V+(IAND48)\2+(IAND448)*8):NEXT:S$="3##B#C#c$B'r$B&s3#%##C#3%S';%S&s;##2#3#B#R#B#<=c'##c'#@C#)#2#,s##&wfw:w3w4w$w3w#w4w,DD0CDDDS0CDSDK0CDKDC0CDC":SOUND3,14
3 SCREEN1:FORO=0TO53:Y=0:FORM=MTOM+1:Y=Y*96+(ASC(MID$(S$,M))-35):NEXT:FORK=KTOK+Y\256:VPOKEK+N+I+8335*(O>V),YANDU:NEXTK,O:FORI=256TO1023:O=VPEEK(I):VPOKEI,(OORO\2)\(2-(IAND4)\4):NEXT:FORI=ITO1279:O=IANDV:VPOKE6432+(IAND63),228+8*(IAND3)-O
4 W=2^(IAND7):J=O*U\W\64:VPOKEI+512,JAND-W:VPOKEI+768,JOR-WANDU:J=8-O\8:VPOKEI,(JANDI)*U\J:NEXT:R=N\2:VPOKE8192,14:VPOKE1209,U:FORW=8TO9:PUTSPRITEW,(80+64*W,159),14,W-2:SOUNDW,14:NEXT:TIME=0:FORT=2TOR:-:PUTSPRITE0,(X+80,156),1,12:SOUND1,83
5 G=G+F*S\2:LOCATE1,1:D=96-(NAND127):Y=D>0:-:D=D*D\96:PRINTUSING"SPEED:##0kmh    RANK:###";S;N\128-82:-:FORW=8216TO8219:G=G+8AND31:VPOKEW,86+(GAND16):VPOKE4+W,85+G\24:NEXT:O=STICK(0):T=T+S-1:-:F=B:IFC<TTHENC=9+T+TMOD99:B=(R-T>99)*(1-CMOD3)
6 S=S-(S<18ANDSTRIG(0))*2+(S>0):-:FORW=3TO4:PUTSPRITEW+1,(F*10+W*V,95),14,4*B+W+1:PUTSPRITE3+W,(W*V,127),14,4*F+3+W:NEXT:-:PUTSPRITE1,(115-(D<34)*((24-D)*B+F*10)+(E-64)*D\225,-Y*(98+D)-31),-6*(T0)*D\6:NEXT:SCREEN0

The reason why I made one without center line is that I don't think it is smooth
enough and maybe we should do something else like a nice intro, or one of the
other features NYYRIKKI suggested.

Por NYYRIKKI

Enlighted (5982)

Imagen del NYYRIKKI

25-04-2005, 15:43

You have rewritten this code lately so much, that it is hard to follow your changes anymore. You have really managed to squeeze this. Smile

If you want to take all characters out, I think, that you can optimize most of the errors. Smile Example: Y=D>0:-: can be written as Y=D>0(:

Por NYYRIKKI

Enlighted (5982)

Imagen del NYYRIKKI

25-04-2005, 16:10

Character generator:
FORI=UTO1023

Por NYYRIKKI

Enlighted (5982)

Imagen del NYYRIKKI

25-04-2005, 16:28

S=15 does not help... To make it help, it should be in the beginning of proram and should use another variable name. If you place it after DEFINTA-Y, line will be too long, but maybe you find a way to relocate U=255...

Por dvik

Prophet (2200)

Imagen del dvik

25-04-2005, 17:39

I'm pretty satisfied with the packing now. The big change was to put the
landscape data RLE encoded. That saved quite a lot. Other than that I think I got rid of one for loop.
I had to move code around quite a lot to make the lines 239 chacaracters.
I looked a bit more at it and I can't really think of more optimizations and I don't
really think it is necessary.
I prefer the second version without a center line so if you have any ideas of
things to put into the game (I also thought of a "get ready, get set, go" text
before the game starts) go ahead. This time I promise not to do anymore
changes.

Por dvik

Prophet (2200)

Imagen del dvik

25-04-2005, 17:48

Another feature that may be nice is the possibility to start a new game after the race is over and maybe disable the screen while generating the vdp data and
maybe disable CTRL-BREAK.
I think a couple of small features to touch the game up is worth more than the
white center line. What do you think?

Página 23/29
16 | 17 | 18 | 19 | 20 | 21 | 22 | | 24 | 25 | 26 | 27 | 28