from math import * from kandinsky import * from time import * from ion import * from random import randint as r target_fps=24 fps=0 player_color_hat=(255,25,60) player_color=(210,50,210) background_color=(28,10,210) player_x=160 player_y=0 player_x_vel=0 player_y_vel=0 camera_x=0 def draw_player(x,y): fill_rect(x,y,20,20,player_color) fill_rect(x,y,20,5,player_color_hat) fill_rect(x+15,y+10,3,3,(0,0,0)) def reach_fps(current_f): global fps draw_string(str(round(fps)),0,0) target_f=1/target_fps if current_f<target_f: sleep(target_f-current_f) fps=1/(monotonic()-begin) def draw_pole(x): fill_rect(x-camera_x,225,20,-20,(200,200,200)) poles=[] poles.append(200) camera_x_vel=5 s=0 rc=0 dj=False fill_rect(0,0,320,230,(21,35,212)) draw_string("jumpin joseph",100,100) sleep(1) while 1: begin=monotonic() if r(0,12)==2: poles.append(r(0,20)*20+camera_x+350) player_y_vel+=5 camera_x=round(camera_x+camera_x_vel) if player_y>=200: s=0 dj=True if keydown(KEY_UP) and (player_y>=200 or player_grounded): player_y_vel=-30 player_y=199 dj=False if keydown(KEY_LEFT): player_x_vel=-round(4*camera_x_vel) if keydown(KEY_RIGHT): player_x_vel=round(4*camera_x_vel) if player_y>=200: player_y=200 s=0 player_y_vel=0 player_x_vel*=0.9 player_x+=player_x_vel player_y+=player_y_vel fill_rect(0,0,320,225,background_color) player_grounded=False for pole_x in poles: if pole_x<camera_x: poles.remove(pole_x) if pole_x-20<=player_x and player_x<=pole_x+20: if player_y>=185: if player_y_vel > 10: s+=1 player_y=185 player_y_vel=0 player_grounded=True draw_pole(pole_x) draw_player(round(player_x)-camera_x,round(player_y)) draw_string(str(s),0,30) draw_string(str(rc),0,60) if s>rc: rc=s reach_fps(monotonic()-begin)