def draw(): global frame pico2d.clear_canvas() BG.draw(400, 300) charicter.clip_draw(frame * 100, right * 100, 100, 100, x + 400, y + 300) pico2d.update_canvas() pico2d.delay(1 / 30) frame = (frame + 1) % 8
def draw(): global road, player, cars, coins, fires pico2d.clear_canvas() road.draw() for c in cars: c.draw() for c in coins: c.draw() for f in fires: f.draw() player.draw() info.draw() pico2d.update_canvas() pico2d.delay(DELAY)
def main(): mainE = MainE() mainM = MainM() mainH = MainH() mainE.Init() mainM.Init() mainH.Init() while (scene >= 0): while (scene == 0): p2.clear_canvas() mainE.draw() p2.update_canvas() p2.delay(0.1) handle_events() while (scene == 1): p2.clear_canvas() mainM.draw() p2.update_canvas() p2.delay(0.1) handle_events() while (scene == 2): p2.clear_canvas() mainH.draw() p2.update_canvas() p2.delay(0.1) handle_events() p2.close_canvas()
grass = pico2d.load_image('grass.png') character = pico2d.load_image('animation_sheet.png') running = True x = 0 y = 0 mouse_x, mouse_y=0,0 frame = 0 speed = 5 dir = 0 while running: pico2d.clear_canvas() grass.draw(400, 30) if mouse_x != x and mouse_y != y: dy=mouse_y-y dx=mouse_x-x grad=dy/dx x+=speed*(grad) y+=speed*(1/grad) character.clip_draw(frame * 100, 100, 100, 100, x, 600-y) pico2d.update_canvas() handle_events() frame = (frame + 1) % 8 x+=dir * 5 pico2d.delay(0.01) pico2d.close_canvas()
map_data_file.close() map_data_view_file.close() pass pass cnt = 0 for i in wall_list: i.draw() if check_simultaneous_key_buffer_dic[ 'ctrl'] is True and check_simultaneous_key_buffer_dic[ 'key_s'] is True: if cnt == 0: map_data_file = open("map_data_save.txt", 'a') map_data_view_file = open("map_data_view.txt", 'a') map_data_view_file.write( " -----------------------------------------\n ") pico2d.delay(1) cnt += 1 map_data_file.write("Wall" + " " + str(i.value) + " " + str(i.pivot.x) + " " + str(i.pivot.y) + "\n") map_data_view_file.write( str(cnt) + "번 째 벽 : " + "< " + str(i.pivot.x) + ", " + str(i.pivot.y) + " > \n") if wall_list.index(i) == (len(wall_list) - 1): map_data_file.close() map_data_view_file.close() pass pass pico2d.update_canvas()
import pico2d as Pico Pico.open_canvas() Grass = Pico.load_image('../res/grass.png') Character = Pico.load_image('../res/run_animation.png') x = 0 FrameIndex = 0 while x < 800 : Pico.clear_canvas() Grass.draw(400,30) Character.clip_draw(100 * FrameIndex, 0, 100, 100, x, 85) Pico.update_canvas() Pico.get_events() x += 4 #FrameIndex += 1 #if FrameIndex >= 8 : # FrameIndex = 0 FrameIndex = (FrameIndex + 1) % 8 Pico.delay(0.05) Pico.close_canvas()