Code: Select all
import os,time from math import sin,cos class grid: def __init__(self,x,y): self.x=x self.y=y def me(self,x,y,character): self.xm=int(x) self.ym=int(y) self.ch=character self._draw() time.sleep(0.5) def decor(self,x,char): self.bot=char self.xbot=int(x) def _build(self,x,y,z): xprint=" " if x==self.xm and y==self.ym: return self.ch if y==10: return "_" if x<=self.xbot+sin(y)*4+z%10-10: return self.bot else: return xprint def _draw(self): for z in range (self.y): os.system("clear") for y in range(self.y): print "|", for x in range(self.x): print self._build(x,y,z), print ("|") plane=grid(40,20) while 1==1: [[plane.decor(20,")"),plane.me((sin(x)*4+20),(cos(x)*4+10),"8")] for x in range(1000)]
Now, this runs very badly in a terminal window. I run this in regular terminal (ctrl+alt+f1 in ubuntu) for a faster print.
lol... I just typed :w out of habit.
Enjoy my fine art!
Oh yes! The purpose of this. I'm trying to figure out why people bother with classes, when you can just as easily import whatever you want from a file of functions, which basically acts like a class. This little task is forcing me to think more in classes and I'm starting to see why they're better. However, if you think I'm not really using them correctly, like if you see something that's drifting from oop, let me know! Thanks.