我正在尝试编写一个俄罗斯方块克隆,在做了一些研究后,我遇到了一个使用小用户控件来构成块的示例以及包含网格的更大的用户控件.
我写的所有内容似乎都工作得很好(块正在生成并放置在网格上,如果我更改代码,我甚至可以将它们放在其他地方),但我似乎无法在块中移动块程序正在运行.我使用的示例通过更改control.left每个块的属性来实现此目的.我试过这个,调试它,当属性改变时,块不移动.
我现在已经四处搜索了大约4个小时.我是一名新手程序员,所以我知道它可能是愚蠢的,但我无法找到它是什么.
这是我写的方法:
//Class TetrisGame.cs
public void MoveRight()
{
blok.MoveBlock("x", 1);
}
//Class Shape.cs
public void MoveBlock(string pos, int Amount)
{
if (pos == "x")
{
for (int i = 0; i < this.Shape().Count; i++)
{
((Blokje)this.Shape()[i]).MoveSide(1);
}
}
if (pos == "y")
{
for (int i = 0; i < this.Shape().Count; i++)
{
((Blokje)this.Shape()[i]).MoveDown(1);
}
}
//And, the code that should actually move the block in Block.cs:
public void MoveSide(int Step)
{
this.Left += (Step * …Run Code Online (Sandbox Code Playgroud) 我正在尝试设计我自己的俄罗斯方块克隆,但是在形状旋转方面遇到了一些问题.我有一个二维数组,表示一个10 x 20的游戏网格和各个形状对象,初始化时包含网格上的位置坐标,形状将从中开始下降.因此,例如,当用户向下移动形状时,每个坐标的y值会减小,并且此更改会反映在网格上.
我似乎无法弄清楚是使用此实现处理形状旋转的有效方法.有没有办法在指定的枢轴周围使用矩阵这些坐标?
任何建议将不胜感激,
谢谢.
我刚接触Java,我发现了这个创建Java Tetris游戏的好教程.
我没有导师或导师帮我这个 - 我一直在寻找一个年龄:(所以目前我自学Java和PHP :)
无论如何,我找到了网站:http://zetcode.com/tutorials/javagamestutorial/tetris/
我没有在Shape.java课堂上学到的程序的一种方法:
public Shape rotateLeft()
{
if (pieceShape == Tetrominoes.SquareShape)
return this;
Shape result = new Shape();
result.pieceShape = pieceShape;
for (int i = 0; i < 4; ++i) {
result.setX(i, y(i));
result.setY(i, -x(i));
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
Shape result = new Shape();如果已经可以从pieceShape变量中获取当前片段,为什么我们需要创建一个新的Object ?
我正在 Linux 中使用 Python 制作俄罗斯方块游戏,但我无法将终端光标移动到我想要定位的位置
如何移动光标位置?在 Python 中
如何生成所有Tetrominos的列表?或者,更一般地说,如何生成限制在多个细胞中的多联骨牌子集?
我正在尝试理解另一位作者在"NAND to Tetris"项目中编写Parser的代码,但是在使用这段代码中所示的"<>"运算符时却不明白它们的含义.我已经包含了他们的构造函数以供参考self.commands函数.
def __init__(self,fname):
self.fname = fname
self.commands = open(fname, 'r').readlines()
self.cleanUp()
.
.
.
def hasMoreCommands(self):
"""Return True if more commands to parse else return False"""
return self.commands <> [ ]
Run Code Online (Sandbox Code Playgroud)
在我看来,这是一种更简单的方法来确定代码中是否有更多行.那是对的吗?感谢您对此问题的任何意见!如果有更多信息可以帮助,请告诉我.
我正在尝试制作我的第一款游戏,一款控制台俄罗斯方块.我有一个类Block,它包含x和y整数.然后我有一个班级Piece : List<Block>和一个班级Pieces : List<Piece>.
我已经可以随机生成碎片,并使它们每秒掉落一行.我仍然没有进行碰撞检测,但我认为我已经知道如何解决它.问题是我不知道如何控制碎片.我已经阅读了一些关于键盘挂钩并检查了一些俄罗斯方块教程,但其中大多数是用于Windows窗体,这真正简化了事件处理等等.
那么......你能指点一下在控制台上控制棋子的路径的开头吗?谢谢!
public class Program
{
static void Main(string[] args)
{
const int limite = 60;
Piezas listaDePiezas = new Piezas(); //list of pieces
bool gameOver = false;
Pieza pieza; //piece
Console.CursorVisible = false;
while (gameOver != true)
{
pieza = CrearPieza(); //Cretes a piece
if (HayColision(listaDePiezas, pieza) == true) //if there's a collition
{
gameOver = true;
break;
}
else
listaDePiezas.Add(pieza); //The piece is added to the list of pieces …Run Code Online (Sandbox Code Playgroud) 对于大学我们应该写一个游戏(语言是模块2你很少有机会知道它).每个tetromino都是通过一个中心部分和3个相对的部分来定义的.现在,当涉及到旋转时,我只需旋转相对的块(线性代数).
我问自己的是如何处理用户在已经"落地"时所做的旋转,因为用户还有一点时间将他的馅饼快速移动到所需的位置但是在整个网络上的俄罗斯方块版本中你可以"旋转"其他部分,但我似乎没有得到它与我的轮换.
我需要旋转什么?有指导方针吗?谢谢
我正在写一个俄罗斯方块克隆,这是我真正做过的最大的项目.在实现行删除代码时,我已经开始收到堆栈溢出异常.我认为这可能与我的大量收藏或Linq的低效率使用有关.以下是导致此问题的具体方法:
void MoveAllAboveDown(int row)
{
List<Block> newBlockList = new List<Block>();
for (int rowCheck = row; rowCheck > _VertOffset; --rowCheck)
{
for (int i = _HorizOffset; i < _HorizOffset + _Width; ++i)
{
//If the spot above this is filled
if (_blockList.Where(block => block.Contains(new Vector2(i, rowCheck - 1))).ToList().Count > 0)
{
//insert block here
newBlockList.Add(new Block(new Vector2(i, rowCheck), new[,] { { true } }, Color.Black, _texture));
}
else
{
var list = _blockList.Where(tempBlock => tempBlock.Contains(new Vector2(i, rowCheck - 1))).ToList();
if (list.Count …Run Code Online (Sandbox Code Playgroud) 我正在尝试编写一个python程序,将随机的俄罗斯方块形状绘制到板上.这是我的代码:
def __init__(self, win):
self.board = Board(win, self.BOARD_WIDTH, self.BOARD_HEIGHT)
self.win = win
self.delay = 1000
self.current_shape = self.create_new_shape()
# Draw the current_shape oan the board
self.current_shape = Board.draw_shape(the_shape)
def create_new_shape(self):
''' Return value: type: Shape
Create a random new shape that is centered
at y = 0 and x = int(self.BOARD_WIDTH/2)
return the shape
'''
y = 0
x = int(self.BOARD_WIDTH/2)
self.shapes = [O_shape,
T_shape,
L_shape,
J_shape,
Z_shape,
S_shape,
I_shape]
the_shape = random.choice(self.shapes)
return the_shape
Run Code Online (Sandbox Code Playgroud)
我的问题在于"self.current_shape = Board.draw_shape(the_shape).它说没有定义the_shape但我认为我在create_new_shape中定义了它.