- python
import pygame
class moving():
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((500, 300))
self.bg_color = self.screen.fill((65, 222, 65))
self.font = pygame.font.Font(None, 36)
self.text = self.font.render('Hello There', 1, (10, 10, 10))
self.rect_width = 50
self.rect_height = 50
self.rect_moving = 10
self.rect1 = pygame.Surface((60, 60), pygame.SRCALPHA)
def text1(self, screen, text):
textpos = text.get_rect()
textpos.centerx = screen.get_rect().centerx
textpos.bottom = screen.get_rect().bottom / 2
screen.blit(text, textpos)
def moving_rect(self,ai_setting):
pygame.draw.rect(self.rect1, (255, 255, 255), [0, 0, self.rect_width, self.rect_height])
x = 0
for i in range(20):
x += self.rect_moving
self.screen.blit(self.rect1, [x, 0])
def run():
pygame.init()
ai_setting = moving()
ai_setting.text1(ai_setting.screen, ai_setting.text)
ai_setting.moving_rect(ai_setting)
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
return
pygame.display.update()
pygame.display.flip()
run()
代码如上,我想要让其矩形进行移动,但是移动却出现问题。。是建立了多个矩形然后X轴进行变化。。如何建立单个矩形进行移动
- 开发语言
Sub test()
Sheets("打印发货单").Cells.Clear
Set dNum = CreateObject("scripting.dictionary")
With Sheets("发货单明细")
LastRowA = .Cells(Rows.Count, "a").End(xlUp).Row
For i = 2 To LastRowA
Key = .Cells(i, 8).Value
dNum(Key) = ""
Next
arr = dNum.keys
'.Range("a12").Resize(1, UBound(arr) + 1) = arr
'.Range("a12").Resize(UBound(arr) + 1) = Application.Transpose(arr)
For i = 0 To UBound(arr)
Sheets("模板").[A3] = "客户:"
Sheets("模板").[c3] = ""
Sheets("模板").[f2] = ""
Sheets("模板").Range("A5:F14").ClearContents
k = 0
For j = 2 To LastRowA
If .Cells(j, 8) = arr(i) Then
Sheets("模板").[A3] = "客户:" & .Cells(j, 2)
Sheets("模板").[c3] = .Cells(j, 1)
Sheets("模板").[f2] = arr(i)
Sheets("模板").Cells(5 + k, 1) = .Cells(j, 3)
Sheets("模板").Cells(5 + k, 2) = .Cells(j, 4)
Sheets("模板").Cells(5 + k, 3) = .Cells(j, 5)
Sheets("模板").Cells(5 + k, 4) = .Cells(j, 6)
Sheets("模板").Cells(5 + k, 5) = .Cells(j, 7)
k = k + 1
End If
Next
Sheets("模板").Range("A1:g19").Copy
Sheets("打印发货单").Activate
Sheets("打印发货单").Cells(i * 19 + 1, 1).Select
Selection.PasteSpecial Paste:=xlPasteColumnWidths, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
ActiveSheet.Paste
Next
End With
End Sub
'1 ,18,35
'1 2 3
- 神经网络
- 深度学习
- 机器学习
- 人工智能
- spring
- java
- java-ee
- jar
- c语言
下面是我部分的代码,求大佬指点,弄了一天了看不出来到底哪里错了,情况是这样的:
1.如果gameover=0,也就是if里面的语句不执行的话,整个程序完全正常,但是只要gameover=1了,函数结束的时候就会跳出stack around the variable 'insx2' was corrupted;
2.如果把insx1和insx2放到全局变量上,就会显示stack around the variable 'score' was corrupted,如果把score也放到全局变量上,游戏结束时直接跳出Buffer!=nullptr&&buffer_count>0;
3.如果给score初始化,也会跳Buffer!=nullptr&&buffer_count>0.
实在不知道怎么回事了,跪求大佬指点!!
char insx1[] = "按AWSD或者方向键控制方向";
char insx2[] = "连按方向键可以加速";
WriteConsoleOutputCharacter(*hOutPutPoint, insx1, strlen(insx1), cursor, &bytes);
cursor.Y++;
WriteConsoleOutputCharacter(*hOutPutPoint, insx2, strlen(insx2), cursor, &bytes);
SetConsoleActiveScreenBuffer(*hOutPutPoint);
if (gameover) {
char score[100] = { 0 };
sprintf_s(score, strlen(score),"您的分数为:%d重来请按1,退出可按任意键", (arr[head_v][head_h] - 2) * 3);
cursor.Y++;
WriteConsoleOutputCharacter(*hOutPutPoint, score, strlen(score), cursor, &bytes);
if (_getch() == 1)main();
}
- java
- 多彩生活
- 测试用例
- iphone
- android
- c++
- javascript
- 开发语言
- 问答团队
- python
- 问答团队
- c语言
- c++