mirror of
https://github.com/irmen/prog8.git
synced 2024-07-05 22:29:04 +00:00
tehtriz example uses when statement
This commit is contained in:
parent
2a0c3377f9
commit
cc078503e3
@ -161,7 +161,7 @@
|
|||||||
else
|
else
|
||||||
c64.SPRPTR[i] = $2000/64 ; small ball
|
c64.SPRPTR[i] = $2000/64 ; small ball
|
||||||
|
|
||||||
c64.SPCOL[i] = spritecolors[zc>>13 as byte + 4] ; further away=darker color
|
c64.SPCOL[i] = spritecolors[zc>>13 as byte + 4] ; further away=darker color TODO doesn't work anymore? ">>" seems broken.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
while multiple < len(sieve) {
|
while multiple < len(sieve) {
|
||||||
sieve[lsb(multiple)] = true
|
sieve[lsb(multiple)] = true
|
||||||
multiple += candidate_prime
|
multiple += candidate_prime
|
||||||
; c64scr.print_uw(multiple) ; TODO
|
|
||||||
; c4.CHROUT('\n') ; TODO
|
|
||||||
}
|
}
|
||||||
return candidate_prime
|
return candidate_prime
|
||||||
}
|
}
|
||||||
|
@ -75,105 +75,116 @@ waitkey:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub move_left() {
|
||||||
|
drawBlock(xpos, ypos, 32)
|
||||||
|
if blocklogic.noCollision(xpos-1, ypos) {
|
||||||
|
xpos--
|
||||||
|
}
|
||||||
|
drawBlock(xpos, ypos, 160)
|
||||||
|
}
|
||||||
|
|
||||||
|
sub move_right() {
|
||||||
|
drawBlock(xpos, ypos, 32)
|
||||||
|
if blocklogic.noCollision(xpos+1, ypos) {
|
||||||
|
xpos++
|
||||||
|
}
|
||||||
|
drawBlock(xpos, ypos, 160)
|
||||||
|
}
|
||||||
|
|
||||||
|
sub move_down_faster() {
|
||||||
|
drawBlock(xpos, ypos, 32)
|
||||||
|
if blocklogic.noCollision(xpos, ypos+1) {
|
||||||
|
ypos++
|
||||||
|
}
|
||||||
|
drawBlock(xpos, ypos, 160)
|
||||||
|
}
|
||||||
|
|
||||||
|
sub drop_down_immediately() {
|
||||||
|
drawBlock(xpos, ypos, 32)
|
||||||
|
ubyte dropypos
|
||||||
|
for dropypos in ypos+1 to boardOffsetY+boardHeight-1 {
|
||||||
|
if not blocklogic.noCollision(xpos, dropypos) {
|
||||||
|
dropypos-- ; the furthest down that still fits
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if dropypos>ypos {
|
||||||
|
ypos = dropypos
|
||||||
|
sound.blockdrop()
|
||||||
|
drawBlock(xpos, ypos, 160)
|
||||||
|
checkForLines()
|
||||||
|
spawnNextBlock()
|
||||||
|
score++
|
||||||
|
drawScore()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub keypress(ubyte key) {
|
sub keypress(ubyte key) {
|
||||||
if key==157 or key==',' {
|
when key {
|
||||||
; move left
|
157 -> move_left()
|
||||||
drawBlock(xpos, ypos, 32)
|
',' -> move_left()
|
||||||
if blocklogic.noCollision(xpos-1, ypos) {
|
29 -> move_right()
|
||||||
xpos--
|
'/' -> move_right()
|
||||||
}
|
17 -> move_down_faster()
|
||||||
drawBlock(xpos, ypos, 160)
|
'.' -> move_down_faster()
|
||||||
}
|
145 -> drop_down_immediately()
|
||||||
else if key==29 or key=='/' {
|
' ' -> drop_down_immediately()
|
||||||
; move right
|
'z' -> {
|
||||||
drawBlock(xpos, ypos, 32)
|
; no joystick equivalent (there is only 1 fire button)
|
||||||
if blocklogic.noCollision(xpos+1, ypos) {
|
; rotate counter clockwise
|
||||||
xpos++
|
drawBlock(xpos, ypos, 32)
|
||||||
}
|
if blocklogic.canRotateCCW(xpos, ypos) {
|
||||||
drawBlock(xpos, ypos, 160)
|
blocklogic.rotateCCW()
|
||||||
}
|
sound.blockrotate()
|
||||||
else if key==17 or key=='.' {
|
}
|
||||||
; move down faster
|
else if blocklogic.canRotateCCW(xpos-1, ypos) {
|
||||||
drawBlock(xpos, ypos, 32)
|
xpos--
|
||||||
if blocklogic.noCollision(xpos, ypos+1) {
|
blocklogic.rotateCCW()
|
||||||
ypos++
|
sound.blockrotate()
|
||||||
}
|
}
|
||||||
drawBlock(xpos, ypos, 160)
|
else if blocklogic.canRotateCCW(xpos+1, ypos) {
|
||||||
}
|
xpos++
|
||||||
else if key==145 or key==' ' {
|
blocklogic.rotateCCW()
|
||||||
; drop down immediately
|
sound.blockrotate()
|
||||||
drawBlock(xpos, ypos, 32)
|
|
||||||
ubyte dropypos
|
|
||||||
for dropypos in ypos+1 to boardOffsetY+boardHeight-1 {
|
|
||||||
if not blocklogic.noCollision(xpos, dropypos) {
|
|
||||||
dropypos-- ; the furthest down that still fits
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if dropypos>ypos {
|
|
||||||
ypos = dropypos
|
|
||||||
sound.blockdrop()
|
|
||||||
drawBlock(xpos, ypos, 160)
|
drawBlock(xpos, ypos, 160)
|
||||||
checkForLines()
|
|
||||||
spawnNextBlock()
|
|
||||||
score++
|
|
||||||
drawScore()
|
|
||||||
}
|
}
|
||||||
}
|
'x' -> {
|
||||||
else if key=='z' { ; no joystick equivalent (there is only 1 fire button)
|
; rotate clockwise
|
||||||
; rotate counter clockwise
|
drawBlock(xpos, ypos, 32)
|
||||||
drawBlock(xpos, ypos, 32)
|
if blocklogic.canRotateCW(xpos, ypos) {
|
||||||
if blocklogic.canRotateCCW(xpos, ypos) {
|
blocklogic.rotateCW()
|
||||||
blocklogic.rotateCCW()
|
sound.blockrotate()
|
||||||
sound.blockrotate()
|
}
|
||||||
}
|
else if blocklogic.canRotateCW(xpos-1, ypos) {
|
||||||
else if blocklogic.canRotateCCW(xpos-1, ypos) {
|
xpos--
|
||||||
xpos--
|
blocklogic.rotateCW()
|
||||||
blocklogic.rotateCCW()
|
sound.blockrotate()
|
||||||
sound.blockrotate()
|
}
|
||||||
}
|
else if blocklogic.canRotateCW(xpos+1, ypos) {
|
||||||
else if blocklogic.canRotateCCW(xpos+1, ypos) {
|
xpos++
|
||||||
xpos++
|
blocklogic.rotateCW()
|
||||||
blocklogic.rotateCCW()
|
sound.blockrotate()
|
||||||
sound.blockrotate()
|
}
|
||||||
}
|
drawBlock(xpos, ypos, 160)
|
||||||
drawBlock(xpos, ypos, 160)
|
}
|
||||||
}
|
'c' -> {
|
||||||
else if key=='x' {
|
; hold
|
||||||
; rotate clockwise
|
if holdingAllowed {
|
||||||
drawBlock(xpos, ypos, 32)
|
sound.swapping()
|
||||||
if blocklogic.canRotateCW(xpos, ypos) {
|
if holding<7 {
|
||||||
blocklogic.rotateCW()
|
drawBlock(xpos, ypos, 32)
|
||||||
sound.blockrotate()
|
ubyte newholding = blocklogic.currentBlockNum
|
||||||
}
|
swapBlock(holding)
|
||||||
else if blocklogic.canRotateCW(xpos-1, ypos) {
|
holding = newholding
|
||||||
xpos--
|
holdingAllowed = false
|
||||||
blocklogic.rotateCW()
|
} else {
|
||||||
sound.blockrotate()
|
holding = blocklogic.currentBlockNum
|
||||||
}
|
drawBlock(xpos, ypos, 32)
|
||||||
else if blocklogic.canRotateCW(xpos+1, ypos) {
|
spawnNextBlock()
|
||||||
xpos++
|
}
|
||||||
blocklogic.rotateCW()
|
drawHoldBlock()
|
||||||
sound.blockrotate()
|
|
||||||
}
|
|
||||||
drawBlock(xpos, ypos, 160)
|
|
||||||
}
|
|
||||||
else if key=='c' {
|
|
||||||
; hold
|
|
||||||
if holdingAllowed {
|
|
||||||
sound.swapping()
|
|
||||||
if holding<7 {
|
|
||||||
drawBlock(xpos, ypos, 32)
|
|
||||||
ubyte newholding = blocklogic.currentBlockNum
|
|
||||||
swapBlock(holding)
|
|
||||||
holding = newholding
|
|
||||||
holdingAllowed = false
|
|
||||||
} else {
|
|
||||||
holding = blocklogic.currentBlockNum
|
|
||||||
drawBlock(xpos, ypos, 32)
|
|
||||||
spawnNextBlock()
|
|
||||||
}
|
}
|
||||||
drawHoldBlock()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user