-
-
Save polyspastos/bf4a1234f57180e8e38857d31083234b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame as pg | |
pg.init() | |
display_width = 800 | |
display_height = 600 | |
gd = pg.display.set_mode((display_width,display_height)) | |
pg.display.set_caption('Coldare') | |
black = (0,0,0) | |
white = (255,255,255) | |
green = (0,255,0) | |
red = (255,0,0) | |
blue = (0,0,255) | |
bright_green = (102,255,0) | |
dark_green = (20,255,0) | |
bright_red = (255,27,7) | |
grey = (50,50,50) | |
light_grey = (80,80,80) | |
dark_grey = (20,20,20) | |
clock = pg.time.Clock() | |
end = False | |
largeText = pg.font.Font('freesansbold.ttf',115) | |
smallText = pg.font.Font('freesansbold.ttf',20) | |
def quit_game(): | |
pg.quit() | |
quit() | |
def text_objects(text, font): | |
textSurface = font.render(text, True, black) | |
return textSurface, textSurface.get_rect() | |
def message_display(text): | |
TextSurf, TextRect = text_objects(text, largeText) | |
TextRect.center = ((display_width/2),(display_height/2)) | |
def button(msg,x,y,w,h,ic,ac,action=None): | |
mouse = pg.mouse.get_pos() | |
click = pg.mouse.get_pressed() | |
#print(click) | |
if x+w > mouse[0] > x and y+h > mouse[1] > y: | |
pg.draw.rect(gd, ac,(x,y,w,h)) | |
if click[0] == 1 and action != None: | |
action() | |
else: | |
pg.draw.rect(gd, ic,(x,y,w,h)) | |
smallText = pg.font.Font("freesansbold.ttf",20) | |
textSurf, textRect = text_objects(msg, smallText) | |
textRect.center = ( (x+(w/2)), (y+(h/2)) ) | |
gd.blit(textSurf, textRect) | |
def quit_button(): | |
button("Quit",550,450,100,50,red,bright_red,quit_game) | |
#game functions | |
def get_wood(wood): | |
wood += 5 | |
print(wood) | |
def set_traps(traps): #tbc | |
traps += number_of_unused_traps | |
def game_loop(): | |
gd.fill(grey) | |
gameExit = False | |
while not gameExit: | |
button("Collect wood",50,50,200,50,light_grey,dark_grey,get_wood) | |
button("Set up traps",50,125,200,50,light_grey,dark_grey,set_traps) | |
button("Hunt",50,200,200,50,light_grey,dark_grey,hunt_animals) | |
button("Forage",50,275,200,50,light_grey,dark_grey,collect_berries) | |
button("Tame",50,350,200,50,light_grey,dark_grey,tame_animals) | |
button("Mine",50,425,200,50,light_grey,dark_grey,mine) | |
#button("Back",50,500,200,50,light_grey,dark_grey,back_to_menu) | |
#button("Quit", display_width*0.85, display_height*0.85, 150, 50, red, bright_red,quit_game) | |
pg.display.update() | |
clock.tick(60) | |
def hunt_animals(): | |
pass | |
def collect_berries(): | |
pass | |
def tame_animals(): | |
pass | |
def mine(): | |
pass | |
#initializing resources | |
wood = 0 | |
traps = 0 | |
meat = 0 | |
berries = 0 | |
stone = 0 | |
tamed_animals = [] | |
while not end: | |
for event in pg.event.get(): | |
if event.type == pg.QUIT: | |
end = True | |
gd.fill(grey) | |
TextSurf, TextRect = text_objects("PUMPA", largeText) | |
TextRect.center = ((display_width/2),(display_height/2)) | |
gd.blit(TextSurf, TextRect) | |
button("Start",150,450,100,50,light_grey,dark_grey,game_loop) | |
button("Quit",550,450,100,50,light_grey,dark_grey,quit_game) | |
pg.display.update() | |
clock.tick(60) | |
pg.quit() | |
quit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment