Skip to content

Commit

Permalink
improve minetris
Browse files Browse the repository at this point in the history
  • Loading branch information
arpruss committed Jul 6, 2016
1 parent 1ac0fb1 commit ea830ef
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python2-scripts/mcpipy/minetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
HEIGHT = 22
WIDTH = 9
BORDER = WOOL_BLACK
BACKGROUND = STAINED_GLASS_BLACK

PIECES = ( (('XXXX',), ('.X','.X','.X','.X')),
(('XX','XX'),),
(('XXX', '..X'), ('.X', '.X', 'XX'), ('X','XXX'), ('XX', 'X', 'X')),
Expand All @@ -21,6 +23,7 @@ def drawBoard():
mc.setBlocks(left-1, bottom+HEIGHT, plane, left+WIDTH, bottom+HEIGHT, plane, BORDER)
mc.setBlocks(left-1, bottom, plane, left, bottom+HEIGHT-1, plane, BORDER)
mc.setBlocks(left+WIDTH, bottom, plane, left+WIDTH, bottom+HEIGHT-1, plane, BORDER)
mc.setBlocks(left-1, bottom-1, plane-1, left+WIDTH, bottom+HEIGHT, plane-1, BACKGROUND)
mc.setBlocks(left, bottom, plane, left+WIDTH-1, bottom+HEIGHT-1, plane, AIR)

def pieceWidth(piece):
Expand Down Expand Up @@ -50,7 +53,7 @@ def drawBuffer(buffer):
def placePiece():
global pieceNum, color, family, orientation, x, y, fall, descendDelay
pieceNum = randint(0, len(PIECES)-1)
color = Block(WOOL.id, pieceNum % 16)
color = Block(WOOL.id, (pieceNum+1) % 16)
family = PIECES[pieceNum]
orientation = 0
x = WIDTH // 2 - pieceWidth(family[orientation])
Expand All @@ -73,7 +76,7 @@ def descend():
return False

def moveDown():
return (win32api.GetAsyncKeyState(win32con.VK_DOWN)&1) or (win32api.GetAsyncKeyState(ord(' '))&1)
return (win32api.GetAsyncKeyState(win32con.VK_DOWN)&1)

def moveLeft():
return (win32api.GetAsyncKeyState(win32con.VK_LEFT)&1)
Expand Down Expand Up @@ -117,6 +120,7 @@ def addPiece(x, y, piece, color):

playerPos = mc.player.getTilePos()
mc.player.setRotation(180)
mc.player.setPitch(-30)
mc.player.setTilePos(playerPos.x, playerPos.y, playerPos.z + 10)
left = playerPos.x - WIDTH // 2
plane = playerPos.z
Expand Down

0 comments on commit ea830ef

Please sign in to comment.