python俄罗斯方块编程思路_少儿编程分享:手把手教你用Python编写俄罗斯方块(十)...

www.codingmarch.com

游戏分享:手把手教你用

Python

编写

俄罗斯方块(十)

2017.12.28

这是俄罗斯方块的最后一章了

经历了这么多游戏

编写了这么多代码

你的心中是否有所收获呢

温故而知新

在一段时间的学习之后

也要懂得总结与回顾

从底板坐标转换为像素坐标

437.

def

convertToPixelCoords(boxx,

boxy):

438.

#

Convert

the

given

xy

coordinates

of

the

board

to

xy

439.

#

coordinates

of

the

location

on

the

screen.

440.

return

(XMARGIN

+

(boxx

*

BOXSIZE)),

(TOPMARGIN

+

(boxy

*

BOXSIZE))

该辅助函数将板的坐标转换为像素坐标。

此功能与前一游戏程序中使用的其他

“转换坐标”功能相同。

在屏幕上绘制底板或任何地方的方块

443.

def

drawBox(boxx,

boxy,

color,

pixelx=None,

pixely=None):

444.

#

draw

a

single

box

(each

tetromino

piece

has

four

boxes)

445.

#

at

xy

coordinates

on

the

board.

Or,

if

pixelx

&

pixely

446.

#

are

specified,

draw

to

the

pixel

coordinates

stored

in

447.

#

pixelx

&

pixely

(this

is

used

for

the

"Next"

piece).

448.

if

color

==

BLANK:

449.

return

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值