Personality Cafe banner

1 - 13 of 13 Posts

·
Registered
Joined
·
122 Posts
Discussion Starter #1
Hi if you happen to know python please feel free to post a snippet of your code and let me know something interesting about it.

here's mine:


import pygame,sys
from pygame.locals import *


pygame.init()
FPS = 150
fpsClock = pygame.time.Clock()

green=(0,255,0)
red=(255,0,0)
white=(255,255,255)
yellow=(0,0,255)
step_initial_pos=1
pos=step_initial_pos

screeendisplay = pygame.display.set_mode((800,600),0,32)
pygame.display.set_caption("Yakshy's Adventure")
#screeendisplay.fill(white)
def rectstays():
pygame.draw.rect(screeendisplay,red,(30, 500, 40, 80))

#green polka dots for illusiom of motion


def step1(pos):

if pos<800:

x=30
xx=1
x=x+pos*xx
y=100
x1=20
y1=25
pygame.draw.circle(screeendisplay,green,(x, y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=2*x1
y-=2*y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
pos+=1

rectstays()
return(pos)
else:
pos=1
rectstays()
return(pos)




def step2(pos):

screeendisplay.fill(white)
step1(pos)
rectstays()

step=1
while True:
pos=step1(pos)
step2(pos)
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)


the code renders a flock of six birds flying and red painted building with no doors.
 

·
Registered
Joined
·
122 Posts
Discussion Starter #2
Hi if you happen to know python please feel free to post a snippet of your code and let me know something interesting about it.

here's mine:


import pygame,sys
from pygame.locals import *


pygame.init()
FPS = 150
fpsClock = pygame.time.Clock()

green=(0,255,0)
red=(255,0,0)
white=(255,255,255)
yellow=(0,0,255)
step_initial_pos=1
pos=step_initial_pos

screeendisplay = pygame.display.set_mode((800,600),0,32)
pygame.display.set_caption("Yakshy's Adventure")
#screeendisplay.fill(white)
def rectstays():
pygame.draw.rect(screeendisplay,red,(30, 500, 40, 80))

#green polka dots for illusiom of motion


def step1(pos):

if pos<800:

x=30
xx=1
x=x+pos*xx
y=100
x1=20
y1=25
pygame.draw.circle(screeendisplay,green,(x, y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x-=x1
y+=y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
x+=2*x1
y-=2*y1
pygame.draw.circle(screeendisplay,green,(x,y), 5)
pos+=1

rectstays()
return(pos)
else:
pos=1
rectstays()
return(pos)




def step2(pos):

screeendisplay.fill(white)
step1(pos)
rectstays()

step=1
while True:
pos=step1(pos)
step2(pos)
for event in pygame.event.get():
if event.type==QUIT:
pygame.quit()
sys.exit()
pygame.display.update()
fpsClock.tick(FPS)


the code renders a flock of six birds flying and red painted building with no doors.
Indention was messed up

some pick to put things into prespective 1.jpg 2.jpg 3.jpg

i am wondering if some one in some corner of this earth would run this code, if it happens to be you please replay with screen shots as a proof of this poignant event.


Regards,
Yerma
 

·
Registered
Introverted intuitive type
Joined
·
5,561 Posts
dude do you even stackoverflow?
I feel like every computer science program at every university should include an introduction to git-hub and stackoverflow in the first semester.
 

·
Registered
Joined
·
49 Posts
I feel like every computer science program at every university should include an introduction to git-hub and stackoverflow in the first semester.
I actually expect people to be able to google because if you choose a cs degree you're probably already spending a lot of time at the computer :D
 

·
Registered
INTJ 5w4
Joined
·
6,463 Posts
Does "Hello, World" count?
 

·
Registered
Introverted intuitive type
Joined
·
5,561 Posts
I actually expect people to be able to google because if you choose a cs degree you're probably already spending a lot of time at the computer :D
If you actually believe "google it" is going to teach you good programming habits when it comes to scripting with git, you have my sympathy.
 

·
Registered
Joined
·
595 Posts
Code:
/* I recommend wrapping your code into [CODE| here [/CODE|  and use comments within your code */

/* 
        github stackoverflow or whatnot..
        this is a comment block 
        within java and c++ btw
*/
Code:
if pos < 800:
    x=30
    xx=1
    x=x+pos*xx
    y=100
    x1=20
    y1=25
    pygame.draw.circle(screeendisplay,green,(x, y), 5)
    x+=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x-=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x+=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x-=x1
    y+=y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    x+=2*x1
    y-=2*y1
    pygame.draw.circle(screeendisplay,green,(x,y), 5)
    pos+=1
    rectstays()
    return(pos)
else: 
    pos=1
    rectstays()
    return(pos)
I'd also replace that with some kind of a for loop, you draw a circle 6 times based on x y coordinates :tongue:
 
1 - 13 of 13 Posts
Top