Skip to content

Instantly share code, notes, and snippets.

@HeyitsJess
Last active October 22, 2018 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HeyitsJess/1bea053ec90587000cc0358cab94d55f to your computer and use it in GitHub Desktop.
Save HeyitsJess/1bea053ec90587000cc0358cab94d55f to your computer and use it in GitHub Desktop.
SpotAFire
import pygame, sys, os, time, random, requests, json, webbrowser
from pygame.locals import *
accesskey="b94d1def18adbe4dbf05c995c76b6266"
pygame.init()
FPS = 60
pygame.mixer.init()
pygame.font.init()
clock = pygame.time.Clock()
BLACK = (0,0,0)
WHITE = (255,255,255)
RED = (255,0,0)
BLUE = (0,0,255)
SIZE = (500,500)
MIDDLE = (250,250)
pygame.display.set_caption("SpotaFire")
DISPLAY = pygame.display.set_mode(SIZE)
font = pygame.font.SysFont('Calibri Body', 30)
textsurface = font.render('Report A Fire!', False, BLACK)
copyright = font.render("Copyright 2018", False, BLACK)
screen = 1
def first_screen():
screen = 1
DISPLAY.fill(WHITE)
pygame.draw.circle(DISPLAY, RED, MIDDLE, 100, 100)
textsurface = font.render('Report A Fire!', False, BLACK)
DISPLAY.blit(copyright, (0,0))
DISPLAY.blit(textsurface, (180,240))
button = False
def second_screen():
map=pygame.image.load("/home/eirik/PycharmProjects/SpotaFire/map.jpg")
DISPLAY.fill(BLUE)
DISPLAY.blit(map, (0,0))
send_url = "http://api.ipstack.com/check?access_key={}".format(accesskey)
geo_req = requests.get(send_url)
geo_json = json.loads(geo_req.text)
latitude = geo_json['latitude']
longitude = geo_json['longitude']
city = geo_json['city']
print(latitude, longitude)
pygame.draw.circle(DISPLAY, RED, (300, 150), 10, 5)
first_screen()
while True: # Main Game Loop
cursor = pygame.mouse.get_pos()
if screen == 1:
if cursor[0] > 150 and cursor[0] < 350 and cursor[1] > 150 and cursor[1] < 350:
pygame.draw.circle(DISPLAY, (255,150,50), MIDDLE, 100, 100)
DISPLAY.blit(textsurface, (180,240))
button = True
else:
pygame.draw.circle(DISPLAY, RED, MIDDLE, 100, 100)
DISPLAY.blit(textsurface, (180, 240))
button = False
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN and button == True:
second_screen()
screen=2
if event.type == QUIT:
sys.exit()
pygame.quit()
elif screen == 2:
for event in pygame.event.get():
if event.type == pygame.MOUSEBUTTONDOWN and button == True:
first_screen()
screen=1
if event.type == QUIT:
sys.exit()
pygame.quit()
clock.tick(FPS)
pygame.display.update()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment