Drawing walls

This commit is contained in:
neauoire 2022-09-10 14:28:00 -07:00
parent 5ddaf0936d
commit a8969d175a
1 changed files with 54 additions and 4 deletions

View File

@ -33,6 +33,7 @@
( vectors ) ( vectors )
;on-frame .Screen/vector DEO2 ;on-frame .Screen/vector DEO2
;on-mouse .Mouse/vector DEO2
#0060 .player/x STZ2 #0060 .player/x STZ2
#0070 .player/y STZ2 #0070 .player/y STZ2
@ -47,6 +48,57 @@ BRK
@on-frame ( -> ) @on-frame ( -> )
BRK
@on-mouse ( -> )
;draw-viewport JSR2
;draw-minimap JSR2
BRK
(
@|drawing )
@draw-viewport ( -- )
#00 .Screen/auto DEO
#3c00
&h
#00 OVR #10 SFT2 #0090 ADD2 .Screen/x DEO2
#00 OVR .Mouse/x DEI2 ADD2 #003c DIV2k MUL2 SUB2 .player/a STZ2
( get distance ) ;cast JSR2 ;draw-col JSR2
INC GTHk ,&h JCN
POP2
JMP2r
@draw-col ( distance -- )
STH
#8000
&l
#00 OVR .Screen/y DEO2
DUP STHkr ;get-color JSR2 .Screen/pixel DEO
INC GTHk ,&l JCN
POP2
POPr
JMP2r
@get-color ( y distance -- color )
OVR #40 GTH ,&bottom JCN
#01 SFT GTH INC
JMP2r
&bottom
#00 SWP SUB #01 SFT LTH INC
JMP2r
@draw-minimap ( -- )
;draw-map JSR2 ;draw-map JSR2
.Mouse/x DEI2 #003c DIV2k MUL2 SUB2 .player/a STZ2 .Mouse/x DEI2 #003c DIV2k MUL2 SUB2 .player/a STZ2
@ -54,18 +106,16 @@ BRK
.player/x LDZ2 .player/x LDZ2
.player/y LDZ2 .player/y LDZ2
#00 ;cast JSR2 [ #00 ;cast JSR2 ]
STH2k ;raycast JSR2 STH2k ;raycast JSR2
OVR2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 OVR2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2
OVR2 .player/y LDZ2 STH2kr #01 SFT2 SUB2 ADD2 OVR2 .player/y LDZ2 STH2kr #01 SFT2 SUB2 ADD2
;get-tile JSR2 #00 NEQ ,&color STR ;get-tile JSR2 #00 NEQ ,&color STR
SWP2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 SWP2 SWP2 .player/x LDZ2 STH2kr #01 SFT2 SUB2 ADD2 SWP2
.player/y LDZ2 STH2r #01 SFT2 SUB2 ADD2 .player/y LDZ2 STH2r #01 SFT2 SUB2 ADD2
#02 [ LIT &color $1 ] ADD ;draw-line JSR2 #02 [ LIT &color $1 ] ADD ;draw-line JSR2
BRK JMP2r
@cast ( -- range ) @cast ( -- range )