mirror of
https://github.com/badvision/lawless-legends.git
synced 2025-02-10 16:31:49 +00:00
Fixed several bugs in the ray caster.
This commit is contained in:
parent
25432cb16a
commit
3b55e1a336
@ -20,12 +20,12 @@ var map = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
var player = {
|
var player = {
|
||||||
x : 2.5, // current x, y position
|
x : 11.0, // current x, y position
|
||||||
y : 2.5,
|
y : 10.5,
|
||||||
dir : 0, // the direction that the player is turning, either -1 for left or 1 for right.
|
dir : 0, // the direction that the player is turning, either -1 for left or 1 for right.
|
||||||
angleNum : 0, // the current angle of rotation
|
angleNum : 0, // the current angle of rotation
|
||||||
speed : 0, // is the playing moving forward (speed = 1) or backwards (speed = -1).
|
speed : 0, // is the playing moving forward (speed = 1) or backwards (speed = -1).
|
||||||
moveSpeed : 0.5, // how far (in map units) does the player move each step/update
|
moveSpeed : 0.25, // how far (in map units) does the player move each step/update
|
||||||
rotSpeed : 22.5 * Math.PI / 180 // how much does the player rotate each step/update (in radians)
|
rotSpeed : 22.5 * Math.PI / 180 // how much does the player rotate each step/update (in radians)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ pixNum = $C ; len 1
|
|||||||
byteNum = $D ; len 1
|
byteNum = $D ; len 1
|
||||||
pTmp = $E ; len 2
|
pTmp = $E ; len 2
|
||||||
tmp = $10 ; len 2
|
tmp = $10 ; len 2
|
||||||
bacKBuf = $12 ; len 1 (value 0 or 1)
|
backBuf = $12 ; len 1 (value 0 or 1)
|
||||||
frontBuf = $13 ; len 1 (value 0 or 1)
|
frontBuf = $13 ; len 1 (value 0 or 1)
|
||||||
pRayData = $14 ; len 2
|
pRayData = $14 ; len 2
|
||||||
playerX = $16 ; len 2 (hi=integer, lo=fraction)
|
playerX = $16 ; len 2 (hi=integer, lo=fraction)
|
||||||
@ -501,8 +501,8 @@ castRay:
|
|||||||
lda mapX ; map X is the integer byte
|
lda mapX ; map X is the integer byte
|
||||||
sbc playerX+1
|
sbc playerX+1
|
||||||
bit stepX
|
bit stepX
|
||||||
bmi :+
|
bpl :+
|
||||||
ina ; if stepping forward, add one to dist
|
ina ; if stepping backward, add one to dist
|
||||||
: sta dist+1
|
: sta dist+1
|
||||||
ldx rayDirX ; parameters for wall calculation
|
ldx rayDirX ; parameters for wall calculation
|
||||||
ldy rayDirY
|
ldy rayDirY
|
||||||
@ -512,7 +512,7 @@ castRay:
|
|||||||
lda playerY ; fractional player pos
|
lda playerY ; fractional player pos
|
||||||
clc
|
clc
|
||||||
adc txColumn
|
adc txColumn
|
||||||
bit stepY ; if stepping forward in X...
|
bit stepX ; if stepping forward in X...
|
||||||
bmi :+
|
bmi :+
|
||||||
eor #$FF ; ...invert the texture coord
|
eor #$FF ; ...invert the texture coord
|
||||||
: sta txColumn
|
: sta txColumn
|
||||||
@ -675,6 +675,7 @@ castRay:
|
|||||||
DEBUG_STR "txCol="
|
DEBUG_STR "txCol="
|
||||||
DEBUG_BYTE txColumn
|
DEBUG_BYTE txColumn
|
||||||
DEBUG_LN
|
DEBUG_LN
|
||||||
|
jsr rdkey
|
||||||
.endif
|
.endif
|
||||||
|
|
||||||
; Advance pLine to the next line on the hi-res screen
|
; Advance pLine to the next line on the hi-res screen
|
||||||
@ -1101,7 +1102,7 @@ makeLines:
|
|||||||
; Set screen lines to current back buf
|
; Set screen lines to current back buf
|
||||||
setBackBuf:
|
setBackBuf:
|
||||||
; calculate screen start
|
; calculate screen start
|
||||||
lda bacKBuf
|
lda backBuf
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
@ -1110,12 +1111,11 @@ setBackBuf:
|
|||||||
clc
|
clc
|
||||||
adc #$20
|
adc #$20
|
||||||
sta setAuxZP
|
sta setAuxZP
|
||||||
sta $FF
|
|
||||||
ldx #0
|
ldx #0
|
||||||
@lup:
|
@lup:
|
||||||
lda 1,x
|
eor 1,x
|
||||||
and #$1F
|
and #$60 ; only two bits control the screen buf
|
||||||
ora $FF
|
eor 1,x
|
||||||
sta 1,x
|
sta 1,x
|
||||||
inx
|
inx
|
||||||
inx
|
inx
|
||||||
@ -1212,7 +1212,7 @@ test:
|
|||||||
sta playerX+1
|
sta playerX+1
|
||||||
lda #$80
|
lda #$80
|
||||||
sta playerX
|
sta playerX
|
||||||
; Y=2.5
|
; Y=2.6
|
||||||
lda #2
|
lda #2
|
||||||
sta playerY+1
|
sta playerY+1
|
||||||
lda #$80
|
lda #$80
|
||||||
@ -1309,13 +1309,14 @@ test:
|
|||||||
.if DOUBLE_BUFFER
|
.if DOUBLE_BUFFER
|
||||||
lda #1
|
lda #1
|
||||||
.endif
|
.endif
|
||||||
sta bacKBuf
|
sta backBuf
|
||||||
|
|
||||||
;DEBUG_STR "Staying in text mode."
|
.if DEBUG
|
||||||
;.if 0
|
DEBUG_STR "Staying in text mode."
|
||||||
|
.else
|
||||||
bit clrText
|
bit clrText
|
||||||
bit setHires
|
bit setHires
|
||||||
;.endif
|
.endif
|
||||||
|
|
||||||
lda #63
|
lda #63
|
||||||
sta lineCt
|
sta lineCt
|
||||||
@ -1385,9 +1386,9 @@ test:
|
|||||||
@nextLevel:
|
@nextLevel:
|
||||||
; flip onto the screen
|
; flip onto the screen
|
||||||
.if DOUBLE_BUFFER
|
.if DOUBLE_BUFFER
|
||||||
ldx bacKBuf
|
ldx backBuf
|
||||||
lda frontBuf
|
lda frontBuf
|
||||||
sta bacKBuf
|
sta backBuf
|
||||||
stx frontBuf
|
stx frontBuf
|
||||||
lda page1,x
|
lda page1,x
|
||||||
.endif
|
.endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user