Пример #1
0
 def collide_detect(self):
     self.player_x = 64 - -cyberpi.get_roll()
     self.player_y = 64 - -cyberpi.get_pitch()
     if self.player_x < 0:
         self.player_x = 5
     if self.player_x > 128:
         self.player_x = 123
     if self.player_y < 0:
         self.player_y = 5
     if self.player_y > 128:
         self.player_y = 123
     self.player.move_to(self.player_x, self.player_y)
Пример #2
0
难度:⭐⭐⭐⭐⭐
支持的模式:在线模式
无

"""
# ---------程序分割线----------------程序分割线----------------程序分割线----------

import cyberpi
import time
from matplotlib import pyplot as plt

plt.rcParams['font.sans-serif'] = ['Microsoft YaHei']
plt.ion()
plt.figure(figsize=(15, 8))

while True:
    hum = cyberpi.humiture.get_humidity()
    temp = cyberpi.humiture.get_temp()
    plt.clf()
    y_locator = plt.MultipleLocator(10)
    x_locator = plt.MultipleLocator(10)
    ax=plt.gca()
    ax.yaxis.set_major_locator(y_locator)
    ax.xaxis.set_major_locator(x_locator)
    plt.ylim(-90,90)
    plt.xlim(-180,180)
    plt.scatter(x=0+cyberpi.get_roll(), y=0+cyberpi.get_pitch())
    plt.title('跟随陀螺仪变化位置的小点')
    plt.show()
    plt.pause(0.01)