我怎样才能使汽车在道路上方而不是下方使用乌龟

如何解决我怎样才能使汽车在道路上方而不是下方使用乌龟

我正在开发我的第一款原创可玩游戏,但我遇到了这个问题。基本上,当汽车在路上行驶时,它会从下面而不是从上面行驶。在绘制道路时,我需要使用一个功能正常的系统,因为我希望游戏能够轻松地拥有多个关卡,而它不能成为背景,因为我需要其他汽车通过检测它的位置来绕着这条轨道行驶。

我知道乌龟先画底部的东西,但我已经这样做了。在我添加汽车图形之前,它工作得很好,但现在不行了。提前致谢,对于语法问题很抱歉,因为英语不是我的母语。

'''` # 关卡绘制 def draw_level(): insert_road(0,90) insert_turn(60,0) insert_road(60,-50,180)

# window
wn = turtle.Screen()
wn.setup(800,600)
wn.clear()
wn.bgcolor("grey")
wn.tracer(0)
wn.title("Millwoods Version - 1.0")

draw_level()


# graphics file code,not included because I don't think it is relevant to the problem

# Car
car = turtle.Turtle()
car.speed(0)
car.penup()
car.shape(car90)
car.goto(100,100)
car.state = 1
car.dx = 0
car.shift = 'Park'
car.inertia = 0
car.rt(90)

# writes the speed of the car in the corner of the screen (not important so removed)


pause = turtle.Turtle()
pause.speed(0)
pause.shape("square")
pause.color("white")
pause.penup()
pause.goto(260,240)
pause.hideturtle()
pause.pendown()
pause.forward(60)
pause.lt(90)
pause.forward(30)
pause.lt(90)
pause.forward(60)
pause.lt(90)
pause.forward(30)
pause.penup()
pause.goto(292,245)

def toggle_stat_mode_on():
    statistics.goto(300,270)

def toggle_stat_mode_off():
    statistics.goto(700,700)

def toggle_control_up():
    car.state += 1
    if car.state > 3:
        car.state = 3

    if car.state == 1:
        car.shift = 'Park'
    elif car.state == 2:
        car.shift = 'Reverse'
    elif car.state == 3:
        car.shift = 'Drive'
    else:
        car.shift = 'ERROR'

def toggle_control_down():
    car.state -= 1
    if car.state < 1:
        car.state = 1

    if car.state == 1:
        car.shift = 'Park'
    elif car.state == 2:
        car.shift = 'Reverse'
    elif car.state == 3:
        car.shift = 'Drive'
    else:
        car.shift = 'ERROR'

def gas():
    if car.state == 3:
        car.dx += 0.1
        if car.dx > 3:
            car.dx = 3
    elif car.state == 2:
        car.dx -= 0.1
        if car.dx < -1:
            car.dx = -1
    elif car.state == 0:
        pass

def brake():
    if car.dx > 0:
        car.dx -= 0.2
        if car.dx < 0:
            car.dx = 0
    elif car.dx < 0:
        car.dx += 0.2
        if car.dx > 0:
            car.dx = 0

def lturn():
    x = 0

    if car.dx != 0:
        x = (car.dx*5)

    if x > 5:
        x = 5

    car.lt(x)

def rturn():
    x = 0

    if car.dx != 0:
        x = (car.dx*5)

    if x > 5:
        x = 5

    car.rt(x)

def inertia():
    if car.dx > 0:
        car.inertia = 0.005
        car.dx -= car.inertia
    elif car.dx < 0:
        car.inertia = -0.005
        car.dx -= car.inertia

def button_click(x,y):
    if x > 260 and x < 320 and y > 240 and y < 270:
        print("'PAUSE' has been clicked")
        pause_screen_level2()

wn.listen()
wn.onkeypress(gas,"w")
wn.onkeypress(brake,"s")
wn.onkeypress(lturn,"a")
wn.onkeypress(rturn,"d")
wn.onkeypress(toggle_control_up,"Up")
wn.onkeypress(toggle_control_down,"Down")

wn.onscreenclick(button_click,1)


while True:
    float(car.heading())

    if car.heading() >= 90 and car.heading() <= 94:
        car.shape(car180)
    elif car.heading() >= 95 and car.heading() <= 99:
        car.shape(car185)
    elif car.heading() >= 100 and car.heading() <= 104:
        car.shape(car190)
    elif car.heading() >= 105 and car.heading() <= 109:
        car.shape(car195)
    elif car.heading() >= 110 and car.heading() <= 114:
        car.shape(car200)
    elif car.heading() >= 115 and car.heading() <= 119:
        car.shape(car205)
    elif car.heading() >= 120 and car.heading() <= 124:
        car.shape(car210)
    elif car.heading() >= 125 and car.heading() <= 129:
        car.shape(car215)
    elif car.heading() >= 130 and car.heading() <= 134:
        car.shape(car220)
    elif car.heading() >= 135 and car.heading() <= 139:
        car.shape(car225)
    elif car.heading() >= 140 and car.heading() <= 144:
        car.shape(car230)
    elif car.heading() >= 145 and car.heading() <= 149:
        car.shape(car235)
    elif car.heading() >= 150 and car.heading() <= 154:
        car.shape(car240)
    elif car.heading() >= 155 and car.heading() <= 159:
        car.shape(car245)
    elif car.heading() >= 160 and car.heading() <= 164:
        car.shape(car250)
    elif car.heading() >= 165 and car.heading() <= 169:
        car.shape(car255)
    elif car.heading() >= 170 and car.heading() <= 174:
        car.shape(car260)
    elif car.heading() >= 175 and car.heading() <= 179:
        car.shape(car265)
    elif car.heading() >= 180 and car.heading() <= 184:
        car.shape(car270)
    elif car.heading() >= 185 and car.heading() <= 189:
        car.shape(car275)
    elif car.heading() >= 190 and car.heading() <= 194:
        car.shape(car280)
    elif car.heading() >= 195 and car.heading() <= 199:
        car.shape(car285)
    elif car.heading() >= 200 and car.heading() <= 204:
        car.shape(car290)
    elif car.heading() >= 205 and car.heading() <= 209:
        car.shape(car295)
    elif car.heading() >= 210 and car.heading() <= 214:
        car.shape(car300)
    elif car.heading() >= 215 and car.heading() <= 219:
        car.shape(car305)
    elif car.heading() >= 220 and car.heading() <= 224:
        car.shape(car310)
    elif car.heading() >= 225 and car.heading() <= 229:
        car.shape(car315)
    elif car.heading() >= 230 and car.heading() <= 234:
        car.shape(car320)
    elif car.heading() >= 235 and car.heading() <= 239:
        car.shape(car325)
    elif car.heading() >= 240 and car.heading() <= 244:
        car.shape(car330)
    elif car.heading() >= 245 and car.heading() <= 249:
        car.shape(car335)
    elif car.heading() >= 250 and car.heading() <= 254:
        car.shape(car340)
    elif car.heading() >= 255 and car.heading() <= 259:
        car.shape(car245)
    elif car.heading() >= 260 and car.heading() <= 264:
        car.shape(car350)
    elif car.heading() >= 265 and car.heading() <= 269:
        car.shape(car355)
    elif car.heading() >= 270 and car.heading() <= 274:
        car.shape(car360)
    elif car.heading() >= 275 and car.heading() <= 279:
        car.shape(car5)
    elif car.heading() >= 280 and car.heading() <= 284:
        car.shape(car10)
    elif car.heading() >= 285 and car.heading() <= 289:
        car.shape(car15)
    elif car.heading() >= 290 and car.heading() <= 294:
        car.shape(car20)
    elif car.heading() >= 295 and car.heading() <= 299:
        car.shape(car25)
    elif car.heading() >= 300 and car.heading() <= 304:
        car.shape(car30)
    elif car.heading() >= 305 and car.heading() <= 309:
        car.shape(car35)
    elif car.heading() >= 310 and car.heading() <= 314:
        car.shape(car40)
    elif car.heading() >= 315 and car.heading() <= 319:
        car.shape(car45)
    elif car.heading() >= 320 and car.heading() <= 324:
        car.shape(car50)
    elif car.heading() >= 325 and car.heading() <= 329:
        car.shape(car55)
    elif car.heading() >= 330 and car.heading() <= 334:
        car.shape(car60)
    elif car.heading() >= 335 and car.heading() <= 339:
        car.shape(car65)
    elif car.heading() >= 340 and car.heading() <= 344:
        car.shape(car70)
    elif car.heading() >= 345 and car.heading() <= 349:
        car.shape(car75)
    elif car.heading() >= 350 and car.heading() <= 354:
        car.shape(car80)
    elif car.heading() >= 355 and car.heading() <= 359:
        car.shape(car85)
    elif car.heading() >= 0 and car.heading() <= 4:
        car.shape(car90)
    elif car.heading() >= 5 and car.heading() <= 9:
        car.shape(car95)
    elif car.heading() >= 10 and car.heading() <= 14:
        car.shape(car100)
    elif car.heading() >= 15 and car.heading() <= 19:
        car.shape(car105)
    elif car.heading() >= 20 and car.heading() <= 24:
        car.shape(car110)
    elif car.heading() >= 25 and car.heading() <= 29:
        car.shape(car115)
    elif car.heading() >= 30 and car.heading() <= 34:
        car.shape(car120)
    elif car.heading() >= 35 and car.heading() <= 39:
        car.shape(car125)
    elif car.heading() >= 40 and car.heading() <= 44:
        car.shape(car130)
    elif car.heading() >= 45 and car.heading() <= 49:
        car.shape(car135)
    elif car.heading() >= 50 and car.heading() <= 54:
        car.shape(car140)
    elif car.heading() >= 55 and car.heading() <= 59:
        car.shape(car145)
    elif car.heading() >= 60 and car.heading() <= 64:
        car.shape(car150)
    elif car.heading() >= 65 and car.heading() <= 69:
        car.shape(car155)
    elif car.heading() >= 70 and car.heading() <= 74:
        car.shape(car160)
    elif car.heading() >= 75 and car.heading() <= 79:
        car.shape(car165)
    elif car.heading() >= 80 and car.heading() <= 84:
        car.shape(car170)
    elif car.heading() >= 85 and car.heading() <= 89:
        car.shape(car175)
    else:
        pass

    statistics.clear()
    state.clear()
    speed.clear()
    inertia()
    car.forward(car.dx - car.inertia)
    pause.write("PAUSE",move=False,align='center',font=('Arial',10,'normal'))
    speed.write("speed: " + str(car.dx),align='left',8,'normal'))
    state.write("gear shift: " + str(car.shift),'normal'))


    wn.update()`'''

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-
参考1 参考2 解决方案 # 点击安装源 协议选择 http:// 路径填写 mirrors.aliyun.com/centos/8.3.2011/BaseOS/x86_64/os URL类型 软件库URL 其他路径 # 版本 7 mirrors.aliyun.com/centos/7/os/x86
报错1 [root@slave1 data_mocker]# kafka-console-consumer.sh --bootstrap-server slave1:9092 --topic topic_db [2023-12-19 18:31:12,770] WARN [Consumer clie
错误1 # 重写数据 hive (edu)&gt; insert overwrite table dwd_trade_cart_add_inc &gt; select data.id, &gt; data.user_id, &gt; data.course_id, &gt; date_format(
错误1 hive (edu)&gt; insert into huanhuan values(1,&#39;haoge&#39;); Query ID = root_20240110071417_fe1517ad-3607-41f4-bdcf-d00b98ac443e Total jobs = 1
报错1:执行到如下就不执行了,没有显示Successfully registered new MBean. [root@slave1 bin]# /usr/local/software/flume-1.9.0/bin/flume-ng agent -n a1 -c /usr/local/softwa
虚拟及没有启动任何服务器查看jps会显示jps,如果没有显示任何东西 [root@slave2 ~]# jps 9647 Jps 解决方案 # 进入/tmp查看 [root@slave1 dfs]# cd /tmp [root@slave1 tmp]# ll 总用量 48 drwxr-xr-x. 2
报错1 hive&gt; show databases; OK Failed with exception java.io.IOException:java.lang.RuntimeException: Error in configuring object Time taken: 0.474 se
报错1 [root@localhost ~]# vim -bash: vim: 未找到命令 安装vim yum -y install vim* # 查看是否安装成功 [root@hadoop01 hadoop]# rpm -qa |grep vim vim-X11-7.4.629-8.el7_9.x
修改hadoop配置 vi /usr/local/software/hadoop-2.9.2/etc/hadoop/yarn-site.xml # 添加如下 &lt;configuration&gt; &lt;property&gt; &lt;name&gt;yarn.nodemanager.res