Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VPython startMenu_Menu_Block_Vpython - Fatal编程技术网

VPython startMenu

VPython startMenu,menu,block,vpython,Menu,Block,Vpython,我的Bloxorz类型程序的主程序运行良好。唯一的问题是我必须实现一个系统,如果方块从地图上掉下来,游戏会在屏幕上显示一条消息,当方块垂直击中洞时,游戏会在屏幕上显示一条gameFinished消息。我认为它的工作方式是匹配孔的坐标,如果孔的坐标匹配块的方形底座,它将显示一条消息。 我的第一个真正的问题是能够显示startMenu消息,其中会显示“按S开始”和“按Q退出”。我知道如何使用scene.kb.getkey(),唯一的问题是在屏幕上显示文本,我将把它实现到我的主while True循环

我的Bloxorz类型程序的主程序运行良好。唯一的问题是我必须实现一个系统,如果方块从地图上掉下来,游戏会在屏幕上显示一条消息,当方块垂直击中洞时,游戏会在屏幕上显示一条gameFinished消息。我认为它的工作方式是匹配孔的坐标,如果孔的坐标匹配块的方形底座,它将显示一条消息。 我的第一个真正的问题是能够显示startMenu消息,其中会显示“按S开始”和“按Q退出”。我知道如何使用scene.kb.getkey(),唯一的问题是在屏幕上显示文本,我将把它实现到我的主while True循环中。这是我的密码:

from __future__ import division, print_function
from visual import *
import math, sys
from visual.graph import *
from sys import exit
"""Necessary Python Libraries"""


# top, left, bottom, right, front, back
tlbrfb = ( 2.0, -0.5, 0.0, 0.5, 0.5, -0.5 )        #the area that the block covers (dimensions)
Top = 0
Left = 1
Bottom = 2
Right = 3
Front = 4
Back = 5


"""Modules defining the Movement of the Block"""
def moveRight():
    global tlbrfb
    for r in range(0, 9):
        rate(30)
        block.rotate( angle = pi/18, axis = vector( 0, 0, -1), origin = vector(tlbrfb[Right], 0, 0) ) #pi/18 = 10degrees, 
    tlbrfb = (tlbrfb[Right]-tlbrfb[Left], tlbrfb[Right], 0, tlbrfb[Right]+tlbrfb[Top], tlbrfb[Front], tlbrfb[Back]) #update block's state of stance

def moveDown():        
    global tlbrfb
    for r in range(0, 9):
        rate(30)
        block.rotate( angle = pi/18, axis = vector( +1, 0, 0), origin = vector(0, 0, tlbrfb[Front]) )
    tlbrfb = (tlbrfb[Front]-tlbrfb[Back], tlbrfb[Left], 0, tlbrfb[Right], tlbrfb[Front]+tlbrfb[Top], tlbrfb[Front])

def moveLeft():            
    global tlbrfb
    for r in range(0, 9):
        rate(30)
        block.rotate( angle = pi/18, axis = vector( 0, 0, +1), origin = vector(tlbrfb[Left], 0, 0) )
    tlbrfb = (tlbrfb[Right]-tlbrfb[Left], tlbrfb[Left]-tlbrfb[Top], 0, tlbrfb[Left], tlbrfb[Front], tlbrfb[Back] )

def moveUp():      
    global tlbrfb
    for r in range(0, 9):
        rate(30)
        block.rotate( angle = pi/18, axis = vector( -1, 0, 0), origin = vector(0, 0, tlbrfb[Back]) )
    tlbrfb = (tlbrfb[Front]-tlbrfb[Back], tlbrfb[Left], 0, tlbrfb[Right], tlbrfb[Back], tlbrfb[Back]-tlbrfb[Top])



level1 = [    #array on the tile placement
    [1,1,1,0,0,0,0,0,0,0],
    [1,1,1,1,1,0,0,0,0,0],
    [1,1,1,1,1,1,1,1,1,0],
    [0,0,0,0,0,1,1,0,1,1],
    [0,0,0,0,0,0,1,1,1,0]
]

def draw_level(array):
    for y in range(0, len(array)):
        for x in range(0, len(array[y])): 
            if array[y][x] == 1:
                box( pos=vector(x, -0.1, y), length=0.9, width = 0.9, height = 0.2, color = vector(0.9, 0.8, 0.8))


block = box( pos=vector(0,1,0), length = 1, width = 1, height = 2, color = vector(0.9, 0.9, 0.5))

def handle_events():
    key = scene.kb.getkey()
    if key =="up":
        moveUp()
    elif key =="down":
        moveDown()
    elif key == "left":
        moveLeft()
    elif key == "right":
        moveRight()
    elif key == "q":
        quit()
    elif key == "escape":
        quit()

def mainGameLoop():
    while True:
        scene.center = vector(4.5, 0, 2)
        scene.forward = scene.center - vector(2, 6, 10)
        scene.background = vector(0.57, 0.2, 0.2)
        draw_level(level1) #draw mapout
        handle_events()

while True:
    mainGameLoop()
    handle_events()
    print(block.pos)

请澄清您的问题。我需要帮助制作显示“按S开始”的开始菜单,然后使用按键输入链接到mainGameLoop。请澄清您的问题。我需要帮助制作显示“按S开始”的开始菜单,然后使用按键输入链接到mainGameLoop。