EgyptPrincess
Account Disabled
- Messages
- 580
- Reaction score
- 36
- Gender
- Female
- Religion
- Islam
Are you interested in the job? I don't mind lack of knowledge. My main concern is that the person is responsible and that they hate complexity (which implies that they aren't part of modern culture). As an example, Python is reasonable but django is not. Django is unnecessarily complicated for what it does.
Here's a ball game thing I made a while ago. Can I have the job?

Code:
[COLOR=#000080][B]from [/B][/COLOR]tkinter [COLOR=#000080][B]import [/B][/COLOR]*
[COLOR=#000080][B]from [/B][/COLOR]random [COLOR=#000080][B]import [/B][/COLOR]randint
[COLOR=#808080][I]#Return random color #RRGGBB
[/I][/COLOR][COLOR=#000080][B]def [/B][/COLOR]getRandomColor():
color = [COLOR=#008080][B]'#'
[/B][/COLOR][COLOR=#000080][B]for [/B][/COLOR]j [COLOR=#000080][B]in [/B][/COLOR][COLOR=#000080]range[/COLOR]([COLOR=#0000ff]6[/COLOR]):
color+= toHexChar(randint([COLOR=#0000ff]0[/COLOR], [COLOR=#0000ff]12[/COLOR]))
[COLOR=#000080][B]return [/B][/COLOR]color
[COLOR=#808080][I]#Convert an integer to a single hex digit in a character
[/I][/COLOR][COLOR=#000080][B]def [/B][/COLOR]toHexChar(hexValue):
[COLOR=#000080][B]if [/B][/COLOR][COLOR=#0000ff]0 [/COLOR]<= hexValue <= [COLOR=#0000ff]9[/COLOR]:
[COLOR=#000080][B]return [/B][/COLOR][COLOR=#000080]chr[/COLOR](hexValue+[COLOR=#000080]ord[/COLOR]([COLOR=#008080][B]'0'[/B][/COLOR]))
[COLOR=#000080][B]else[/B][/COLOR]:
[COLOR=#000080][B]return [/B][/COLOR][COLOR=#000080]chr[/COLOR](hexValue - [COLOR=#0000ff]10 [/COLOR]+ [COLOR=#000080]ord[/COLOR]([COLOR=#008080][B]'A'[/B][/COLOR]))
[COLOR=#808080][I]#Define ball class
[/I][/COLOR][COLOR=#000080][B]class [/B][/COLOR]Ball:
[COLOR=#000080][B]def [/B][/COLOR][COLOR=#b200b2]__init__[/COLOR]([COLOR=#94558d]self[/COLOR]):
[COLOR=#94558d]self[/COLOR].x = randint([COLOR=#0000ff]0[/COLOR],[COLOR=#0000ff]800[/COLOR])
[COLOR=#94558d]self[/COLOR].y = randint([COLOR=#0000ff]0[/COLOR],[COLOR=#0000ff]600[/COLOR])
[COLOR=#94558d]self[/COLOR].dx = randint(-[COLOR=#0000ff]15[/COLOR],[COLOR=#0000ff]15[/COLOR])
[COLOR=#94558d]self[/COLOR].dy = randint(-[COLOR=#0000ff]15[/COLOR],[COLOR=#0000ff]15[/COLOR])
[COLOR=#94558d]self[/COLOR].radius = randint([COLOR=#0000ff]20[/COLOR],[COLOR=#0000ff]20[/COLOR])
[COLOR=#94558d]self[/COLOR].color = getRandomColor()
[COLOR=#000080][B]class [/B][/COLOR]BounceBalls():
[COLOR=#000080][B]def [/B][/COLOR][COLOR=#b200b2]__init__[/COLOR]([COLOR=#94558d]self[/COLOR]):
[COLOR=#94558d]self[/COLOR].xPos = []
[COLOR=#94558d]self[/COLOR].yPos = []
[COLOR=#94558d]self[/COLOR].ballList = []
window = Tk()
window.title([COLOR=#008080][B]"Bouncing Balls"[/B][/COLOR])
[COLOR=#94558d]self[/COLOR].width = [COLOR=#0000ff]800
[/COLOR][COLOR=#94558d]self[/COLOR].height = [COLOR=#0000ff]600
[/COLOR][COLOR=#94558d]self[/COLOR].canvas = Canvas(window, [COLOR=#660099]bg [/COLOR]= [COLOR=#008080][B]"white"[/B][/COLOR], [COLOR=#660099]width [/COLOR]= [COLOR=#94558d]self[/COLOR].width, [COLOR=#660099]height [/COLOR]= [COLOR=#94558d]self[/COLOR].height)
[COLOR=#94558d]self[/COLOR].canvas.pack()
frame = Frame(window)
frame.pack()
buttonstop = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Stop"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].stop)
buttonstop.pack([COLOR=#660099]side [/COLOR]= LEFT)
buttonFaster = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Faster"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].increaseBallSpeed)
buttonFaster.pack([COLOR=#660099]side [/COLOR]= LEFT)
buttonSlower = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Slower"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].decreaseBallSpeed)
buttonSlower.pack([COLOR=#660099]side [/COLOR]= LEFT)
buttonresume = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Resume"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].resume)
buttonresume.pack([COLOR=#660099]side [/COLOR]= LEFT)
buttonAdd = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Add"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].add)
buttonAdd.pack([COLOR=#660099]side [/COLOR]= LEFT)
buttonRemove = Button(frame, [COLOR=#660099]text [/COLOR]= [COLOR=#008080][B]"Remove"[/B][/COLOR], [COLOR=#660099]command [/COLOR]= [COLOR=#94558d]self[/COLOR].remove)
buttonRemove.pack([COLOR=#660099]side [/COLOR]= LEFT)
[COLOR=#94558d]self[/COLOR].sleepTime = [COLOR=#0000ff]50
[/COLOR][COLOR=#94558d]self[/COLOR].isStopped = [COLOR=#000080][B]False
[/B][/COLOR][COLOR=#94558d]self[/COLOR].animate()
window.mainloop()
[COLOR=#000080][B]def [/B][/COLOR]stop([COLOR=#94558d]self[/COLOR]): [COLOR=#808080][I]#Stop animation
[/I][/COLOR][COLOR=#94558d]self[/COLOR].isStopped = [COLOR=#000080][B]True
[/B][/COLOR][COLOR=#000080][/COLOR][COLOR=#000080][B] def [/B][/COLOR]resume([COLOR=#94558d]self[/COLOR]): [COLOR=#808080][I]#Resume animation
[/I][/COLOR][COLOR=#94558d]self[/COLOR].isStopped = [COLOR=#000080][B]False
[/B][/COLOR][COLOR=#94558d]self[/COLOR].animate()
[COLOR=#000080][B]def [/B][/COLOR]add([COLOR=#94558d]self[/COLOR]): [COLOR=#808080][I]#Add a new ball
[/I][/COLOR][COLOR=#94558d]self[/COLOR].ballList.append(Ball())
[COLOR=#94558d]self[/COLOR].xPos.append(([COLOR=#000080][B]None[/B][/COLOR]))
[COLOR=#94558d]self[/COLOR].yPos.append([COLOR=#000080][B]None[/B][/COLOR])
[COLOR=#000080][B]def [/B][/COLOR]remove([COLOR=#94558d]self[/COLOR]): [COLOR=#808080][I]#Remove the last ball
[/I][/COLOR][COLOR=#94558d]self[/COLOR].ballList.pop()
[COLOR=#000080][B]def [/B][/COLOR]animate([COLOR=#94558d]self[/COLOR]): [COLOR=#808080][I]#Animate ball movements
[/I][/COLOR][COLOR=#000080][B]while not [/B][/COLOR][COLOR=#94558d]self[/COLOR].isStopped:
[COLOR=#94558d]self[/COLOR].canvas.after([COLOR=#94558d]self[/COLOR].sleepTime)
[COLOR=#94558d]self[/COLOR].canvas.update()
[COLOR=#94558d]self[/COLOR].canvas.delete([COLOR=#008080][B]"ball"[/B][/COLOR])
[COLOR=#000080][B]for [/B][/COLOR]ball [COLOR=#000080][B]in [/B][/COLOR][COLOR=#94558d]self[/COLOR].ballList:
[COLOR=#94558d]self[/COLOR].redisplayBall(ball)
[COLOR=#000080][B]def [/B][/COLOR]increaseBallSpeed([COLOR=#94558d]self[/COLOR]):
[COLOR=#000080][B]if [/B][/COLOR][COLOR=#94558d]self[/COLOR].sleepTime <= [COLOR=#0000ff]10[/COLOR]:
[COLOR=#94558d]self[/COLOR].sleepTime = [COLOR=#0000ff]10
[/COLOR][COLOR=#000080][B]else[/B][/COLOR]:
[COLOR=#94558d]self[/COLOR].sleepTime-=[COLOR=#0000ff]10
[/COLOR][COLOR=#0000ff]
[/COLOR][COLOR=#0000ff]
[/COLOR][COLOR=#000080][B]def [/B][/COLOR]decreaseBallSpeed([COLOR=#94558d]self[/COLOR]):
[COLOR=#94558d]self[/COLOR].sleepTime+=[COLOR=#0000ff]10
[/COLOR][COLOR=#0000ff]
[/COLOR][COLOR=#0000ff]
[/COLOR][COLOR=#000080][B]def [/B][/COLOR]redisplayBall(self, ball):
[COLOR=#000080][B]for [/B][/COLOR]i, xandy [COLOR=#000080][B]in [/B][/COLOR][COLOR=#000080]enumerate[/COLOR](self.ballList):
self.xPos[i] = ball.x
self.yPos[i] = ball.y
[COLOR=#808080][I]#print(self.xPos, self.yPos)
[/I][/COLOR][COLOR=#000080][B]if [/B][/COLOR]ball.x > self.width [COLOR=#000080][B]or [/B][/COLOR]ball.x < [COLOR=#0000ff]0[/COLOR]:
ball.dx = -ball.dx
[COLOR=#000080][B]if [/B][/COLOR]ball.y > self.height [COLOR=#000080][B]or [/B][/COLOR]ball.y < [COLOR=#0000ff]0[/COLOR]:
ball.dy = -ball.dy
ball.x += ball.dx
ball.y += ball.dy
self.canvas.create_oval(ball.x - ball.radius, ball.y - ball.radius,
ball.x + ball.radius, ball.y + ball.radius,
[COLOR=#660099]fill [/COLOR]= ball.color, [COLOR=#660099]tags [/COLOR]= [COLOR=#008080][B]"ball"[/B][/COLOR])
[COLOR=#000080][B]try[/B][/COLOR]:
[COLOR=#000080][B]for [/B][/COLOR]x [COLOR=#000080][B]in [/B][/COLOR]self.xPos:
[COLOR=#000080][B]for [/B][/COLOR]y [COLOR=#000080][B]in [/B][/COLOR]self.yPos:
[COLOR=#000080][B]if [/B][/COLOR]self.xPos[x] == self.xPos[x+[COLOR=#0000ff]1[/COLOR]] [COLOR=#000080][B]and [/B][/COLOR]self.yPos[y] == self.yPos[y+[COLOR=#0000ff]1[/COLOR]]:
[COLOR=#000080][B]break
[/B][/COLOR][COLOR=#000080][B] except[/B][/COLOR]:
[COLOR=#000080][B]pass[/B][/COLOR]
BounceBalls()
It doesn't do anything useful, just puts blobs on the screen and they move around. I was going to add collision but I could not figure it out. I've not done any programming for a while though, kinda rusty