tehtriz example uses when statement

This commit is contained in:
Irmen de Jong 2019-07-09 23:39:03 +02:00
parent 2a0c3377f9
commit cc078503e3
3 changed files with 106 additions and 97 deletions

View File

@ -161,7 +161,7 @@
else
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.
}
}
}

View File

@ -43,8 +43,6 @@
while multiple < len(sieve) {
sieve[lsb(multiple)] = true
multiple += candidate_prime
; c64scr.print_uw(multiple) ; TODO
; c4.CHROUT('\n') ; TODO
}
return candidate_prime
}

View File

@ -75,33 +75,31 @@ waitkey:
}
sub keypress(ubyte key) {
if key==157 or key==',' {
; move left
sub move_left() {
drawBlock(xpos, ypos, 32)
if blocklogic.noCollision(xpos-1, ypos) {
xpos--
}
drawBlock(xpos, ypos, 160)
}
else if key==29 or key=='/' {
; move right
sub move_right() {
drawBlock(xpos, ypos, 32)
if blocklogic.noCollision(xpos+1, ypos) {
xpos++
}
drawBlock(xpos, ypos, 160)
}
else if key==17 or key=='.' {
; move down faster
sub move_down_faster() {
drawBlock(xpos, ypos, 32)
if blocklogic.noCollision(xpos, ypos+1) {
ypos++
}
drawBlock(xpos, ypos, 160)
}
else if key==145 or key==' ' {
; drop down immediately
sub drop_down_immediately() {
drawBlock(xpos, ypos, 32)
ubyte dropypos
for dropypos in ypos+1 to boardOffsetY+boardHeight-1 {
@ -120,7 +118,19 @@ waitkey:
drawScore()
}
}
else if key=='z' { ; no joystick equivalent (there is only 1 fire button)
sub keypress(ubyte key) {
when key {
157 -> move_left()
',' -> move_left()
29 -> move_right()
'/' -> move_right()
17 -> move_down_faster()
'.' -> move_down_faster()
145 -> drop_down_immediately()
' ' -> drop_down_immediately()
'z' -> {
; no joystick equivalent (there is only 1 fire button)
; rotate counter clockwise
drawBlock(xpos, ypos, 32)
if blocklogic.canRotateCCW(xpos, ypos) {
@ -139,7 +149,7 @@ waitkey:
}
drawBlock(xpos, ypos, 160)
}
else if key=='x' {
'x' -> {
; rotate clockwise
drawBlock(xpos, ypos, 32)
if blocklogic.canRotateCW(xpos, ypos) {
@ -158,7 +168,7 @@ waitkey:
}
drawBlock(xpos, ypos, 160)
}
else if key=='c' {
'c' -> {
; hold
if holdingAllowed {
sound.swapping()
@ -177,6 +187,7 @@ waitkey:
}
}
}
}
sub checkForLines() {
; check if line(s) are full -> flash/clear line(s) + add score + move rest down