mirror of
https://github.com/irmen/prog8.git
synced 2025-01-11 13:29:45 +00:00
speedup at every 10 lines
This commit is contained in:
parent
f36ce5e0ee
commit
b040e5ddad
@ -15,12 +15,13 @@
|
|||||||
const ubyte boardHeight = 20
|
const ubyte boardHeight = 20
|
||||||
const ubyte startXpos = boardOffsetX + 3
|
const ubyte startXpos = boardOffsetX + 3
|
||||||
const ubyte startYpos = boardOffsetY - 2
|
const ubyte startYpos = boardOffsetY - 2
|
||||||
|
const ubyte startSpeedLevel = 30
|
||||||
uword lines
|
uword lines
|
||||||
uword score
|
uword score
|
||||||
ubyte xpos
|
ubyte xpos
|
||||||
ubyte ypos
|
ubyte ypos
|
||||||
ubyte nextBlock
|
ubyte nextBlock
|
||||||
|
ubyte speedlevel = startSpeedLevel
|
||||||
|
|
||||||
|
|
||||||
sub start() {
|
sub start() {
|
||||||
@ -36,7 +37,7 @@ newgame:
|
|||||||
spawnNextBlock()
|
spawnNextBlock()
|
||||||
|
|
||||||
waitkey:
|
waitkey:
|
||||||
if c64.TIME_LO==30 {
|
if c64.TIME_LO>=speedlevel {
|
||||||
c64.TIME_LO = 0
|
c64.TIME_LO = 0
|
||||||
|
|
||||||
drawBlock(xpos, ypos, 32) ; hide block
|
drawBlock(xpos, ypos, 32) ; hide block
|
||||||
@ -63,6 +64,13 @@ waitkey:
|
|||||||
ubyte key=c64.GETIN()
|
ubyte key=c64.GETIN()
|
||||||
if key==0 goto waitkey
|
if key==0 goto waitkey
|
||||||
|
|
||||||
|
keypress(key)
|
||||||
|
|
||||||
|
goto waitkey
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sub keypress(ubyte key) {
|
||||||
if key==157 or key==',' {
|
if key==157 or key==',' {
|
||||||
; move left
|
; move left
|
||||||
drawBlock(xpos, ypos, 32)
|
drawBlock(xpos, ypos, 32)
|
||||||
@ -146,9 +154,6 @@ waitkey:
|
|||||||
}
|
}
|
||||||
drawBlock(xpos, ypos, 160)
|
drawBlock(xpos, ypos, 160)
|
||||||
}
|
}
|
||||||
|
|
||||||
goto waitkey
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub checkForLines() {
|
sub checkForLines() {
|
||||||
@ -174,8 +179,13 @@ waitkey:
|
|||||||
if linepos and blocklogic.isLineFull(linepos)
|
if linepos and blocklogic.isLineFull(linepos)
|
||||||
blocklogic.collapse(linepos)
|
blocklogic.collapse(linepos)
|
||||||
lines += num_lines
|
lines += num_lines
|
||||||
uword[4] scores = [100, 250, 500, 800] ; can never clear more than 4 lines
|
uword[4] scores = [10, 25, 50, 100] ; can never clear more than 4 lines
|
||||||
score += scores[num_lines-1]
|
score += scores[num_lines-1]
|
||||||
|
word speed = startSpeedLevel-(lines as word)/10
|
||||||
|
if speed>0
|
||||||
|
speedlevel = lsb(speed)
|
||||||
|
else
|
||||||
|
speedlevel = 0
|
||||||
drawScore()
|
drawScore()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,6 +246,8 @@ waitkey:
|
|||||||
c64scr.print("irmen's")
|
c64scr.print("irmen's")
|
||||||
c64scr.PLOT(1,2)
|
c64scr.PLOT(1,2)
|
||||||
c64scr.print("teh▁triz")
|
c64scr.print("teh▁triz")
|
||||||
|
c64scr.PLOT(2,22)
|
||||||
|
c64scr.print("speed: ")
|
||||||
c64.COLOR = 5
|
c64.COLOR = 5
|
||||||
c64scr.PLOT(28,3)
|
c64scr.PLOT(28,3)
|
||||||
c64scr.print("next:")
|
c64scr.print("next:")
|
||||||
@ -278,7 +290,7 @@ waitkey:
|
|||||||
c64scr.setcc(boardOffsetX+boardWidth, i, 84, 11)
|
c64scr.setcc(boardOffsetX+boardWidth, i, 84, 11)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in 6 to 0 step -1 {
|
for i in 5 to 0 step -1 {
|
||||||
blocklogic.newCurrentBlock(i)
|
blocklogic.newCurrentBlock(i)
|
||||||
drawBlock(3, 3+i*3, 102) ; 102 = stipple
|
drawBlock(3, 3+i*3, 102) ; 102 = stipple
|
||||||
}
|
}
|
||||||
@ -291,10 +303,13 @@ waitkey:
|
|||||||
c64scr.print_uw(lines)
|
c64scr.print_uw(lines)
|
||||||
c64scr.PLOT(30,15)
|
c64scr.PLOT(30,15)
|
||||||
c64scr.print_uw(score)
|
c64scr.print_uw(score)
|
||||||
|
c64scr.PLOT(9,22)
|
||||||
|
c64scr.print_ub(startSpeedLevel+1-speedlevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
sub drawNextBlock() {
|
sub drawNextBlock() {
|
||||||
for ubyte x in 31 to 28 step -1 {
|
const ubyte nextBlockXpos = 29
|
||||||
|
for ubyte x in nextBlockXpos+3 to nextBlockXpos step -1 {
|
||||||
c64scr.setcc(x, 5, ' ', 0)
|
c64scr.setcc(x, 5, ' ', 0)
|
||||||
c64scr.setcc(x, 6, ' ', 0)
|
c64scr.setcc(x, 6, ' ', 0)
|
||||||
}
|
}
|
||||||
@ -302,7 +317,7 @@ waitkey:
|
|||||||
; reuse the normal block draw routine (because we can't manipulate array pointers yet)
|
; reuse the normal block draw routine (because we can't manipulate array pointers yet)
|
||||||
ubyte prev = blocklogic.currentBlockNum
|
ubyte prev = blocklogic.currentBlockNum
|
||||||
blocklogic.newCurrentBlock(nextBlock)
|
blocklogic.newCurrentBlock(nextBlock)
|
||||||
drawBlock(28, 5, 160)
|
drawBlock(nextBlockXpos, 5, 160)
|
||||||
blocklogic.newCurrentBlock(prev)
|
blocklogic.newCurrentBlock(prev)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user