General Category > Programming

Castle Dungeon - Locomotive Basic

(1/8) > >>

Fabrizio Radica:
New Update.
- add player- add collisions- add "monsters"- some optimizations.
But now i need to optimize the rendering of camera with a best solution of that.
Clear the rendering area is not a best solution.
I need to draw and delete (fast) tiles left, right, up and down.
Any idea?Tnx

sorry for my poor english :(




--- Code: ---10 clear:mode 0: ON BREAK GOSUB 8000
11 OUT &BC00,0:OUT &BD00,127
12 OUT &BC00,4:OUT &BD00,18
13 OUT &BC00,5:OUT &BD00,15
14 OUT &BC00,6:OUT &BD00,15
15 OUT &BC00,7:OUT &BD00,17

18 border 0: ink 0,0:call &BD19

20 mx%=20:my%=11:cx%=3:cy%=3:DIM map%(mx%,my%):DIM camera%(cx%,cy%):movx%=1:movy%=1
30 XOROn$=CHR$(23)+CHR$(1):XOROff$=CHR$(23)+CHR$(0)
50 gosub 3000:gosub 2000

500 while 1 'Main Loop
505 call &BD19 'frame
550 IF NOT(INKEY(1)) AND (movx%<18) AND NOT(map%(1+movx%+1,1+movy%)=1) THEN gosub 7000:movx%=movx%+1:gosub 2000
560 IF NOT(INKEY() AND (movx%>0) AND NOT(map%(1+movx%-1,1+movy%)=1) THEN gosub 7000:movx%=movx%-1:gosub 2000
570 IF NOT(INKEY(0)) AND (movy%>0) AND NOT(map%(1+movx%,1+movy%-1)=1) THEN gosub 7000:movy%=movy%-1:gosub 2000
580 IF NOT(INKEY(2)) AND (movy%<9) AND NOT(map%(1+movx%,1+movy%+1)=1) then gosub 7000:movy%=movy%+1:gosub 2000
1500 wend

2000 'Camera
2005 sound 1,50,1,15:locate 1+movx%,1+movy%:PEN 3:PRINT CHR$(249);:
2010 IF map%(1+movx%,1+movy%)=2 THEN SOUND 1,800,10,15,2,10,1:goto 10
2015 x2%=movx%:y2%=movy%: locate 1,14:pen 3:Print " Castle Dungeon CPC ":locate 1,15:Print " www.retroacademy.it ":

2040 FOR y%=1 TO cy%
2050 FOR x%=1 TO cx%
2080 LOCATE (x%+movx%)-1,(y%+movy%)-1
2085 IF map%(x2%,y2%)=1 THEN PEN 2: print CHR$(127);:
2090 'IF map%(x2%,y2%)=0 then print " ";:
2092 IF map%(x2%,y2%)=2 then PEN 3: print CHR$(253);:
2110 x2%=x2%+1
2120 NEXT x%
2130 y2%=y2%+1:x2%=movx%
2150 NEXT y%
2180 return

3000 'map
3010 restore 5000
3050 for y%=1 to my%
3100 for x%=1 to mx%
3150 READ a%:map%(x%,y%)=a%:LOCATE x%,y%
3200 'if map%(x%,y%)=1 then PRINT CHR$(15);CHR$(;CHR$(207);:
3250 NEXT x%
3300 NEXT y%
3350 RETURN

4000 'Tiles
4050 PRINT CHR$(15);CHR$(;CHR$(207);:RETURN

5000 'Map Data
5010 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
5100 DATA 1,0,0,0,0,0,1,0,0,0,0,0,0,2,0,0,0,1,0,1
5200 DATA 1,1,1,1,1,0,1,0,2,0,0,1,0,0,0,0,0,1,0,1
5300 DATA 1,0,1,0,0,0,1,0,0,0,0,1,1,1,1,2,0,1,0,1
5400 DATA 1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1
5500 DATA 1,0,1,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1
5600 DATA 1,0,2,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1
5700 DATA 1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1
5800 DATA 1,0,1,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,1,1
5900 DATA 1,0,0,0,0,0,0,2,0,0,0,0,1,0,0,1,0,0,0,1
6000 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

6999 'Clear camera only
7000 FOR y%=1 TO cy%
7010 FOR x%=1 TO cx%
7020 LOCATE (x%+movx%)-1,(y%+movy%)-1
7030 print " ";:
7040 NEXT x%
7050 x2%=movx%
7060 NEXT y%
7070 return

8000 CLEAR:CALL &BC02:PEN 1:MODE 2:print "Hi, Visit www.retroacademy.it ":print" "
8010 OUT &BC00,0: OUT &BD00,&3F
8020 OUT &BC00,1: OUT &BD00,&28
8030 OUT &BC00,2: OUT &BD00,&2E
8040 OUT &BC00,3: OUT &BD00,&8E
8050 OUT &BC00,4: OUT &BD00,&26
8060 OUT &BC00,5: OUT &BD00,&00
8070 OUT &BC00,6: OUT &BD00,&19
8080 OUT &BC00,7: OUT &BD00,&1E
8090 OUT &BC00,8: OUT &BD00,&00
8100 OUT &BC00,9: OUT &BD00,&07
8110 OUT &BC00,10: OUT &BD00,&00
8120 OUT &BC00,11: OUT &BD00,&00
8130 OUT &BC00,12: OUT &BD00,&30
8140 OUT &BC00,13: OUT &BD00,&00
8150 OUT &BC00,14: OUT &BD00,&00
8160 OUT &BC00,15: OUT &BD00,&00


--- End code ---

AMSDOS:
Line 520 is exclusive to BASIC 1.1, it could be replaced with 520 CALL &BD19 which is what that BASIC 1.1 is, though it's a call to Firmware, the alternative BASIC approach is a delayed FOR loop, though I don't have any accurate timings of this in BASIC, perhaps something could be rigged up. Here's one weird approach involving a TIME delay:



--- Code: ---10 MODE 1:p=0
20 WHILE 1
30 LOCATE 1,1:p=p+1:PRINT p;
40 t2=TIME/300
50 WHILE t2>t:t=TIME/300.2:WEND
60 WEND

--- End code ---


The delay in this case is line 50, line 40 sets up t2 as the initial counter, it's value is larger than t, so the WHILE loop is initiated, from there t=TIME/300.2 - the closer it gets to 300 the quicker the delayed loop exits. I'm unsure if it would help you in your game though, I tried setting it as t=TIME/300.01 and watch my number count very quickly, t=TIME/300.05 or 300.04 produce a more delayed response.

AMSDOS:
This might be of some use, I wrote it so now it uses TAG:TAGOFF along with the use of a TIME delay, with it you could compare how quick you want the delay along with your FRAME example, simply REM lines 140 & 150 when you're using FRAME and REM out FRAME when using 140 & 150, as you will see I now have a number with 5 decimal places which is probably just fractionally longer than the FRAME counterpart.


--- Code: ---100 MODE 1:p=0:x=0:y=398
110 PRINT CHR$(23);CHR$(1);
120 WHILE 1
130 MOVE x,y:p=p+1:TAG:PRINT p;:TAGOFF
140 t2=TIME/300
150 WHILE t2>t:t=TIME/300.00005:WEND
160 ox=x:x=x+2:IF x>576 THEN x=0
170 oy=y:y=y-2:IF y<16 THEN y=398
180 MOVE ox,oy:TAG:PRINT p;:TAGOFF
190 WEND

--- End code ---

Fabrizio Radica:
Hi, if you want, here ny Code :)



--- Code: ---10 clear:mode 0: border 0: ink 0,0
11 OUT &BC00,0:OUT &BD00,127
12 OUT &BC00,4:OUT &BD00,18
13 OUT &BC00,5:OUT &BD00,15
14 OUT &BC00,6:OUT &BD00,15
15 OUT &BC00,7:OUT &BD00,17

20 mx%=20:my%=11:cx%=4:cy%=3:DIM map%(mx%,my%):DIM camera%(cx%,cy%):movx%=1:movy%=1
30 XOROn$=CHR$(23)+CHR$(1):XOROff$=CHR$(23)+CHR$(0)
50 gosub 3000

60 FOR x%=1 TO cx%
70 FOR y%=1 TO cy%
80 camera%(x%,y%)=0
90 NEXT y%
100 NEXT x%

150 gosub 2020


500 while 1 'Main Loop
505 call &BD19 'frame
550 IF NOT(INKEY(1)) AND (movx%<17) THEN movx%=movx%+1:gosub 2030
560 IF NOT(INKEY() AND (movx%>1) THEN movx%=movx%-1:gosub 2030
570 IF NOT(INKEY(0)) AND (movy%>1) THEN movy%=movy%-1:gosub 2030
580 IF NOT(INKEY(2)) AND (movy%<9) then movy%=movy%+1:gosub 2030
1500 wend

2020 'Camera
2030 clg : x2%=movx%:y2%=movy%:locate 1,13:Print "Castel Dungeon CPC":locate 1,14:Print "www.retroacademy.it":
2040 FOR y%=1 TO cy%
2050 FOR x%=1 TO cx%
2070 camera%(x%,y%)=map%(x2%,y2%)
2080 LOCATE x%+movx%-1,y%+movy%
2085 IF map%(x2%,y2%)=1 THEN PEN 2: print CHR$(127);:
2090 IF map%(x2%,y2%)=0 then PEN 2: print CHR$(143);:
2110 x2%=x2%+1
2120 NEXT x%
2130 y2%=y2%+1
2140 x2%=movx%
2150 NEXT y%
2160 return

3000 'map
3010 restore 5000
3050 for y%=1 to my%
3100 for x%=1 to mx%
3150 READ a%:map%(x%,y%)=a%:LOCATE x%,y%
3200 if map%(x%,y%)=1 then PRINT CHR$(15);CHR$(;CHR$(207);:
3250 NEXT x%
3300 NEXT y%
3350 RETURN

4000 'Tiles
4050 PRINT CHR$(15);CHR$(;CHR$(207);:RETURN

5000 'Map Data
5010 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
5100 DATA 1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1,0,1
5200 DATA 1,1,1,1,1,0,1,0,0,0,0,1,0,0,0,0,0,1,0,1
5300 DATA 1,0,1,0,0,0,1,0,0,0,0,1,1,1,1,0,0,1,0,1
5400 DATA 1,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1
5500 DATA 1,0,1,0,1,1,1,1,1,0,0,1,0,1,1,1,1,0,0,1
5600 DATA 1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1
5700 DATA 1,1,1,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1
5800 DATA 1,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,1
5900 DATA 1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,16000 DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
--- End code ---

Fabrizio Radica:
Engine Update :)

https://www.youtube.com/watch?v=txjXJ7fWi1Qhttp://

Navigation

[0] Message Index

[#] Next page

Go to full version
Powered by SMFPacks Media Embedder
Powered by SMFPacks Alerts Pro Mod
Powered by SMFPacks Mentions Pro Mod