我编写了一个动画(在python中),用于沙滩球在屏幕上反弹.我现在希望在窗口添加第二个球,当两个球碰撞时它们互相反弹.
到目前为止,我对此的尝试都没有成功.任何想法如何做到这一点?我到目前为止的代码如下.
import pygame
import sys
if __name__ =='__main__':
ball_image = 'Beachball.jpg'
bounce_sound = 'Thump.wav'
width = 800
height = 600
background_colour = 0,0,0
caption= 'Bouncing Ball animation'
velocity = [1,1]
pygame.init ()
frame = pygame.display.set_mode ((width, height))
pygame.display.set_caption (caption)
ball= pygame.image.load (ball_image). convert()
ball_boundary = ball.get_rect (center=(300,300))
sound = pygame.mixer.Sound (bounce_sound)
while True:
for event in pygame.event.get():
print event
if event.type == pygame.QUIT: sys.exit(0)
if ball_boundary.left < 0 or ball_boundary.right > width:
sound.play()
velocity[0] = -1 * velocity[0]
if …Run Code Online (Sandbox Code Playgroud) 我们是否可以从ping服务器的时间找到互联网带宽,如果是,它是如何完成的
大多数SQL查询都没有对where子句进行数学运算.
将它们放在'where子句'上有什么问题?有任何性能问题吗?
例如:
SELECT*FROM Employee WHERE Salary*3 = 5000
我们将一些网站应用程序中的数据导出到Excel电子表格中,但是,当使用GBP符号时,不会输出"£9.99"而是产生"9.99英镑".
以下是同事编写的用于生成电子表格的代码[tableOut是一个包含HTML表格的StringBuilder]:
string filename = "EngageReplies.xls";
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader( "content-disposition", "attachment;filename=" + filename );
Response.Charset = "UTF-8";
Response.ContentEncoding = System.Text.Encoding.UTF8;
this.EnableViewState = false;
Response.Write( tableOut );
Response.End();
Run Code Online (Sandbox Code Playgroud)
我们如何获得所需的输出?
ps不确定是否应将其分成单独的问题,但在生成电子表格时会触发警告消息:
您尝试打开的文件"EngageReplies.xls"的格式与文件扩展名指定的格式不同.在打开文件之前,请验证文件是否已损坏且是否来自受信任的源.你想现在打开文件吗?
我已经使用Firefox和IE用Office 2007打开文件.单击是打开文件可以,但如果我的用户没有受到它,我会更喜欢它.
我正在编写一个shell脚本来编辑aegis的Change-Set属性.我正在使用的命令是:
Run Code Online (Sandbox Code Playgroud)aegis -Change_Attributes -Edit
这打开了一个vi编辑器来执行更改.我想做一个搜索并替换:
Run Code Online (Sandbox Code Playgroud)s/brief_description \= \"none\"\;/brief_description \=\ "测试\"/克
我可以通过脚本将这些直接传递给open vi实例而无需输入任何内容吗?我想在编辑后保存文档(:wq).
PS该文件是执行命令时创建的临时文件,因此我不知道原始路径
编辑:在这种情况下我可以使用sed:
Run Code Online (Sandbox Code Playgroud)sed -e 's/brief_description\ \=\ \"none\"\;/brief_description\ \=\\ "测试\" \;/G"
解决方案(不优雅的黑客??)将"cat"来自aegis(setenv VISUAL cat)的输出,使用上述命令修改输出流并将其保存到临时文件,并使用:
Run Code Online (Sandbox Code Playgroud)aegis -change_attributes -file <temp file>
编辑2:我几乎得到了它的工作.但是我使用的方式存在问题sed
我的脚本中有以下行:
sed -i 's/brief_description\ \=\ \"none\"\;/brief_description\ \=\ \"${DESC}\"\;/g' temp_next.txt
Run Code Online (Sandbox Code Playgroud)
但$ DESC变量不评估其值,输出值为:
brief_description ="$ {DESC}";
我怎样才能将DESC传递给sed,它会评估它的实际值?
EDIT3:
运用
sed -i 's%brief_description\ \=\ \"none\"\;%brief_description\ \=\ \"'"$DESC"'\"\;%g' temp_next.txt
Run Code Online (Sandbox Code Playgroud)
工作.我用%替换正常分隔符(/)并将环境变量放在双引号中.
在我们的开发团队中,我们创建了许多小应用程序,所有这些应用程序都针对客户的特定需求.
因此,我们经常遇到创建统一用户体验的问题:
我能想到解决这些问题的几种方法......
一般来说,获得有凝聚力的用户体验或统一结果的最佳方法是什么?就个人而言,我不喜欢我的任何方法,但也许这是一种误解,所以请随意支持他们:)
是否可以在git或mercurial中创建一个不可见的分支,我可以用作备份?例如,在一天结束时,我有未完成的工作(甚至可能留下语法错误),但我希望它在网上存储库中备份,而不会让其他人讨论剩下的混乱.
我被要求提供我在3个月前进入ClearCase的签到的详细信息.我知道评论中包含的QC编号但到目前为止还未能完全找到通过评论搜索ClearCase进行签入的方法.
有任何想法吗?
我正在创建一个特殊的搜索文本框.除此之外,还有这两个事件:
[Category("Behavior")]
public event EventHandler<GenericEventArgs<string>> Search;
[Category("Property Changed")]
public event EventHandler<EventArgs> ActiveColorChanged;
[Category("Property Changed")]
public event EventHandler<EventArgs> InactiveColorChanged;
Run Code Online (Sandbox Code Playgroud)
事情是只有底部的两个显示在设计视图属性事件资源管理器thingy(无论它的名称是什么......).我想知道为什么.是因为我没有使用标准EventArgs吗?不应该是这种情况,因为我的意思是,还有其他事件没有使用...就像关键的新闻相关事件等...
这个GenericEventArgs<T>类看起来像这样:
public class GenericEventArgs<T> : EventArgs
{
public T Value { get; private set; }
public GenericEventArgs() : this(default(T)) { }
public GenericEventArgs(T value) { Value = value; }
}
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?
c# ×2
.net ×1
ado ×1
animation ×1
bandwidth ×1
bde ×1
character ×1
clearcase ×1
delphi ×1
events ×1
excel ×1
git ×1
measurement ×1
mercurial ×1
networking ×1
performance ×1
ping ×1
propertygrid ×1
pygame ×1
python ×1
sed ×1
shell ×1
sql-server ×1