-
Notifications
You must be signed in to change notification settings - Fork 1
circ
Kyuchumimo edited this page Jul 9, 2022
·
13 revisions
circ x y radius color
- x, y : the coordinates of the circle's center
- radius : the radius of the circle in pixels
- color: the index of the desired color in the current palette
This function draws a filled circle of the desired radius and color with its center at x, y.
import random
_TIC["PALETTE"] = [[0x14,0x0c,0x1c], [0x44,0x24,0x34], [0x30,0x34,0x6d], [0x4e,0x4a,0x4e], [0x85,0x4c,0x30], [0x34,0x65,0x24], [0xd0,0x46,0x48], [0x75,0x71,0x61], [0x59,0x7d,0xce], [0xd2,0x7d,0x2c], [0x85,0x95,0xa1], [0x6d,0xaa,0x2c], [0xd2,0xaa,0x99], [0x6d,0xc2,0xca], [0xda,0xd4,0x5e], [0xde,0xee,0xd6]] #DB16
# title: circ demo
# author: Filippo, edited by Kyuchumimo
# desc: circ wiki demo
# script: python
# pal: 0000001b2632493c2bf7e26bbe263344891a31a2f2ffffff005784a46422ffffffeb8931a3ce27b2dcefbfce72ffffff
#init balls
balls={}
d=1
for i in range(0,51):
ball={'x' :random.randint(10,220),
'y' :random.randint(10,126),
'dx':random.randint(1,2)*d,
'dy':random.randint(1,2)*d,
'r' :random.randint(6,12),
'c' :random.randint(1,6)}
balls[i]=ball
d=d*-1
def TIC():
cls()
for k,b in enumerate(balls.values()):
#move the ball
b['x']=b['x']+b['dx']
b['y']=b['y']+b['dy']
#check right/left walls
if b['x'] >= 240-b['r']:
b['x']=240-b['r']-1 #constraints inside the wall
b['dx']=-b['dx'] #reverse direction
elif b['x'] < b['r']:
b['x']=b['r']
b['dx']=-b['dx']
#check bottom/top walls
if b['y'] >= 136-b['r']:
b['y']=136-b['r']-1
b['dy']=-b['dy']
elif b['y'] < b['r']:
b['y']=b['r']
b['dy']=-b['dy']
#draw balls
circ(b['x'],b['y'],b['r'],b['c'])
circ(b['x']+b['r']/4,b['y']-b['r']/4,b['r']/4,b['c']+7)
import random
_TIC["PALETTE"] = [[0x14,0x0c,0x1c], [0x44,0x24,0x34], [0x30,0x34,0x6d], [0x4e,0x4a,0x4e],[0x85,0x4c,0x30], [0x34,0x65,0x24], [0xd0,0x46,0x48], [0x75,0x71,0x61], [0x59,0x7d,0xce], [0xd2,0x7d,0x2c], [0x85,0x95,0xa1], [0x6d,0xaa,0x2c], [0xd2,0xaa,0x99], [0x6d,0xc2,0xca], [0xda,0xd4,0x5e], [0xde,0xee,0xd6]] #DB16
# title: circ example
# author: Al Rado, edited by Kyuchumimo
# desc: particular qualities 'circ'
# script: python
cls(15)
SCREEN_WIDTH=240
SCREEN_HEIGHT=136
STEP=20
for radius in range(1,7):
#vertical
circ(radius,radius*STEP,radius,0)
circ(SCREEN_WIDTH-radius-1,radius*STEP,radius,0)# minus one!
#horizontal
circ(radius*STEP,radius,radius,0)
circ(radius*STEP,SCREEN_HEIGHT-radius-1,radius,0)# minus one!
def TIC():