我该怎么做?原因是我想尝试一些pygame,但我目前安装了python 3并且一直在学习.我也有兴趣尝试wxpython或类似的东西,但我还没有看过它们的兼容性.
编辑:: im在Windows Vista 64位上
所以我正在尝试学习SDL并创建一个小游戏.当用户按下空格键时,它应该播放声音.这有效,但声音需要大约0.5秒才能播放......我该如何解决这个问题?我已经检查了实际的文件,看看延迟是否只是其中的一部分,事实证明并非如此.
在win vista上使用c ++进行SDL.
这是一些相关的代码:
...
Mix_OpenAudio( 22050, MIX_DEFAULT_FORMAT, 2, 4096 )
...
main()
{
...
Mix_PlayMusic( BG_Music, 0 ); //background music
while( quit == false )
{
fps.start();
fire.handleInput( event, ship.get_x_pos() );
...
}
Run Code Online (Sandbox Code Playgroud)
句柄输入功能:
void lasersC::handleInput( SDL_Event &event, int x )
{
Uint8 *keystates = SDL_GetKeyState( NULL );
if ( keystates[ SDLK_SPACE ] && delay == 0)
{
Mix_PlayChannel(-1, laser, 0);
fired * F = new fired( NULL, S_HEIGHT - 50, x + 20 );
F->shot = lasers; …Run Code Online (Sandbox Code Playgroud) 我有一个div,我设置样式从溢出:自动显示:无取决于按下哪些按钮.有没有办法检索它具有哪种当前样式并将该值作为字符串或C#中的某些内容返回?
刚进入python,所以我决定做一个刽子手游戏.工作得很好,但我想知道是否有任何可以优化的方法或清理代码的方法.此外,如果有人可以推荐一个我可以做的项目那很酷.
import sys
import codecs
import random
def printInterface(lst, attempts):
""" Prints user interface which includes:
- hangman drawing
- word updater """
for update in lst:
print (update, end = '')
if attempts == 1:
print ("\n\n\n\n\n\n\n\n\n\n\n\t\t _____________")
elif attempts == 2:
print ("""
|
|
|
|
|
|
|
|
|
______|______""")
elif attempts == 3:
print ("""
______
|
|
|
|
|
|
|
|
|
______|______""")
elif attempts == 4:
print ("""
______
| …Run Code Online (Sandbox Code Playgroud) 我在这个网页上迭代我的控件,当按下按钮修改一个数据时,我正在禁用页面上的其他控件.此类控件由TextBoxes,ListBoxes和Buttons组成.所有这些控件都有Enable属性,所以我想知道是否有办法将控件转换为某种通用数据类型并将其属性设置为enabled.
protected void DisableSQRcontrols( Control Page )
{
foreach ( Control ctrl in Page.Controls )
if ( ctrl is TextBox )
((TextBox)ctrl).Enabled = false;
else if ( ctrl is Button )
((Button)ctrl).Enabled = false;
else if ( ctrl is ListBox )
((ListBox)ctrl).Enabled = false;
else if ( ctrl.Controls.Count > 0 )
DisableSQRcontrols( ctrl );
}
Run Code Online (Sandbox Code Playgroud)
我想将顶部更改为类似的东西
protected void DisableSQRcontrols( Control Page )
{
foreach ( Control ctrl in Page.Controls )
if ( ( ctrl is TextBox ) ||
( ctrl …Run Code Online (Sandbox Code Playgroud) 我正在使用 ItemCheckEventArgs 并且可以从中获取索引值,但是从该值中我不确定如何查找所检查的文本的内容。
我只是想进入python,但我发现很难找到任何Python 3的资源.到目前为止我所有的都是diveintopython3.org,而且它有限.无论如何,我只是试图通过做一些非常基本的东西来感受语言,但我无法弄清楚为什么这个小程序不会做我想要的,即添加2个数字.我相信这里有人知道如何修复它,但是非常感谢包含Python 3教程的任何其他资源:
def add(num=0,num2=0):
sumEm = (num+num2)
print (sumEm)
if __name__ == '__main__':
num = input("Enter a number: ")
num2 = input("Enter a number: ")
add(num,num2)
Run Code Online (Sandbox Code Playgroud)
输出:
Enter a number: 23
Enter a number: 24
23
24
Run Code Online (Sandbox Code Playgroud) 我正在尝试测试/ t或空格字符,我无法理解为什么这些代码不起作用.我正在做的是读取文件,计算文件的loc,然后记录文件中存在的每个函数的名称以及它们各自的代码行.下面的代码是我尝试计算函数的loc的地方.
import re
...
else:
loc += 1
for line in infile:
line_t = line.lstrip()
if len(line_t) > 0 \
and not line_t.startswith('#') \
and not line_t.startswith('"""'):
if not line.startswith('\s'):
print ('line = ' + repr(line))
loc += 1
return (loc, name)
else:
loc += 1
elif line_t.startswith('"""'):
while True:
if line_t.rstrip().endswith('"""'):
break
line_t = infile.readline().rstrip()
return(loc,name)
Run Code Online (Sandbox Code Playgroud)
输出:
Enter the file name: test.txt
line = '\tloc = 0\n'
There were 19 lines of code in "test.txt"
Function names:
count_loc …Run Code Online (Sandbox Code Playgroud) 我正在尝试学习python,我正在尝试一个刽子手游戏.但是,当我尝试将用户的猜测与单词进行比较时,它不起作用.我错过了什么?
import sys
import codecs
import random
if __name__ == '__main__':
try:
wordlist = codecs.open("words.txt", "r")
except Exception as ex:
print (ex)
print ("\n**Could not open file!**\n")
sys.exit(0)
rand = int(random.random()*5 + 1)
i = 0
for word in wordlist:
i+=1
if i == rand:
print (word, end = '')
break
wordlist.close()
guess = input("Guess a letter: ")
print (guess) #for testing purposes
for letters in word:
if guess == letters:
print ("Yessssh")
#guessing part and user interface here
Run Code Online (Sandbox Code Playgroud) 我正在编写一个按钮,如果单击该按钮将从数据库中删除记录.但是,我想在点击它之后进行某种确认,这样就不会发生意外.我想象一个弹出框,告诉他们他们即将删除这条记录,两个按钮取消和确定.如果取消,则没有任何反应,但如果按下确定,则服务器将按编码执行删除.我如何在asp/vb中执行此操作?
这是家庭作业的一部分.我有几个问题要求找到薪水最高或薪水最高的员工.找到经过大多数飞机认证的飞行员.我对如何做到这一点一无所知.本章中没有任何示例,谷歌证明不那么有用.如果有人能告诉我如何做其中之一,那将会有很大帮助.
这是表格:
飞机(援助:整数,aname:string,cruisingrange:整数)
认证(eid:整数,辅助:整数)
员工(eid:integer,ename:string,salary:int)
python-3.x ×5
python ×4
asp.net ×3
c# ×3
string ×2
c++ ×1
controls ×1
file-io ×1
javascript ×1
recursion ×1
relational ×1
sdl ×1
sdl-mixer ×1
tuples ×1
vb.net ×1