cubee2.py

Created by wperez274

Created on December 31, 2021

1.18 KB

this is a potential game. game template. will work on it and post new versions; eventually.


from math import *
from kandinsky import *
from kandinsky import fill_rect as fill 
from ion import *
from time import *
from random import *

p_dir=randint(1,4)

left=False
right=False

bg=(randint(50,150),randint(50,150),randint(50,150))

x=100
y=100
c1=(randint(0,125),randint(0,125),randint(0,125))

c2=(255,0,0)

clock=0

fill_rect(0,0,322,222,bg)

fill_rect(0,0,322,2,"red")
fill_rect(0,220,322,2,"red")
fill_rect(0,0,2,222,"red")
fill_rect(319,0,2,222,"red")

while 1:
  clock+=1
  fill_rect(x,y,10,10,c1)
  fill_rect(x+2,y+2,2,2,"cyan")
  fill_rect(x+7,y+2,2,2,"cyan")
  
  if p_dir==1:
    sleep(.005)
    x-=1
    fill_rect(x+11,y,1,10,bg)
  if p_dir==2:
    sleep(.005)
    x+=1
    fill_rect(x-1,y,1,10,bg)
  if p_dir==3:
    sleep(.005)
    y-=1
    fill_rect(x,y+10,10,1,bg)
  if p_dir==4:
    sleep(.005)
    y+=1
    fill_rect(x,y-1,10,1,bg)
  
  if keydown(KEY_OK):
    sleep(0.05)
    p_dir=randint(1,4)
  
  if x<2:
    x=2
    p_dir=choice([2,3,4])
  if x+10>318:
    x=318-10
    p_dir=choice([1,3,4])
  if y<2:
    y=2
    p_dir=choice([1,2,4])
  if y+10>219:
    y>222
    p_dir=choice([1,2,3]) 
  if clock>randint(100,200):
    p_dir=choice([1,2,3,4])
    clock=0

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.