![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() ![]() |
Feedback on program please.
100% original code, so I know exactly how to change it if you think it would look better changed. Any input will be considered. I tried using a sprite image, but there were too many images for it to load at once, that it lagged. If anyone can actually put it into the code so that it works, that would be great.
import pygame
import random
def video_settings():
pygame.init()
screen = pygame.display.set_mode((800, 700))
pygame.display.set_caption('Soulodine v 0.2')
pygame.mouse.set_visible(1)
return screen
snowfall = 50
speed = 1
def create_snow(screen):
snow_set = []
colors = []
direction = []
for set in range (0, snowfall):
snow = [ random.randrange(240, screen.get_width() - 240),
random.randrange(240, screen.get_height() - 240)]
snow_set.append(snow);
col = random.randrange(170, 255)
colors.append(col);
direct = random.randrange(1, 3)
if direct == 2:
direct = -1
else:
direct = 1
direction.append(direct);
return snow_set, colors, direction
def check_snow(snow_set, temp, direction, speed):
temp = temp + 1
for set in range (0, snowfall):
if snow_set[set][1] > 460:
snow_set[set] = [random.randrange(240, screen.get_width() - 240),
240]
else:
snow_set[set][1] = snow_set[set][1] + speed
if temp < 40:
if temp %4 == 0:
snow_set[set][0] = snow_set[set][0] + direction[set]
elif temp > 39:
if temp %4 == 0:
snow_set[set][0] = snow_set[set][0] - direction[set]
if temp == 79:
temp = -1
return temp
def draw_snow(snow_set, screen, colors):
for set in range (0, snowfall):
pygame.draw.circle(screen, (colors[set],colors[set],colors[set]), (snow_set[set][0], snow_set[set][1]), 3, 0)
def main_loop(screen, temp):
pygame.init()
pygame.display.set_caption("Soulodine v0.2")
snow_set, colors, direction = create_snow(screen)
while 1:
pygame.draw.rect(screen, (255, 255, 255), ( (250, 250), (550, 450) ), 0)
draw_snow(snow_set, screen, colors)
temp = check_snow(snow_set, temp, direction, speed)
pygame.draw.rect(screen, 0, ( (0, 0), (250, 700) ), 0)
pygame.draw.rect(screen, 0, ( (250, 0), (800, 250) ), 0)
pygame.draw.rect(screen, 0, ( (550, 250), (800, 700) ), 0)
pygame.draw.rect(screen, 0, ( (250, 450), (550, 700) ), 0)
pygame.display.update()
screen = video_settings()
temp = 0
main_loop(screen, temp) |
|
|
|
|
|
#2 | |
|
Programming Guru
![]() |
Quote:
__________________
|
|
|
|
|
|
|
#3 |
|
Programming Guru
![]() ![]() |
You need pygame.
www.pygame.org Get the one for your version if you are still interested in seeing it. |
|
|
|
|
|
#4 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Quote:
|
|
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() |
I didn't know how else then loading them and displaying them in a for loop. Because I'm not sure how to load more then one image in the same frame.
Unless....if I add pygame.update() at the end of all the images being displayed, it only displays in one frame? Hmm...I'll try this later... Edit: That aside, what did you think of it? |
|
|
|
|
|
#6 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Seems good in general. If there's any part you want specific advice with just say so and i'll be more meticulous in that area.
|
|
|
|
|
|
#7 |
|
Programming Guru
![]() ![]() |
Well, if you saw it overlapping a game window during an RPG whenever it snows, would you be like "whatever", or would you yell at the people who made the game? =P
|
|
|
|
|
|
#8 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Depends on the style of the game. That looks like cartoony/animated snow, so yeah, I think it would look quite good on a game of that style (older final fantasy's, etc).
For a little more realism try making the snow not just go left and right while falling down - try making some cut across from the top left of the window to the bottom right, if you see what I mean. Looks a little pre-defined. As an exercise, try making the snow pile up at the bottom if you're bored ![]() |
|
|
|
|
|
#9 |
|
Hobbyist Programmer
|
When i tried to run the module, it said "error, need module." i dont know if thats my problem? or an error in your code.
__________________
When will Jesus bring the porkchops? |
|
|
|
|
|
#10 | |
|
Hobbyist Programmer
|
Quote:
__________________
When will Jesus bring the porkchops? |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|