过早客
  • 首页
  • 节点
  • 成员
  • 广告投放
  • 登录
  • 注册

Microsoft Edge 免费扩展Sider ChatGPT 来啦!

IT技术 • w3school_CN • 发表于 2 年前 • 最后回复来自 xgq910223 • 2 年前

可以直接注册,亲测有效:

https://gochitchat.ai/invited?c=df790b56e6d4f6880b99b818a636d62c

刚刚让ChatGPT 写了一段贪吃蛇脚本:

你是一名程序员,帮忙写一个贪吃蛇代码:
import pygame
import random

初始化 pygame

pygame.init()

游戏窗口大小

WINDOW_WIDTH = 800
WINDOW_HEIGHT = 600

蛇身大小

BLOCK_SIZE = 20

颜色定义

WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

创建游戏窗口

window = pygame.display.set_mode((WINDOW_WIDTH, WINDOW_HEIGHT))
pygame.display.set_caption("贪吃蛇")

创建时钟对象

clock = pygame.time.Clock()

定义蛇类

class Snake:
def init(self):
self.length = 1
self.positions = [((WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2))]
self.direction = random.choice([UP, DOWN, LEFT, RIGHT])
self.color = GREEN

def get_head_position(self):
    return self.positions[0]

def turn(self, point):
    if self.length > 1 and (point[0] * -1, point[1] * -1) == self.direction:
        return
    else:
        self.direction = point

def move(self):
    cur = self.get_head_position()
    x, y = self.direction
    new = (((cur[0] + (x * BLOCK_SIZE)) % WINDOW_WIDTH), (cur[1] + (y * BLOCK_SIZE)) % WINDOW_HEIGHT)
    if new in self.positions[2:]:
        self.reset()
    else:
        self.positions.insert(0, new)
        if len(self.positions) > self.length:
            self.positions.pop()

def reset(self):
    self.length = 1
    self.positions = [((WINDOW_WIDTH / 2), (WINDOW_HEIGHT / 2))]
    self.direction = random.choice([UP, DOWN, LEFT, RIGHT])

def draw(self, surface):
    for p in self.positions:
        r = pygame.Rect((p[0], p[1]), (BLOCK_SIZE, BLOCK_SIZE))
        pygame.draw.rect(surface, self.color, r)
        pygame.draw.rect(surface, BLACK, r, 1)

定义食物类

class Food:
def init(self):
x = random.randrange(0, WINDOW_WIDTH, BLOCK_SIZE)
y = random.randrange(0, WINDOW_HEIGHT, BLOCK_SIZE)
self.position = (x, y)
self.color = RED

def draw(self, surface):
    r = pygame.Rect((self.position[0], self.position[1]), (BLOCK_SIZE, BLOCK_SIZE))
    pygame.draw.rect(surface, self.color, r)
    pygame.draw.rect(surface, BLACK, r, 1)

定义方向常量

UP = (0, -1)
DOWN = (0, 1)
LEFT = (-1, 0)
RIGHT = (1, 0)

创建蛇和食物对象

snake = Snake()
food = Food()

游戏循环

while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
snake.turn(UP)
elif event.key == pygame.K_DOWN:
snake.turn(DOWN)
elif event.key == pygame.K_LEFT:
snake.turn(LEFT)
elif event.key == pygame.K_RIGHT:
snake.turn(RIGHT)

# 移动蛇
snake.move()

# 检测蛇是否吃到食物
if snake.get_head_position() == food.position:
    snake.length += 1
    food = Food()

# 绘制游戏窗口
window.fill(WHITE)
snake.draw(window)
food.draw(window)
pygame.display.update()

# 控制帧率
clock.tick(10)
加入收藏 新浪微博 分享到微信 ❤赞 2226 次点击 0 人赞 4 人收藏

打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮

共收到7条回复
lingjing88 2 年前 湖北省 #1 赞 0

可否共享一下这个插件,google商店打不开

XiaoXiaMI 2 年前 湖北省 #2 赞 0

不是官方插件吧?

lingjing88 2 年前 湖北省 #3 赞 0

edge可以用,多谢了

w3school_CN 楼主 2 年前 湖北省 #4 赞 0

@lingjing88 EDGE 免费可用

xiongyitao 2 年前 湖北省 #5 赞 1

3.5每天30个免费查询,4.0每天0个;邀请朋友赚取 1 个 GPT-4.0 查询和 5 个 GPT-3.5 查询。
感觉一般,不如wetab插件

visvlee 2 年前 广东省 #6 赞 0

这种插件好多,chrome我用的monica!

xgq910223 2 年前 湖北省 #7 赞 0

作为程序员翻个墙不难把

请绑定手机号后,再发言,点击此处
Guozaoke.com—源自武汉的高端交流分享社区
相关主题
现在工作越来越难做了
最近时间少了, 隔了这么久, 才做了一个网站
求推荐一个AI智能体客服
请问大家都是通过哪些好用的链接访问GPT
请教机器学习人工智能的一个技术问题
搞了个AI 生图的网站,不需要登录,永久免费
[第二波送码]动动嘴皮,AI秒出图!2025最炸裂图标神器:免费生成+手机实时预览
开发了一个管理 Linux 服务器的桌面可视化管理工具,求蹂躏
服务器可视化采用纯前端渲染,这个技术实现难度如何
做了一款摸鱼软件,有人要试用吗?

过早客微信公众号:guozaoke • 过早客新浪微博:@过早客 • 广告投放合作微信:fullygroup50 鄂ICP备2021016276号-2 • 鄂公网安备42018502001446号